Improved exit code handling. ihse-testmakefiles-branch
authorihse
Wed, 29 Nov 2017 22:35:35 +0100
branchihse-testmakefiles-branch
changeset 55915 edbc895d637b
parent 55914 dda999e8814c
child 55916 8cda3ed38148
Improved exit code handling.
make/RunTests.gmk
test/Makefile
--- a/make/RunTests.gmk	Wed Nov 29 22:02:21 2017 +0100
+++ b/make/RunTests.gmk	Wed Nov 29 22:35:35 2017 +0100
@@ -265,6 +265,7 @@
 define SetupRunGtestTestBody
   $1_TEST_RESULTS_DIR := $$(TEST_RESULTS_DIR)/$1
   $1_TEST_SUPPORT_DIR := $$(TEST_SUPPORT_DIR)/$1
+  $1_EXITCODE := $$($1_TEST_RESULTS_DIR)/exitcode.txt
 
   $1_TEST_NAME := $$(strip $$(patsubst gtest:%, %, $$($1_TEST)))
   ifneq ($$($1_TEST_NAME), all)
@@ -281,11 +282,13 @@
 	$$(call MakeDir, $$($1_TEST_RESULTS_DIR) $$($1_TEST_SUPPORT_DIR))
 	$$(call ExecuteWithLog, $$($1_TEST_SUPPORT_DIR)/gtest, \
 	    $$(FIXPATH) $$(TEST_IMAGE_DIR)/hotspot/gtest/server/gtestLauncher \
-	    -jdk $(JDK_IMAGE_DIR) $$($1_GTEST_FILTER) \
-	    --gtest_output=xml:$$($1_TEST_RESULTS_DIR)/gtest.xml \
-	    $$($1_GTEST_REPEAT) $$(GTEST_OPTIONS) \
-	    > >($(TEE) $$($1_TEST_RESULTS_DIR)/gtest.txt) ; \
-	    $$(ECHO) $$$$? > $$($1_TEST_RESULTS_DIR)/exitcode.txt )
+	         -jdk $(JDK_IMAGE_DIR) $$($1_GTEST_FILTER) \
+	         --gtest_output=xml:$$($1_TEST_RESULTS_DIR)/gtest.xml \
+	         $$($1_GTEST_REPEAT) $$(GTEST_OPTIONS) \
+	        > >($(TEE) $$($1_TEST_RESULTS_DIR)/gtest.txt) && \
+	    $$(ECHO) $$$$? > $$($1_EXITCODE) ||
+	    $$(ECHO) $$$$? > $$($1_EXITCODE) \
+	)
 
   $1_RESULT_FILE := $$($1_TEST_RESULTS_DIR)/gtest.txt
 
@@ -339,6 +342,7 @@
 define SetupRunJtregTestBody
   $1_TEST_RESULTS_DIR := $$(TEST_RESULTS_DIR)/$1
   $1_TEST_SUPPORT_DIR := $$(TEST_SUPPORT_DIR)/$1
+  $1_EXITCODE := $$($1_TEST_RESULTS_DIR)/exitcode.txt
 
   $1_TEST_NAME := $$(strip $$(patsubst jtreg:%, %, $$($1_TEST)))
 
@@ -441,8 +445,10 @@
 	        -reportDir:$$($1_TEST_RESULTS_DIR) \
 	        -workDir:$$($1_TEST_SUPPORT_DIR) \
 	        $$(JTREG_OPTIONS) \
-	        $$($1_TEST_NAME) ; \
-	    $$(ECHO) $$$$? > $$($1_TEST_RESULTS_DIR)/exitcode.txt )
+	        $$($1_TEST_NAME) && \
+	    $$(ECHO) $$$$? > $$($1_EXITCODE) ||
+	    $$(ECHO) $$$$? > $$($1_EXITCODE) \
+	)
 
   $1_RESULT_FILE := $$($1_TEST_RESULTS_DIR)/text/stats.txt
 
--- a/test/Makefile	Wed Nov 29 22:02:21 2017 +0100
+++ b/test/Makefile	Wed Nov 29 22:35:35 2017 +0100
@@ -129,6 +129,7 @@
 	$(MKDIR) -p $(TEST_OUTPUT_DIR)/jtreg
 	$(MV) $(TEST_OUTPUT_DIR)/test-results/`$(HEAD) -n 1 $(TEST_OUTPUT_DIR)/test-support/test-last-ids.txt` $(TEST_OUTPUT_DIR)/jtreg/JTreport
 	$(MV) $(TEST_OUTPUT_DIR)/test-support/`$(HEAD) -n 1 $(TEST_OUTPUT_DIR)/test-support/test-last-ids.txt` $(TEST_OUTPUT_DIR)/jtreg/JTwork
+	$(MV) $(TEST_OUTPUT_DIR)/jtreg/JTreport/exitcode.txt $(TEST_OUTPUT_DIR)/jtreg/exitcode.txt
 else
   jtreg_tests:
 	$(MAKE) --no-print-directory TESTDIRS=$(TESTDIRS_TESTS) \