blob: d003e0395497b1f3df3283fcdf73ed34494411e3 [file] [log] [blame]
Akash Agrawalabca7d42019-04-05 08:21:21 -07001#!/bin/bash
Akash Agrawal05116452019-04-18 07:53:24 -07002# It is to be used with BYOB setup to run tests on cloud VMs.
3# It will run UI and boot tests on them.
Akash Agrawalabca7d42019-04-05 08:21:21 -07004#
Akash Agrawal05116452019-04-18 07:53:24 -07005# It takes 3 command line arguments.
Akash Agrawalabca7d42019-04-05 08:21:21 -07006# DIST_DIR => Absolute path for the distribution directory.
Akash Agrawal05116452019-04-18 07:53:24 -07007# API => API number for the system image
8# ORI => branch code for the system image
Akash Agrawalabca7d42019-04-05 08:21:21 -07009#
10# It will return 0 if it is able to execute tests, otherwise
11# it will return 1.
12#
Akash Agrawal05116452019-04-18 07:53:24 -070013# For the test results please refer to go/dashboard-adt
14#
Akash Agrawalabca7d42019-04-05 08:21:21 -070015# Owner: akagrawal@google.com
16
17DIST_DIR=$1
Akash Agrawal05116452019-04-18 07:53:24 -070018API=$2
19ORI=$3
20
21function run_with_timeout () {
22 ( $1 $2 $3 $4 ) & pid=$!
23 ( sleep $5 && kill -HUP $pid ) 2>/dev/null & watcher=$!
24 if wait $pid 2>/dev/null; then
25 pkill -HUP -P $watcher
26 wait $watcher
27 else
28 echo "Test time out."
29 exit 1
30 fi
31}
32
33echo "Checkout adt-infra repo"
34# $ADT_INFRA has to be set on the build machine. It should have absolute path
35# where adt-infra needs to be checked out.
36rm -rf $ADT_INFRA
37git clone https://android.googlesource.com/platform/external/adt-infra -b emu-master-dev $ADT_INFRA
Akash Agrawalabca7d42019-04-05 08:21:21 -070038
39BUILD_DIR="out/prebuilt_cached/builds"
40
Akash Agrawal05116452019-04-18 07:53:24 -070041export ANDROID_HOME=$SDK_SYS_IMAGE
42export ANDROID_SDK_ROOT=$SDK_SYS_IMAGE
Akash Agrawalabca7d42019-04-05 08:21:21 -070043
Akash Agrawal05116452019-04-18 07:53:24 -070044echo "Setup builds"
45$ADT_INFRA/emu_test/utils/setup_builds.sh $BUILD_DIR $API
Akash Agrawalabca7d42019-04-05 08:21:21 -070046
Akash Agrawal05116452019-04-18 07:53:24 -070047echo "Run Boot tests from $ADT_INFRA"
48cmd="$ADT_INFRA/emu_test/utils/run_boot_test.sh"
49run_with_timeout $cmd $DIST_DIR $ORI $API 5400
Akash Agrawalabca7d42019-04-05 08:21:21 -070050
Weilun Du86882ff2019-06-27 12:17:07 -070051# Skip UI tests for presubmit build which has a build number starts with P.
52if [[ $BUILD_NUMBER != P* ]]; then
53 echo "Run UI tests from $ADT_INFRA"
54 cmd="$ADT_INFRA/emu_test/utils/run_ui_test.sh"
55 run_with_timeout $cmd $DIST_DIR $ORI $API 10800
56fi
Akash Agrawalabca7d42019-04-05 08:21:21 -070057
Akash Agrawalc5e6c032019-04-09 11:34:38 -070058echo "Cleanup prebuilts"
59rm -rf /buildbot/prebuilt/*
60
Akash Agrawalabca7d42019-04-05 08:21:21 -070061exit 0