1#!/bin/bash
2# It is to be used with BYOB setup to run CTS tests.
3#
4# It takes 1 command line argument.
5# DIST_DIR => Absolute path for the distribution directory.
6#
7# It will return 0 if it is able to execute tests, otherwise
8# it will return 1.
9#
10# Owner: akagrawal@google.com
11
12DIST_DIR=$1
13BUILD_ID=$2
14
15BUILD_DIR="out/prebuilt_cached/builds"
16
17if [ ! -d "$BUILD_DIR/test_suite" ];
18then
19    echo "Test suite does not exist"
20    exit 1
21fi
22#for cts, android-cts.zip
23#for gts, android-gts.zip
24if [[ `ls $BUILD_DIR/test_suite` == *"cts"* ]]
25then
26    TEST_SUITE="android-cts.zip"
27elif [[ `ls $BUILD_DIR/test_suite` == *"gts"* ]]
28then
29    TEST_SUITE="android-gts.zip"
30else
31    echo "Test suite does not exist"
32    exit 1
33fi
34echo "$TEST_SUITE"
35
36mkdir -p $BUILD_DIR/emulator
37fetch_artifacts.py -build_target linux-sdk_tools_linux -branch aosp-emu-master-dev -image_path gs://android-build-emu/builds -dest $BUILD_DIR/emulator/
38EMU_BIN=`ls $BUILD_DIR/emulator`
39echo "$EMU_BIN"
40
41if [ -d "$BUILD_DIR/gphone_x86-user" ];
42then
43    SYS_IMAGE=`ls $BUILD_DIR/gphone_x86-user`
44    if [[ $TEST_SUITE == *"cts"* ]]
45    then
46        echo "Run CTS with $SYS_IMAGE"
47    elif [[ $TEST_SUITE == *"gts"* ]]
48    then
49        echo "Run GTS with $SYS_IMAGE"
50    fi
51fi
52
53if [ -d "$BUILD_DIR/gphone_x86_64-user" ];
54then
55    SYS_IMAGE_64=`ls $BUILD_DIR/gphone_x86_64-user`
56    if [[ $TEST_SUITE == *"cts"* ]]
57    then
58        echo "Run CTS with $SYS_IMAGE_64"
59    elif [[ $TEST_SUITE == *"gts"* ]]
60    then
61        echo "Run GTS with $SYS_IMAGE_64"
62    fi
63fi
64
65echo "Cleanup prebuilts"
66rm -rf /buildbot/prebuilt/*
67
68exit 0
69