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