Allow tests to take serial number as a parameter

[ Merge of http://go/wvgerrit/67583 ]

The new command formats are
$ build_and_run_all_unit_tests.sh [-j <num>] [-s <device_number>]
$ run_all_unit_tests.sh [-s <device_number>]

Bug: 120519038
Test: WV unit/integration tests with a single device and with two devices
      connected (with and without specifying a target serial number)

Change-Id: I518038c3fc178a7eb658fcd4cf82dd13dfa7131f
This commit is contained in:
Rahul Frias
2018-12-04 23:33:11 -08:00
parent cb8631776a
commit 7653f2dc15
2 changed files with 32 additions and 17 deletions

View File

@@ -1,5 +1,16 @@
#!/bin/sh
# 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=()
@@ -19,7 +30,7 @@ fi
adb_shell_run() {
local test_file=$1
shift
if adb shell ls /data/bin/$test_file &> /dev/null; then
if adb $SERIAL_NUM shell ls /data/bin/$test_file &> /dev/null; then
test_file=/data/bin/$test_file
else
echo "Please install the test on the device in /data/bin, "
@@ -29,7 +40,7 @@ adb_shell_run() {
echo "------ Starting: $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"
adb $SERIAL_NUM 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
@@ -42,7 +53,7 @@ adb_shell_run() {
# 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
adb $SERIAL_NUM shell pm $1 com.google.android.gms/com.google.android.gms.droidguard.DroidGuardService
}
if [ -z "$ANDROID_BUILD_TOP" ]; then
@@ -51,13 +62,13 @@ if [ -z "$ANDROID_BUILD_TOP" ]; then
fi
echo "waiting for device"
ADB_OUTPUT=`adb root && echo ". " && adb wait-for-device remount`
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. run_all_unit_tests.sh does not "
echo "work if Verity is enabled. Please disable Verity with"
echo "\"adb disable-verity\" and try again."
echo "\"adb $SERIAL_NUM disable-verity\" and try again."
exit -1
fi
@@ -108,15 +119,15 @@ adb_shell_run value_metric_unittest
adb_shell_run wv_cdm_metrics_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
if adb $SERIAL_NUM shell ls /vendor/lib/mediadrm/libwvdrmengine.so &> /dev/null ||
adb $SERIAL_NUM 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
if adb $SERIAL_NUM shell ls /vendor/lib/libwvhidl.so &> /dev/null ||
adb $SERIAL_NUM shell ls /vendor/lib64/libwvhidl.so &> /dev/null; then
adb_shell_run libwvdrmengine_hidl_test
fi