From 45d02c545cc40b4193632ba0aec63d25b750eb26 Mon Sep 17 00:00:00 2001 From: Srujan Gaddam Date: Thu, 23 May 2019 11:17:57 -0700 Subject: [PATCH] Reverse LD_LIBRARY_PATH order based on liboemcrypto.so Bug: b/133427576 Test: Unit tests on Taimen and Crosshatch Merge of http://go/wvgerrit/79804 Currently, the run_all_unit_tests.sh script fails to load in the Level 1 OEMCrypto for some devices that don't have a 64-bit liboemcrypto.so. This is because the liboemcrypto.so tries to load in libQSEEComAPI.so, which some devices contain both a 32-bit and 64-bit version of. Since we set the LD_LIBRARY_PATH to use /vendor/lib64 first, and since we only have a 32-bit liboemcrypto.so, the 32-bit liboemcrypto.so will try to load in the libQSEEComAPI.so in the lib64 path first. Since the liboemcrypto.so is 32-bit, it will fail to open the 64-bit library. The solution to this is to conditionally set the LD_LIBRARY_PATH based on if a 64-bit liboemcrypto.so exists or not. Change-Id: I80a9e778f31f089f66df0544cb022d810e9d3de3 --- libwvdrmengine/run_all_unit_tests.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libwvdrmengine/run_all_unit_tests.sh b/libwvdrmengine/run_all_unit_tests.sh index cee2d20c..addf9424 100755 --- a/libwvdrmengine/run_all_unit_tests.sh +++ b/libwvdrmengine/run_all_unit_tests.sh @@ -43,6 +43,14 @@ adb_shell_run() { echo "------ Starting: $test_file" local tmp_log="$OUT/mediadrmtest.log" local adb_error="[ADB SHELL] $@ $test_file failed" + # The liboemcrypto.so looks for other shared libraries using the + # LD_LIBRARY_PATH. It is possible that even though the 64-bit liboemcrypto.so + # does not exist, there are 64-bit versions of the shared libraries it tries + # to load. We must reverse the library path in this case so we don't attempt + # to load 64-bit libraries with the 32-bit liboemcrypto.so. + if ! adb $SERIAL_NUM shell ls /vendor/lib64/liboemcrypto.so &> /dev/null; then + OEC_PATHS=/vendor/lib:/vendor/lib64 + fi adb $SERIAL_NUM shell "LD_LIBRARY_PATH=$OEC_PATHS GTEST_FILTER=$GTEST_FILTER $@ $test_file" \|\| echo "$adb_error" | tee "$tmp_log" ! grep -Fq "$adb_error" "$tmp_log" local result=$?