Home | History | Annotate | Download | only in tools
      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 if [ ! -d libcore ]; then
     18   echo "Script needs to be run at the root of the android tree"
     19   exit 1
     20 fi
     21 
     22 # Jar containing all the tests.
     23 test_jack=${OUT_DIR-out}/host/common/obj/JAVA_LIBRARIES/apache-harmony-jdwp-tests-hostdex_intermediates/classes.jack
     24 
     25 if [ ! -f $test_jack ]; then
     26   echo "Before running, you must build jdwp tests and vogar:" \
     27        "make apache-harmony-jdwp-tests-hostdex vogar"
     28   exit 1
     29 fi
     30 
     31 if [ "x$ART_USE_READ_BARRIER" = xtrue ]; then
     32   # For the moment, skip JDWP tests when read barriers are enabled, as
     33   # they sometimes exhibit a deadlock issue with the concurrent
     34   # copying collector in the read barrier configuration, between the
     35   # HeapTaskDeamon and the JDWP thread (b/25800335).
     36   #
     37   # TODO: Re-enable the JDWP tests when this deadlock issue is fixed.
     38   echo "JDWP tests are temporarily disabled in the read barrier configuration because of"
     39   echo "a deadlock issue (b/25800335)."
     40   exit 0
     41 fi
     42 
     43 art="/data/local/tmp/system/bin/art"
     44 art_debugee="sh /data/local/tmp/system/bin/art"
     45 args=$@
     46 debuggee_args="-Xcompiler-option --debuggable"
     47 device_dir="--device-dir=/data/local/tmp"
     48 # We use the art script on target to ensure the runner and the debuggee share the same
     49 # image.
     50 vm_command="--vm-command=$art"
     51 image_compiler_option=""
     52 debug="no"
     53 verbose="no"
     54 image="-Ximage:/data/art-test/core-optimizing-pic.art"
     55 vm_args=""
     56 # By default, we run the whole JDWP test suite.
     57 test="org.apache.harmony.jpda.tests.share.AllTests"
     58 host="no"
     59 
     60 while true; do
     61   if [[ "$1" == "--mode=host" ]]; then
     62     host="yes"
     63     # Specify bash explicitly since the art script cannot, since it has to run on the device
     64     # with mksh.
     65     art="bash ${OUT_DIR-out}/host/linux-x86/bin/art"
     66     art_debugee="bash ${OUT_DIR-out}/host/linux-x86/bin/art"
     67     # We force generation of a new image to avoid build-time and run-time classpath differences.
     68     image="-Ximage:/system/non/existent/vogar.art"
     69     # We do not need a device directory on host.
     70     device_dir=""
     71     # Vogar knows which VM to use on host.
     72     vm_command=""
     73     shift
     74   elif [[ $1 == -Ximage:* ]]; then
     75     image="$1"
     76     shift
     77   elif [[ $1 == "--debug" ]]; then
     78     debug="yes"
     79     # Remove the --debug from the arguments.
     80     args=${args/$1}
     81     shift
     82   elif [[ $1 == "--verbose" ]]; then
     83     verbose="yes"
     84     # Remove the --verbose from the arguments.
     85     args=${args/$1}
     86     shift
     87   elif [[ $1 == "--test" ]]; then
     88     # Remove the --test from the arguments.
     89     args=${args/$1}
     90     shift
     91     test=$1
     92     # Remove the test from the arguments.
     93     args=${args/$1}
     94     shift
     95   elif [[ "$1" == "" ]]; then
     96     break
     97   else
     98     shift
     99   fi
    100 done
    101 
    102 if [[ "$image" != "" ]]; then
    103   vm_args="--vm-arg $image"
    104 fi
    105 vm_args="$vm_args --vm-arg -Xusejit:true"
    106 debuggee_args="$debuggee_args -Xusejit:true"
    107 if [[ $debug == "yes" ]]; then
    108   art="$art -d"
    109   art_debugee="$art_debugee -d"
    110   vm_args="$vm_args --vm-arg -XXlib:libartd.so"
    111 fi
    112 if [[ $verbose == "yes" ]]; then
    113   # Enable JDWP logs in the debuggee.
    114   art_debugee="$art_debugee -verbose:jdwp"
    115 fi
    116 
    117 # Run the tests using vogar.
    118 vogar $vm_command \
    119       $vm_args \
    120       --verbose \
    121       $args \
    122       $device_dir \
    123       $image_compiler_option \
    124       --timeout 800 \
    125       --vm-arg -Djpda.settings.verbose=true \
    126       --vm-arg -Djpda.settings.transportAddress=127.0.0.1:55107 \
    127       --vm-arg -Djpda.settings.debuggeeJavaPath="$art_debugee $image $debuggee_args" \
    128       --classpath $test_jack \
    129       --toolchain jack --language JN \
    130       --vm-arg -Xcompiler-option --vm-arg --debuggable \
    131       $test
    132 
    133 vogar_exit_status=$?
    134 
    135 echo "Killing stalled dalvikvm processes..."
    136 if [[ $host == "yes" ]]; then
    137   pkill -9 -f /bin/dalvikvm
    138 else
    139   adb shell pkill -9 -f /bin/dalvikvm
    140 fi
    141 echo "Done."
    142 
    143 exit $vogar_exit_status
    144