1#!/usr/bin/env bash
2
3if [[ "$1" == "--help" ]]; then
4  cat <<END
5Usage for $0
6
7	<no-args>			run all tests
8	-r				print raw results
9	-e class <class-name>		run all the tests in <class-name>
10	-e class <class-name>#<method>	run just the specified <method>
11
12Example:
13$ $0 -r -e class \\
14  com.android.server.wifi.WifiDiagnosticsTest#startLoggingRegistersLogEventHandler
15Run just the specified test, and show the raw output.
16
17For more options, see https://goo.gl/JxYjIw
18END
19  exit 0
20fi
21
22if [ -z $ANDROID_BUILD_TOP ]; then
23  echo "You need to source and lunch before you can use this script"
24  exit 1
25fi
26
27echo "Running tests"
28
29set -e # fail early
30
31echo "+ mmma -j32 $ANDROID_BUILD_TOP/frameworks/opt/net/wifi/tests"
32# NOTE Don't actually run the command above since this shell doesn't inherit functions from the
33#      caller.
34$ANDROID_BUILD_TOP/build/soong/soong_ui.bash --make-mode MODULES-IN-frameworks-opt-net-wifi-tests
35APK_NAME="$(ls -t $(find $OUT -name FrameworksWifiTests.apk) | head -n 1)"
36
37set -x # print commands
38
39adb root
40adb wait-for-device
41
42adb install -r -g "$APK_NAME"
43
44adb shell am instrument --no-hidden-api-checks -w "$@" \
45  'com.android.server.wifi.test/com.android.server.wifi.CustomTestRunner'
46