Push android unit tests to /data

Merge of http://go/wvgerrit/17652

This CL changes the android/build_and_run_all_unit_tests.sh script to
push exectuables to /data if it can't push to /system/bin.

The script run_all_unit_tests.sh will check if test files are in /data
and run those first, if not, it runs the files in /system/bin.

This change is needed to test unit tests on devices where /system/bin
is a read only file system, even after running "adb remount".

This CL will help verify, but will not fix
b/27678092

Change-Id: Ia0fe8c2e68722f58c2626f22113abdbdc8c5e408
This commit is contained in:
Fred Gylys-Colwell
2016-04-26 14:09:10 -07:00
parent ecfd61e803
commit a4ebdf80b5
2 changed files with 57 additions and 41 deletions

View File

@@ -40,25 +40,33 @@ mm WITH_DEXPREOPT=false || mma WITH_DEXPREOPT=false
echo "waiting for device"
adb root && adb wait-for-device remount
try_adb_push() {
# Swallow the error message -- assume it is a read-only file system.
if ! adb push $@ /system/bin > /dev/null; then
adb shell mkdir -p /data/widevine_tests
# If this fails, the user will get the error message.
adb push $@ /data/widevine_tests
fi
}
adb push $OUT/system/bin/oemcrypto_test /system/bin
adb push $OUT/system/bin/request_license_test /system/bin
adb push $OUT/system/bin/cdm_extended_duration_test /system/bin
adb push $OUT/system/bin/max_res_engine_unittest /system/bin
adb push $OUT/system/bin/policy_engine_unittest /system/bin
adb push $OUT/system/bin/libwvdrmmediacrypto_test /system/bin
adb push $OUT/system/bin/libwvdrmdrmplugin_test /system/bin
adb push $OUT/system/bin/cdm_engine_test /system/bin
adb push $OUT/system/bin/cdm_session_unittest /system/bin
adb push $OUT/system/bin/file_store_unittest /system/bin
adb push $OUT/system/bin/license_unittest /system/bin
adb push $OUT/system/bin/initialization_data_unittest /system/bin
adb push $OUT/system/bin/device_files_unittest /system/bin
adb push $OUT/system/bin/timer_unittest /system/bin
adb push $OUT/system/bin/libwvdrmengine_test /system/bin
adb push $OUT/system/bin/buffer_reader_test /system/bin
adb push $OUT/system/bin/circular_buffer_test /system/bin
adb push $OUT/system/bin/entry_writer_test /system/bin
try_adb_push $OUT/system/bin/oemcrypto_test
try_adb_push $OUT/system/bin/request_license_test
try_adb_push $OUT/system/bin/cdm_extended_duration_test
try_adb_push $OUT/system/bin/max_res_engine_unittest
try_adb_push $OUT/system/bin/policy_engine_unittest
try_adb_push $OUT/system/bin/libwvdrmmediacrypto_test
try_adb_push $OUT/system/bin/libwvdrmdrmplugin_test
try_adb_push $OUT/system/bin/cdm_engine_test
try_adb_push $OUT/system/bin/cdm_session_unittest
try_adb_push $OUT/system/bin/file_store_unittest
try_adb_push $OUT/system/bin/license_unittest
try_adb_push $OUT/system/bin/initialization_data_unittest
try_adb_push $OUT/system/bin/device_files_unittest
try_adb_push $OUT/system/bin/timer_unittest
try_adb_push $OUT/system/bin/libwvdrmengine_test
try_adb_push $OUT/system/bin/buffer_reader_test
try_adb_push $OUT/system/bin/circular_buffer_test
try_adb_push $OUT/system/bin/entry_writer_test
adb install -r $OUT/system/app/MediaDrmAPITest/MediaDrmAPITest.apk
cd $ANDROID_BUILD_TOP/vendor/widevine/libwvdrmengine

View File

@@ -17,9 +17,17 @@ fi
# Execute a command in "adb shell" and capture the result.
adb_shell_run() {
local test_file=$1
shift
if adb shell ls /data/widevine_tests/$test_file; then
test_file=/data/widevine_tests/$test_file
else
test_file=/system/bin/$test_file
echo $test_file
fi
local tmp_log="$OUT/mediadrmtest.log"
local adb_error="[ADB SHELL] $@ failed"
adb shell "GTEST_FILTER=$GTEST_FILTER $@" \|\| echo "$adb_error" | tee "$tmp_log"
local adb_error="[ADB SHELL] $@ $test_file failed"
adb shell "GTEST_FILTER=$GTEST_FILTER $@ $test_file" \|\| echo "$adb_error" | tee "$tmp_log"
! grep -Fq "$adb_error" "$tmp_log"
local result=$?
if [ $result -ne 0 ]; then
@@ -54,34 +62,34 @@ fi
# Disable DroidGuard to prevent provisioning collisions
set_droidguard disable
adb_shell_run GTEST_FILTER="$GTEST_FILTER:*Level1Required" FORCE_LEVEL3_OEMCRYPTO=yes \
/system/bin/oemcrypto_test
adb_shell_run /system/bin/oemcrypto_test
adb_shell_run /system/bin/request_license_test
adb_shell_run oemcrypto_test \
GTEST_FILTER="$GTEST_FILTER:*Level1Required" FORCE_LEVEL3_OEMCRYPTO=yes
adb_shell_run oemcrypto_test
adb_shell_run request_license_test
# cdm_extended_duration_test takes >30 minutes to run.
# adb_shell_run /system/bin/cdm_extended_duration_test
adb_shell_run /system/bin/max_res_engine_unittest
adb_shell_run /system/bin/policy_engine_unittest
adb_shell_run /system/bin/libwvdrmmediacrypto_test
adb_shell_run /system/bin/libwvdrmdrmplugin_test
adb_shell_run /system/bin/cdm_engine_test
adb_shell_run /system/bin/cdm_session_unittest
adb_shell_run /system/bin/file_store_unittest
adb_shell_run /system/bin/license_unittest
adb_shell_run /system/bin/initialization_data_unittest
adb_shell_run /system/bin/device_files_unittest
adb_shell_run /system/bin/timer_unittest
adb_shell_run /system/bin/buffer_reader_test
adb_shell_run /system/bin/circular_buffer_test
adb_shell_run /system/bin/entry_writer_test
# adb_shell_run cdm_extended_duration_test
adb_shell_run max_res_engine_unittest
adb_shell_run policy_engine_unittest
adb_shell_run libwvdrmmediacrypto_test
adb_shell_run libwvdrmdrmplugin_test
adb_shell_run cdm_engine_test
adb_shell_run cdm_session_unittest
adb_shell_run file_store_unittest
adb_shell_run license_unittest
adb_shell_run initialization_data_unittest
adb_shell_run device_files_unittest
adb_shell_run timer_unittest
adb_shell_run buffer_reader_test
adb_shell_run circular_buffer_test
adb_shell_run entry_writer_test
library_path="/system/vendor/lib/mediadrm/ "
adb_shell_run LD_LIBRARY_PATH=$library_path /system/bin/libwvdrmengine_test
adb_shell_run libwvdrmengine_test LD_LIBRARY_PATH=$library_path
# Re-enable DroidGuard
set_droidguard enable
adb_shell_run am start com.widevine.test/com.widevine.test.MediaDrmAPITest
adb shell am start com.widevine.test/com.widevine.test.MediaDrmAPITest
if [ $final_result -eq 0 ]; then
echo "MediaDrm unittests completed successfully!"
else