Files
android/libwvdrmengine/run_reboot_test.sh
Alex Dale 659301abd3 Specified /bin/bash for Android scripts.
[ Merge of http://go/wvgerrit/165139 ]

Changed the specified shell program used to execute our team's Android
scripts to bash.

Bug: 266891333
Test: ./build_all_unit_tests.sh
Change-Id: Id6fc8e4db10a71e9f17fc48a52a4883331e908d3
2023-01-26 22:23:25 -08:00

96 lines
3.1 KiB
Bash
Executable File

#!/bin/bash
# Read arguments in case the user wants to copy files to a specific
# android device by providing a serial number
SERIAL_NUM=""
while getopts "j:s:" opt; do
case $opt in
s)
SERIAL_NUM="-s $OPTARG"
;;
esac
done
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
# The Android supplement allows for installation in these paths:
OEC_PATHS=/vendor/lib64:/vendor/lib:/system/lib64/vndk-R:/system/lib/vndk-R
# Execute reboot_test in "adb shell" and capture the result.
run_one_pass() {
local test_file=$1
shift
local test_pass=$1
shift
if adb $SERIAL_NUM shell ls /data/nativetest/$test_file &> /dev/null; then
test_file=/data/nativetest/$test_file
else
echo "Please install the test on the device in /data/nativetest, "
echo "or begin execution by running ./build_and_run_all_unit_tests.sh"
exit 1
fi
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
TEST_ENV="LD_LIBRARY_PATH=$OEC_PATHS GTEST_FILTER=$GTEST_FILTER"
COMMAND="$test_file --pass=$test_pass --test_data_path=/data/vendor/mediadrm"
echo "adb $SERIAL_NUM shell \"$TEST_ENV $COMMAND\""
adb $SERIAL_NUM shell "$TEST_ENV $COMMAND" \|\| 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
}
if [ -z "$ANDROID_BUILD_TOP" ]; then
echo "Android build environment not set"
exit -1
fi
echo "waiting for device"
ADB_OUTPUT=`adb $SERIAL_NUM root && echo ". " && adb $SERIAL_NUM wait-for-device remount`
echo $ADB_OUTPUT
if echo $ADB_OUTPUT | grep -qi "verity"; then
echo
echo "ERROR: This device has Verity enabled. $0 does not "
echo "work if Verity is enabled. Please disable Verity with"
echo "\"adb $SERIAL_NUM disable-verity\" and try again."
exit -1
fi
run_one_pass reboot_test 0 || exit -1
echo "ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ Reboot device."
sleep 1
adb reboot
sleep 1
adb wait-for-device root
sleep 1
adb wait-for-device remount
sleep 1
run_one_pass reboot_test 1 || exit -1