Exit on error when build and run Android unit tests

Merged from Widevine CDM repo:
https://widevine-internal-review.googlesource.com/#/c/13200/

Change-Id: Ifd785a9b30293746f0ae0262b37f03bc905a5e09
This commit is contained in:
KongQun Yang
2015-02-25 15:49:03 -08:00
parent dff91b48c1
commit e3f668785e
2 changed files with 36 additions and 22 deletions

View File

@@ -1,5 +1,7 @@
#!/bin/sh
set -e
if [ -z "$ANDROID_BUILD_TOP" ]; then
echo "Android build environment not set"
exit -1
@@ -41,7 +43,7 @@ mm
cd $ANDROID_BUILD_TOP/vendor/widevine/libwvdrmengine/test/java/src/com/widevine/test
pwd
mm
mm WITH_DEXPREOPT=false
echo "waiting for device"
adb root && adb wait-for-device remount
@@ -57,14 +59,12 @@ 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
if [ -r $OUT/system/app/MediaDrmAPITest.apk ]; then
adb install -r $OUT/system/app/MediaDrmAPITest.apk
else
adb install -r $OUT/system/app/MediaDrmAPITest/MediaDrmAPITest.apk
fi
adb install -r $OUT/system/app/MediaDrmAPITest/MediaDrmAPITest.apk
cd $ANDROID_BUILD_TOP/vendor/widevine/libwvdrmengine
./run_all_unit_tests.sh

View File

@@ -1,5 +1,15 @@
#!/bin/sh
set -e
# Execute a command in "adb shell" and capture the result.
adb_shell_run() {
local tmp_log="$OUT/mediadrmtest.log"
local adb_error="[ADB SHELL] $1 failed"
adb shell $1 \|\| echo "$adb_error" | tee "$tmp_log"
! grep -Fq "$adb_error" "$tmp_log"
}
if [ -z "$ANDROID_BUILD_TOP" ]; then
echo "Android build environment not set"
exit -1
@@ -8,21 +18,25 @@ fi
echo "waiting for device"
adb root && adb wait-for-device remount
adb shell /system/bin/oemcrypto_test
adb shell /system/bin/request_license_test
adb shell /system/bin/max_res_engine_unittest
adb shell /system/bin/policy_engine_unittest
adb shell /system/bin/libwvdrmmediacrypto_test
adb shell /system/bin/libwvdrmdrmplugin_test
adb shell /system/bin/cdm_engine_test
adb shell /system/bin/cdm_session_unittest
adb shell /system/bin/file_store_unittest
adb shell /system/bin/initialization_data_unittest
adb shell /system/bin/device_files_unittest
adb shell /system/bin/timer_unittest
adb shell LD_LIBRARY_PATH=/system/vendor/lib/mediadrm/ /system/bin/libwvdrmengine_test
adb_shell_run /system/bin/oemcrypto_test
adb_shell_run /system/bin/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 am start com.widevine.test/com.widevine.test.MediaDrmAPITest
# TODO: make this test more command line friendly
echo "check logcat output for MediaDrmAPITest"
library_path="/system/vendor/lib/mediadrm/ "
adb_shell_run "LD_LIBRARY_PATH=$library_path /system/bin/libwvdrmengine_test"
adb_shell_run "am start com.widevine.test/com.widevine.test.MediaDrmAPITest"
echo "MediaDrm unittests completed successfully!"