• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#! /bin/bash
2
3# Copyright (C) 2009 The Android Open Source Project
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 [ -z "${SDK_ROOT}" ]; then
18# CONFIGURATION
19# Set this variable to the root of your Android SDK installation.
20SDK_ROOT=NOT_CONFIGURED
21fi;
22
23if [ -z "${CTS_ROOT}" ]; then
24# CONFIGURATION
25# Set this variable to the root of unzipped CTS directory
26# This only needs to be changed if this script has been moved
27CTS_ROOT="$(dirname $0)/.."
28fi;
29
30# ----------------------------------------------------------------------------
31# END OF CONFIGURATION SECTION
32# ----------------------------------------------------------------------------
33
34checkDir() {
35    if [ ! -d $1 ]; then
36        echo "$2"
37        exit
38    fi;
39}
40
41
42checkFile() {
43    if [ ! -f "$1" ]; then
44        echo "Unable to locate $1."
45        exit
46    fi;
47}
48
49checkDir ${CTS_ROOT} "Error: Cannot locate CTS in \"${CTS_DIR}\". Please check your configuration in $0"
50checkDir ${SDK_ROOT} "Error: Cannot locate SDK installation in \"${SDK_ROOT}\". Please check your configuration in $0"
51
52DDM_LIB=${SDK_ROOT}/tools/lib/ddmlib.jar
53CTS_LIB=${CTS_ROOT}/tools/cts.jar
54JUNIT_LIB=${CTS_ROOT}/tools/junit.jar
55HOSTTEST_LIB=${CTS_ROOT}/tools/hosttestlib.jar
56ADB_PATH=${SDK_ROOT}/tools
57ADB_EXE=${ADB_PATH}/adb
58
59checkFile ${DDM_LIB}
60checkFile ${CTS_LIB}
61checkFile ${JUNIT_LIB}
62checkFile ${HOSTTEST_LIB}
63checkFile ${ADB_EXE}
64
65JARS=${CTS_LIB}:${DDM_LIB}:${JUNIT_LIB}:${HOSTTEST_LIB}
66
67PATH=${ADB_PATH}:${PATH}
68
69# options for the JVM
70JAVA_OPTS="-Xmx512M"
71# configuration supplied as single argument
72CONFIG=
73# configuration supplied with --config option
74DDCONFIG=
75
76if [ $# -eq 1 ]; then
77    # single argument specifies configuration file
78    :
79else
80    if [ $(echo "$*" | grep -c -e --config -) -gt 0 ]; then
81        # --config supplied on command line
82        :
83    else
84        if [ $# -eq 0 ]; then
85            # no arguments; supply config as single argument
86            CONFIG=${CTS_ROOT}/repository/host_config.xml
87        else
88            # no config; append --config to existing command line
89            DDCONFIG="--config ${CTS_ROOT}/repository/host_config.xml"
90        fi;
91    fi;
92fi;
93
94java ${JAVA_OPTS} -cp ${JARS} com.android.cts.TestHost ${CONFIG} "$@" ${DDCONFIG}
95