Akash Agrawal | abca7d4 | 2019-04-05 08:21:21 -0700 | [diff] [blame] | 1 | #!/bin/bash |
Akash Agrawal | 0511645 | 2019-04-18 07:53:24 -0700 | [diff] [blame] | 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. |
Akash Agrawal | abca7d4 | 2019-04-05 08:21:21 -0700 | [diff] [blame] | 4 | # |
Akash Agrawal | 0511645 | 2019-04-18 07:53:24 -0700 | [diff] [blame] | 5 | # It takes 3 command line arguments. |
Akash Agrawal | abca7d4 | 2019-04-05 08:21:21 -0700 | [diff] [blame] | 6 | # DIST_DIR => Absolute path for the distribution directory. |
Akash Agrawal | 0511645 | 2019-04-18 07:53:24 -0700 | [diff] [blame] | 7 | # API => API number for the system image |
| 8 | # ORI => branch code for the system image |
Akash Agrawal | abca7d4 | 2019-04-05 08:21:21 -0700 | [diff] [blame] | 9 | # |
| 10 | # It will return 0 if it is able to execute tests, otherwise |
| 11 | # it will return 1. |
| 12 | # |
Akash Agrawal | 0511645 | 2019-04-18 07:53:24 -0700 | [diff] [blame] | 13 | # For the test results please refer to go/dashboard-adt |
| 14 | # |
Akash Agrawal | abca7d4 | 2019-04-05 08:21:21 -0700 | [diff] [blame] | 15 | # Owner: akagrawal@google.com |
| 16 | |
| 17 | DIST_DIR=$1 |
Akash Agrawal | 0511645 | 2019-04-18 07:53:24 -0700 | [diff] [blame] | 18 | API=$2 |
| 19 | ORI=$3 |
| 20 | |
| 21 | function 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 | |
| 33 | echo "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. |
| 36 | rm -rf $ADT_INFRA |
| 37 | git clone https://android.googlesource.com/platform/external/adt-infra -b emu-master-dev $ADT_INFRA |
Akash Agrawal | abca7d4 | 2019-04-05 08:21:21 -0700 | [diff] [blame] | 38 | |
| 39 | BUILD_DIR="out/prebuilt_cached/builds" |
| 40 | |
Akash Agrawal | 0511645 | 2019-04-18 07:53:24 -0700 | [diff] [blame] | 41 | export ANDROID_HOME=$SDK_SYS_IMAGE |
| 42 | export ANDROID_SDK_ROOT=$SDK_SYS_IMAGE |
Akash Agrawal | abca7d4 | 2019-04-05 08:21:21 -0700 | [diff] [blame] | 43 | |
Akash Agrawal | 0511645 | 2019-04-18 07:53:24 -0700 | [diff] [blame] | 44 | echo "Setup builds" |
| 45 | $ADT_INFRA/emu_test/utils/setup_builds.sh $BUILD_DIR $API |
Akash Agrawal | abca7d4 | 2019-04-05 08:21:21 -0700 | [diff] [blame] | 46 | |
Akash Agrawal | 0511645 | 2019-04-18 07:53:24 -0700 | [diff] [blame] | 47 | echo "Run Boot tests from $ADT_INFRA" |
| 48 | cmd="$ADT_INFRA/emu_test/utils/run_boot_test.sh" |
| 49 | run_with_timeout $cmd $DIST_DIR $ORI $API 5400 |
Akash Agrawal | abca7d4 | 2019-04-05 08:21:21 -0700 | [diff] [blame] | 50 | |
Weilun Du | 86882ff | 2019-06-27 12:17:07 -0700 | [diff] [blame] | 51 | # Skip UI tests for presubmit build which has a build number starts with P. |
| 52 | if [[ $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 |
| 56 | fi |
Akash Agrawal | abca7d4 | 2019-04-05 08:21:21 -0700 | [diff] [blame] | 57 | |
Akash Agrawal | c5e6c03 | 2019-04-09 11:34:38 -0700 | [diff] [blame] | 58 | echo "Cleanup prebuilts" |
| 59 | rm -rf /buildbot/prebuilt/* |
| 60 | |
Akash Agrawal | abca7d4 | 2019-04-05 08:21:21 -0700 | [diff] [blame] | 61 | exit 0 |