MicrodroidHostTests: unset LD_LIBRARY_PATH
The LD_LIBRARY_PATH setting is breaking the sign_virt_apex command
when it indirectly invokes lpunpack.
resigning the Virt APEX failed:
out: lpunpack: symbol lookup error: /tmp/tf-workfolder11116240515786222079/device-tests_configs.zip16900091241849603943/host/testcases/MicrodroidHostTestCases/lib64/liblog.so: undefined symbol: _ZNSt3__122__libcpp_verbose_abortEPKcz
Clear LD_LIBRARY_PATH before running sign_virt_apex. It's unclear if
the other programs also need this fix (adb, avbtool, lz4,
sepolicy-analyze), but it's probably a better default.
Bug: 333782216
Test: v2/android-kvm-team/avf_presubmit_tests
Change-Id: I761f526d31d042115f5babb633761816e1142938
diff --git a/tests/hostside/java/com/android/microdroid/test/MicrodroidHostTests.java b/tests/hostside/java/com/android/microdroid/test/MicrodroidHostTests.java
index 2b53571..57f0c77 100644
--- a/tests/hostside/java/com/android/microdroid/test/MicrodroidHostTests.java
+++ b/tests/hostside/java/com/android/microdroid/test/MicrodroidHostTests.java
@@ -174,7 +174,7 @@
boolean updateBootconfigs) {
File signVirtApex = findTestFile("sign_virt_apex");
- RunUtil runUtil = new RunUtil();
+ RunUtil runUtil = createRunUtil();
// Set the parent dir on the PATH (e.g. <workdir>/bin)
String separator = System.getProperty("path.separator");
String path = signVirtApex.getParentFile().getPath() + separator + System.getenv("PATH");
@@ -409,7 +409,7 @@
configPath);
PipedInputStream pis = new PipedInputStream();
- Process process = RunUtil.getDefault().runCmdInBackground(args, new PipedOutputStream(pis));
+ Process process = createRunUtil().runCmdInBackground(args, new PipedOutputStream(pis));
return new VmInfo(process);
}
@@ -885,7 +885,7 @@
File sepolicyAnalyzeBin = findTestFile("sepolicy-analyze");
CommandResult result =
- RunUtil.getDefault()
+ createRunUtil()
.runTimedCmd(
10000,
sepolicyAnalyzeBin.getPath(),
@@ -1029,14 +1029,14 @@
private boolean isLz4(String path) throws Exception {
File lz4tool = findTestFile("lz4");
CommandResult result =
- new RunUtil().runTimedCmd(5000, lz4tool.getAbsolutePath(), "-t", path);
+ createRunUtil().runTimedCmd(5000, lz4tool.getAbsolutePath(), "-t", path);
return result.getStatus() == CommandStatus.SUCCESS;
}
private void decompressLz4(String inputPath, String outputPath) throws Exception {
File lz4tool = findTestFile("lz4");
CommandResult result =
- new RunUtil()
+ createRunUtil()
.runTimedCmd(
5000, lz4tool.getAbsolutePath(), "-d", "-f", inputPath, outputPath);
String out = result.getStdout();
@@ -1067,7 +1067,7 @@
List<String> command =
Arrays.asList(avbtool.getAbsolutePath(), "info_image", "--image", image_path);
CommandResult result =
- new RunUtil().runTimedCmd(5000, "/bin/bash", "-c", String.join(" ", command));
+ createRunUtil().runTimedCmd(5000, "/bin/bash", "-c", String.join(" ", command));
String out = result.getStdout();
String err = result.getStderr();
assertWithMessage(
@@ -1236,4 +1236,14 @@
assertThat(androidDevice).isNotNull();
return androidDevice;
}
+
+ // The TradeFed Dockerfile sets LD_LIBRARY_PATH to a directory with an older libc++.so, which
+ // breaks binaries that are linked against a newer libc++.so. Binaries commonly use DT_RUNPATH
+ // to find an adjacent libc++.so (e.g. `$ORIGIN/../lib64`), but LD_LIBRARY_PATH overrides
+ // DT_RUNPATH, so clear LD_LIBRARY_PATH. See b/332593805 and b/333782216.
+ private static RunUtil createRunUtil() {
+ RunUtil runUtil = new RunUtil();
+ runUtil.unsetEnvVariable("LD_LIBRARY_PATH");
+ return runUtil;
+ }
}