Advertisement
Guest User

Untitled

a guest
Apr 8th, 2018
124
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2.  
  3. # Copyright (C) 2015 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.  
  17. # launcher script for cts-tradefed harness
  18. # can be used from an Android build environment, or a standalone cts zip
  19.  
  20. checkFile() {
  21.     if [ ! -f "$1" ]; then
  22.         echo "Unable to locate $1"
  23.         exit
  24.     fi;
  25. }
  26.  
  27. checkPath() {
  28.     if ! type -P $1 &> /dev/null; then
  29.         echo "Unable to find $1 in path."
  30.         exit
  31.     fi;
  32. }
  33.  
  34. checkPath aapt
  35. checkPath adb
  36. checkPath java
  37.  
  38. # check java version
  39. JAVA_VERSION=$(java -version 2>&1 | head -n 2 | grep '[ "]1\.[678][\. "$$]')
  40. if [ "${JAVA_VERSION}" == "" ]; then
  41.     echo "Wrong java version. 1.6, 1.7 or 1.8 is required."
  42.     exit
  43. fi
  44.  
  45. # check debug flag and set up remote debugging
  46. if [ -n "${TF_DEBUG}" ]; then
  47.   if [ -z "${TF_DEBUG_PORT}" ]; then
  48.     TF_DEBUG_PORT=10088
  49.   fi
  50.   RDBG_FLAG=-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=${TF_DEBUG_PORT}
  51. fi
  52.  
  53. # get OS
  54. HOST=`uname`
  55. if [ "$HOST" == "Linux" ]; then
  56.     OS="linux-x86"
  57. elif [ "$HOST" == "Darwin" ]; then
  58.     OS="darwin-x86"
  59. else
  60.     echo "Unrecognized OS"
  61.     exit
  62. fi
  63.  
  64. # check if in Android build env
  65. if [ ! -z "${ANDROID_BUILD_TOP}" ]; then
  66.     if [ ! -z "${ANDROID_HOST_OUT}" ]; then
  67.       CTS_ROOT=${ANDROID_HOST_OUT}/cts
  68.     else
  69.       CTS_ROOT=${ANDROID_BUILD_TOP}/${OUT_DIR:-out}/host/${OS}/cts
  70.     fi
  71.     if [ ! -d ${CTS_ROOT} ]; then
  72.         echo "Could not find $CTS_ROOT in Android build environment. Try 'make cts'"
  73.         exit
  74.     fi;
  75. fi;
  76.  
  77. if [ -z ${CTS_ROOT} ]; then
  78.     # assume we're in an extracted cts install
  79.     CTS_ROOT="$(dirname $0)/../.."
  80. fi;
  81.  
  82. JAR_DIR=${CTS_ROOT}/android-cts/tools
  83. JARS="tradefed
  84.  hosttestlib
  85.  compatibility-host-util
  86.  compatibility-host-util-tests
  87.  cts-tradefed
  88.  cts-tradefed-tests
  89.  compatibility-common-util-tests
  90.  compatibility-tradefed-tests
  91.  host-libprotobuf-java-full"
  92.  
  93. for JAR in $JARS; do
  94.     checkFile ${JAR_DIR}/${JAR}.jar
  95.     JAR_PATH=${JAR_PATH}:${JAR_DIR}/${JAR}.jar
  96. done
  97.  
  98. OPTIONAL_JARS="
  99.  google-tradefed
  100.  google-tradefed-tests
  101.  google-tf-prod-tests"
  102.  
  103. for JAR in $OPTIONAL_JARS; do
  104.     if [ -f "${JAR_DIR}/${JAR}.jar" ]; then
  105.         JAR_PATH=${JAR_PATH}:${JAR_DIR}/${JAR}.jar
  106.     fi;
  107. done
  108.  
  109. # load any shared libraries for host-side executables
  110. LIB_DIR=${CTS_ROOT}/android-cts/lib
  111. if [ "$HOST" == "Linux" ]; then
  112.     LD_LIBRARY_PATH=${LIB_DIR}:${LIB_DIR}64:${LD_LIBRARY_PATH}
  113.     export LD_LIBRARY_PATH
  114. elif [ "$HOST" == "Darwin" ]; then
  115.     DYLD_LIBRARY_PATH=${LIB_DIR}:${LIB_DIR}64:${DYLD_LIBRARY_PATH}
  116.     export DYLD_LIBRARY_PATH
  117. fi
  118.  
  119. # include any host-side test jars
  120. for j in ${CTS_ROOT}/android-cts/testcases/*.jar; do
  121.     JAR_PATH=${JAR_PATH}:$j
  122. done
  123.  
  124. java $RDBG_FLAG -Xmx4g -XX:+HeapDumpOnOutOfMemoryError -cp ${JAR_PATH} -DCTS_ROOT=${CTS_ROOT} com.android.compatibility.common.tradefed.command.CompatibilityConsole "$@"
Advertisement
RAW Paste Data Copied
Advertisement