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
23jdwp_test_classpath_target := /data/jdwp/apache-harmony-jdwp-tests.jar:/data/junit/junit-targetdex.jar
24jdwp_test_runtime_bin_target := dalvikvm
25
26# Host settings
27jdwp_test_classpath_host := $(HOST_OUT_JAVA_LIBRARIES)/apache-harmony-jdwp-tests-hostdex.jar:$(HOST_OUT_JAVA_LIBRARIES)/junit-hostdex.jar
28jdwp_test_runtime_bin_host := $(HOST_OUT_EXECUTABLES)/art
29
30# Common runtime settings for runner and debuggee.
31jdwp_test_common_runtime_options := -XXlib:libartd.so -Xcompiler-option --debuggable
32
33# Debuggee runtime options
34jdwp_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
41jdwp_test_suite_class_name := org.apache.harmony.jpda.tests.share.AllTests
42
43# The lists of ABIs supported on host and target.
44jdwp_tests_host_abis :=
45jdwp_tests_target_abis :=
46
47ifneq ($(HOST_PREFER_32_BIT),true)
48  jdwp_tests_host_abis := 64 32
49else
50  jdwp_tests_host_abis := 32
51endif
52
53ifdef TARGET_2ND_ARCH
54  ifeq ($(TARGET_IS_64_BIT),true)
55    jdwp_tests_target_abis := 64 32
56  else
57    $(error Unsupported multi-target configuration!)
58  endif
59else
60  ifeq ($(TARGET_IS_64_BIT),true)
61    jdwp_tests_target_abis := 64
62  else
63    jdwp_tests_target_abis := 32
64  endif
65endif
66
67jdwp_tests_host_dependencies := \
68  $(HOST_OUT_EXECUTABLES)/art \
69  $(HOST_OUT_JAVA_LIBRARIES)/apache-harmony-jdwp-tests-hostdex.jar \
70  $(HOST_OUT_JAVA_LIBRARIES)/junit-hostdex.jar
71
72jdwp_tests_target_dependencies := \
73  $(TARGET_OUT_DATA)/jdwp/apache-harmony-jdwp-tests.jar \
74  $(TARGET_OUT_DATA)/junit/junit-targetdex.jar
75
76# Define a JDWP host rule
77#
78# $(1) ABI (32 or 64)
79# $(2) rule name (ex: run-jdwp-tests-host32)
80# $(3) extra dependency rule (ex: run-jdwp-tests-host-all64)
81define define-jdwp-host-rule
82.PHONY: $(2)
83$(2): jdwp_test_runtime_host := $(jdwp_test_runtime_bin_host) --$(1) $(jdwp_test_common_runtime_options)
84$(2): $(jdwp_tests_host_dependencies) $(3)
85	$(hide) echo "Running JDWP $(1)-bit host tests"
86	$$(jdwp_test_runtime_host) -cp $(jdwp_test_classpath_host) \
87    $(jdwp_test_target_runtime_common_args) \
88    -Djpda.settings.debuggeeJavaPath='$$(jdwp_test_runtime_host) $(jdwp_test_runtime_options)' \
89    $(jdwp_test_suite_class_name)
90endef
91
92# Declare all JDWP host rules
93#
94# $(1) ABI (32 or 64)
95define declare-jdwp-host-rule
96  # Declare standalone host rule for the given ABI.
97  $(eval $(call define-jdwp-host-rule,$(1),run-jdwp-tests-host$(1),))
98
99  # Declare variant host rule for run-jdwp-tests-host. It depends on the previous abi rule(s)
100  # so all ABIs are tested.
101  $(eval $(call define-jdwp-host-rule,$(1),run-jdwp-tests-host-all$(1),$(jdwp_tests_previous_host_rule)))
102  jdwp_tests_previous_host_rule := run-jdwp-tests-host-all$(1)
103endef
104
105# Waits for device to boot completely.
106define wait-for-boot-complete
107$(hide) echo "Wait for boot complete ..."
108$(hide) while [ `adb wait-for-device shell getprop dev.bootcomplete | grep -c 1` -eq 0 ]; \
109do \
110  sleep 1; \
111done
112$(hide) echo "Boot complete"
113endef
114
115# Define a JDWP target rule
116#
117# $(1) ABI (32 or 64)
118# $(2) rule name (ex: run-jdwp-tests-target32)
119# $(3) extra dependency rule (ex: run-jdwp-tests-target-all64)
120define define-jdwp-target-rule
121.PHONY: $(2)
122$(2): jdwp_test_runtime_target := $(jdwp_test_runtime_bin_target)$(1) $(jdwp_test_common_runtime_options)
123$(2): $(jdwp_tests_target_dependencies) $(3)
124	$(hide) echo "Running JDWP $(1)-bit target tests"
125	adb root
126	adb wait-for-device shell stop
127	adb remount
128	adb sync
129	adb reboot
130	$$(call wait-for-boot-complete)
131	adb shell $$(jdwp_test_runtime_target) -cp $(jdwp_test_classpath_target) \
132    $(jdwp_test_target_runtime_common_args) \
133    -Djpda.settings.debuggeeJavaPath='$$(jdwp_test_runtime_target) $(jdwp_test_runtime_options)' \
134    $(jdwp_test_suite_class_name)
135endef
136
137# Declare all JDWP target rules
138#
139# $(1) ABI (32 or 64)
140define declare-jdwp-target-rule
141  # Declare standalone target rule for the given ABI.
142  $(eval $(call define-jdwp-target-rule,$(1),run-jdwp-tests-target$(1),))
143
144  # Declare variant target rule for run-jdwp-tests-target. It depends on the previous abi rule(s)
145  # so all ABIs are tested.
146  $(eval $(call define-jdwp-target-rule,$(1),run-jdwp-tests-target-all$(1),$(jdwp_tests_previous_target_rule)))
147  jdwp_tests_previous_target_rule := run-jdwp-tests-target-all$(1)
148endef
149
150# Declare host and target rules for each ABI
151$(foreach abi,$(jdwp_tests_host_abis),$(eval $(call declare-jdwp-host-rule,$(abi))))
152$(foreach abi,$(jdwp_tests_target_abis),$(eval $(call declare-jdwp-target-rule,$(abi))))
153
154# High level host and target rules running tests for each ABI.
155.PHONY: run-jdwp-tests-host
156run-jdwp-tests-host: $(jdwp_tests_previous_host_rule)
157
158.PHONY: run-jdwp-tests-target
159run-jdwp-tests-target: $(jdwp_tests_previous_target_rule)
160
161jdwp_tests_host_abis :=
162jdwp_tests_target_abis :=
163jdwp_tests_host_dependencies :=
164jdwp_tests_target_dependencies :=
165
166.PHONY: run-jdwp-tests-ri
167run-jdwp-tests-ri: $(HOST_OUT_JAVA_LIBRARIES)/apache-harmony-jdwp-tests-host.jar $(HOST_OUT_JAVA_LIBRARIES)/junit.jar
168	$(hide) java -cp $(HOST_OUT_JAVA_LIBRARIES)/apache-harmony-jdwp-tests-host.jar:$(HOST_OUT_JAVA_LIBRARIES)/junit.jar \
169          -Djpda.settings.verbose=true \
170          -Djpda.settings.debuggeeJavaPath=java \
171          $(jdwp_test_suite_class_name)
172
173