Skip to content

Commit bd5fd6e

Browse files
committed
auto merge of #6150 : yichoi/rust/arm-test-pull, r=brson
Support #5297 install.mk : install-runtime-target added for conveneice automatically push runtime library to android device test.mk : expanded to support android test automation with adb compiletest : expanded to support android test automation with adb
2 parents a5891be + 5681571 commit bd5fd6e

File tree

6 files changed

+344
-12
lines changed

6 files changed

+344
-12
lines changed

configure

+4
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,10 @@ then
439439
probe CFG_ZCAT zcat
440440
fi
441441

442+
step_msg "looking for target specific programs"
443+
444+
probe CFG_ADB adb
445+
442446
if [ ! -z "$CFG_PANDOC" ]
443447
then
444448
PV_MAJOR_MINOR=$(pandoc --version | grep '^pandoc ' |

mk/install.mk

+73
Original file line numberDiff line numberDiff line change
@@ -154,3 +154,76 @@ uninstall:
154154
done
155155
$(Q)rm -Rf $(PHL)/rustc
156156
$(Q)rm -f $(PREFIX_ROOT)/share/man/man1/rustc.1
157+
158+
# target platform specific variables
159+
# for arm-linux-androidabi
160+
define DEF_ADB_DEVICE_STATUS
161+
CFG_ADB_DEVICE_STATUS=$(1)
162+
endef
163+
164+
$(foreach target,$(CFG_TARGET_TRIPLES), \
165+
$(if $(findstring $(target),"arm-linux-androideabi"), \
166+
$(if $(findstring adb,$(CFG_ADB)), \
167+
$(if $(findstring device,$(shell adb devices 2>/dev/null | grep -E '^[_A-Za-z0-9-]+[[:blank:]]+device')), \
168+
$(info install: install-runtime-target for $(target) enabled \
169+
$(info install: android device attached) \
170+
$(eval $(call DEF_ADB_DEVICE_STATUS, true))), \
171+
$(info install: install-runtime-target for $(target) disabled \
172+
$(info install: android device not attached) \
173+
$(eval $(call DEF_ADB_DEVICE_STATUS, false))) \
174+
), \
175+
$(info install: install-runtime-target for $(target) disabled \
176+
$(info install: adb not found) \
177+
$(eval $(call DEF_ADB_DEVICE_STATUS, false))) \
178+
), \
179+
) \
180+
)
181+
182+
ifeq (install-runtime-target,$(firstword $(MAKECMDGOALS)))
183+
$(eval $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS)):;@:)
184+
L_TOKEN := $(word 2,$(MAKECMDGOALS))
185+
ifeq ($(L_TOKEN),)
186+
CFG_RUNTIME_PUSH_DIR=/system/lib
187+
else
188+
CFG_RUNTIME_PUSH_DIR=$(L_TOKEN)
189+
endif
190+
191+
ifeq ($(CFG_ADB_DEVICE_STATUS),true)
192+
ifdef VERBOSE
193+
ADB = adb $(1)
194+
ADB_PUSH = adb push $(1) $(2)
195+
ADB_SHELL = adb shell $(1) $(2)
196+
else
197+
ADB = $(Q)$(call E, adb $(1)) && adb $(1) 1>/dev/null
198+
ADB_PUSH = $(Q)$(call E, adb push $(1)) && adb push $(1) $(2) 1>/dev/null
199+
ADB_SHELL = $(Q)$(call E, adb shell $(1) $(2)) && adb shell $(1) $(2) 1>/dev/null
200+
endif
201+
202+
define INSTALL_RUNTIME_TARGET_N
203+
install-runtime-target-$(1)-host-$(2): $$(TSREQ$$(ISTAGE)_T_$(1)_H_$(2)) $$(SREQ$$(ISTAGE)_T_$(1)_H_$(2))
204+
$(Q)$(call ADB_SHELL,mkdir,$(CFG_RUNTIME_PUSH_DIR))
205+
$(Q)$(call ADB_PUSH,$$(TL$(1)$(2))/$$(CFG_RUNTIME_$(1)),$(CFG_RUNTIME_PUSH_DIR))
206+
$(Q)$(call ADB_PUSH,$$(TL$(1)$(2))/$$(CORELIB_GLOB_$(1)),$(CFG_RUNTIME_PUSH_DIR))
207+
$(Q)$(call ADB_PUSH,$$(TL$(1)$(2))/$$(STDLIB_GLOB_$(1)),$(CFG_RUNTIME_PUSH_DIR))
208+
endef
209+
210+
define INSTALL_RUNTIME_TARGET_CLEANUP_N
211+
install-runtime-target-$(1)-cleanup:
212+
$(Q)$(call ADB,remount)
213+
$(Q)$(call ADB_SHELL,rm,$(CFG_RUNTIME_PUSH_DIR)/$(CFG_RUNTIME_$(1)))
214+
$(Q)$(call ADB_SHELL,rm,$(CFG_RUNTIME_PUSH_DIR)/$(CORELIB_GLOB_$(1)))
215+
$(Q)$(call ADB_SHELL,rm,$(CFG_RUNTIME_PUSH_DIR)/$(STDLIB_GLOB_$(1)))
216+
endef
217+
218+
$(eval $(call INSTALL_RUNTIME_TARGET_N,arm-linux-androideabi,$(CFG_BUILD_TRIPLE)))
219+
$(eval $(call INSTALL_RUNTIME_TARGET_CLEANUP_N,arm-linux-androideabi))
220+
221+
install-runtime-target: \
222+
install-runtime-target-arm-linux-androideabi-cleanup \
223+
install-runtime-target-arm-linux-androideabi-host-$(CFG_BUILD_TRIPLE)
224+
else
225+
install-runtime-target:
226+
@echo "No device to install runtime library"
227+
@echo
228+
endif
229+
endif

mk/tests.mk

+87-5
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,43 @@ endef
9292
$(foreach target,$(CFG_TARGET_TRIPLES), \
9393
$(eval $(call DEF_TARGET_COMMANDS,$(target))))
9494

95+
# Target platform specific variables
96+
# for arm-linux-androidabi
97+
define DEF_ADB_DEVICE_STATUS
98+
CFG_ADB_DEVICE_STATUS=$(1)
99+
endef
100+
101+
$(foreach target,$(CFG_TARGET_TRIPLES), \
102+
$(if $(findstring $(target),"arm-linux-androideabi"), \
103+
$(if $(findstring adb,$(CFG_ADB)), \
104+
$(if $(findstring device,$(shell adb devices 2>/dev/null | grep -E '^[_A-Za-z0-9-]+[[:blank:]]+device')), \
105+
$(info check: $(target) test enabled \
106+
$(info check: android device attached) \
107+
$(eval $(call DEF_ADB_DEVICE_STATUS, true))), \
108+
$(info check: $(target) test disabled \
109+
$(info check: android device not attached) \
110+
$(eval $(call DEF_ADB_DEVICE_STATUS, false))) \
111+
), \
112+
$(info check: $(target) test disabled \
113+
$(info check: adb not found) \
114+
$(eval $(call DEF_ADB_DEVICE_STATUS, false))) \
115+
), \
116+
) \
117+
)
118+
119+
ifeq ($(CFG_ADB_DEVICE_STATUS),true)
120+
CFG_ADB_TEST_DIR=/data/tmp
121+
122+
$(info check: android device test dir $(CFG_ADB_TEST_DIR) ready \
123+
$(shell adb remount 1>/dev/null) \
124+
$(shell adb shell mkdir $(CFG_ADB_TEST_DIR) 1>/dev/null) \
125+
$(shell adb push $(CFG_ANDROID_CROSS_PATH)/arm-linux-androideabi/lib/armv7-a/libgnustl_shared.so \
126+
$(CFG_ADB_TEST_DIR) 1>/dev/null) \
127+
)
128+
else
129+
CFG_ADB_TEST_DIR=
130+
endif
131+
95132

96133
######################################################################
97134
# Main test targets
@@ -319,11 +356,53 @@ $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
319356
&& touch $$@
320357
endef
321358

359+
define DEF_TEST_CRATE_RULES_arm-linux-androideabi
360+
check-stage$(1)-T-$(2)-H-$(3)-$(4)-exec: $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4))
361+
362+
$$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
363+
$(3)/test/$(4)test.stage$(1)-$(2)$$(X_$(2))
364+
@$$(call E, run: $$< via adb)
365+
@$(CFG_ADB) push $$< $(CFG_ADB_TEST_DIR)
366+
@$(CFG_ADB) shell LD_LIBRARY_PATH=$(CFG_ADB_TEST_DIR) \
367+
$(CFG_ADB_TEST_DIR)/`echo $$< | sed 's/.*\///'` \
368+
--logfile $(CFG_ADB_TEST_DIR)/check-stage$(1)-T-$(2)-H-$(3)-$(4).log > \
369+
tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).tmp
370+
@cat tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).tmp
371+
@touch tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).log
372+
@$(CFG_ADB) pull $(CFG_ADB_TEST_DIR)/check-stage$(1)-T-$(2)-H-$(3)-$(4).log tmp/
373+
@$(CFG_ADB) shell rm $(CFG_ADB_TEST_DIR)/check-stage$(1)-T-$(2)-H-$(3)-$(4).log
374+
@if grep -q "result: ok" tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).tmp; \
375+
then \
376+
rm tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).tmp; \
377+
touch $$@; \
378+
else \
379+
rm tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).tmp; \
380+
exit 101; \
381+
fi
382+
endef
383+
384+
define DEF_TEST_CRATE_RULES_null
385+
check-stage$(1)-T-$(2)-H-$(3)-$(4)-exec: $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4))
386+
387+
$$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
388+
$(3)/test/$(4)test.stage$(1)-$(2)$$(X_$(2))
389+
@$$(call E, run: skipped $$< )
390+
@touch $$@
391+
endef
392+
322393
$(foreach host,$(CFG_HOST_TRIPLES), \
323394
$(foreach target,$(CFG_TARGET_TRIPLES), \
324395
$(foreach stage,$(STAGES), \
325396
$(foreach crate, $(TEST_CRATES), \
326-
$(eval $(call DEF_TEST_CRATE_RULES,$(stage),$(target),$(host),$(crate)))))))
397+
$(if $(findstring $(target),$(CFG_BUILD_TRIPLE)), \
398+
$(eval $(call DEF_TEST_CRATE_RULES,$(stage),$(target),$(host),$(crate))), \
399+
$(if $(findstring $(target),"arm-linux-androideabi"), \
400+
$(if $(findstring $(CFG_ADB_DEVICE_STATUS),"true"), \
401+
$(eval $(call DEF_TEST_CRATE_RULES_arm-linux-androideabi,$(stage),$(target),$(host),$(crate))), \
402+
$(eval $(call DEF_TEST_CRATE_RULES_null,$(stage),$(target),$(host),$(crate))) \
403+
), \
404+
$(eval $(call DEF_TEST_CRATE_RULES,$(stage),$(target),$(host),$(crate))) \
405+
))))))
327406

328407

329408
######################################################################
@@ -420,6 +499,9 @@ CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3) := \
420499
--rustc-path $$(HBIN$(1)_H_$(3))/rustc$$(X_$(3)) \
421500
--aux-base $$(S)src/test/auxiliary/ \
422501
--stage-id stage$(1)-$(2) \
502+
--target $(2) \
503+
--adb-path=$(CFG_ADB) \
504+
--adb-test-dir=$(CFG_ADB_TEST_DIR) \
423505
--rustcflags "$(RUSTC_FLAGS_$(2)) $$(CFG_RUSTC_FLAGS) --target=$(2)" \
424506
$$(CTEST_TESTARGS)
425507

@@ -454,7 +536,7 @@ ifeq ($$(CTEST_DISABLE_$(4)),)
454536
$$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
455537
$$(TEST_SREQ$(1)_T_$(2)_H_$(3)) \
456538
$$(CTEST_DEPS_$(4)_$(1)-T-$(2)-H-$(3))
457-
@$$(call E, run $(4): $$<)
539+
@$$(call E, run $(4) [$(2)]: $$<)
458540
$$(Q)$$(call CFG_RUN_CTEST_$(2),$(1),$$<,$(3)) \
459541
$$(CTEST_ARGS$(1)-T-$(2)-H-$(3)-$(4)) \
460542
--logfile $$(call TEST_LOG_FILE,$(1),$(2),$(3),$(4)) \
@@ -465,7 +547,7 @@ else
465547
$$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
466548
$$(TEST_SREQ$(1)_T_$(2)_H_$(3)) \
467549
$$(CTEST_DEPS_$(4)_$(1)-T-$(2)-H-$(3))
468-
@$$(call E, run $(4): $$<)
550+
@$$(call E, run $(4) [$(2)]: $$<)
469551
@$$(call E, warning: tests disabled: $$(CTEST_DISABLE_$(4)))
470552
touch $$@
471553

@@ -506,7 +588,7 @@ check-stage$(1)-T-$(2)-H-$(3)-$(4)-exec: $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4
506588
$$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
507589
$$(TEST_SREQ$(1)_T_$(2)_H_$(3)) \
508590
$$(PRETTY_DEPS_$(4))
509-
@$$(call E, run pretty-rpass: $$<)
591+
@$$(call E, run pretty-rpass [$(2)]: $$<)
510592
$$(Q)$$(call CFG_RUN_CTEST_$(2),$(1),$$<,$(3)) \
511593
$$(PRETTY_ARGS$(1)-T-$(2)-H-$(3)-$(4)) \
512594
--logfile $$(call TEST_LOG_FILE,$(1),$(2),$(3),$(4)) \
@@ -533,7 +615,7 @@ check-stage$(1)-T-$(2)-H-$(3)-doc-$(4)-exec: $$(call TEST_OK_FILE,$(1),$(2),$(3)
533615
$$(call TEST_OK_FILE,$(1),$(2),$(3),doc-$(4)): \
534616
$$(TEST_SREQ$(1)_T_$(2)_H_$(3)) \
535617
doc-$(4)-extract$(3)
536-
@$$(call E, run doc-$(4): $$<)
618+
@$$(call E, run doc-$(4) [$(2)]: $$<)
537619
$$(Q)$$(call CFG_RUN_CTEST_$(2),$(1),$$<,$(3)) \
538620
$$(DOC_TEST_ARGS$(1)-T-$(2)-H-$(3)-doc-$(4)) \
539621
--logfile $$(call TEST_LOG_FILE,$(1),$(2),$(3),doc-$(4)) \

src/compiletest/common.rs

+12
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,18 @@ pub struct config {
6464
// Run tests using the new runtime
6565
newrt: bool,
6666

67+
// Target system to be tested
68+
target: ~str,
69+
70+
// Extra parameter to run adb on arm-linux-androideabi
71+
adb_path: ~str,
72+
73+
// Extra parameter to run test sute on arm-linux-androideabi
74+
adb_test_dir: ~str,
75+
76+
// status whether android device available or not
77+
adb_device_status: bool,
78+
6779
// Explain what's going on
6880
verbose: bool
6981

src/compiletest/compiletest.rc

+21-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,11 @@ pub fn parse_config(args: ~[~str]) -> config {
6060
getopts::optflag(~"verbose"),
6161
getopts::optopt(~"logfile"),
6262
getopts::optflag(~"jit"),
63-
getopts::optflag(~"newrt")];
63+
getopts::optflag(~"newrt"),
64+
getopts::optopt(~"target"),
65+
getopts::optopt(~"adb-path"),
66+
getopts::optopt(~"adb-test-dir")
67+
];
6468

6569
assert!(!args.is_empty());
6670
let args_ = vec::tail(args);
@@ -93,6 +97,18 @@ pub fn parse_config(args: ~[~str]) -> config {
9397
rustcflags: getopts::opt_maybe_str(matches, ~"rustcflags"),
9498
jit: getopts::opt_present(matches, ~"jit"),
9599
newrt: getopts::opt_present(matches, ~"newrt"),
100+
target: opt_str(getopts::opt_maybe_str(matches, ~"target")),
101+
adb_path: opt_str(getopts::opt_maybe_str(matches, ~"adb-path")),
102+
adb_test_dir: opt_str(getopts::opt_maybe_str(matches, ~"adb-test-dir")),
103+
adb_device_status:
104+
if (opt_str(getopts::opt_maybe_str(matches, ~"target")) ==
105+
~"arm-linux-androideabi") {
106+
if (opt_str(getopts::opt_maybe_str(matches, ~"adb-test-dir")) !=
107+
~"(none)" &&
108+
opt_str(getopts::opt_maybe_str(matches, ~"adb-test-dir")) !=
109+
~"") { true }
110+
else { false }
111+
} else { false },
96112
verbose: getopts::opt_present(matches, ~"verbose")
97113
}
98114
}
@@ -113,6 +129,10 @@ pub fn log_config(config: config) {
113129
logv(c, fmt!("rustcflags: %s", opt_str(config.rustcflags)));
114130
logv(c, fmt!("jit: %b", config.jit));
115131
logv(c, fmt!("newrt: %b", config.newrt));
132+
logv(c, fmt!("target: %s", config.target));
133+
logv(c, fmt!("adb_path: %s", config.adb_path));
134+
logv(c, fmt!("adb_test_dir: %s", config.adb_test_dir));
135+
logv(c, fmt!("adb_device_status: %b", config.adb_device_status));
116136
logv(c, fmt!("verbose: %b", config.verbose));
117137
logv(c, fmt!("\n"));
118138
}

0 commit comments

Comments
 (0)