• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2# It is to be used with BYOB setup to run tests on cloud VMs.
3# It will run UI and boot tests on them.
4#
5# It takes 3 command line arguments.
6# DIST_DIR => Absolute path for the distribution directory.
7# API => API number for the system image
8# ORI => branch code for the system image
9#
10# It will return 0 if it is able to execute tests, otherwise
11# it will return 1.
12#
13# For the test results please refer to go/dashboard-adt
14#
15# Owner: akagrawal@google.com
16
17DIST_DIR=$1
18API=$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
38
39BUILD_DIR="out/prebuilt_cached/builds"
40
41export ANDROID_HOME=$SDK_SYS_IMAGE
42export ANDROID_SDK_ROOT=$SDK_SYS_IMAGE
43
44echo "Setup builds"
45$ADT_INFRA/emu_test/utils/setup_builds.sh $BUILD_DIR $API
46
47echo "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
50
51# 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
57
58echo "Cleanup prebuilts"
59rm -rf /buildbot/prebuilt/*
60
61exit 0
62