changeset 49684:26f624b33218

8199681: Remove boilerplate code from creating native jtreg tests Reviewed-by: erikj
author ihse
date Thu, 15 Mar 2018 19:33:04 +0100
parents 6628683fde28
children d677c3c3ca5d 310517a2be2e 6448c7f1dc1a c9ec6bd25825 956d81c32894 e27c4e4e760e bec646ff7f36 2205fba7d191 6310392f2c03 c66cba389571 422615764e12 ac821c698c3a
files make/common/TestFilesCompilation.gmk make/test/JtregNativeHotspot.gmk make/test/JtregNativeJdk.gmk
diffstat 3 files changed, 33 insertions(+), 78 deletions(-) [+]
line wrap: on
line diff
--- a/make/common/TestFilesCompilation.gmk	Thu Mar 15 19:30:58 2018 +0100
+++ b/make/common/TestFilesCompilation.gmk	Thu Mar 15 19:33:04 2018 +0100
@@ -44,6 +44,7 @@
 #   TYPE Must be either PROGRAM or LIBRARY.
 #   SOURCE_DIRS A list of source directories to search
 #   OUTPUT_DIR Where to put the resulting files
+#   EXCLUDE A list of filenames to exclude from compilation
 SetupTestFilesCompilation = $(NamedParamsMacroTemplate)
 define SetupTestFilesCompilationBody
 
@@ -76,19 +77,23 @@
   $1_FILE_LIST := \
       $$(shell $$(FIND) $$($1_SOURCE_DIRS) -type f -name "$$($1_PREFIX)*.c")
 
+  $1_EXCLUDE_PATTERN := $$(addprefix %/, $$($1_EXCLUDE))
+  $1_FILTERED_FILE_LIST := $$(filter-out $$($1_EXCLUDE_PATTERN), $$($1_FILE_LIST))
+
   # Setup a compilation for each and every one of them
-  $$(foreach file, $$($1_FILE_LIST),\
-    $$(eval name := $$(strip $$(patsubst $$($1_PREFIX)%, %, $$(basename $$(notdir $$(file)))))) \
+  $$(foreach file, $$($1_FILTERED_FILE_LIST),\
+    $$(eval name := $$(strip $$(basename $$(notdir $$(file))))) \
+    $$(eval unprefixed_name := $$(patsubst $$($1_PREFIX)%, %, $$(name))) \
     $$(eval $$(call SetupNativeCompilation, BUILD_TEST_$$(name), \
-        NAME := $$(name), \
+        NAME := $$(unprefixed_name), \
         TYPE := $$($1_COMPILATION_TYPE), \
         SRC := $$(patsubst %/,%,$$(dir $$(file))), \
         INCLUDE_FILES := $$(notdir $$(file)), \
-        OBJECT_DIR := $$($1_OUTPUT_DIR)/support/$$($1_PREFIX)$$(name), \
+        OBJECT_DIR := $$($1_OUTPUT_DIR)/support/$$(name), \
         OUTPUT_DIR := $$($1_OUTPUT_DIR)/$$($1_OUTPUT_SUBDIR), \
-        CFLAGS := $$($1_CFLAGS) $$($1_CFLAGS_$$($1_PREFIX)$$(name)), \
-        LDFLAGS := $$($1_LDFLAGS) $$($1_LDFLAGS_$$($1_PREFIX)$$(name)), \
-        LIBS := $$($1_LIBS_$$($1_PREFIX)$$(name)), \
+        CFLAGS := $$($1_CFLAGS) $$($1_CFLAGS_$$(name)), \
+        LDFLAGS := $$($1_LDFLAGS) $$($1_LDFLAGS_$$(name)), \
+        LIBS := $$($1_LIBS_$$(name)), \
         OPTIMIZATION := LOW, \
         COPY_DEBUG_SYMBOLS := false, \
         STRIP_SYMBOLS := false, \
--- a/make/test/JtregNativeHotspot.gmk	Thu Mar 15 19:30:58 2018 +0100
+++ b/make/test/JtregNativeHotspot.gmk	Thu Mar 15 19:33:04 2018 +0100
@@ -41,90 +41,45 @@
 # Targets for building the native tests themselves.
 ################################################################################
 
-# Add more directories here when needed.
-BUILD_HOTSPOT_JTREG_NATIVE_SRC += \
-    $(TOPDIR)/test/hotspot/jtreg/gc/g1/TestJNIWeakG1 \
-    $(TOPDIR)/test/hotspot/jtreg/gc/stress/TestJNIBlockFullGC \
-    $(TOPDIR)/test/hotspot/jtreg/gc/stress/gclocker \
-    $(TOPDIR)/test/hotspot/jtreg/gc/cslocker \
-    $(TOPDIR)/test/hotspot/jtreg/native_sanity \
-    $(TOPDIR)/test/hotspot/jtreg/runtime/jni/8025979 \
-    $(TOPDIR)/test/hotspot/jtreg/runtime/jni/8033445 \
-    $(TOPDIR)/test/hotspot/jtreg/runtime/jni/checked \
-    $(TOPDIR)/test/hotspot/jtreg/runtime/jni/FindClass \
-    $(TOPDIR)/test/hotspot/jtreg/runtime/jni/PrivateInterfaceMethods \
-    $(TOPDIR)/test/hotspot/jtreg/runtime/jni/ToStringInInterfaceTest \
-    $(TOPDIR)/test/hotspot/jtreg/runtime/jni/CalleeSavedRegisters \
-    $(TOPDIR)/test/hotspot/jtreg/runtime/jni/CallWithJNIWeak \
-    $(TOPDIR)/test/hotspot/jtreg/runtime/jni/ReturnJNIWeak \
-    $(TOPDIR)/test/hotspot/jtreg/runtime/modules/getModuleJNI \
-    $(TOPDIR)/test/hotspot/jtreg/runtime/SameObject \
-    $(TOPDIR)/test/hotspot/jtreg/runtime/BoolReturn \
-    $(TOPDIR)/test/hotspot/jtreg/runtime/noClassDefFoundMsg \
-    $(TOPDIR)/test/hotspot/jtreg/runtime/handshake \
-    $(TOPDIR)/test/hotspot/jtreg/runtime/RedefineTests \
-    $(TOPDIR)/test/hotspot/jtreg/compiler/floatingpoint/ \
-    $(TOPDIR)/test/hotspot/jtreg/compiler/calls \
-    $(TOPDIR)/test/hotspot/jtreg/compiler/runtime/criticalnatives/lookup \
-    $(TOPDIR)/test/hotspot/jtreg/compiler/runtime/criticalnatives/argumentcorruption \
-    $(TOPDIR)/test/hotspot/jtreg/serviceability/jvmti/CanGenerateAllClassHook \
-    $(TOPDIR)/test/hotspot/jtreg/serviceability/jvmti/GetOwnedMonitorInfo \
-    $(TOPDIR)/test/hotspot/jtreg/serviceability/jvmti/GetOwnedMonitorStackDepthInfo \
-    $(TOPDIR)/test/hotspot/jtreg/serviceability/jvmti/GetNamedModule \
-    $(TOPDIR)/test/hotspot/jtreg/serviceability/jvmti/IsModifiableModule \
-    $(TOPDIR)/test/hotspot/jtreg/serviceability/jvmti/AddModuleReads \
-    $(TOPDIR)/test/hotspot/jtreg/serviceability/jvmti/AddModuleExportsAndOpens \
-    $(TOPDIR)/test/hotspot/jtreg/serviceability/jvmti/AddModuleUsesAndProvides \
-    $(TOPDIR)/test/hotspot/jtreg/testlibrary/jvmti \
-    $(TOPDIR)/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test \
-    $(TOPDIR)/test/hotspot/jtreg/serviceability/jvmti/GetModulesInfo \
-    $(TOPDIR)/test/hotspot/jtreg/serviceability/jvmti/ModuleAwareAgents/ClassFileLoadHook \
-    $(TOPDIR)/test/hotspot/jtreg/serviceability/jvmti/ModuleAwareAgents/ClassLoadPrepare \
-    $(TOPDIR)/test/hotspot/jtreg/serviceability/jvmti/ModuleAwareAgents/ThreadStart \
-    $(TOPDIR)/test/hotspot/jtreg/serviceability/jvmti/StartPhase/AllowedFunctions \
-    $(TOPDIR)/test/hotspot/jtreg/serviceability/dcmd/jvmti/AttachFailed \
-    #
+# This might have been added to by a custom extension.
+BUILD_HOTSPOT_JTREG_NATIVE_SRC += $(TOPDIR)/test/hotspot/jtreg
 
-# Add conditional directories here when needed.
-ifeq ($(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU_ARCH), solaris-sparc)
-BUILD_HOTSPOT_JTREG_NATIVE_SRC += \
-    $(TOPDIR)/test/hotspot/jtreg/runtime/libadimalloc.solaris.sparc \
-    $(TOPDIR)/test/hotspot/jtreg/runtime/ThreadSignalMask
-endif
+BUILD_HOTSPOT_JTREG_OUTPUT_DIR := $(OUTPUTDIR)/support/test/hotspot/jtreg/native
 
-ifeq ($(OPENJDK_TARGET_OS), linux)
-BUILD_HOTSPOT_JTREG_NATIVE_SRC += \
-    $(TOPDIR)/test/hotspot/jtreg/runtime/execstack \
-    $(TOPDIR)/test/hotspot/jtreg/runtime/jsig \
-    $(TOPDIR)/test/hotspot/jtreg/runtime/StackGuardPages
+BUILD_HOTSPOT_JTREG_IMAGE_DIR := $(TEST_IMAGE_DIR)/hotspot/jtreg
+
+# Platform specific setup
+ifneq ($(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU_ARCH), solaris-sparc)
+  BUILD_HOTSPOT_JTREG_EXCLUDE += liboverflow.c exeThreadSignalMask.c
 endif
 
 ifeq ($(OPENJDK_TARGET_OS), linux)
     BUILD_HOTSPOT_JTREG_LIBRARIES_LDFLAGS_libtest-rw := -z noexecstack
     BUILD_HOTSPOT_JTREG_LIBRARIES_LDFLAGS_libtest-rwx := -z execstack
     BUILD_HOTSPOT_JTREG_EXECUTABLES_LIBS_exeinvoke := -ljvm -lpthread
-    BUILD_TEST_invoke_exeinvoke.c_OPTIMIZATION := NONE
+    BUILD_TEST_exeinvoke_exeinvoke.c_OPTIMIZATION := NONE
     BUILD_HOTSPOT_JTREG_EXECUTABLES_LIBS_exeFPRegs := -ldl
+else
+  BUILD_HOTSPOT_JTREG_EXCLUDE += libtest-rw.c libtest-rwx.c libTestJNI.c \
+      exeinvoke.c
 endif
 
 ifeq ($(OPENJDK_TARGET_OS), windows)
     BUILD_HOTSPOT_JTREG_EXECUTABLES_CFLAGS_exeFPRegs := -MT
 endif
 
-BUILD_HOTSPOT_JTREG_OUTPUT_DIR := $(OUTPUTDIR)/support/test/hotspot/jtreg/native
-
-BUILD_HOTSPOT_JTREG_IMAGE_DIR := $(TEST_IMAGE_DIR)/hotspot/jtreg
-
 $(eval $(call SetupTestFilesCompilation, BUILD_HOTSPOT_JTREG_LIBRARIES, \
     TYPE := LIBRARY, \
     SOURCE_DIRS := $(BUILD_HOTSPOT_JTREG_NATIVE_SRC), \
     OUTPUT_DIR := $(BUILD_HOTSPOT_JTREG_OUTPUT_DIR), \
+    EXCLUDE := $(BUILD_HOTSPOT_JTREG_EXCLUDE), \
 ))
 
 $(eval $(call SetupTestFilesCompilation, BUILD_HOTSPOT_JTREG_EXECUTABLES, \
     TYPE := PROGRAM, \
     SOURCE_DIRS := $(BUILD_HOTSPOT_JTREG_NATIVE_SRC), \
     OUTPUT_DIR := $(BUILD_HOTSPOT_JTREG_OUTPUT_DIR), \
+    EXCLUDE := $(BUILD_HOTSPOT_JTREG_EXCLUDE), \
 ))
 
 build-test-hotspot-jtreg-native: $(BUILD_HOTSPOT_JTREG_LIBRARIES) $(BUILD_HOTSPOT_JTREG_EXECUTABLES)
--- a/make/test/JtregNativeJdk.gmk	Thu Mar 15 19:30:58 2018 +0100
+++ b/make/test/JtregNativeJdk.gmk	Thu Mar 15 19:33:04 2018 +0100
@@ -41,23 +41,17 @@
 # Targets for building the native tests themselves.
 ################################################################################
 
-# Add more directories here when needed.
-BUILD_JDK_JTREG_NATIVE_SRC += \
-    $(TOPDIR)/test/jdk/native_sanity \
-    $(TOPDIR)/test/jdk/java/lang/ClassLoader/nativeLibrary \
-    $(TOPDIR)/test/jdk/java/lang/String/nativeEncoding \
-    #
-
-ifneq ($(OPENJDK_TARGET_OS), windows)
-  BUILD_JDK_JTREG_NATIVE_SRC += $(TOPDIR)/test/jdk/java/nio/channels/FileChannel/directio
-  BUILD_JDK_JTREG_NATIVE_SRC += $(TOPDIR)/test/jdk/java/nio/channels/spi/SelectorProvider/inheritedChannel
-endif
+# This might have been added to by a custom extension.
+BUILD_JDK_JTREG_NATIVE_SRC += $(TOPDIR)/test/jdk
 
 BUILD_JDK_JTREG_OUTPUT_DIR := $(OUTPUTDIR)/support/test/jdk/jtreg/native
 
 BUILD_JDK_JTREG_IMAGE_DIR := $(TEST_IMAGE_DIR)/jdk/jtreg
 
+# Platform specific setup
 ifeq ($(OPENJDK_TARGET_OS), windows)
+  BUILD_JDK_JTREG_EXCLUDE += libDirectIO.c libInheritedChannel.c
+
   WIN_LIB_JAVA := $(SUPPORT_OUTPUTDIR)/native/java.base/libjava/java.lib
   BUILD_JDK_JTREG_LIBRARIES_LIBS_libstringPlatformChars := $(WIN_LIB_JAVA)
 else
@@ -74,17 +68,18 @@
     TYPE := LIBRARY, \
     SOURCE_DIRS := $(BUILD_JDK_JTREG_NATIVE_SRC), \
     OUTPUT_DIR := $(BUILD_JDK_JTREG_OUTPUT_DIR), \
+    EXCLUDE := $(BUILD_JDK_JTREG_EXCLUDE), \
 ))
 
 $(eval $(call SetupTestFilesCompilation, BUILD_JDK_JTREG_EXECUTABLES, \
     TYPE := PROGRAM, \
     SOURCE_DIRS := $(BUILD_JDK_JTREG_NATIVE_SRC), \
     OUTPUT_DIR := $(BUILD_JDK_JTREG_OUTPUT_DIR), \
+    EXCLUDE := $(BUILD_JDK_JTREG_EXCLUDE), \
 ))
 
 build-test-jdk-jtreg-native: $(BUILD_JDK_JTREG_LIBRARIES) $(BUILD_JDK_JTREG_EXECUTABLES)
 
-
 ################################################################################
 # Targets for building test-image.
 ################################################################################