make/RunTests.gmk
changeset 47937 c1437939b0d8
parent 47932 0c22f6b9b5e2
child 47938 a182ac1491d7
equal deleted inserted replaced
47936:3b1ef48862cf 47937:c1437939b0d8
    36 $(eval $(call IncludeCustomExtension, RunTests.gmk))
    36 $(eval $(call IncludeCustomExtension, RunTests.gmk))
    37 
    37 
    38 TEST_RESULTS_DIR := $(OUTPUTDIR)/test-results
    38 TEST_RESULTS_DIR := $(OUTPUTDIR)/test-results
    39 TEST_SUPPORT_DIR := $(OUTPUTDIR)/test-support
    39 TEST_SUPPORT_DIR := $(OUTPUTDIR)/test-support
    40 
    40 
       
    41 ifeq ($(CUSTOM_ROOT), )
       
    42   JTREG_TOPDIR := $(TOPDIR)
       
    43 else
       
    44   JTREG_TOPDIR := $(CUSTOM_ROOT)
       
    45 endif
    41 
    46 
    42 ################################################################################
    47 ################################################################################
    43 # Parse control variables
    48 # Parse control variables
    44 ################################################################################
    49 ################################################################################
    45 
    50 
   114       ) \
   119       ) \
   115     ) \
   120     ) \
   116   )
   121   )
   117 endef
   122 endef
   118 
   123 
       
   124 # Helper function that removes the TOPDIR part
       
   125 CleanupJtregPath = \
       
   126   $(strip $(patsubst %/, %, $(subst $(JTREG_TOPDIR)/,, $1)))
       
   127 
   119 # Take a partial Jtreg root path and return a full, absolute path to that Jtreg
   128 # Take a partial Jtreg root path and return a full, absolute path to that Jtreg
   120 # root. Also support having "hotspot" as an alias for "hotspot/jtreg".
   129 # root. Also support having "hotspot" as an alias for "hotspot/jtreg".
   121 ExpandJtregRoot = \
   130 ExpandJtregRoot = \
   122   $(strip $(wildcard $(patsubst %/, %, \
   131   $(call CleanupJtregPath, $(wildcard \
   123     $(if $(filter /%, $1), \
   132     $(if $(filter /%, $1), \
   124       $1 \
   133       $(if $(wildcard $(strip $1)/TEST.ROOT), \
       
   134         $1 \
       
   135       ) \
   125     , \
   136     , \
   126       $(filter $(addprefix %, $1), $(JTREG_TESTROOTS) $(addsuffix /, $(JTREG_TESTROOTS))) \
   137       $(filter $(addprefix %, $1), $(JTREG_TESTROOTS) $(addsuffix /, $(JTREG_TESTROOTS))) \
   127       $(filter $(addprefix %, $(strip $1)/jtreg), $(JTREG_TESTROOTS) $(addsuffix /, $(JTREG_TESTROOTS))) \
   138       $(filter $(addprefix %, $(strip $1)/jtreg), $(JTREG_TESTROOTS) $(addsuffix /, $(JTREG_TESTROOTS))) \
   128     ) \
   139     ) \
   129   )))
   140   ))
   130 
   141 
   131 # Take a partial Jtreg test path and return a full, absolute path to that Jtreg
   142 # Take a partial Jtreg test path and return a full, absolute path to that Jtreg
   132 # test. Also support having "hotspot" as an alias for "hotspot/jtreg".
   143 # test. Also support having "hotspot" as an alias for "hotspot/jtreg".
   133 ExpandJtregPath = \
   144 ExpandJtregPath = \
   134   $(if $(call ExpandJtregRoot, $1), \
   145   $(if $(call ExpandJtregRoot, $1), \
   135     $(call ExpandJtregRoot, $1) \
   146     $(call ExpandJtregRoot, $1) \
   136   , \
   147   , \
   137     $(strip $(wildcard $(patsubst %/, %, \
   148     $(call CleanupJtregPath, $(wildcard \
   138       $(if $(filter /%, $1), \
   149       $(if $(filter /%, $1), \
   139         $1 \
   150         $1 \
   140       , \
   151       , \
   141         $(addsuffix /$(strip $1), $(JTREG_TESTROOTS) $(TEST_BASEDIRS)) \
   152         $(addsuffix /$(strip $1), $(JTREG_TESTROOTS) $(TEST_BASEDIRS)) \
   142         $(addsuffix $(strip $(patsubst hotspot/%, /hotspot/jtreg/%, $1)), $(JTREG_TESTROOTS) $(TEST_BASEDIRS)) \
   153         $(addsuffix $(strip $(patsubst hotspot/%, /hotspot/jtreg/%, $1)), $(JTREG_TESTROOTS) $(TEST_BASEDIRS)) \
   143       ) \
   154       ) \
   144     ))) \
   155     )) \
   145   )
   156   )
   146 
   157 
   147 # Helper function to determine if a test specification is a Jtreg test
   158 # Helper function to determine if a test specification is a Jtreg test
   148 #
   159 #
   149 # It is a Jtreg test if it optionally begins with jtreg:, and then is either
   160 # It is a Jtreg test if it optionally begins with jtreg:, and then is either
   163       $(eval TEST_PATH := $(word 1, $(subst :, $(SPACE), $(TEST_NAME)))) \
   174       $(eval TEST_PATH := $(word 1, $(subst :, $(SPACE), $(TEST_NAME)))) \
   164       $(eval TEST_GROUP := $(word 2, $(subst :, $(SPACE), $(TEST_NAME)))) \
   175       $(eval TEST_GROUP := $(word 2, $(subst :, $(SPACE), $(TEST_NAME)))) \
   165       $(eval TEST_ROOTS := $(call ExpandJtregRoot, $(TEST_PATH))) \
   176       $(eval TEST_ROOTS := $(call ExpandJtregRoot, $(TEST_PATH))) \
   166     ) \
   177     ) \
   167     $(foreach test_root, $(TEST_ROOTS), \
   178     $(foreach test_root, $(TEST_ROOTS), \
   168       $(if $(filter $(TEST_GROUP), $($(test_root)_JTREG_TEST_GROUPS)), \
   179       $(if $(filter /%, $(test_root)), \
   169         jtreg:$(test_root):$(TEST_GROUP) \
   180         jtreg:$(test_root):$(TEST_GROUP) \
       
   181       , \
       
   182         $(if $(filter $(TEST_GROUP), $($(JTREG_TOPDIR)/$(test_root)_JTREG_TEST_GROUPS)), \
       
   183           jtreg:$(test_root):$(TEST_GROUP) \
       
   184         ) \
   170       ) \
   185       ) \
   171     ) \
   186     ) \
   172   , \
   187   , \
   173     $(if $(filter /%, $(TEST_NAME)), \
   188     $(eval TEST_PATHS := $(call ExpandJtregPath, $(TEST_NAME))) \
   174       $(if $(wildcard $(TEST_NAME)), \
   189     $(foreach test_path, $(TEST_PATHS), \
   175         jtreg:$(TEST_NAME) \
   190       jtreg:$(test_path) \
   176       ) \
       
   177     , \
       
   178       $(eval TEST_PATHS := $(call ExpandJtregPath, $(TEST_NAME))) \
       
   179       $(foreach test_path, $(TEST_PATHS), \
       
   180         jtreg:$(test_path) \
       
   181       ) \
       
   182     ) \
   191     ) \
   183   )
   192   )
   184 endef
   193 endef
   185 
   194 
   186 ifeq ($(TEST), )
   195 ifeq ($(TEST), )
   324 
   333 
   325   $1_TEST_NAME := $$(strip $$(patsubst jtreg:%, %, $$($1_TEST)))
   334   $1_TEST_NAME := $$(strip $$(patsubst jtreg:%, %, $$($1_TEST)))
   326 
   335 
   327   $1_COMPONENT := \
   336   $1_COMPONENT := \
   328       $$(strip $$(foreach root, $$(JTREG_TESTROOTS), \
   337       $$(strip $$(foreach root, $$(JTREG_TESTROOTS), \
   329         $$(if $$(filter $$(root)%, $$($1_TEST_NAME)), \
   338         $$(if $$(filter $$(root)%, $$(JTREG_TOPDIR)/$$($1_TEST_NAME)), \
   330           $$(lastword $$(subst /, $$(SPACE), $$(root))) \
   339           $$(lastword $$(subst /, $$(SPACE), $$(root))) \
   331         ) \
   340         ) \
   332       ))
   341       ))
   333   # This will work only as long as just hotspot has the additional "jtreg" directory
   342   # This will work only as long as just hotspot has the additional "jtreg" directory
   334   ifeq ($$($1_COMPONENT), jtreg)
   343   ifeq ($$($1_COMPONENT), jtreg)
   414 	$$(call ExecuteWithLog, $$($1_TEST_SUPPORT_DIR)/jtreg, \
   423 	$$(call ExecuteWithLog, $$($1_TEST_SUPPORT_DIR)/jtreg, \
   415 	    $$(JAVA) $$($1_JTREG_LAUNCHER_OPTIONS) \
   424 	    $$(JAVA) $$($1_JTREG_LAUNCHER_OPTIONS) \
   416 	        -Dprogram=jtreg -jar $$(JT_HOME)/lib/jtreg.jar \
   425 	        -Dprogram=jtreg -jar $$(JT_HOME)/lib/jtreg.jar \
   417 	        $$($1_JTREG_BASIC_OPTIONS) \
   426 	        $$($1_JTREG_BASIC_OPTIONS) \
   418 	        -testjdk:$$(JDK_IMAGE_DIR) \
   427 	        -testjdk:$$(JDK_IMAGE_DIR) \
   419 	        -dir:$$(TOPDIR) \
   428 	        -dir:$$(JTREG_TOPDIR) \
   420 	        -reportDir:$$($1_TEST_RESULTS_DIR) \
   429 	        -reportDir:$$($1_TEST_RESULTS_DIR) \
   421 	        -workDir:$$($1_TEST_SUPPORT_DIR) \
   430 	        -workDir:$$($1_TEST_SUPPORT_DIR) \
   422 	        $$(JTREG_OPTIONS) \
   431 	        $$(JTREG_OPTIONS) \
   423 	        $$($1_TEST_NAME) || true )
   432 	        $$($1_TEST_NAME) || true )
   424 
   433 
   512 	$(PRINTF) "%2s %-49s %5s %5s %5s %5s %2s\n" "  " TEST \
   521 	$(PRINTF) "%2s %-49s %5s %5s %5s %5s %2s\n" "  " TEST \
   513 	    TOTAL PASS FAIL ERROR " "
   522 	    TOTAL PASS FAIL ERROR " "
   514 	$(foreach test, $(TESTS_TO_RUN), \
   523 	$(foreach test, $(TESTS_TO_RUN), \
   515 	  $(eval TEST_ID := $(shell $(ECHO) $(strip $(test)) | \
   524 	  $(eval TEST_ID := $(shell $(ECHO) $(strip $(test)) | \
   516 	      $(TR) -cs '[a-z][A-Z][0-9]\n' '_')) \
   525 	      $(TR) -cs '[a-z][A-Z][0-9]\n' '_')) \
       
   526 	  $(eval NAME_PATTERN := $(shell $(ECHO) $(test) | $(TR) -c \\n _)) \
       
   527 	  $(if $(filter __________________________________________________%, $(NAME_PATTERN)), \
       
   528 	    $(eval TEST_NAME := ) \
       
   529 	    $(PRINTF) "%2s %-49s\n" "  " "$(test)"  $(NEWLINE) \
       
   530 	  , \
       
   531 	    $(eval TEST_NAME := $(test)) \
       
   532 	  ) \
   517 	  $(if $(filter $($(TEST_ID)_PASSED), $($(TEST_ID)_TOTAL)), \
   533 	  $(if $(filter $($(TEST_ID)_PASSED), $($(TEST_ID)_TOTAL)), \
   518 	    $(PRINTF) "%2s %-49s %5d %5d %5d %5d %2s\n" "  " "$(test)" \
   534 	    $(PRINTF) "%2s %-49s %5d %5d %5d %5d %2s\n" "  " "$(TEST_NAME)" \
   519 	        $($(TEST_ID)_TOTAL) $($(TEST_ID)_PASSED) $($(TEST_ID)_FAILED) \
   535 	        $($(TEST_ID)_TOTAL) $($(TEST_ID)_PASSED) $($(TEST_ID)_FAILED) \
   520 	        $($(TEST_ID)_ERROR) "  " $(NEWLINE) \
   536 	        $($(TEST_ID)_ERROR) "  " $(NEWLINE) \
   521 	  , \
   537 	  , \
   522 	    $(PRINTF) "%2s %-49s %5d %5d %5d %5d %2s\n" ">>" "$(test)" \
   538 	    $(PRINTF) "%2s %-49s %5d %5d %5d %5d %2s\n" ">>" "$(TEST_NAME)" \
   523 	        $($(TEST_ID)_TOTAL) $($(TEST_ID)_PASSED) $($(TEST_ID)_FAILED) \
   539 	        $($(TEST_ID)_TOTAL) $($(TEST_ID)_PASSED) $($(TEST_ID)_FAILED) \
   524 	        $($(TEST_ID)_ERROR) "<<" $(NEWLINE) \
   540 	        $($(TEST_ID)_ERROR) "<<" $(NEWLINE) \
   525 	    $(eval TEST_FAILURE := true) \
   541 	    $(eval TEST_FAILURE := true) \
   526 	  ) \
   542 	  ) \
   527 	)
   543 	)