1#!/usr/bin/env bash
2
3# Copyright 2018 Google Inc. All rights reserved.
4
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8
9#     http://www.apache.org/licenses/LICENSE-2.0
10
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
17if [[ "$1" == "--help" ]]; then
18  cat <<END
19Usage for $0
20
21	<no-args>			run all tests
22	-r				print raw results
23	-e class <class>[#<test>]	run test/s specified by class
24
25Example:
26$ $0 -r -e class com.android.cuttlefish.wifi.WifiE2eTests#testWifiConnects
27Run just the specified test, and show the raw output.
28END
29  exit 0
30fi
31
32if [ -z $ANDROID_BUILD_TOP ]; then
33  echo "You need to source and lunch before you can use this script"
34  exit 1
35fi
36
37set -e # fail early
38make -j32 -C $ANDROID_BUILD_TOP -f build/core/main.mk CuttlefishWifiTests
39adb wait-for-device
40# Same as 'package' in manifest file
41adb uninstall com.android.cuttlefish.wifi.tests || true
42adb install -r -g "$OUT/data/app/CuttlefishWifiTests/CuttlefishWifiTests.apk"
43# optionally: -e class com.android.cuttlefish.wifi.WifiE2eTests#testName
44adb shell am instrument -w "$@" 'com.android.cuttlefish.wifi.tests/androidx.test.runner.AndroidJUnitRunner'
45