Home | History | Annotate | Download | only in jdwp
      1 #
      2 # Copyright (C) 2015 The Android Open Source Project
      3 #
      4 # Licensed under the Apache License, Version 2.0 (the "License");
      5 # you may not use this file except in compliance with the License.
      6 # You may obtain a copy of the License at
      7 #
      8 #      http://www.apache.org/licenses/LICENSE-2.0
      9 #
     10 # Unless required by applicable law or agreed to in writing, software
     11 # distributed under the License is distributed on an "AS IS" BASIS,
     12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13 # See the License for the specific language governing permissions and
     14 # limitations under the License.
     15 #
     16 
     17 # Debug configuration (development and continuous testing)
     18 #
     19 # We run in debug mode to get more error checking and enable JDWP verbose logs
     20 # to investigate failures during testing.
     21 
     22 # Target settings
     23 jdwp_test_classpath_target := /data/jdwp/apache-harmony-jdwp-tests.jar:/data/junit/junit.jar
     24 jdwp_test_runtime_bin_target := dalvikvm
     25 
     26 # Host settings
     27 jdwp_test_classpath_host := $(HOST_OUT_JAVA_LIBRARIES)/apache-harmony-jdwp-tests-hostdex.jar:$(HOST_OUT_JAVA_LIBRARIES)/junit-hostdex.jar
     28 jdwp_test_runtime_bin_host := $(HOST_OUT_EXECUTABLES)/art
     29 
     30 # Common runtime settings for runner and debuggee.
     31 jdwp_test_common_runtime_options := -XXlib:libartd.so -Xcompiler-option --debuggable
     32 
     33 # Debuggee runtime options
     34 jdwp_test_runtime_options := -verbose:jdwp
     35 #jdwp_test_runtime_options += -Xint # interpret-only mode
     36 #jdwp_test_runtime_options += -Xnoimage-dex2oat # imageless mode
     37 #jdwp_test_runtime_options += -Xcompiler-option --compiler-backend=Optimizing # optimizing compiler
     38 #jdwp_test_runtime_options += -verbose:threads
     39 
     40 # Test suite class name
     41 jdwp_test_suite_class_name := org.apache.harmony.jpda.tests.share.AllTests
     42 
     43 # The lists of ABIs supported on host and target.
     44 jdwp_tests_host_abis :=
     45 jdwp_tests_target_abis :=
     46 
     47 ifneq ($(HOST_PREFER_32_BIT),true)
     48   jdwp_tests_host_abis := 64 32
     49 else
     50   jdwp_tests_host_abis := 32
     51 endif
     52 
     53 ifdef TARGET_2ND_ARCH
     54   ifeq ($(TARGET_IS_64_BIT),true)
     55     jdwp_tests_target_abis := 64 32
     56   else
     57     jdwp_tests_target_abis := 32
     58     $(warning Unsupported multi-target configuration!)
     59   endif
     60 else
     61   ifeq ($(TARGET_IS_64_BIT),true)
     62     jdwp_tests_target_abis := 64
     63   else
     64     jdwp_tests_target_abis := 32
     65   endif
     66 endif
     67 
     68 jdwp_tests_host_dependencies := \
     69   $(HOST_OUT_EXECUTABLES)/art \
     70   $(HOST_OUT_JAVA_LIBRARIES)/apache-harmony-jdwp-tests-hostdex.jar \
     71   $(HOST_OUT_JAVA_LIBRARIES)/junit-hostdex.jar
     72 
     73 jdwp_tests_target_dependencies := \
     74   $(TARGET_OUT_DATA)/jdwp/apache-harmony-jdwp-tests.jar \
     75   $(TARGET_OUT_DATA)/junit/junit.jar
     76 
     77 # Define a JDWP host rule
     78 #
     79 # $(1) ABI (32 or 64)
     80 # $(2) rule name (ex: run-jdwp-tests-host32)
     81 # $(3) extra dependency rule (ex: run-jdwp-tests-host-all64)
     82 define define-jdwp-host-rule
     83 .PHONY: $(2)
     84 $(2): jdwp_test_runtime_host := $(jdwp_test_runtime_bin_host) --$(1) $(jdwp_test_common_runtime_options)
     85 $(2): $(jdwp_tests_host_dependencies) $(3)
     86 	$(hide) echo "Running JDWP $(1)-bit host tests"
     87 	$$(jdwp_test_runtime_host) -cp $(jdwp_test_classpath_host) \
     88     $(jdwp_test_target_runtime_common_args) \
     89     -Djpda.settings.debuggeeJavaPath='$$(jdwp_test_runtime_host) $(jdwp_test_runtime_options)' \
     90     $(jdwp_test_suite_class_name)
     91 endef
     92 
     93 # Declare all JDWP host rules
     94 #
     95 # $(1) ABI (32 or 64)
     96 define declare-jdwp-host-rule
     97   # Declare standalone host rule for the given ABI.
     98   $(eval $(call define-jdwp-host-rule,$(1),run-jdwp-tests-host$(1),))
     99 
    100   # Declare variant host rule for run-jdwp-tests-host. It depends on the previous abi rule(s)
    101   # so all ABIs are tested.
    102   $(eval $(call define-jdwp-host-rule,$(1),run-jdwp-tests-host-all$(1),$(jdwp_tests_previous_host_rule)))
    103   jdwp_tests_previous_host_rule := run-jdwp-tests-host-all$(1)
    104 endef
    105 
    106 # Waits for device to boot completely.
    107 define wait-for-boot-complete
    108 $(hide) echo "Wait for boot complete ..."
    109 $(hide) while [ `adb wait-for-device shell getprop dev.bootcomplete | grep -c 1` -eq 0 ]; \
    110 do \
    111   sleep 1; \
    112 done
    113 $(hide) echo "Boot complete"
    114 endef
    115 
    116 # Define a JDWP target rule
    117 #
    118 # $(1) ABI (32 or 64)
    119 # $(2) rule name (ex: run-jdwp-tests-target32)
    120 # $(3) extra dependency rule (ex: run-jdwp-tests-target-all64)
    121 define define-jdwp-target-rule
    122 .PHONY: $(2)
    123 $(2): jdwp_test_runtime_target := $(jdwp_test_runtime_bin_target)$(1) $(jdwp_test_common_runtime_options)
    124 $(2): $(jdwp_tests_target_dependencies) $(3)
    125 	$(hide) echo "Running JDWP $(1)-bit target tests"
    126 	adb root
    127 	adb wait-for-device shell stop
    128 	adb remount
    129 	adb sync
    130 	adb reboot
    131 	$$(call wait-for-boot-complete)
    132 	adb shell $$(jdwp_test_runtime_target) -cp $(jdwp_test_classpath_target) \
    133     $(jdwp_test_target_runtime_common_args) \
    134     -Djpda.settings.debuggeeJavaPath='$$(jdwp_test_runtime_target) $(jdwp_test_runtime_options)' \
    135     $(jdwp_test_suite_class_name)
    136 endef
    137 
    138 # Declare all JDWP target rules
    139 #
    140 # $(1) ABI (32 or 64)
    141 define declare-jdwp-target-rule
    142   # Declare standalone target rule for the given ABI.
    143   $(eval $(call define-jdwp-target-rule,$(1),run-jdwp-tests-target$(1),))
    144 
    145   # Declare variant target rule for run-jdwp-tests-target. It depends on the previous abi rule(s)
    146   # so all ABIs are tested.
    147   $(eval $(call define-jdwp-target-rule,$(1),run-jdwp-tests-target-all$(1),$(jdwp_tests_previous_target_rule)))
    148   jdwp_tests_previous_target_rule := run-jdwp-tests-target-all$(1)
    149 endef
    150 
    151 # Declare host and target rules for each ABI
    152 $(foreach abi,$(jdwp_tests_host_abis),$(eval $(call declare-jdwp-host-rule,$(abi))))
    153 $(foreach abi,$(jdwp_tests_target_abis),$(eval $(call declare-jdwp-target-rule,$(abi))))
    154 
    155 # High level host and target rules running tests for each ABI.
    156 .PHONY: run-jdwp-tests-host
    157 run-jdwp-tests-host: $(jdwp_tests_previous_host_rule)
    158 
    159 .PHONY: run-jdwp-tests-target
    160 run-jdwp-tests-target: $(jdwp_tests_previous_target_rule)
    161 
    162 jdwp_tests_host_abis :=
    163 jdwp_tests_target_abis :=
    164 jdwp_tests_host_dependencies :=
    165 jdwp_tests_target_dependencies :=
    166 
    167 .PHONY: run-jdwp-tests-ri
    168 run-jdwp-tests-ri: $(HOST_OUT_JAVA_LIBRARIES)/apache-harmony-jdwp-tests-host.jar $(HOST_OUT_JAVA_LIBRARIES)/junit.jar
    169 	$(hide) java -cp $(HOST_OUT_JAVA_LIBRARIES)/apache-harmony-jdwp-tests-host.jar:$(HOST_OUT_JAVA_LIBRARIES)/junit.jar \
    170           -Djpda.settings.verbose=true \
    171           -Djpda.settings.debuggeeJavaPath=java \
    172           $(jdwp_test_suite_class_name)
    173