about summary refs log tree commit diff
diff options
context:
space:
mode:
authorYoung-il Choi <duddlf.choi@samsung.com>2013-05-01 18:50:23 +0900
committerYoung-il Choi <duddlf.choi@samsung.com>2013-05-01 18:50:23 +0900
commit57c126e9bbcb4d02c40787afc46f5865874220d7 (patch)
treed678644c8188457bf6aa588df0d17eb189cc8754
parentdca88701a311c7dffec1ee5e990df9570647ba03 (diff)
downloadrust-57c126e9bbcb4d02c40787afc46f5865874220d7.tar.gz
rust-57c126e9bbcb4d02c40787afc46f5865874220d7.zip
mk: test.mk expanded to ARM test automation
-rw-r--r--mk/tests.mk113
1 files changed, 108 insertions, 5 deletions
diff --git a/mk/tests.mk b/mk/tests.mk
index f96b7325f60..9b01c4af80f 100644
--- a/mk/tests.mk
+++ b/mk/tests.mk
@@ -92,6 +92,48 @@ endef
 $(foreach target,$(CFG_TARGET_TRIPLES), \
   $(eval $(call DEF_TARGET_COMMANDS,$(target))))
 
+# Target specific variables 
+# for arm-linux-androidabi
+define DEF_RUNNABLE_STATUS
+CFG_RUNNABLE_$(1)=$(2)
+endef
+
+$(foreach target,$(CFG_TARGET_TRIPLES), \
+  $(if $(findstring $(target),$(CFG_BUILD_TRIPLE)), \
+    $(info check: $(target) test set is runnable \
+      $(eval $(call DEF_RUNNABLE_STATUS,$(target),true))), \
+    $(if $(findstring $(target),"arm-linux-androideabi"), \
+      $(if $(findstring adb,$(shell which adb)), \
+        $(if $(findstring device,$(shell adb devices 2>/dev/null | grep -E '^[A-Za-z0-9]+[[:blank:]]+device')), \
+          $(info check: $(target) test set is runnable \
+            $(info check: adb device attached) \
+            $(eval $(call DEF_RUNNABLE_STATUS,$(target),true))), \
+          $(info check: $(target) test set is not runnable \
+            $(info check: adb device not attached) \
+            $(eval $(call DEF_RUNNABLE_STATUS,$(target),false))) \
+        ), \
+        $(info check: $(target) test set is not runnable \
+          $(info check: adb not found) \
+          $(eval $(call DEF_RUNNABLE_STATUS,$(target),false))) \
+      ), \
+      $(info check: $(target) test set is not runnable \
+        $(eval $(call DEF_RUNNABLE_STATUS,$(target),false)) \
+      ) \
+    ) \
+  ) \
+)
+
+ifeq ($(CFG_RUNNABLE_arm-linux-androideabi),true)
+CFG_ADB_DEVICE=true
+CFG_ADB_PATH := $(shell which adb)
+CFG_ADB_TEST_DIR=/system/tmp
+
+$(info check: device $(CFG_ADB_TEST_DIR) \
+ $(shell $(CFG_ADB_PATH) shell mkdir $(CFG_ADB_TEST_DIR) 1>/dev/null) \
+ $(shell $(CFG_ADB_PATH) shell rm $(CFG_ADB_TEST_DIR)/*-arm-linux-androideabi 1>/dev/null) \
+ $(shell $(CFG_ADB_PATH) shell rm $(CFG_ADB_TEST_DIR)/*.so 1>/dev/null) \
+ )
+endif
 
 ######################################################################
 # Main test targets
@@ -319,11 +361,52 @@ $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
 	&& touch $$@
 endef
 
+define DEF_TEST_CRATE_RULES_arm-linux-androideabi
+check-stage$(1)-T-$(2)-H-$(3)-$(4)-exec: $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4))
+
+$$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
+		$(3)/test/$(4)test.stage$(1)-$(2)$$(X_$(2))
+	@$$(call E, run: $$< via adb)
+	@$(CFG_ADB_PATH) push $$< $(CFG_ADB_TEST_DIR)
+	@$(CFG_ADB_PATH) shell $(CFG_ADB_TEST_DIR)/`echo $$< | sed 's/.*\///'` \
+		--logfile $(CFG_ADB_TEST_DIR)/check-stage$(1)-T-$(2)-H-$(3)-$(4).log > \
+		tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).tmp
+	@cat tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).tmp
+	@touch tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).log
+	@$(CFG_ADB_PATH) pull $(CFG_ADB_TEST_DIR)/check-stage$(1)-T-$(2)-H-$(3)-$(4).log tmp/
+	@$(CFG_ADB_PATH) shell rm $(CFG_ADB_TEST_DIR)/check-stage$(1)-T-$(2)-H-$(3)-$(4).log
+	@if grep -q "result: ok" tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).tmp; \
+	then \
+		rm tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).tmp; \
+		touch $$@; \
+	else \
+		rm tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).tmp; \
+		exit 101; \
+	fi
+endef
+
+define DEF_TEST_CRATE_RULES_null
+check-stage$(1)-T-$(2)-H-$(3)-$(4)-exec: $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4))
+
+$$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
+		$(3)/test/$(4)test.stage$(1)-$(2)$$(X_$(2))
+	@$$(call E, run: skipped $$< )
+	@touch $$@
+endef
+
 $(foreach host,$(CFG_HOST_TRIPLES), \
  $(foreach target,$(CFG_TARGET_TRIPLES), \
   $(foreach stage,$(STAGES), \
    $(foreach crate, $(TEST_CRATES), \
-    $(eval $(call DEF_TEST_CRATE_RULES,$(stage),$(target),$(host),$(crate)))))))
+    $(if $(findstring $(target),$(CFG_BUILD_TRIPLE)), \
+     $(eval $(call DEF_TEST_CRATE_RULES,$(stage),$(target),$(host),$(crate))), \
+     $(if $(findstring $(target),"arm-linux-androideabi"), \
+      $(if $(findstring $(CFG_RUNNABLE_arm-linux-androideabi),"true"), \
+       $(eval $(call DEF_TEST_CRATE_RULES_arm-linux-androideabi,$(stage),$(target),$(host),$(crate))), \
+       $(eval $(call DEF_TEST_CRATE_RULES_null,$(stage),$(target),$(host),$(crate))) \
+      ), \
+      $(eval $(call DEF_TEST_CRATE_RULES_null,$(stage),$(target),$(host),$(crate))) \
+     )))))) 
 
 
 ######################################################################
@@ -414,15 +497,35 @@ TEST_SREQ$(1)_T_$(2)_H_$(3) = \
 
 # Rules for the cfail/rfail/rpass/bench/perf test runner
 
+ifeq ($(CFG_ADB_DEVICE),true)
+
 CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3) :=						\
 		--compile-lib-path $$(HLIB$(1)_H_$(3))				\
         --run-lib-path $$(TLIB$(1)_T_$(2)_H_$(3))			\
         --rustc-path $$(HBIN$(1)_H_$(3))/rustc$$(X_$(3))			\
         --aux-base $$(S)src/test/auxiliary/                 \
         --stage-id stage$(1)-$(2)							\
+        --host $(3)                                         \
+        --target $(2)                                       \
+        --adb-path=$(CFG_ADB_PATH)                          \
         --rustcflags "$(RUSTC_FLAGS_$(2)) $$(CFG_RUSTC_FLAGS) --target=$(2)" \
         $$(CTEST_TESTARGS)
 
+else
+
+CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3) :=						\
+		--compile-lib-path $$(HLIB$(1)_H_$(3))				\
+        --run-lib-path $$(TLIB$(1)_T_$(2)_H_$(3))			\
+        --rustc-path $$(HBIN$(1)_H_$(3))/rustc$$(X_$(3))			\
+        --aux-base $$(S)src/test/auxiliary/                 \
+        --stage-id stage$(1)-$(2)							\
+        --host $(3)                                         \
+        --target $(2)                                       \
+        --rustcflags "$(RUSTC_FLAGS_$(2)) $$(CFG_RUSTC_FLAGS) --target=$(2)" \
+        $$(CTEST_TESTARGS)
+
+endif
+
 CTEST_DEPS_rpass_$(1)-T-$(2)-H-$(3) = $$(RPASS_TESTS)
 CTEST_DEPS_rpass_full_$(1)-T-$(2)-H-$(3) = $$(RPASS_FULL_TESTS) $$(TLIBRUSTC_DEFAULT$(1)_T_$(2)_H_$(3))
 CTEST_DEPS_rfail_$(1)-T-$(2)-H-$(3) = $$(RFAIL_TESTS)
@@ -454,7 +557,7 @@ ifeq ($$(CTEST_DISABLE_$(4)),)
 $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
 		$$(TEST_SREQ$(1)_T_$(2)_H_$(3)) \
                 $$(CTEST_DEPS_$(4)_$(1)-T-$(2)-H-$(3))
-	@$$(call E, run $(4): $$<)
+	@$$(call E, run $(4) [$(2)]: $$<)
 	$$(Q)$$(call CFG_RUN_CTEST_$(2),$(1),$$<,$(3)) \
 		$$(CTEST_ARGS$(1)-T-$(2)-H-$(3)-$(4)) \
 		--logfile $$(call TEST_LOG_FILE,$(1),$(2),$(3),$(4)) \
@@ -465,7 +568,7 @@ else
 $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
 		$$(TEST_SREQ$(1)_T_$(2)_H_$(3)) \
                 $$(CTEST_DEPS_$(4)_$(1)-T-$(2)-H-$(3))
-	@$$(call E, run $(4): $$<)
+	@$$(call E, run $(4) [$(2)]: $$<)
 	@$$(call E, warning: tests disabled: $$(CTEST_DISABLE_$(4)))
 	touch $$@
 
@@ -506,7 +609,7 @@ check-stage$(1)-T-$(2)-H-$(3)-$(4)-exec: $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4
 $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
 	        $$(TEST_SREQ$(1)_T_$(2)_H_$(3))		\
 	        $$(PRETTY_DEPS_$(4))
-	@$$(call E, run pretty-rpass: $$<)
+	@$$(call E, run pretty-rpass [$(2)]: $$<)
 	$$(Q)$$(call CFG_RUN_CTEST_$(2),$(1),$$<,$(3)) \
 		$$(PRETTY_ARGS$(1)-T-$(2)-H-$(3)-$(4)) \
 		--logfile $$(call TEST_LOG_FILE,$(1),$(2),$(3),$(4)) \
@@ -533,7 +636,7 @@ check-stage$(1)-T-$(2)-H-$(3)-doc-$(4)-exec: $$(call TEST_OK_FILE,$(1),$(2),$(3)
 $$(call TEST_OK_FILE,$(1),$(2),$(3),doc-$(4)): \
 	        $$(TEST_SREQ$(1)_T_$(2)_H_$(3))		\
                 doc-$(4)-extract$(3)
-	@$$(call E, run doc-$(4): $$<)
+	@$$(call E, run doc-$(4) [$(2)]: $$<)
 	$$(Q)$$(call CFG_RUN_CTEST_$(2),$(1),$$<,$(3)) \
                 $$(DOC_TEST_ARGS$(1)-T-$(2)-H-$(3)-doc-$(4)) \
 		--logfile $$(call TEST_LOG_FILE,$(1),$(2),$(3),doc-$(4)) \