make/RunTests.gmk
changeset 47956 72a474c85aee
parent 47943 cece8b7adf10
child 47986 45c5d7817e9e
equal deleted inserted replaced
47955:0887e20e7173 47956:72a474c85aee
    30 include FindTests.gmk
    30 include FindTests.gmk
    31 
    31 
    32 # We will always run multiple tests serially
    32 # We will always run multiple tests serially
    33 .NOTPARALLEL:
    33 .NOTPARALLEL:
    34 
    34 
       
    35 ################################################################################
       
    36 # Parse global control variables
       
    37 ################################################################################
       
    38 
       
    39 ifneq ($(TEST_VM_OPTS), )
       
    40   ifneq ($(TEST_OPTS), )
       
    41     TEST_OPTS := $(TEST_OPTS);VM_OPTIONS=$(TEST_VM_OPTS)
       
    42   else
       
    43     TEST_OPTS := VM_OPTIONS=$(TEST_VM_OPTS)
       
    44   endif
       
    45 endif
       
    46 
       
    47 $(eval $(call ParseKeywordVariable, TEST_OPTS, \
       
    48     KEYWORDS := JOBS TIMEOUT, \
       
    49     STRING_KEYWORDS := VM_OPTIONS, \
       
    50 ))
       
    51 
       
    52 # Helper function to propagate TEST_OPTS values.
       
    53 #
       
    54 # Note: No spaces are allowed around the arguments.
       
    55 # Arg $1 The variable in TEST_OPTS to propagate
       
    56 # Arg $2 The control variable to propagate it to
       
    57 define SetTestOpt
       
    58   ifneq ($$(TEST_OPTS_$1), )
       
    59     $2_$1 := $$(TEST_OPTS_$1)
       
    60   endif
       
    61 endef
       
    62 
       
    63 ################################################################################
    35 # Hook to include the corresponding custom file, if present.
    64 # Hook to include the corresponding custom file, if present.
    36 $(eval $(call IncludeCustomExtension, RunTests.gmk))
    65 $(eval $(call IncludeCustomExtension, RunTests.gmk))
       
    66 ################################################################################
    37 
    67 
    38 TEST_RESULTS_DIR := $(OUTPUTDIR)/test-results
    68 TEST_RESULTS_DIR := $(OUTPUTDIR)/test-results
    39 TEST_SUPPORT_DIR := $(OUTPUTDIR)/test-support
    69 TEST_SUPPORT_DIR := $(OUTPUTDIR)/test-support
    40 TEST_SUMMARY := $(TEST_RESULTS_DIR)/test-summary.txt
    70 TEST_SUMMARY := $(TEST_RESULTS_DIR)/test-summary.txt
    41 
    71 
    47 
    77 
    48 ################################################################################
    78 ################################################################################
    49 # Parse control variables
    79 # Parse control variables
    50 ################################################################################
    80 ################################################################################
    51 
    81 
       
    82 ifneq ($(TEST_OPTS), )
       
    83   # Inform the user
       
    84   $(info Running tests using TEST_OPTS control variable '$(TEST_OPTS)')
       
    85 
       
    86   $(eval $(call SetTestOpt,VM_OPTIONS,JTREG))
       
    87   $(eval $(call SetTestOpt,VM_OPTIONS,GTEST))
       
    88 
       
    89   $(eval $(call SetTestOpt,JOBS,JTREG))
       
    90   $(eval $(call SetTestOpt,TIMEOUT,JTREG))
       
    91 endif
       
    92 
    52 $(eval $(call ParseKeywordVariable, JTREG, \
    93 $(eval $(call ParseKeywordVariable, JTREG, \
    53     KEYWORDS := JOBS TIMEOUT TEST_MODE ASSERT VERBOSE RETAIN MAX_MEM, \
    94     KEYWORDS := JOBS TIMEOUT TEST_MODE ASSERT VERBOSE RETAIN MAX_MEM, \
    54     STRING_KEYWORDS := OPTIONS JAVA_OPTIONS VM_OPTIONS, \
    95     STRING_KEYWORDS := OPTIONS JAVA_OPTIONS VM_OPTIONS, \
    55 ))
    96 ))
    56 
    97 
    59   $(info Running tests using JTREG control variable '$(JTREG)')
   100   $(info Running tests using JTREG control variable '$(JTREG)')
    60 endif
   101 endif
    61 
   102 
    62 $(eval $(call ParseKeywordVariable, GTEST, \
   103 $(eval $(call ParseKeywordVariable, GTEST, \
    63     KEYWORDS := REPEAT, \
   104     KEYWORDS := REPEAT, \
    64     STRING_KEYWORDS := OPTIONS, \
   105     STRING_KEYWORDS := OPTIONS VM_OPTIONS, \
    65 ))
   106 ))
    66 
   107 
    67 ifneq ($(GTEST), )
   108 ifneq ($(GTEST), )
    68   # Inform the user
   109   # Inform the user
    69   $(info Running tests using GTEST control variable '$(GTEST)')
   110   $(info Running tests using GTEST control variable '$(GTEST)')
   279 	$$(call MakeDir, $$($1_TEST_RESULTS_DIR) $$($1_TEST_SUPPORT_DIR))
   320 	$$(call MakeDir, $$($1_TEST_RESULTS_DIR) $$($1_TEST_SUPPORT_DIR))
   280 	$$(call ExecuteWithLog, $$($1_TEST_SUPPORT_DIR)/gtest, \
   321 	$$(call ExecuteWithLog, $$($1_TEST_SUPPORT_DIR)/gtest, \
   281 	    $$(FIXPATH) $$(TEST_IMAGE_DIR)/hotspot/gtest/server/gtestLauncher \
   322 	    $$(FIXPATH) $$(TEST_IMAGE_DIR)/hotspot/gtest/server/gtestLauncher \
   282 	    -jdk $(JDK_IMAGE_DIR) $$($1_GTEST_FILTER) \
   323 	    -jdk $(JDK_IMAGE_DIR) $$($1_GTEST_FILTER) \
   283 	    --gtest_output=xml:$$($1_TEST_RESULTS_DIR)/gtest.xml \
   324 	    --gtest_output=xml:$$($1_TEST_RESULTS_DIR)/gtest.xml \
   284 	    $$($1_GTEST_REPEAT) $$(GTEST_OPTIONS) \
   325 	    $$($1_GTEST_REPEAT) $$(GTEST_OPTIONS) $$(GTEST_VM_OPTIONS) \
   285 	    > >($(TEE) $$($1_TEST_RESULTS_DIR)/gtest.txt) || true )
   326 	    > >($(TEE) $$($1_TEST_RESULTS_DIR)/gtest.txt) || true )
   286 
   327 
   287   $1_RESULT_FILE := $$($1_TEST_RESULTS_DIR)/gtest.txt
   328   $1_RESULT_FILE := $$($1_TEST_RESULTS_DIR)/gtest.txt
   288 
   329 
   289   parse-test-$1: run-test-$1
   330   parse-test-$1: run-test-$1
   290 	$$(call LogWarn, Finished running test '$$($1_TEST)')
   331 	$$(call LogWarn, Finished running test '$$($1_TEST)')
   291 	$$(call LogWarn, Test report is stored in $$(strip \
   332 	$$(call LogWarn, Test report is stored in $$(strip \
   292 	    $$(subst $$(TOPDIR)/, , $$($1_TEST_RESULTS_DIR))))
   333 	    $$(subst $$(TOPDIR)/, , $$($1_TEST_RESULTS_DIR))))
   293 	$$(eval $1_TOTAL := $$(shell $$(AWK) '/==========.* tests? from .* \
   334 	$$(if  $$(wildcard $$($1_RESULT_FILE)), \
   294 	    test cases? ran/ { print $$$$2 }' $$($1_RESULT_FILE)))
   335 	  $$(eval $1_TOTAL := $$(shell $$(AWK) '/==========.* tests? from .* \
   295 	$$(eval $1_PASSED := $$(shell $$(AWK) '/\[  PASSED  \] .* tests?./ \
   336 	      test cases? ran/ { print $$$$2 }' $$($1_RESULT_FILE))) \
   296 	    { print $$$$4 }' $$($1_RESULT_FILE)))
   337 	  $$(if $$($1_TOTAL), , $$(eval $1_TOTAL := 0)) \
   297 	$$(eval $1_FAILED := $$(shell $$(AWK) '/\[  FAILED  \] .* tests?, \
   338 	  $$(eval $1_PASSED := $$(shell $$(AWK) '/\[  PASSED  \] .* tests?./ \
   298 	    listed below/ { print $$$$4 }' $$($1_RESULT_FILE)))
   339 	      { print $$$$4 }' $$($1_RESULT_FILE))) \
   299 	$$(if $$($1_FAILED), , $$(eval $1_FAILED := 0))
   340 	  $$(if $$($1_PASSED), , $$(eval $1_PASSED := 0)) \
   300 	$$(eval $1_ERROR := $$(shell \
   341 	  $$(eval $1_FAILED := $$(shell $$(AWK) '/\[  FAILED  \] .* tests?, \
   301 	    $$(EXPR) $$($1_TOTAL) - $$($1_PASSED) - $$($1_FAILED)))
   342 	      listed below/ { print $$$$4 }' $$($1_RESULT_FILE))) \
       
   343 	  $$(if $$($1_FAILED), , $$(eval $1_FAILED := 0)) \
       
   344 	  $$(eval $1_ERROR := $$(shell \
       
   345 	      $$(EXPR) $$($1_TOTAL) - $$($1_PASSED) - $$($1_FAILED))) \
       
   346 	, \
       
   347 	  $$(eval $1_PASSED := 0) \
       
   348 	  $$(eval $1_FAILED := 0) \
       
   349 	  $$(eval $1_ERROR := 1) \
       
   350 	  $$(eval $1_TOTAL := 1) \
       
   351 	)
   302 
   352 
   303   $1: run-test-$1 parse-test-$1
   353   $1: run-test-$1 parse-test-$1
   304 
   354 
   305   TARGETS += $1
   355   TARGETS += $1
   306 endef
   356 endef