(This is a merge of wvgerrit/24922) This contains several fixes and improvements to the build_and_run_all_unit_tests.sh and run_all_unit_tests.sh scripts: * All tests are now identified as vendor binaries and thus are stored in the /vendor/bin/ directory instead of /system/bin/. Previously, some tests had moved to /vendor/bin/ but the scripts had not been updated, causing these tests to fail to run. * The -j parameter can now be passed to build_and_run_all_unit_tests.sh, for those who want to speed up their build by using multiple cores. * The 64-bit library directories are now added to the library search path, in anticipation of devices with 64-bit DRM Plugins. * Checking for Verity protection is now done in build_and_run_all_unit_tests.sh (which is the script that actually modifies the file system) instead of just in run_all_unit_tests.sh. * The library search path is no longer set unnecessarily for libwvdrmengine_hidl_test. * The Treble-only tests and non-Treble-only tests now only run on devices that meet their respective criteria. Bug: 36071236 Test: Ran build_and_run_all_unit_tests.sh Change-Id: Iea236880c4445858111c801dfa278a528bca0f6c
106 lines
3.5 KiB
Bash
Executable File
106 lines
3.5 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
final_result=0
|
|
failed_tests=()
|
|
|
|
# Below, we will append filters to the exclusion portion of GTEST_FILTER, so we
|
|
# need to guarantee it has one.
|
|
if [ -z "$GTEST_FILTER" ]; then
|
|
# If it wasn't set, make it add all tests, and remove none.
|
|
GTEST_FILTER="*-"
|
|
# if GTEST_FILTER already has a negative sign, we leave it alone.
|
|
elif [ 0 -eq `expr index "$GTEST_FILTER" "-"` ]; then
|
|
# If GTEST_FILTER was set, but does not have a negative sign, add one. This
|
|
# gives gtest an empty list of tests to skip.
|
|
GTEST_FILTER="$GTEST_FILTER-"
|
|
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 &> /dev/null; then
|
|
test_file=/data/widevine_tests/$test_file
|
|
else
|
|
test_file=/vendor/bin/$test_file
|
|
fi
|
|
echo $test_file
|
|
local tmp_log="$OUT/mediadrmtest.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
|
|
final_result=$result
|
|
failed_tests+=("$adb_error")
|
|
fi
|
|
}
|
|
|
|
# Use Package Manager (via adb shell) to enable or disable DroidGuard.
|
|
# Disabling DroidGuard during the test run prevents concurrency issues
|
|
# with provisioning status.
|
|
set_droidguard() {
|
|
adb shell pm $1 com.google.android.gms/com.google.android.gms.droidguard.DroidGuardService
|
|
}
|
|
|
|
if [ -z "$ANDROID_BUILD_TOP" ]; then
|
|
echo "Android build environment not set"
|
|
exit -1
|
|
fi
|
|
|
|
echo "waiting for device"
|
|
ADB_OUTPUT=`adb root && adb wait-for-device remount`
|
|
echo $ADB_OUTPUT
|
|
if echo $ADB_OUTPUT | grep -qi "verity"; then
|
|
echo
|
|
echo "ERROR: This device has Verity enabled. run_all_unit_tests.sh does not "
|
|
echo "work if Verity is enabled. Please disable Verity with"
|
|
echo "\"adb disable-verity\" and try again."
|
|
exit -1
|
|
fi
|
|
|
|
# Disable DroidGuard to prevent provisioning collisions
|
|
set_droidguard disable
|
|
|
|
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 cdm_extended_duration_test
|
|
adb_shell_run policy_engine_unittest
|
|
adb_shell_run policy_engine_constraints_unittest
|
|
adb_shell_run libwvdrmmediacrypto_test
|
|
adb_shell_run libwvdrmmediacrypto_hidl_test
|
|
adb_shell_run libwvdrmdrmplugin_test
|
|
adb_shell_run libwvdrmdrmplugin_hidl_test
|
|
adb_shell_run cdm_engine_test
|
|
adb_shell_run cdm_session_unittest
|
|
adb_shell_run file_store_unittest
|
|
adb_shell_run file_utils_unittest
|
|
adb_shell_run license_unittest
|
|
adb_shell_run license_keys_unittest
|
|
adb_shell_run initialization_data_unittest
|
|
adb_shell_run device_files_unittest
|
|
adb_shell_run service_certificate_unittest
|
|
adb_shell_run timer_unittest
|
|
adb_shell_run buffer_reader_test
|
|
adb_shell_run distribution_test
|
|
adb_shell_run event_metric_test
|
|
|
|
# Run the non-Treble test on non-Treble devices
|
|
if adb shell ls /vendor/lib/mediadrm/libwvdrmengine.so &> /dev/null ||
|
|
adb shell ls /vendor/lib64/mediadrm/libwvdrmengine.so &> /dev/null; then
|
|
library_path="/vendor/lib/mediadrm/:/vendor/lib64/mediadrm/"
|
|
adb_shell_run libwvdrmengine_test LD_LIBRARY_PATH=$library_path
|
|
fi
|
|
|
|
# Run the Treble test on Treble devices
|
|
if adb shell ls /vendor/lib/libwvhidl.so &> /dev/null ||
|
|
adb shell ls /vendor/lib64/libwvhidl.so &> /dev/null; then
|
|
adb_shell_run libwvdrmengine_hidl_test
|
|
fi
|
|
|
|
# Re-enable DroidGuard
|
|
set_droidguard enable
|