From 992c9ee022b409947680d0b428be18111c9bbfd2 Mon Sep 17 00:00:00 2001 From: Ekaterina Pavlova Date: Thu, 28 Jun 2018 17:07:34 -0700 Subject: [PATCH] 8205207: Port Graal unit tests under jtreg Reviewed-by: kvn, erikj, iignatyev --- make/Main.gmk | 17 + make/RunTests.gmk | 2 + make/autoconf/lib-tests.m4 | 57 +++ make/autoconf/libraries.m4 | 2 + make/autoconf/spec.gmk.in | 1 + make/conf/jib-profiles.js | 14 +- make/test/JtregGraalUnit.gmk | 144 ++++++ test/TestCommon.gmk | 3 + test/hotspot/jtreg/ProblemList-graal.txt | 17 + test/hotspot/jtreg/TEST.groups | 3 +- .../compiler/graalunit/ApiDirectivesTest.java | 38 ++ .../jtreg/compiler/graalunit/ApiTest.java | 38 ++ .../compiler/graalunit/AsmAarch64Test.java | 38 ++ .../compiler/graalunit/AsmAmd64Test.java | 38 ++ .../compiler/graalunit/AsmSparcTest.java | 38 ++ .../compiler/graalunit/CollectionsTest.java | 38 ++ .../compiler/graalunit/CoreAmd64Test.java | 38 ++ .../compiler/graalunit/CoreSparcTest.java | 38 ++ .../jtreg/compiler/graalunit/CoreTest.java | 38 ++ .../jtreg/compiler/graalunit/DebugTest.java | 38 ++ .../jtreg/compiler/graalunit/GraphTest.java | 38 ++ .../compiler/graalunit/HotspotAmd64Test.java | 38 ++ .../compiler/graalunit/HotspotLirTest.java | 38 ++ .../jtreg/compiler/graalunit/HotspotTest.java | 38 ++ .../compiler/graalunit/Jtt.MicroTest.java | 38 ++ .../compiler/graalunit/JttBackendTest.java | 38 ++ .../compiler/graalunit/JttBytecodeTest.java | 38 ++ .../compiler/graalunit/JttExceptTest.java | 38 ++ .../compiler/graalunit/JttHotpathTest.java | 38 ++ .../compiler/graalunit/JttHotspotTest.java | 38 ++ .../jtreg/compiler/graalunit/JttJdkTest.java | 38 ++ .../compiler/graalunit/JttLangALTest.java | 38 ++ .../compiler/graalunit/JttLangMTest.java | 38 ++ .../compiler/graalunit/JttLangNZTest.java | 38 ++ .../jtreg/compiler/graalunit/JttLoopTest.java | 38 ++ .../compiler/graalunit/JttOptimizeTest.java | 38 ++ .../compiler/graalunit/JttReflectAETest.java | 38 ++ .../compiler/graalunit/JttReflectFTest.java | 38 ++ .../compiler/graalunit/JttReflectGZTest.java | 38 ++ .../compiler/graalunit/JttThreadsTest.java | 38 ++ .../jtreg/compiler/graalunit/LirJttTest.java | 38 ++ .../jtreg/compiler/graalunit/LoopTest.java | 38 ++ .../jtreg/compiler/graalunit/NodesTest.java | 38 ++ .../jtreg/compiler/graalunit/OptionsTest.java | 38 ++ .../compiler/graalunit/PhasesCommonTest.java | 38 ++ .../jtreg/compiler/graalunit/README.md | 36 ++ .../compiler/graalunit/ReplacementsTest.java | 38 ++ .../jtreg/compiler/graalunit/TestPackages.txt | 38 ++ .../jtreg/compiler/graalunit/UtilTest.java | 38 ++ .../mxtool/junit/AnsiTerminalDecorator.java | 120 +++++ .../junit/EagerStackTraceDecorator.java | 41 ++ .../junit/FindClassesByAnnotatedMethods.java | 341 ++++++++++++ .../mxtool/junit/GCAfterTestDecorator.java | 38 ++ .../com/oracle/mxtool/junit/JLModule.java | 211 ++++++++ .../oracle/mxtool/junit/MxJUnitRequest.java | 116 +++++ .../oracle/mxtool/junit/MxJUnitWrapper.java | 484 ++++++++++++++++++ .../oracle/mxtool/junit/MxRunListener.java | 147 ++++++ .../mxtool/junit/MxRunListenerDecorator.java | 113 ++++ .../junit/TestResultLoggerDecorator.java | 56 ++ .../oracle/mxtool/junit/TextRunListener.java | 148 ++++++ .../oracle/mxtool/junit/TimingDecorator.java | 101 ++++ .../mxtool/junit/VerboseTextListener.java | 132 +++++ .../common/GraalUnitTestLauncher.java | 266 ++++++++++ .../jtreg/compiler/graalunit/generateTests.sh | 72 +++ test/jtreg-ext/requires/VMProps.java | 3 +- 65 files changed, 4124 insertions(+), 5 deletions(-) create mode 100644 make/autoconf/lib-tests.m4 create mode 100644 make/test/JtregGraalUnit.gmk create mode 100644 test/hotspot/jtreg/compiler/graalunit/ApiDirectivesTest.java create mode 100644 test/hotspot/jtreg/compiler/graalunit/ApiTest.java create mode 100644 test/hotspot/jtreg/compiler/graalunit/AsmAarch64Test.java create mode 100644 test/hotspot/jtreg/compiler/graalunit/AsmAmd64Test.java create mode 100644 test/hotspot/jtreg/compiler/graalunit/AsmSparcTest.java create mode 100644 test/hotspot/jtreg/compiler/graalunit/CollectionsTest.java create mode 100644 test/hotspot/jtreg/compiler/graalunit/CoreAmd64Test.java create mode 100644 test/hotspot/jtreg/compiler/graalunit/CoreSparcTest.java create mode 100644 test/hotspot/jtreg/compiler/graalunit/CoreTest.java create mode 100644 test/hotspot/jtreg/compiler/graalunit/DebugTest.java create mode 100644 test/hotspot/jtreg/compiler/graalunit/GraphTest.java create mode 100644 test/hotspot/jtreg/compiler/graalunit/HotspotAmd64Test.java create mode 100644 test/hotspot/jtreg/compiler/graalunit/HotspotLirTest.java create mode 100644 test/hotspot/jtreg/compiler/graalunit/HotspotTest.java create mode 100644 test/hotspot/jtreg/compiler/graalunit/Jtt.MicroTest.java create mode 100644 test/hotspot/jtreg/compiler/graalunit/JttBackendTest.java create mode 100644 test/hotspot/jtreg/compiler/graalunit/JttBytecodeTest.java create mode 100644 test/hotspot/jtreg/compiler/graalunit/JttExceptTest.java create mode 100644 test/hotspot/jtreg/compiler/graalunit/JttHotpathTest.java create mode 100644 test/hotspot/jtreg/compiler/graalunit/JttHotspotTest.java create mode 100644 test/hotspot/jtreg/compiler/graalunit/JttJdkTest.java create mode 100644 test/hotspot/jtreg/compiler/graalunit/JttLangALTest.java create mode 100644 test/hotspot/jtreg/compiler/graalunit/JttLangMTest.java create mode 100644 test/hotspot/jtreg/compiler/graalunit/JttLangNZTest.java create mode 100644 test/hotspot/jtreg/compiler/graalunit/JttLoopTest.java create mode 100644 test/hotspot/jtreg/compiler/graalunit/JttOptimizeTest.java create mode 100644 test/hotspot/jtreg/compiler/graalunit/JttReflectAETest.java create mode 100644 test/hotspot/jtreg/compiler/graalunit/JttReflectFTest.java create mode 100644 test/hotspot/jtreg/compiler/graalunit/JttReflectGZTest.java create mode 100644 test/hotspot/jtreg/compiler/graalunit/JttThreadsTest.java create mode 100644 test/hotspot/jtreg/compiler/graalunit/LirJttTest.java create mode 100644 test/hotspot/jtreg/compiler/graalunit/LoopTest.java create mode 100644 test/hotspot/jtreg/compiler/graalunit/NodesTest.java create mode 100644 test/hotspot/jtreg/compiler/graalunit/OptionsTest.java create mode 100644 test/hotspot/jtreg/compiler/graalunit/PhasesCommonTest.java create mode 100644 test/hotspot/jtreg/compiler/graalunit/README.md create mode 100644 test/hotspot/jtreg/compiler/graalunit/ReplacementsTest.java create mode 100644 test/hotspot/jtreg/compiler/graalunit/TestPackages.txt create mode 100644 test/hotspot/jtreg/compiler/graalunit/UtilTest.java create mode 100644 test/hotspot/jtreg/compiler/graalunit/com.oracle.mxtool.junit/com/oracle/mxtool/junit/AnsiTerminalDecorator.java create mode 100644 test/hotspot/jtreg/compiler/graalunit/com.oracle.mxtool.junit/com/oracle/mxtool/junit/EagerStackTraceDecorator.java create mode 100644 test/hotspot/jtreg/compiler/graalunit/com.oracle.mxtool.junit/com/oracle/mxtool/junit/FindClassesByAnnotatedMethods.java create mode 100644 test/hotspot/jtreg/compiler/graalunit/com.oracle.mxtool.junit/com/oracle/mxtool/junit/GCAfterTestDecorator.java create mode 100644 test/hotspot/jtreg/compiler/graalunit/com.oracle.mxtool.junit/com/oracle/mxtool/junit/JLModule.java create mode 100644 test/hotspot/jtreg/compiler/graalunit/com.oracle.mxtool.junit/com/oracle/mxtool/junit/MxJUnitRequest.java create mode 100644 test/hotspot/jtreg/compiler/graalunit/com.oracle.mxtool.junit/com/oracle/mxtool/junit/MxJUnitWrapper.java create mode 100644 test/hotspot/jtreg/compiler/graalunit/com.oracle.mxtool.junit/com/oracle/mxtool/junit/MxRunListener.java create mode 100644 test/hotspot/jtreg/compiler/graalunit/com.oracle.mxtool.junit/com/oracle/mxtool/junit/MxRunListenerDecorator.java create mode 100644 test/hotspot/jtreg/compiler/graalunit/com.oracle.mxtool.junit/com/oracle/mxtool/junit/TestResultLoggerDecorator.java create mode 100644 test/hotspot/jtreg/compiler/graalunit/com.oracle.mxtool.junit/com/oracle/mxtool/junit/TextRunListener.java create mode 100644 test/hotspot/jtreg/compiler/graalunit/com.oracle.mxtool.junit/com/oracle/mxtool/junit/TimingDecorator.java create mode 100644 test/hotspot/jtreg/compiler/graalunit/com.oracle.mxtool.junit/com/oracle/mxtool/junit/VerboseTextListener.java create mode 100644 test/hotspot/jtreg/compiler/graalunit/common/GraalUnitTestLauncher.java create mode 100644 test/hotspot/jtreg/compiler/graalunit/generateTests.sh diff --git a/make/Main.gmk b/make/Main.gmk index 81626672c55..1a6e317e7fe 100644 --- a/make/Main.gmk +++ b/make/Main.gmk @@ -487,6 +487,14 @@ test-image-jdk-jtreg-native: +($(CD) $(TOPDIR)/make/test && $(MAKE) $(MAKE_ARGS) -f JtregNativeJdk.gmk \ test-image-jdk-jtreg-native) +build-test-hotspot-jtreg-graal: + +($(CD) $(TOPDIR)/make/test && $(MAKE) $(MAKE_ARGS) -f JtregGraalUnit.gmk \ + build-test-hotspot-jtreg-graal) + +test-image-hotspot-jtreg-graal: + +($(CD) $(TOPDIR)/make/test && $(MAKE) $(MAKE_ARGS) -f JtregGraalUnit.gmk \ + test-image-hotspot-jtreg-graal) + run-test: +($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f RunTests.gmk run-test TEST="$(TEST)") @@ -523,6 +531,7 @@ ALL_TARGETS += prepare-test-image build-test-hotspot-jtreg-native \ test-image-hotspot-jtreg-native build-test-jdk-jtreg-native \ test-image-jdk-jtreg-native build-test-lib build-test-failure-handler \ test-failure-handler test-image-failure-handler test-image-hotspot-gtest \ + test-image-hotspot-jtreg-graal build-test-hotspot-jtreg-graal \ run-test exploded-run-test ################################################################################ @@ -853,10 +862,14 @@ else build-test-jdk-jtreg-native: buildtools-jdk java.base-libs + build-test-hotspot-jtreg-graal: exploded-image-optimize + test-image-hotspot-jtreg-native: build-test-hotspot-jtreg-native test-image-jdk-jtreg-native: build-test-jdk-jtreg-native + test-image-hotspot-jtreg-graal: build-test-hotspot-jtreg-graal + test-image-hotspot-gtest: hotspot test-hotspot-internal: exploded-image @@ -993,6 +1006,10 @@ docs-image: docs-jdk # If not already set, set the JVM specific targets to build the test image JVM_TEST_IMAGE_TARGETS ?= test-image-hotspot-jtreg-native test-image-hotspot-gtest +ifeq ($(INCLUDE_GRAAL), true) + JVM_TEST_IMAGE_TARGETS += test-image-hotspot-jtreg-graal +endif + # This target builds the test image test-image: prepare-test-image \ test-image-jdk-jtreg-native test-image-failure-handler \ diff --git a/make/RunTests.gmk b/make/RunTests.gmk index 83cb4f68e91..749f3570f7d 100644 --- a/make/RunTests.gmk +++ b/make/RunTests.gmk @@ -535,6 +535,8 @@ define SetupRunJtregTestBody $1_JTREG_BASIC_OPTIONS += -cpa:$$(JIB_JAR) endif + $1_JTREG_BASIC_OPTIONS += -e:TEST_IMAGE_GRAAL_DIR=${TEST_IMAGE_DIR}/hotspot/jtreg/graal + ifneq ($$(JTREG_FAILURE_HANDLER_OPTIONS), ) $1_JTREG_LAUNCHER_OPTIONS += -Djava.library.path="$(JTREG_FAILURE_HANDLER_DIR)" endif diff --git a/make/autoconf/lib-tests.m4 b/make/autoconf/lib-tests.m4 new file mode 100644 index 00000000000..15b0a0df443 --- /dev/null +++ b/make/autoconf/lib-tests.m4 @@ -0,0 +1,57 @@ +# +# Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + +############################################################################### +# +# Check for graalunit libs, needed for running graalunit tests. +# +AC_DEFUN_ONCE([LIB_TESTS_SETUP_GRAALUNIT], +[ + AC_ARG_WITH(graalunit-lib, [AS_HELP_STRING([--with-graalunit-lib], + [specify location of 3rd party libraries used by Graal unit tests])]) + + GRAALUNIT_LIB= + if test "x${with_graalunit_lib}" != x; then + AC_MSG_CHECKING([for graalunit libs]) + if test "x${with_graalunit_lib}" = xno; then + AC_MSG_RESULT([disabled, graalunit tests can not be run]) + elif test "x${with_graalunit_lib}" = xyes; then + AC_MSG_RESULT([not specified]) + AC_MSG_ERROR([You must specify the path to 3rd party libraries used by Graal unit tests]) + else + GRAALUNIT_LIB="${with_graalunit_lib}" + if test ! -d "${GRAALUNIT_LIB}"; then + AC_MSG_RESULT([no]) + AC_MSG_ERROR([Could not find graalunit 3rd party libraries as specified. (${with_graalunit_lib})]) + else + AC_MSG_RESULT([$GRAALUNIT_LIB]) + fi + fi + fi + + BASIC_FIXUP_PATH([GRAALUNIT_LIB]) + AC_SUBST(GRAALUNIT_LIB) +]) + diff --git a/make/autoconf/libraries.m4 b/make/autoconf/libraries.m4 index 5bf8569ab2f..ab40c8bd22e 100644 --- a/make/autoconf/libraries.m4 +++ b/make/autoconf/libraries.m4 @@ -32,6 +32,7 @@ m4_include([lib-freetype.m4]) m4_include([lib-std.m4]) m4_include([lib-x11.m4]) m4_include([lib-fontconfig.m4]) +m4_include([lib-tests.m4]) ################################################################################ # Determine which libraries are needed for this configuration @@ -101,6 +102,7 @@ AC_DEFUN_ONCE([LIB_SETUP_LIBRARIES], LIB_SETUP_BUNDLED_LIBS LIB_SETUP_MISC_LIBS LIB_SETUP_SOLARIS_STLPORT + LIB_TESTS_SETUP_GRAALUNIT if test "x$TOOLCHAIN_TYPE" = xsolstudio; then GLOBAL_LIBS="-lc" diff --git a/make/autoconf/spec.gmk.in b/make/autoconf/spec.gmk.in index 38ab871bd2a..3ea5047af5a 100644 --- a/make/autoconf/spec.gmk.in +++ b/make/autoconf/spec.gmk.in @@ -347,6 +347,7 @@ LIBFFI_LIBS:=@LIBFFI_LIBS@ LIBFFI_CFLAGS:=@LIBFFI_CFLAGS@ ENABLE_LIBFFI_BUNDLING:=@ENABLE_LIBFFI_BUNDLING@ LIBFFI_LIB_FILE:=@LIBFFI_LIB_FILE@ +GRAALUNIT_LIB := @GRAALUNIT_LIB@ PACKAGE_PATH=@PACKAGE_PATH@ diff --git a/make/conf/jib-profiles.js b/make/conf/jib-profiles.js index 8fe02101fe0..3201cd1a110 100644 --- a/make/conf/jib-profiles.js +++ b/make/conf/jib-profiles.js @@ -378,7 +378,7 @@ var getJibProfilesProfiles = function (input, common, data) { "linux-x64": { target_os: "linux", target_cpu: "x64", - dependencies: ["devkit", "autoconf", "graphviz", "pandoc"], + dependencies: ["devkit", "autoconf", "graphviz", "pandoc", "graalunit_lib"], configure_args: concat(common.configure_args_64bit, "--enable-full-docs", "--with-zlib=system"), default_make_targets: ["docs-bundles"], @@ -396,7 +396,7 @@ var getJibProfilesProfiles = function (input, common, data) { "macosx-x64": { target_os: "macosx", target_cpu: "x64", - dependencies: ["devkit", "autoconf"], + dependencies: ["devkit", "autoconf", "graalunit_lib"], configure_args: concat(common.configure_args_64bit, "--with-zlib=system", "--with-macosx-version-max=10.9.0"), }, @@ -420,7 +420,7 @@ var getJibProfilesProfiles = function (input, common, data) { "windows-x64": { target_os: "windows", target_cpu: "x64", - dependencies: ["devkit", "autoconf"], + dependencies: ["devkit", "autoconf", "graalunit_lib"], configure_args: concat(common.configure_args_64bit), }, @@ -972,6 +972,14 @@ var getJibProfilesDependencies = function (input, common) { configure_args: "", }, + graalunit_lib: { + organization: common.organization, + ext: "zip", + revision: "619_Apr_12_2018", + module: "graalunit-lib", + configure_args: "--with-graalunit-lib=" + input.get("graalunit_lib", "install_path"), + environment_name: "GRAALUNIT_LIB" + }, }; // Need to add a value for the Visual Studio tools variable to make diff --git a/make/test/JtregGraalUnit.gmk b/make/test/JtregGraalUnit.gmk new file mode 100644 index 00000000000..cbb738c2eea --- /dev/null +++ b/make/test/JtregGraalUnit.gmk @@ -0,0 +1,144 @@ +# +# Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + +################################################################################ +# This file builds Graal component of the JTReg tests for Hotspot. +# It also covers the test-image part, where the built files are copied to the +# test image. +################################################################################ + +default: all + +include $(SPEC) +include MakeBase.gmk +include SetupJavaCompilers.gmk + +TARGETS_BUILD := +TARGETS_IMAGE := +TARGETS_EXTRA_LIB := + +ifeq ($(INCLUDE_GRAAL), true) + ifneq ($(GRAALUNIT_LIB), ) + SRC_DIR := $(TOPDIR)/src/jdk.internal.vm.compiler/share/classes + TEST_DIR := $(TOPDIR)/test/hotspot/jtreg/compiler/graalunit + COMPILE_OUTPUTDIR := $(SUPPORT_OUTPUTDIR)/test/graalunit + LIB_OUTPUTDIR := $(TEST_IMAGE_DIR)/hotspot/jtreg/graal + + ### Copy 3rd party libs + $(eval $(call SetupCopyFiles, COPY_GRAALUNIT_LIBS, \ + FILES := $(wildcard $(GRAALUNIT_LIB)/*.jar), \ + DEST := $(LIB_OUTPUTDIR), \ + )) + + TARGETS_EXTRA_LIB += $(COPY_GRAALUNIT_LIBS) + + ### Compile and build graalunit tests + $(eval $(call SetupJavaCompilation, BUILD_VM_COMPILER_TESTS, \ + SETUP := GENERATE_USINGJDKBYTECODE, \ + SRC := \ + $(SRC_DIR)/jdk.internal.vm.compiler.collections.test/src \ + $(SRC_DIR)/org.graalvm.compiler.api.directives.test/src \ + $(SRC_DIR)/org.graalvm.compiler.api.test/src \ + $(SRC_DIR)/org.graalvm.compiler.asm.aarch64.test/src \ + $(SRC_DIR)/org.graalvm.compiler.asm.amd64.test/src \ + $(SRC_DIR)/org.graalvm.compiler.asm.sparc.test/src \ + $(SRC_DIR)/org.graalvm.compiler.asm.test/src \ + $(SRC_DIR)/org.graalvm.compiler.core.amd64.test/src \ + $(SRC_DIR)/org.graalvm.compiler.core.test/src \ + $(SRC_DIR)/org.graalvm.compiler.debug.test/src \ + $(SRC_DIR)/org.graalvm.compiler.graph.test/src \ + $(SRC_DIR)/org.graalvm.compiler.hotspot.amd64.test/src \ + $(SRC_DIR)/org.graalvm.compiler.hotspot.lir.test/src \ + $(SRC_DIR)/org.graalvm.compiler.hotspot.sparc.test/src \ + $(SRC_DIR)/org.graalvm.compiler.hotspot.test/src \ + $(SRC_DIR)/org.graalvm.compiler.lir.test/src \ + $(SRC_DIR)/org.graalvm.compiler.loop.test/src \ + $(SRC_DIR)/org.graalvm.compiler.nodes.test/src \ + $(SRC_DIR)/org.graalvm.compiler.options.test/src \ + $(SRC_DIR)/org.graalvm.compiler.phases.common.test/src \ + $(SRC_DIR)/org.graalvm.compiler.replacements.test/src \ + $(SRC_DIR)/org.graalvm.compiler.test/src \ + $(SRC_DIR)/org.graalvm.util.test/src \ + $(SRC_DIR)/org.graalvm.compiler.jtt/src \ + $(SRC_DIR)/org.graalvm.compiler.lir.jtt/src \ + , \ + BIN := $(COMPILE_OUTPUTDIR)/jdk.vm.compiler.tests, \ + JAR := $(COMPILE_OUTPUTDIR)/jdk.vm.compiler.tests.jar, \ + CLASSPATH := \ + $(JDK_OUTPUTDIR)/modules/jdk.internal.vm.compiler \ + $(JDK_OUTPUTDIR)/modules/jdk.internal.vm.ci \ + $(LIB_OUTPUTDIR)/junit-4.12.jar \ + $(LIB_OUTPUTDIR)/asm-5.0.4.jar \ + $(LIB_OUTPUTDIR)/asm-tree-5.0.4.jar \ + $(LIB_OUTPUTDIR)/java-allocation-instrumenter.jar \ + $(LIB_OUTPUTDIR)/hamcrest-core-1.3.jar \ + , \ + ADD_JAVAC_FLAGS := \ + -Xlint:none -processorpath \ + $(BUILDTOOLS_OUTPUTDIR)/jdk.vm.compiler.replacements.verifier.jar \ + --add-exports jdk.unsupported/sun.misc=ALL-UNNAMED \ + , \ + )) + + TARGETS_BUILD += $(BUILD_VM_COMPILER_TESTS) + + + ### Compile and build mxtool + $(eval $(call SetupJavaCompilation, BUILD_MXTOOL, \ + SETUP := GENERATE_USINGJDKBYTECODE, \ + SRC := $(TEST_DIR)/com.oracle.mxtool.junit, \ + BIN := $(COMPILE_OUTPUTDIR)/com.oracle.mxtool.junit, \ + JAR := $(COMPILE_OUTPUTDIR)/com.oracle.mxtool.junit.jar, \ + CLASSPATH := $(LIB_OUTPUTDIR)/junit-4.12.jar, \ + )) + + TARGETS_BUILD += $(BUILD_MXTOOL) + + + ################################################################################ + # Targets for building test-image. + ################################################################################ + + # Copy to hotspot jtreg test image + $(eval $(call SetupCopyFiles, COPY_HOTSPOT_JTREG_GRAAL, \ + SRC := $(COMPILE_OUTPUTDIR), \ + DEST := $(LIB_OUTPUTDIR), \ + FILES := jdk.vm.compiler.tests.jar com.oracle.mxtool.junit.jar, \ + )) + + TARGETS_IMAGE += $(COPY_HOTSPOT_JTREG_GRAAL) + else + $(ECHO) "Skip building of Graal unit tests because 3rd party libraries directory is not specified" + endif +endif + +$(TARGETS_BUILD): $(TARGETS_EXTRA_LIB) +build-test-hotspot-jtreg-graal: $(TARGETS_BUILD) +test-image-hotspot-jtreg-graal: $(TARGETS_IMAGE) + +all: build-test-hotspot-jtreg-graal +test-image: test-image-hotspot-jtreg-graal + +.PHONY: default all build-test-hotspot-jtreg-graal test-image-hotspot-jtreg-graal test-image diff --git a/test/TestCommon.gmk b/test/TestCommon.gmk index 73db6f22642..46597fd2a58 100644 --- a/test/TestCommon.gmk +++ b/test/TestCommon.gmk @@ -448,6 +448,9 @@ JTREG_BASIC_OPTIONS += -e:JDK8_HOME=${JT_JAVA} ifneq ($(VS120COMNTOOLS), ) JTREG_BASIC_OPTIONS += -e:VS120COMNTOOLS="$(shell $(GETMIXEDPATH) "$(patsubst %\,%,$(VS120COMNTOOLS))")" endif + +JTREG_BASIC_OPTIONS += -e:TEST_IMAGE_GRAAL_DIR=${TEST_IMAGE_DIR}/hotspot/jtreg/graal + # Set other vm and test options JTREG_TEST_OPTIONS += $(JAVA_ARGS:%=-javaoptions:%) $(JAVA_VM_ARGS:%=-vmoption:%) ifneq ($(JIB_JAR), ) diff --git a/test/hotspot/jtreg/ProblemList-graal.txt b/test/hotspot/jtreg/ProblemList-graal.txt index 5ab046614ce..8715509abae 100644 --- a/test/hotspot/jtreg/ProblemList-graal.txt +++ b/test/hotspot/jtreg/ProblemList-graal.txt @@ -171,3 +171,20 @@ compiler/stable/TestStableObject.java 8204347 gener compiler/stable/TestStableShort.java 8204347 generic-all compiler/stable/TestStableUByte.java 8204347 generic-all compiler/stable/TestStableUShort.java 8204347 generic-all + +# Graal unit tests +org.graalvm.compiler.core.test.CheckGraalInvariants 8205081 +org.graalvm.compiler.core.test.inlining.PolymorphicInliningTest 8205081 +org.graalvm.compiler.core.test.OptionsVerifierTest 8205081 +org.graalvm.compiler.core.test.ProfilingInfoTest 8205081 +org.graalvm.compiler.hotspot.test.CompilationWrapperTest 8205081 +org.graalvm.compiler.hotspot.test.HsErrLogTest 8205081 +org.graalvm.compiler.hotspot.test.OptionsInFileTest 8205081 +org.graalvm.compiler.replacements.test.classfile.ClassfileBytecodeProviderTest 8205081 +org.graalvm.compiler.replacements.test.classfile.RedefineIntrinsicTest 8205081 + +org.graalvm.compiler.core.test.deopt.CompiledMethodTest 8202955 +org.graalvm.compiler.core.test.CountedLoopTest 8199885 +org.graalvm.compiler.debug.test.DebugContextTest 8203504 +org.graalvm.compiler.debug.test.VersionsTest 8204517 +org.graalvm.compiler.core.test.VerifyDebugUsageTest 8205078 diff --git a/test/hotspot/jtreg/TEST.groups b/test/hotspot/jtreg/TEST.groups index c5689ca81f0..73fdc8676ea 100644 --- a/test/hotspot/jtreg/TEST.groups +++ b/test/hotspot/jtreg/TEST.groups @@ -76,7 +76,8 @@ tier1_compiler = \ hotspot_not_fast_compiler = \ :hotspot_compiler \ -:tier1_compiler \ - -:hotspot_slow_compiler + -:hotspot_slow_compiler \ + -compiler/graalunit hotspot_slow_compiler = \ compiler/codegen/aes \ diff --git a/test/hotspot/jtreg/compiler/graalunit/ApiDirectivesTest.java b/test/hotspot/jtreg/compiler/graalunit/ApiDirectivesTest.java new file mode 100644 index 00000000000..1be28eeed86 --- /dev/null +++ b/test/hotspot/jtreg/compiler/graalunit/ApiDirectivesTest.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @summary + * @requires vm.opt.final.EnableJVMCI + * + * @modules jdk.internal.vm.compiler + * + * @library /test/lib /compiler/graalunit / + * + * @build compiler.graalunit.common.GraalUnitTestLauncher + * + * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt + * + * @run main/othervm compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.api.directives.test -exclude ExcludeList.txt + */ diff --git a/test/hotspot/jtreg/compiler/graalunit/ApiTest.java b/test/hotspot/jtreg/compiler/graalunit/ApiTest.java new file mode 100644 index 00000000000..8e605e8ca8c --- /dev/null +++ b/test/hotspot/jtreg/compiler/graalunit/ApiTest.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @summary + * @requires vm.opt.final.EnableJVMCI + * + * @modules jdk.internal.vm.compiler + * + * @library /test/lib /compiler/graalunit / + * + * @build compiler.graalunit.common.GraalUnitTestLauncher + * + * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt + * + * @run main/othervm compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.api.test -exclude ExcludeList.txt + */ diff --git a/test/hotspot/jtreg/compiler/graalunit/AsmAarch64Test.java b/test/hotspot/jtreg/compiler/graalunit/AsmAarch64Test.java new file mode 100644 index 00000000000..74891c59b4d --- /dev/null +++ b/test/hotspot/jtreg/compiler/graalunit/AsmAarch64Test.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @summary + * @requires vm.opt.final.EnableJVMCI + * + * @modules jdk.internal.vm.compiler + * + * @library /test/lib /compiler/graalunit / + * + * @build compiler.graalunit.common.GraalUnitTestLauncher + * + * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt + * + * @run main/othervm compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.asm.aarch64.test -exclude ExcludeList.txt + */ diff --git a/test/hotspot/jtreg/compiler/graalunit/AsmAmd64Test.java b/test/hotspot/jtreg/compiler/graalunit/AsmAmd64Test.java new file mode 100644 index 00000000000..63d985d1427 --- /dev/null +++ b/test/hotspot/jtreg/compiler/graalunit/AsmAmd64Test.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @summary + * @requires vm.opt.final.EnableJVMCI + * + * @modules jdk.internal.vm.compiler + * + * @library /test/lib /compiler/graalunit / + * + * @build compiler.graalunit.common.GraalUnitTestLauncher + * + * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt + * + * @run main/othervm compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.asm.amd64.test -exclude ExcludeList.txt + */ diff --git a/test/hotspot/jtreg/compiler/graalunit/AsmSparcTest.java b/test/hotspot/jtreg/compiler/graalunit/AsmSparcTest.java new file mode 100644 index 00000000000..1240f6de7df --- /dev/null +++ b/test/hotspot/jtreg/compiler/graalunit/AsmSparcTest.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @summary + * @requires vm.opt.final.EnableJVMCI + * + * @modules jdk.internal.vm.compiler + * + * @library /test/lib /compiler/graalunit / + * + * @build compiler.graalunit.common.GraalUnitTestLauncher + * + * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt + * + * @run main/othervm compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.asm.sparc.test -exclude ExcludeList.txt + */ diff --git a/test/hotspot/jtreg/compiler/graalunit/CollectionsTest.java b/test/hotspot/jtreg/compiler/graalunit/CollectionsTest.java new file mode 100644 index 00000000000..0efdf9f4a2b --- /dev/null +++ b/test/hotspot/jtreg/compiler/graalunit/CollectionsTest.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @summary + * @requires vm.opt.final.EnableJVMCI + * + * @modules jdk.internal.vm.compiler + * + * @library /test/lib /compiler/graalunit / + * + * @build compiler.graalunit.common.GraalUnitTestLauncher + * + * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt + * + * @run main/othervm compiler.graalunit.common.GraalUnitTestLauncher -prefix jdk.internal.vm.compiler.collections.test -exclude ExcludeList.txt + */ diff --git a/test/hotspot/jtreg/compiler/graalunit/CoreAmd64Test.java b/test/hotspot/jtreg/compiler/graalunit/CoreAmd64Test.java new file mode 100644 index 00000000000..dbb03609cb8 --- /dev/null +++ b/test/hotspot/jtreg/compiler/graalunit/CoreAmd64Test.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @summary + * @requires vm.opt.final.EnableJVMCI + * + * @modules jdk.internal.vm.compiler + * + * @library /test/lib /compiler/graalunit / + * + * @build compiler.graalunit.common.GraalUnitTestLauncher + * + * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt + * + * @run main/othervm compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.core.amd64.test -exclude ExcludeList.txt + */ diff --git a/test/hotspot/jtreg/compiler/graalunit/CoreSparcTest.java b/test/hotspot/jtreg/compiler/graalunit/CoreSparcTest.java new file mode 100644 index 00000000000..a0f419b96a6 --- /dev/null +++ b/test/hotspot/jtreg/compiler/graalunit/CoreSparcTest.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @summary + * @requires vm.opt.final.EnableJVMCI + * @requires vm.simpleArch == "sparcv9" + * @modules jdk.internal.vm.compiler + * + * @library /test/lib /compiler/graalunit / + * + * @build compiler.graalunit.common.GraalUnitTestLauncher + * + * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt + * + * @run main/othervm compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.core.sparc.test -exclude ExcludeList.txt + */ diff --git a/test/hotspot/jtreg/compiler/graalunit/CoreTest.java b/test/hotspot/jtreg/compiler/graalunit/CoreTest.java new file mode 100644 index 00000000000..f56ff287bf1 --- /dev/null +++ b/test/hotspot/jtreg/compiler/graalunit/CoreTest.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @summary + * @requires vm.opt.final.EnableJVMCI + * + * @modules jdk.internal.vm.compiler + * + * @library /test/lib /compiler/graalunit / + * + * @build compiler.graalunit.common.GraalUnitTestLauncher + * + * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt + * + * @run main/othervm compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.core.test -exclude ExcludeList.txt + */ diff --git a/test/hotspot/jtreg/compiler/graalunit/DebugTest.java b/test/hotspot/jtreg/compiler/graalunit/DebugTest.java new file mode 100644 index 00000000000..29afa9d8e3f --- /dev/null +++ b/test/hotspot/jtreg/compiler/graalunit/DebugTest.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @summary + * @requires vm.opt.final.EnableJVMCI + * + * @modules jdk.internal.vm.compiler + * + * @library /test/lib /compiler/graalunit / + * + * @build compiler.graalunit.common.GraalUnitTestLauncher + * + * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt + * + * @run main/othervm compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.debug.test -exclude ExcludeList.txt + */ diff --git a/test/hotspot/jtreg/compiler/graalunit/GraphTest.java b/test/hotspot/jtreg/compiler/graalunit/GraphTest.java new file mode 100644 index 00000000000..a0608487ca5 --- /dev/null +++ b/test/hotspot/jtreg/compiler/graalunit/GraphTest.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @summary + * @requires vm.opt.final.EnableJVMCI + * @requires vm.graal.enabled + * @modules jdk.internal.vm.compiler + * + * @library /test/lib /compiler/graalunit / + * + * @build compiler.graalunit.common.GraalUnitTestLauncher + * + * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt + * + * @run main/othervm compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.graph.test -exclude ExcludeList.txt + */ diff --git a/test/hotspot/jtreg/compiler/graalunit/HotspotAmd64Test.java b/test/hotspot/jtreg/compiler/graalunit/HotspotAmd64Test.java new file mode 100644 index 00000000000..449d1a4d627 --- /dev/null +++ b/test/hotspot/jtreg/compiler/graalunit/HotspotAmd64Test.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @summary + * @requires vm.opt.final.EnableJVMCI + * + * @modules jdk.internal.vm.compiler + * + * @library /test/lib /compiler/graalunit / + * + * @build compiler.graalunit.common.GraalUnitTestLauncher + * + * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt + * + * @run main/othervm compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.hotspot.amd64.test -exclude ExcludeList.txt + */ diff --git a/test/hotspot/jtreg/compiler/graalunit/HotspotLirTest.java b/test/hotspot/jtreg/compiler/graalunit/HotspotLirTest.java new file mode 100644 index 00000000000..9153e3c1ab2 --- /dev/null +++ b/test/hotspot/jtreg/compiler/graalunit/HotspotLirTest.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @summary + * @requires vm.opt.final.EnableJVMCI + * + * @modules jdk.internal.vm.compiler + * + * @library /test/lib /compiler/graalunit / + * + * @build compiler.graalunit.common.GraalUnitTestLauncher + * + * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt + * + * @run main/othervm compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.hotspot.lir.test -exclude ExcludeList.txt + */ diff --git a/test/hotspot/jtreg/compiler/graalunit/HotspotTest.java b/test/hotspot/jtreg/compiler/graalunit/HotspotTest.java new file mode 100644 index 00000000000..b3fa5d1ae7a --- /dev/null +++ b/test/hotspot/jtreg/compiler/graalunit/HotspotTest.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @summary + * @requires vm.opt.final.EnableJVMCI + * + * @modules jdk.internal.vm.compiler + * + * @library /test/lib /compiler/graalunit / + * + * @build compiler.graalunit.common.GraalUnitTestLauncher + * + * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt + * + * @run main/othervm compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.hotspot.test -exclude ExcludeList.txt + */ diff --git a/test/hotspot/jtreg/compiler/graalunit/Jtt.MicroTest.java b/test/hotspot/jtreg/compiler/graalunit/Jtt.MicroTest.java new file mode 100644 index 00000000000..9d21e7d52d8 --- /dev/null +++ b/test/hotspot/jtreg/compiler/graalunit/Jtt.MicroTest.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @summary + * @requires vm.opt.final.EnableJVMCI + * + * @modules jdk.internal.vm.compiler + * + * @library /test/lib /compiler/graalunit / + * + * @build compiler.graalunit.common.GraalUnitTestLauncher + * + * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt + * + * @run main/othervm compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.jtt.micro -exclude ExcludeList.txt + */ diff --git a/test/hotspot/jtreg/compiler/graalunit/JttBackendTest.java b/test/hotspot/jtreg/compiler/graalunit/JttBackendTest.java new file mode 100644 index 00000000000..5b02e315db9 --- /dev/null +++ b/test/hotspot/jtreg/compiler/graalunit/JttBackendTest.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @summary + * @requires vm.opt.final.EnableJVMCI + * + * @modules jdk.internal.vm.compiler + * + * @library /test/lib /compiler/graalunit / + * + * @build compiler.graalunit.common.GraalUnitTestLauncher + * + * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt + * + * @run main/othervm compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.jtt.backend -exclude ExcludeList.txt + */ diff --git a/test/hotspot/jtreg/compiler/graalunit/JttBytecodeTest.java b/test/hotspot/jtreg/compiler/graalunit/JttBytecodeTest.java new file mode 100644 index 00000000000..fdda92bcc86 --- /dev/null +++ b/test/hotspot/jtreg/compiler/graalunit/JttBytecodeTest.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @summary + * @requires vm.opt.final.EnableJVMCI + * + * @modules jdk.internal.vm.compiler + * + * @library /test/lib /compiler/graalunit / + * + * @build compiler.graalunit.common.GraalUnitTestLauncher + * + * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt + * + * @run main/othervm compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.jtt.bytecode -exclude ExcludeList.txt + */ diff --git a/test/hotspot/jtreg/compiler/graalunit/JttExceptTest.java b/test/hotspot/jtreg/compiler/graalunit/JttExceptTest.java new file mode 100644 index 00000000000..f6b3b44aeba --- /dev/null +++ b/test/hotspot/jtreg/compiler/graalunit/JttExceptTest.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @summary + * @requires vm.opt.final.EnableJVMCI + * + * @modules jdk.internal.vm.compiler + * + * @library /test/lib /compiler/graalunit / + * + * @build compiler.graalunit.common.GraalUnitTestLauncher + * + * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt + * + * @run main/othervm compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.jtt.except -exclude ExcludeList.txt + */ diff --git a/test/hotspot/jtreg/compiler/graalunit/JttHotpathTest.java b/test/hotspot/jtreg/compiler/graalunit/JttHotpathTest.java new file mode 100644 index 00000000000..6087d902416 --- /dev/null +++ b/test/hotspot/jtreg/compiler/graalunit/JttHotpathTest.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @summary + * @requires vm.opt.final.EnableJVMCI + * + * @modules jdk.internal.vm.compiler + * + * @library /test/lib /compiler/graalunit / + * + * @build compiler.graalunit.common.GraalUnitTestLauncher + * + * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt + * + * @run main/othervm compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.jtt.hotpath -exclude ExcludeList.txt + */ diff --git a/test/hotspot/jtreg/compiler/graalunit/JttHotspotTest.java b/test/hotspot/jtreg/compiler/graalunit/JttHotspotTest.java new file mode 100644 index 00000000000..6fbbf6d7120 --- /dev/null +++ b/test/hotspot/jtreg/compiler/graalunit/JttHotspotTest.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @summary + * @requires vm.opt.final.EnableJVMCI + * + * @modules jdk.internal.vm.compiler + * + * @library /test/lib /compiler/graalunit / + * + * @build compiler.graalunit.common.GraalUnitTestLauncher + * + * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt + * + * @run main/othervm compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.jtt.hotspot -exclude ExcludeList.txt + */ diff --git a/test/hotspot/jtreg/compiler/graalunit/JttJdkTest.java b/test/hotspot/jtreg/compiler/graalunit/JttJdkTest.java new file mode 100644 index 00000000000..efbe70e098f --- /dev/null +++ b/test/hotspot/jtreg/compiler/graalunit/JttJdkTest.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @summary + * @requires vm.opt.final.EnableJVMCI + * + * @modules jdk.internal.vm.compiler + * + * @library /test/lib /compiler/graalunit / + * + * @build compiler.graalunit.common.GraalUnitTestLauncher + * + * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt + * + * @run main/othervm compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.jtt.jdk -exclude ExcludeList.txt + */ diff --git a/test/hotspot/jtreg/compiler/graalunit/JttLangALTest.java b/test/hotspot/jtreg/compiler/graalunit/JttLangALTest.java new file mode 100644 index 00000000000..6b5ad657eb8 --- /dev/null +++ b/test/hotspot/jtreg/compiler/graalunit/JttLangALTest.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @summary + * @requires vm.opt.final.EnableJVMCI + * + * @modules jdk.internal.vm.compiler + * + * @library /test/lib /compiler/graalunit / + * + * @build compiler.graalunit.common.GraalUnitTestLauncher + * + * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt + * + * @run main/othervm compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.jtt.lang.[a-lA-L] -exclude ExcludeList.txt + */ diff --git a/test/hotspot/jtreg/compiler/graalunit/JttLangMTest.java b/test/hotspot/jtreg/compiler/graalunit/JttLangMTest.java new file mode 100644 index 00000000000..40e09a9b8e3 --- /dev/null +++ b/test/hotspot/jtreg/compiler/graalunit/JttLangMTest.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @summary + * @requires vm.opt.final.EnableJVMCI + * + * @modules jdk.internal.vm.compiler + * + * @library /test/lib /compiler/graalunit / + * + * @build compiler.graalunit.common.GraalUnitTestLauncher + * + * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt + * + * @run main/othervm compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.jtt.lang.[mM] -exclude ExcludeList.txt + */ diff --git a/test/hotspot/jtreg/compiler/graalunit/JttLangNZTest.java b/test/hotspot/jtreg/compiler/graalunit/JttLangNZTest.java new file mode 100644 index 00000000000..cecff6c1e8c --- /dev/null +++ b/test/hotspot/jtreg/compiler/graalunit/JttLangNZTest.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @summary + * @requires vm.opt.final.EnableJVMCI + * + * @modules jdk.internal.vm.compiler + * + * @library /test/lib /compiler/graalunit / + * + * @build compiler.graalunit.common.GraalUnitTestLauncher + * + * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt + * + * @run main/othervm compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.jtt.lang.[n-zN-Z] -exclude ExcludeList.txt + */ diff --git a/test/hotspot/jtreg/compiler/graalunit/JttLoopTest.java b/test/hotspot/jtreg/compiler/graalunit/JttLoopTest.java new file mode 100644 index 00000000000..5e6e86fdc7d --- /dev/null +++ b/test/hotspot/jtreg/compiler/graalunit/JttLoopTest.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @summary + * @requires vm.opt.final.EnableJVMCI + * + * @modules jdk.internal.vm.compiler + * + * @library /test/lib /compiler/graalunit / + * + * @build compiler.graalunit.common.GraalUnitTestLauncher + * + * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt + * + * @run main/othervm compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.jtt.loop -exclude ExcludeList.txt + */ diff --git a/test/hotspot/jtreg/compiler/graalunit/JttOptimizeTest.java b/test/hotspot/jtreg/compiler/graalunit/JttOptimizeTest.java new file mode 100644 index 00000000000..a627eddb01a --- /dev/null +++ b/test/hotspot/jtreg/compiler/graalunit/JttOptimizeTest.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @summary + * @requires vm.opt.final.EnableJVMCI + * + * @modules jdk.internal.vm.compiler + * + * @library /test/lib /compiler/graalunit / + * + * @build compiler.graalunit.common.GraalUnitTestLauncher + * + * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt + * + * @run main/othervm compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.jtt.optimize -exclude ExcludeList.txt + */ diff --git a/test/hotspot/jtreg/compiler/graalunit/JttReflectAETest.java b/test/hotspot/jtreg/compiler/graalunit/JttReflectAETest.java new file mode 100644 index 00000000000..66361bcb0c6 --- /dev/null +++ b/test/hotspot/jtreg/compiler/graalunit/JttReflectAETest.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @summary + * @requires vm.opt.final.EnableJVMCI + * + * @modules jdk.internal.vm.compiler + * + * @library /test/lib /compiler/graalunit / + * + * @build compiler.graalunit.common.GraalUnitTestLauncher + * + * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt + * + * @run main/othervm compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.jtt.reflect.[a-eA-E] -exclude ExcludeList.txt + */ diff --git a/test/hotspot/jtreg/compiler/graalunit/JttReflectFTest.java b/test/hotspot/jtreg/compiler/graalunit/JttReflectFTest.java new file mode 100644 index 00000000000..ac1fdd0b63a --- /dev/null +++ b/test/hotspot/jtreg/compiler/graalunit/JttReflectFTest.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @summary + * @requires vm.opt.final.EnableJVMCI + * + * @modules jdk.internal.vm.compiler + * + * @library /test/lib /compiler/graalunit / + * + * @build compiler.graalunit.common.GraalUnitTestLauncher + * + * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt + * + * @run main/othervm compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.jtt.reflect.[fF] -exclude ExcludeList.txt + */ diff --git a/test/hotspot/jtreg/compiler/graalunit/JttReflectGZTest.java b/test/hotspot/jtreg/compiler/graalunit/JttReflectGZTest.java new file mode 100644 index 00000000000..98cd910dcd9 --- /dev/null +++ b/test/hotspot/jtreg/compiler/graalunit/JttReflectGZTest.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @summary + * @requires vm.opt.final.EnableJVMCI + * + * @modules jdk.internal.vm.compiler + * + * @library /test/lib /compiler/graalunit / + * + * @build compiler.graalunit.common.GraalUnitTestLauncher + * + * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt + * + * @run main/othervm compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.jtt.reflect.[g-zG-Z] -exclude ExcludeList.txt + */ diff --git a/test/hotspot/jtreg/compiler/graalunit/JttThreadsTest.java b/test/hotspot/jtreg/compiler/graalunit/JttThreadsTest.java new file mode 100644 index 00000000000..09defe668b7 --- /dev/null +++ b/test/hotspot/jtreg/compiler/graalunit/JttThreadsTest.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @summary + * @requires vm.opt.final.EnableJVMCI + * + * @modules jdk.internal.vm.compiler + * + * @library /test/lib /compiler/graalunit / + * + * @build compiler.graalunit.common.GraalUnitTestLauncher + * + * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt + * + * @run main/othervm compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.jtt.threads -exclude ExcludeList.txt + */ diff --git a/test/hotspot/jtreg/compiler/graalunit/LirJttTest.java b/test/hotspot/jtreg/compiler/graalunit/LirJttTest.java new file mode 100644 index 00000000000..38ec8eec33a --- /dev/null +++ b/test/hotspot/jtreg/compiler/graalunit/LirJttTest.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @summary + * @requires vm.opt.final.EnableJVMCI + * + * @modules jdk.internal.vm.compiler + * + * @library /test/lib /compiler/graalunit / + * + * @build compiler.graalunit.common.GraalUnitTestLauncher + * + * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt + * + * @run main/othervm compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.lir.jtt -exclude ExcludeList.txt + */ diff --git a/test/hotspot/jtreg/compiler/graalunit/LoopTest.java b/test/hotspot/jtreg/compiler/graalunit/LoopTest.java new file mode 100644 index 00000000000..f9a42e9b14e --- /dev/null +++ b/test/hotspot/jtreg/compiler/graalunit/LoopTest.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @summary + * @requires vm.opt.final.EnableJVMCI + * + * @modules jdk.internal.vm.compiler + * + * @library /test/lib /compiler/graalunit / + * + * @build compiler.graalunit.common.GraalUnitTestLauncher + * + * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt + * + * @run main/othervm compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.loop.test -exclude ExcludeList.txt + */ diff --git a/test/hotspot/jtreg/compiler/graalunit/NodesTest.java b/test/hotspot/jtreg/compiler/graalunit/NodesTest.java new file mode 100644 index 00000000000..e099f3c17ad --- /dev/null +++ b/test/hotspot/jtreg/compiler/graalunit/NodesTest.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @summary + * @requires vm.opt.final.EnableJVMCI + * @requires vm.graal.enabled + * @modules jdk.internal.vm.compiler + * + * @library /test/lib /compiler/graalunit / + * + * @build compiler.graalunit.common.GraalUnitTestLauncher + * + * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt + * + * @run main/othervm compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.nodes.test -exclude ExcludeList.txt + */ diff --git a/test/hotspot/jtreg/compiler/graalunit/OptionsTest.java b/test/hotspot/jtreg/compiler/graalunit/OptionsTest.java new file mode 100644 index 00000000000..4cb1d2326e2 --- /dev/null +++ b/test/hotspot/jtreg/compiler/graalunit/OptionsTest.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @summary + * @requires vm.opt.final.EnableJVMCI + * + * @modules jdk.internal.vm.compiler + * + * @library /test/lib /compiler/graalunit / + * + * @build compiler.graalunit.common.GraalUnitTestLauncher + * + * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt + * + * @run main/othervm compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.options.test -exclude ExcludeList.txt + */ diff --git a/test/hotspot/jtreg/compiler/graalunit/PhasesCommonTest.java b/test/hotspot/jtreg/compiler/graalunit/PhasesCommonTest.java new file mode 100644 index 00000000000..0ee9bb86f10 --- /dev/null +++ b/test/hotspot/jtreg/compiler/graalunit/PhasesCommonTest.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @summary + * @requires vm.opt.final.EnableJVMCI + * + * @modules jdk.internal.vm.compiler + * + * @library /test/lib /compiler/graalunit / + * + * @build compiler.graalunit.common.GraalUnitTestLauncher + * + * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt + * + * @run main/othervm compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.phases.common.test -exclude ExcludeList.txt + */ diff --git a/test/hotspot/jtreg/compiler/graalunit/README.md b/test/hotspot/jtreg/compiler/graalunit/README.md new file mode 100644 index 00000000000..362dddb4ab9 --- /dev/null +++ b/test/hotspot/jtreg/compiler/graalunit/README.md @@ -0,0 +1,36 @@ +This directory contains jtreg tests which are wrapper tests to execute Graal unit tests similar way they are run in Graal project. +The tests use compiler.graalunit.common.GraalUnitTestLauncher helper class to run Graal unit tests where the set of tests to execute +is specified by '-prefix' argument. GraalUnitTestLauncher launches ported com.oracle.mxtool.junit.MxJUnitWrapper to run Graal unit +tests as it is done by "mx unittest" command from Graal project. + +All compiler/graalunit/*.java tests were automatically generated by generateTests.sh script which reads +"testName -> testPrefix [requiresStatement]" mapping from TestPackages.txt file and generates corresponding Test.java +tests. The mapping takes into account tests execution time to avoid very long test runs. + +Graal unit tests depends on following external jar files: + asm-5.0.4.jar: + https://lafo.ssw.uni-linz.ac.at/pub/graal-external-deps/asm-5.0.4.jar + + asm-tree-5.0.4.jar: + https://lafo.ssw.uni-linz.ac.at/pub/graal-external-deps/asm-tree-5.0.4.jar + + junit-4.12.jar: + https://lafo.ssw.uni-linz.ac.at/pub/graal-external-deps/junit-4.12.jar + + hamcrest-core-1.3.jar: + https://lafo.ssw.uni-linz.ac.at/pub/graal-external-deps/hamcrest-core-1.3.jar + + java-allocation-instrumenter.jar: + https://lafo.ssw.uni-linz.ac.at/pub/java-allocation-instrumenter/java-allocation-instrumenter-8f0db117e64e.jar + +Before running the tests you need to download these jars from above locations in build//images/test/hotspot/jtreg/graal/ +directory. Then you can pass it to jtreg as java option by using "-vmoptions:-Dgraalunit.libs=" or as environment variable +by using "-e:TEST_IMAGE_GRAAL_DIR=..." + +Example: +> jtreg -vt -jdk: -vmoptions:"-vmoptions:-Dgraalunit.libs=build//images/test/hotspot/jtreg/graal" + compiler/graalunit/UtilTest.java + +To run Graal unit tests in Graal as JIT mode pass additional -vmoptions to jtreg: + -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -XX:+TieredCompilation -XX:+UseJVMCICompiler -Djvmci.Compiler=graal + diff --git a/test/hotspot/jtreg/compiler/graalunit/ReplacementsTest.java b/test/hotspot/jtreg/compiler/graalunit/ReplacementsTest.java new file mode 100644 index 00000000000..3aabcb4151a --- /dev/null +++ b/test/hotspot/jtreg/compiler/graalunit/ReplacementsTest.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @summary + * @requires vm.opt.final.EnableJVMCI + * + * @modules jdk.internal.vm.compiler + * + * @library /test/lib /compiler/graalunit / + * + * @build compiler.graalunit.common.GraalUnitTestLauncher + * + * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt + * + * @run main/othervm compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.replacements.test -exclude ExcludeList.txt + */ diff --git a/test/hotspot/jtreg/compiler/graalunit/TestPackages.txt b/test/hotspot/jtreg/compiler/graalunit/TestPackages.txt new file mode 100644 index 00000000000..bc0e1c88f3c --- /dev/null +++ b/test/hotspot/jtreg/compiler/graalunit/TestPackages.txt @@ -0,0 +1,38 @@ +Collections jdk.internal.vm.compiler.collections.test +ApiDirectives org.graalvm.compiler.api.directives.test +Api org.graalvm.compiler.api.test +AsmAarch64 org.graalvm.compiler.asm.aarch64.test +AsmAmd64 org.graalvm.compiler.asm.amd64.test +AsmSparc org.graalvm.compiler.asm.sparc.test +CoreAmd64 org.graalvm.compiler.core.amd64.test +CoreSparc org.graalvm.compiler.core.sparc.test @requires vm.simpleArch == "sparcv9" +Core org.graalvm.compiler.core.test +Debug org.graalvm.compiler.debug.test +Graph org.graalvm.compiler.graph.test @requires vm.graal.enabled +HotspotAmd64 org.graalvm.compiler.hotspot.amd64.test +HotspotLir org.graalvm.compiler.hotspot.lir.test +Hotspot org.graalvm.compiler.hotspot.test +Loop org.graalvm.compiler.loop.test +Nodes org.graalvm.compiler.nodes.test @requires vm.graal.enabled +Options org.graalvm.compiler.options.test +PhasesCommon org.graalvm.compiler.phases.common.test +Replacements org.graalvm.compiler.replacements.test +Util org.graalvm.util.test +JttBackend org.graalvm.compiler.jtt.backend +JttBytecode org.graalvm.compiler.jtt.bytecode +JttExcept org.graalvm.compiler.jtt.except +JttHotpath org.graalvm.compiler.jtt.hotpath +JttHotspot org.graalvm.compiler.jtt.hotspot +JttJdk org.graalvm.compiler.jtt.jdk +JttLangAL org.graalvm.compiler.jtt.lang.[a-lA-L] +JttLangM org.graalvm.compiler.jtt.lang.[mM] +JttLangNZ org.graalvm.compiler.jtt.lang.[n-zN-Z] +JttLoop org.graalvm.compiler.jtt.loop +Jtt.Micro org.graalvm.compiler.jtt.micro +JttOptimize org.graalvm.compiler.jtt.optimize +JttReflectAE org.graalvm.compiler.jtt.reflect.[a-eA-E] +JttReflectF org.graalvm.compiler.jtt.reflect.[fF] +JttReflectGZ org.graalvm.compiler.jtt.reflect.[g-zG-Z] +JttThreads org.graalvm.compiler.jtt.threads +LirJtt org.graalvm.compiler.lir.jtt +Lir org.graalvm.compiler.lir.test \ No newline at end of file diff --git a/test/hotspot/jtreg/compiler/graalunit/UtilTest.java b/test/hotspot/jtreg/compiler/graalunit/UtilTest.java new file mode 100644 index 00000000000..67100613bc0 --- /dev/null +++ b/test/hotspot/jtreg/compiler/graalunit/UtilTest.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @summary + * @requires vm.opt.final.EnableJVMCI + * + * @modules jdk.internal.vm.compiler + * + * @library /test/lib /compiler/graalunit / + * + * @build compiler.graalunit.common.GraalUnitTestLauncher + * + * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt + * + * @run main/othervm compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.util.test -exclude ExcludeList.txt + */ diff --git a/test/hotspot/jtreg/compiler/graalunit/com.oracle.mxtool.junit/com/oracle/mxtool/junit/AnsiTerminalDecorator.java b/test/hotspot/jtreg/compiler/graalunit/com.oracle.mxtool.junit/com/oracle/mxtool/junit/AnsiTerminalDecorator.java new file mode 100644 index 00000000000..52db81cdebe --- /dev/null +++ b/test/hotspot/jtreg/compiler/graalunit/com.oracle.mxtool.junit/com/oracle/mxtool/junit/AnsiTerminalDecorator.java @@ -0,0 +1,120 @@ +/* + * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.mxtool.junit; + +import org.junit.runner.*; +import org.junit.runner.notification.*; + +/** + * Color support for JUnit test output using ANSI escapes codes. + */ +class AnsiTerminalDecorator extends MxRunListenerDecorator { + + /** Foreground black. */ + public static final String BLACK = "\u001b[30m"; + /** Foreground red. */ + public static final String RED = "\u001b[31m"; + /** Foreground green. */ + public static final String GREEN = "\u001b[32m"; + /** Foreground yellow. */ + public static final String YELLOW = "\u001b[33m"; + /** Foreground blue. */ + public static final String BLUE = "\u001b[34m"; + /** Foreground magenta. */ + public static final String MAGENTA = "\u001b[35m"; + /** Foreground cyan. */ + public static final String CYAN = "\u001b[36m"; + /** Foreground white. */ + public static final String WHITE = "\u001b[37m"; + + /** Foreground bold black. */ + public static final String BOLD_BLACK = "\u001b[30;1m"; + /** Foreground bold red. */ + public static final String BOLD_RED = "\u001b[31;1m"; + /** Foreground bold green. */ + public static final String BOLD_GREEN = "\u001b[32;1m"; + /** Foreground bold yellow. */ + public static final String BOLD_YELLOW = "\u001b[33;1m"; + /** Foreground bold blue. */ + public static final String BOLD_BLUE = "\u001b[34;1m"; + /** Foreground bold magenta. */ + public static final String BOLD_MAGENTA = "\u001b[35;1m"; + /** Foreground bold cyan. */ + public static final String BOLD_CYAN = "\u001b[36;1m"; + /** Foreground bold white. */ + public static final String BOLD_WHITE = "\u001b[37;1m"; + + /** Background black. */ + public static final String BG_BLACK = "\u001b[40m"; + /** Background red. */ + public static final String BG_RED = "\u001b[41m"; + /** Background green. */ + public static final String BG_GREEN = "\u001b[42m"; + /** Background yellow. */ + public static final String BG_YELLOW = "\u001b[43m"; + /** Background blue. */ + public static final String BG_BLUE = "\u001b[44m"; + /** Background magenta. */ + public static final String BG_MAGENTA = "\u001b[45m"; + /** Background cyan. */ + public static final String BG_CYAN = "\u001b[46m"; + /** Background white. */ + public static final String BG_WHITE = "\u001b[47m"; + + /** Reset. */ + public static final String RESET = "\u001b[0m"; + /** Underline. */ + public static final String UNDERLINED = "\u001b[4m"; + + AnsiTerminalDecorator(MxRunListener l) { + super(l); + } + + @Override + public void testSucceeded(Description description) { + getWriter().print(GREEN); + super.testSucceeded(description); + getWriter().print(RESET); + } + + @Override + public void testAssumptionFailure(Failure failure) { + getWriter().print(BLUE); + super.testAssumptionFailure(failure); + getWriter().print(RESET); + } + + @Override + public void testFailed(Failure failure) { + getWriter().print(RED); + super.testFailed(failure); + getWriter().print(RESET); + } + + @Override + public void testIgnored(Description description) { + getWriter().print(MAGENTA); + super.testIgnored(description); + getWriter().print(RESET); + } +} diff --git a/test/hotspot/jtreg/compiler/graalunit/com.oracle.mxtool.junit/com/oracle/mxtool/junit/EagerStackTraceDecorator.java b/test/hotspot/jtreg/compiler/graalunit/com.oracle.mxtool.junit/com/oracle/mxtool/junit/EagerStackTraceDecorator.java new file mode 100644 index 00000000000..dd99f650aee --- /dev/null +++ b/test/hotspot/jtreg/compiler/graalunit/com.oracle.mxtool.junit/com/oracle/mxtool/junit/EagerStackTraceDecorator.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.mxtool.junit; + +import org.junit.runner.notification.*; + +class EagerStackTraceDecorator extends MxRunListenerDecorator { + + EagerStackTraceDecorator(MxRunListener l) { + super(l); + } + + @Override + public void testFailed(Failure failure) { + super.testFailed(failure); + getWriter().println(); + getWriter().println(failure.getTestHeader()); + getWriter().print(failure.getTrace()); + } + +} diff --git a/test/hotspot/jtreg/compiler/graalunit/com.oracle.mxtool.junit/com/oracle/mxtool/junit/FindClassesByAnnotatedMethods.java b/test/hotspot/jtreg/compiler/graalunit/com.oracle.mxtool.junit/com/oracle/mxtool/junit/FindClassesByAnnotatedMethods.java new file mode 100644 index 00000000000..154a602d287 --- /dev/null +++ b/test/hotspot/jtreg/compiler/graalunit/com.oracle.mxtool.junit/com/oracle/mxtool/junit/FindClassesByAnnotatedMethods.java @@ -0,0 +1,341 @@ +/* + * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.mxtool.junit; + +import java.io.BufferedInputStream; +import java.io.DataInputStream; +import java.io.IOException; +import java.util.Collection; +import java.util.Enumeration; +import java.util.HashSet; +import java.util.Set; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; + +/** + * Finds classes in given jar files that contain methods annotated by a given set of annotations. + */ +public class FindClassesByAnnotatedMethods { + + /** + * Finds classes in a given set of jar files that contain at least one method with an annotation + * from a given set of annotations. The qualified name and containing jar file (separated by a + * space) is written to {@link System#out} for each matching class. + * + * @param args jar file names, annotations and snippets patterns. Annotations are those starting + * with "@" and can be either qualified or unqualified annotation class names, + * snippets patterns are those starting with {@code "snippetsPattern:"} and the rest + * are jar file names + */ + public static void main(String... args) throws Throwable { + Set qualifiedAnnotations = new HashSet<>(); + Set unqualifiedAnnotations = new HashSet<>(); + for (String arg : args) { + if (isAnnotationArg(arg)) { + String annotation = arg.substring(1); + int lastDot = annotation.lastIndexOf('.'); + if (lastDot != -1) { + qualifiedAnnotations.add(annotation); + } else { + String unqualifed = annotation.substring(lastDot + 1); + unqualifiedAnnotations.add(unqualifed); + } + } + } + + for (String jarFilePath : args) { + if (isSnippetArg(jarFilePath) || isAnnotationArg(jarFilePath)) { + continue; + } + JarFile jarFile = new JarFile(jarFilePath); + Enumeration e = jarFile.entries(); + int unsupportedClasses = 0; + System.out.print(jarFilePath); + while (e.hasMoreElements()) { + JarEntry je = e.nextElement(); + if (je.isDirectory() || !je.getName().endsWith(".class")) { + continue; + } + Set methodAnnotationTypes = new HashSet<>(); + DataInputStream stream = new DataInputStream(new BufferedInputStream(jarFile.getInputStream(je), (int) je.getSize())); + boolean isSupported = true; + try { + readClassfile(stream, methodAnnotationTypes); + } catch (UnsupportedClassVersionError ucve) { + isSupported = false; + unsupportedClasses++; + } + String className = je.getName().substring(0, je.getName().length() - ".class".length()).replaceAll("/", "."); + if (!isSupported) { + System.out.print(" !" + className); + } + for (String annotationType : methodAnnotationTypes) { + if (!qualifiedAnnotations.isEmpty()) { + if (qualifiedAnnotations.contains(annotationType)) { + System.out.print(" " + className); + } + } + if (!unqualifiedAnnotations.isEmpty()) { + final int lastDot = annotationType.lastIndexOf('.'); + if (lastDot != -1) { + String simpleName = annotationType.substring(lastDot + 1); + int lastDollar = simpleName.lastIndexOf('$'); + if (lastDollar != -1) { + simpleName = simpleName.substring(lastDollar + 1); + } + if (unqualifiedAnnotations.contains(simpleName)) { + System.out.print(" " + className); + } + } + } + } + } + if (unsupportedClasses != 0) { + System.err.printf("Warning: %d classes in %s skipped as their class file version is not supported by %s%n", unsupportedClasses, jarFilePath, + FindClassesByAnnotatedMethods.class.getSimpleName()); + } + System.out.println(); + } + } + + private static boolean isAnnotationArg(String arg) { + return arg.charAt(0) == '@'; + } + + private static boolean isSnippetArg(String arg) { + return arg.startsWith("snippetsPattern:"); + } + + /* + * Small bytecode parser that extract annotations. + */ + private static final int MAJOR_VERSION_JAVA7 = 51; + private static final int MAJOR_VERSION_OFFSET = 44; + private static final byte CONSTANT_Utf8 = 1; + private static final byte CONSTANT_Integer = 3; + private static final byte CONSTANT_Float = 4; + private static final byte CONSTANT_Long = 5; + private static final byte CONSTANT_Double = 6; + private static final byte CONSTANT_Class = 7; + private static final byte CONSTANT_Fieldref = 9; + private static final byte CONSTANT_String = 8; + private static final byte CONSTANT_Methodref = 10; + private static final byte CONSTANT_InterfaceMethodref = 11; + private static final byte CONSTANT_NameAndType = 12; + private static final byte CONSTANT_MethodHandle = 15; + private static final byte CONSTANT_MethodType = 16; + private static final byte CONSTANT_Dynamic = 17; + private static final byte CONSTANT_InvokeDynamic = 18; + + private static void readClassfile(DataInputStream stream, Collection methodAnnotationTypes) throws IOException { + // magic + int magic = stream.readInt(); + assert magic == 0xCAFEBABE; + + int minor = stream.readUnsignedShort(); + int major = stream.readUnsignedShort(); + if (major < MAJOR_VERSION_JAVA7) { + throw new UnsupportedClassVersionError("Unsupported class file version: " + major + "." + minor); + } + // Starting with JDK8, ignore a classfile that has a newer format than the current JDK. + String javaVersion = System.getProperties().get("java.specification.version").toString(); + int majorJavaVersion; + if (javaVersion.startsWith("1.")) { + javaVersion = javaVersion.substring(2); + majorJavaVersion = Integer.parseInt(javaVersion); + } else { + majorJavaVersion = Integer.parseInt(javaVersion); + } + if (major > MAJOR_VERSION_OFFSET + majorJavaVersion) { + throw new UnsupportedClassVersionError("Unsupported class file version: " + major + "." + minor); + } + + String[] cp = readConstantPool(stream, major, minor); + + // access_flags, this_class, super_class + stream.skipBytes(6); + + // interfaces + stream.skipBytes(stream.readUnsignedShort() * 2); + + // fields + skipFields(stream); + + // methods + readMethods(stream, cp, methodAnnotationTypes); + } + + private static void skipFully(DataInputStream stream, int n) throws IOException { + long skipped = 0; + do { + long s = stream.skip(n - skipped); + skipped += s; + if (s == 0 && skipped != n) { + // Check for EOF (i.e., truncated class file) + if (stream.read() == -1) { + throw new IOException("truncated stream"); + } + skipped++; + } + } while (skipped != n); + } + + private static String[] readConstantPool(DataInputStream stream, int major, int minor) throws IOException { + int count = stream.readUnsignedShort(); + String[] cp = new String[count]; + + int i = 1; + while (i < count) { + byte tag = stream.readByte(); + switch (tag) { + case CONSTANT_Class: + case CONSTANT_String: + case CONSTANT_MethodType: { + skipFully(stream, 2); + break; + } + case CONSTANT_InterfaceMethodref: + case CONSTANT_Methodref: + case CONSTANT_Fieldref: + case CONSTANT_NameAndType: + case CONSTANT_Float: + case CONSTANT_Integer: + case CONSTANT_Dynamic: + case CONSTANT_InvokeDynamic: { + skipFully(stream, 4); + break; + } + case CONSTANT_Long: + case CONSTANT_Double: { + skipFully(stream, 8); + break; + } + case CONSTANT_Utf8: { + cp[i] = stream.readUTF(); + break; + } + case CONSTANT_MethodHandle: { + skipFully(stream, 3); + break; + } + default: { + throw new InternalError(String.format("Invalid constant pool tag: " + tag + ". Maybe %s needs updating for changes introduced by class file version %d.%d?", + FindClassesByAnnotatedMethods.class, major, minor)); + } + } + if ((tag == CONSTANT_Double) || (tag == CONSTANT_Long)) { + i += 2; + } else { + i += 1; + } + } + return cp; + } + + private static void skipAttributes(DataInputStream stream) throws IOException { + int attributesCount; + attributesCount = stream.readUnsignedShort(); + for (int i = 0; i < attributesCount; i++) { + stream.skipBytes(2); // name_index + int attributeLength = stream.readInt(); + skipFully(stream, attributeLength); + } + } + + private static void readMethodAttributes(DataInputStream stream, String[] cp, Collection methodAnnotationTypes) throws IOException { + int attributesCount; + attributesCount = stream.readUnsignedShort(); + for (int i = 0; i < attributesCount; i++) { + String attributeName = cp[stream.readUnsignedShort()]; + int attributeLength = stream.readInt(); + + if (attributeName.equals("RuntimeVisibleAnnotations")) { + int numAnnotations = stream.readUnsignedShort(); + for (int a = 0; a != numAnnotations; a++) { + readAnnotation(stream, cp, methodAnnotationTypes); + } + } else { + skipFully(stream, attributeLength); + } + } + } + + private static void readAnnotation(DataInputStream stream, String[] cp, Collection methodAnnotationTypes) throws IOException { + int typeIndex = stream.readUnsignedShort(); + int pairs = stream.readUnsignedShort(); + String type = cp[typeIndex]; + String className = type.substring(1, type.length() - 1).replace('/', '.'); + methodAnnotationTypes.add(className); + readAnnotationElements(stream, cp, pairs, true, methodAnnotationTypes); + } + + private static void readAnnotationElements(DataInputStream stream, String[] cp, int pairs, boolean withElementName, Collection methodAnnotationTypes) throws IOException { + for (int p = 0; p < pairs; p++) { + if (withElementName) { + skipFully(stream, 2); + } + int tag = stream.readByte(); + switch (tag) { + case 'B': + case 'C': + case 'D': + case 'F': + case 'I': + case 'J': + case 'S': + case 'Z': + case 's': + case 'c': + skipFully(stream, 2); + break; + case 'e': + skipFully(stream, 4); + break; + case '@': + readAnnotation(stream, cp, methodAnnotationTypes); + break; + case '[': { + int numValues = stream.readUnsignedShort(); + readAnnotationElements(stream, cp, numValues, false, methodAnnotationTypes); + break; + } + } + } + } + + private static void skipFields(DataInputStream stream) throws IOException { + int count = stream.readUnsignedShort(); + for (int i = 0; i < count; i++) { + stream.skipBytes(6); // access_flags, name_index, descriptor_index + skipAttributes(stream); + } + } + + private static void readMethods(DataInputStream stream, String[] cp, Collection methodAnnotationTypes) throws IOException { + int count = stream.readUnsignedShort(); + for (int i = 0; i < count; i++) { + skipFully(stream, 6); // access_flags, name_index, descriptor_index + readMethodAttributes(stream, cp, methodAnnotationTypes); + } + } +} diff --git a/test/hotspot/jtreg/compiler/graalunit/com.oracle.mxtool.junit/com/oracle/mxtool/junit/GCAfterTestDecorator.java b/test/hotspot/jtreg/compiler/graalunit/com.oracle.mxtool.junit/com/oracle/mxtool/junit/GCAfterTestDecorator.java new file mode 100644 index 00000000000..8c8218bee88 --- /dev/null +++ b/test/hotspot/jtreg/compiler/graalunit/com.oracle.mxtool.junit/com/oracle/mxtool/junit/GCAfterTestDecorator.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.mxtool.junit; + +import org.junit.runner.*; + +class GCAfterTestDecorator extends MxRunListenerDecorator { + + GCAfterTestDecorator(MxRunListener l) { + super(l); + } + + @Override + public void testFinished(Description description) { + System.gc(); + super.testFinished(description); + } +} diff --git a/test/hotspot/jtreg/compiler/graalunit/com.oracle.mxtool.junit/com/oracle/mxtool/junit/JLModule.java b/test/hotspot/jtreg/compiler/graalunit/com.oracle.mxtool.junit/com/oracle/mxtool/junit/JLModule.java new file mode 100644 index 00000000000..9116a92d827 --- /dev/null +++ b/test/hotspot/jtreg/compiler/graalunit/com.oracle.mxtool.junit/com/oracle/mxtool/junit/JLModule.java @@ -0,0 +1,211 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.mxtool.junit; + +import java.lang.reflect.Method; +import java.util.Arrays; +import java.util.Set; + +/** + * Facade for the {@code java.lang.Module} class introduced in JDK9 that allows tests to be + * developed against JDK8 but use module logic if deployed on JDK9. + */ +class JLModule { + + private final Object realModule; + + JLModule(Object module) { + this.realModule = module; + } + + private static final Class moduleClass; + private static final Class layerClass; + + private static final Method bootMethod; + private static final Method modulesMethod; + private static final Method getModuleMethod; + private static final Method getUnnamedModuleMethod; + private static final Method getNameMethod; + private static final Method getPackagesMethod; + private static final Method isExportedMethod; + private static final Method isExported2Method; + private static final Method addExportsMethod; + private static final Method addOpensMethod; + static { + try { + moduleClass = findModuleClass(); + Class modulesClass = Class.forName("jdk.internal.module.Modules"); + layerClass = findModuleLayerClass(); + bootMethod = layerClass.getMethod("boot"); + modulesMethod = layerClass.getMethod("modules"); + getModuleMethod = Class.class.getMethod("getModule"); + getUnnamedModuleMethod = ClassLoader.class.getMethod("getUnnamedModule"); + getNameMethod = moduleClass.getMethod("getName"); + getPackagesMethod = moduleClass.getMethod("getPackages"); + isExportedMethod = moduleClass.getMethod("isExported", String.class); + isExported2Method = moduleClass.getMethod("isExported", String.class, moduleClass); + addExportsMethod = modulesClass.getDeclaredMethod("addExports", moduleClass, String.class, moduleClass); + addOpensMethod = getDeclaredMethodOptional(modulesClass, "addOpens", moduleClass, String.class, moduleClass); + } catch (Exception e) { + throw new AssertionError(e); + } + } + + // API change http://hg.openjdk.java.net/jdk9/dev/hotspot/rev/afedee84773e. + protected static Class findModuleClass() throws ClassNotFoundException { + try { + return Class.forName("java.lang.Module"); + } catch (ClassNotFoundException e) { + return Class.forName("java.lang.reflect.Module"); + } + } + + // API change http://hg.openjdk.java.net/jdk9/dev/hotspot/rev/afedee84773e. + protected static Class findModuleLayerClass() throws ClassNotFoundException { + try { + return Class.forName("java.lang.ModuleLayer"); + } catch (ClassNotFoundException e) { + return Class.forName("java.lang.reflect.Layer"); + } + } + + private static Method getDeclaredMethodOptional(Class declaringClass, String name, Class... parameterTypes) { + try { + return declaringClass.getDeclaredMethod(name, parameterTypes); + } catch (NoSuchMethodException e) { + return null; + } + } + + public static JLModule fromClass(Class cls) { + try { + return new JLModule(getModuleMethod.invoke(cls)); + } catch (Exception e) { + throw new AssertionError(e); + } + } + + @SuppressWarnings("unchecked") + public static JLModule find(String name) { + try { + Object bootLayer = bootMethod.invoke(null); + Set modules = (Set) modulesMethod.invoke(bootLayer); + for (Object m : modules) { + JLModule module = new JLModule(m); + String mname = module.getName(); + if (mname.equals(name)) { + return module; + } + } + } catch (Exception e) { + throw new InternalError(e); + } + return null; + } + + public static JLModule getUnnamedModuleFor(ClassLoader cl) { + try { + return new JLModule(getUnnamedModuleMethod.invoke(cl)); + } catch (Exception e) { + throw new AssertionError(e); + } + } + + public String getName() { + try { + return (String) getNameMethod.invoke(realModule); + } catch (Exception e) { + throw new AssertionError(e); + } + } + + /** + * Exports all packages in this module to a given module. + */ + public void exportAllPackagesTo(JLModule module) { + if (this != module) { + for (String pkg : getPackages()) { + // Export all JVMCI packages dynamically instead + // of requiring a long list of -XaddExports + // options on the JVM command line. + if (!isExported(pkg, module)) { + addExports(pkg, module); + addOpens(pkg, module); + } + } + } + } + + @SuppressWarnings("unchecked") + public Iterable getPackages() { + try { + // API change http://hg.openjdk.java.net/jdk9/dev/hotspot/rev/afedee84773e#l1.15 + Object res = getPackagesMethod.invoke(realModule); + if (res instanceof String[]) { + return Arrays.asList((String[]) res); + } + return (Set) res; + } catch (Exception e) { + throw new AssertionError(e); + } + } + + public boolean isExported(String pn) { + try { + return (Boolean) isExportedMethod.invoke(realModule, pn); + } catch (Exception e) { + throw new AssertionError(e); + } + } + + public boolean isExported(String pn, JLModule other) { + try { + return (Boolean) isExported2Method.invoke(realModule, pn, other.realModule); + } catch (Exception e) { + throw new AssertionError(e); + } + } + + public void addExports(String pn, JLModule other) { + try { + addExportsMethod.invoke(null, realModule, pn, other.realModule); + } catch (Exception e) { + throw new AssertionError(e); + } + } + + public void addOpens(String pn, JLModule other) { + if (addOpensMethod != null) { + try { + addOpensMethod.invoke(null, realModule, pn, other.realModule); + } catch (Exception e) { + throw new AssertionError(e); + } + } + } + + @Override + public String toString() { + return realModule.toString(); + } +} diff --git a/test/hotspot/jtreg/compiler/graalunit/com.oracle.mxtool.junit/com/oracle/mxtool/junit/MxJUnitRequest.java b/test/hotspot/jtreg/compiler/graalunit/com.oracle.mxtool.junit/com/oracle/mxtool/junit/MxJUnitRequest.java new file mode 100644 index 00000000000..328980a4d0f --- /dev/null +++ b/test/hotspot/jtreg/compiler/graalunit/com.oracle.mxtool.junit/com/oracle/mxtool/junit/MxJUnitRequest.java @@ -0,0 +1,116 @@ +/* + * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.mxtool.junit; + +import java.lang.reflect.Modifier; +import java.util.ArrayList; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Set; +import org.junit.runner.Description; +import org.junit.runner.Request; +import org.junit.runner.notification.Failure; + +public final class MxJUnitRequest { + + private final Request request; + + final Set> classes; + final String methodName; + + final List missingClasses; + + private MxJUnitRequest(Request request, Set> classes, String methodName, List missingClasses) { + this.request = request; + this.classes = classes; + this.methodName = methodName; + this.missingClasses = missingClasses; + } + + public Request getRequest() { + return request; + } + + public static final class BuilderException extends Exception { + + private static final long serialVersionUID = 1L; + + private BuilderException(String msg) { + super(msg); + } + } + + public static class Builder { + + private final Set> classes = new LinkedHashSet<>(); + private String methodName = null; + private final List missingClasses = new ArrayList<>(); + + protected Class resolveClass(String name) throws ClassNotFoundException { + return Class.forName(name, false, Builder.class.getClassLoader()); + } + + public void addTestSpec(String arg) throws BuilderException { + String className; + /* + * Entries of the form class#method are handled specially. Only one can be specified on + * the command line as there's no obvious way to build a runner for multiple ones. + */ + if (methodName != null) { + throw new BuilderException("Only a single class and method can be specified: " + arg); + } else if (arg.contains("#")) { + String[] pair = arg.split("#"); + if (pair.length != 2) { + throw new BuilderException("Malformed class and method request: " + arg); + } else if (!classes.isEmpty()) { + throw new BuilderException("Only a single class and method can be specified: " + arg); + } else { + methodName = pair[1]; + className = pair[0]; + } + } else { + className = arg; + } + try { + Class cls = resolveClass(className); + if ((cls.getModifiers() & Modifier.ABSTRACT) == 0) { + classes.add(cls); + } + } catch (ClassNotFoundException e) { + Description description = Description.createSuiteDescription(className); + Failure failure = new Failure(description, e); + missingClasses.add(failure); + } + } + + public MxJUnitRequest build() { + Request request; + if (methodName == null) { + request = Request.classes(classes.toArray(new Class[0])); + } else { + request = Request.method(classes.iterator().next(), methodName); + } + return new MxJUnitRequest(request, classes, methodName, missingClasses); + } + } +} diff --git a/test/hotspot/jtreg/compiler/graalunit/com.oracle.mxtool.junit/com/oracle/mxtool/junit/MxJUnitWrapper.java b/test/hotspot/jtreg/compiler/graalunit/com.oracle.mxtool.junit/com/oracle/mxtool/junit/MxJUnitWrapper.java new file mode 100644 index 00000000000..30721ab7998 --- /dev/null +++ b/test/hotspot/jtreg/compiler/graalunit/com.oracle.mxtool.junit/com/oracle/mxtool/junit/MxJUnitWrapper.java @@ -0,0 +1,484 @@ +/* + * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.mxtool.junit; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.FileReader; +import java.io.IOException; +import java.io.PrintStream; +import java.lang.annotation.Annotation; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.ServiceLoader; +import java.util.Set; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.junit.internal.JUnitSystem; +import org.junit.internal.RealSystem; +import org.junit.runner.Description; +import org.junit.runner.JUnitCore; +import org.junit.runner.Request; +import org.junit.runner.Result; +import org.junit.runner.Runner; +import org.junit.runner.notification.Failure; +import org.junit.runner.notification.RunListener; +import org.junit.runner.notification.RunNotifier; +import org.junit.runners.ParentRunner; +import org.junit.runners.model.RunnerScheduler; + +import junit.runner.Version; + +public class MxJUnitWrapper { + + public static class MxJUnitConfig { + + public boolean verbose = false; + public boolean veryVerbose = false; + public boolean enableTiming = false; + public boolean failFast = false; + public boolean color = false; + public boolean eagerStackTrace = false; + public boolean gcAfterTest = false; + public boolean recordResults = false; + public int repeatCount = 1; + } + + private static class RepeatingRunner extends Runner { + + private final Runner parent; + private int repeat; + + RepeatingRunner(Runner parent, int repeat) { + this.parent = parent; + this.repeat = repeat; + } + + @Override + public Description getDescription() { + return parent.getDescription(); + } + + @Override + public void run(RunNotifier notifier) { + for (int i = 0; i < repeat; i++) { + parent.run(notifier); + } + } + + @Override + public int testCount() { + return super.testCount() * repeat; + } + } + + private static class RepeatingRequest extends Request { + + private final Request request; + private final int repeat; + + RepeatingRequest(Request request, int repeat) { + this.request = request; + this.repeat = repeat; + } + + @Override + public Runner getRunner() { + return new RepeatingRunner(request.getRunner(), repeat); + } + } + + /** + * Run the tests contained in the classes named in the args. A single test method + * can be specified by adding #method after the class name. Only a single test can be run in + * this way. If all tests run successfully, exit with a status of 0. Otherwise exit with a + * status of 1. Write feedback while tests are running and write stack traces for all failed + * tests after the tests all complete. + * + * @param args names of classes in which to find tests to run + */ + public static void main(String... args) { + JUnitSystem system = new RealSystem(); + JUnitCore junitCore = new JUnitCore(); + system.out().println("MxJUnitCore"); + system.out().println("JUnit version " + Version.id()); + + MxJUnitRequest.Builder builder = new MxJUnitRequest.Builder(); + MxJUnitConfig config = new MxJUnitConfig(); + + String[] expandedArgs = expandArgs(args); + int i = 0; + while (i < expandedArgs.length) { + String each = expandedArgs[i]; + if (each.charAt(0) == '-') { + // command line arguments + if (each.contentEquals("-JUnitVerbose")) { + config.verbose = true; + } else if (each.contentEquals("-JUnitVeryVerbose")) { + config.veryVerbose = true; + } else if (each.contentEquals("-JUnitFailFast")) { + config.failFast = true; + } else if (each.contentEquals("-JUnitEnableTiming")) { + config.enableTiming = true; + } else if (each.contentEquals("-JUnitColor")) { + config.color = true; + } else if (each.contentEquals("-JUnitEagerStackTrace")) { + config.eagerStackTrace = true; + } else if (each.contentEquals("-JUnitGCAfterTest")) { + config.gcAfterTest = true; + } else if (each.contentEquals("-JUnitRecordResults")) { + config.recordResults = true; + } else if (each.contentEquals("-JUnitRepeat")) { + if (i + 1 >= expandedArgs.length) { + system.out().println("Must include argument for -JUnitRepeat"); + System.exit(1); + } + try { + config.repeatCount = Integer.parseInt(expandedArgs[++i]); + } catch (NumberFormatException e) { + system.out().println("Expected integer argument for -JUnitRepeat. Found: " + expandedArgs[i]); + System.exit(1); + } + } else { + system.out().println("Unknown command line argument: " + each); + } + + } else { + + try { + builder.addTestSpec(each); + } catch (MxJUnitRequest.BuilderException ex) { + system.out().println(ex.getMessage()); + System.exit(1); + } + } + i++; + } + + MxJUnitRequest request = builder.build(); + + if (System.getProperty("java.specification.version").compareTo("1.9") >= 0) { + addExports(request.classes, system.out()); + } + + for (RunListener p : ServiceLoader.load(RunListener.class)) { + junitCore.addListener(p); + } + + Result result = runRequest(junitCore, system, config, request); + System.exit(result.wasSuccessful() ? 0 : 1); + } + + private static PrintStream openFile(JUnitSystem system, String name) { + File file = new File(name).getAbsoluteFile(); + try { + FileOutputStream fos = new FileOutputStream(file); + return new PrintStream(fos, true); + } catch (FileNotFoundException e) { + system.out().println("Could not open " + file + " for writing: " + e); + System.exit(1); + return null; + } + } + + public static Result runRequest(JUnitCore junitCore, JUnitSystem system, MxJUnitConfig config, MxJUnitRequest mxRequest) { + final TextRunListener textListener; + if (config.veryVerbose) { + textListener = new VerboseTextListener(system, mxRequest.classes.size(), VerboseTextListener.SHOW_ALL_TESTS); + } else if (config.verbose) { + textListener = new VerboseTextListener(system, mxRequest.classes.size()); + } else { + textListener = new TextRunListener(system); + } + TimingDecorator timings = config.enableTiming ? new TimingDecorator(textListener) : null; + MxRunListener mxListener = config.enableTiming ? timings : textListener; + + if (config.color) { + mxListener = new AnsiTerminalDecorator(mxListener); + } + if (config.eagerStackTrace) { + mxListener = new EagerStackTraceDecorator(mxListener); + } + if (config.gcAfterTest) { + mxListener = new GCAfterTestDecorator(mxListener); + } + if (config.recordResults) { + PrintStream passed = openFile(system, "passed.txt"); + PrintStream failed = openFile(system, "failed.txt"); + mxListener = new TestResultLoggerDecorator(passed, failed, mxListener); + } + + junitCore.addListener(TextRunListener.createRunListener(mxListener)); + + Request request = mxRequest.getRequest(); + if (mxRequest.methodName == null) { + if (config.failFast) { + Runner runner = request.getRunner(); + if (runner instanceof ParentRunner) { + ParentRunner parentRunner = (ParentRunner) runner; + parentRunner.setScheduler(new RunnerScheduler() { + public void schedule(Runnable childStatement) { + if (textListener.getLastFailure() == null) { + childStatement.run(); + } + } + + public void finished() { + } + }); + } else { + system.out().println("Unexpected Runner subclass " + runner.getClass().getName() + " - fail fast not supported"); + } + } + } else { + if (config.failFast) { + system.out().println("Single method selected - fail fast not supported"); + } + } + + if (config.repeatCount != 1) { + request = new RepeatingRequest(request, config.repeatCount); + } + + if (config.enableTiming) { + Runtime.getRuntime().addShutdownHook(new Thread() { + @Override + public void run() { + printTimings(timings); + } + }); + } + + Result result = junitCore.run(request); + for (Failure each : mxRequest.missingClasses) { + result.getFailures().add(each); + } + + return result; + } + + private static final Pattern MODULE_PACKAGE_RE = Pattern.compile("([^/]+)/(.+)"); + + private static class Timing implements Comparable> { + final T subject; + final long value; + + Timing(T subject, long value) { + this.subject = subject; + this.value = value; + } + + public int compareTo(Timing o) { + if (this.value < o.value) { + return -1; + } + if (this.value > o.value) { + return 1; + } + return 0; + } + } + + // Should never need to customize so using a system property instead + // of a command line option for customization is fine. + private static final int TIMINGS_TO_PRINT = Integer.getInteger("mx.junit.timings_to_print", 10); + + private static void printTimings(TimingDecorator timings) { + if (TIMINGS_TO_PRINT != 0) { + List>> classTimes = new ArrayList<>(timings.classTimes.size()); + List> testTimes = new ArrayList<>(timings.testTimes.size()); + for (Map.Entry, Long> e : timings.classTimes.entrySet()) { + classTimes.add(new Timing<>(e.getKey(), e.getValue())); + } + for (Map.Entry e : timings.testTimes.entrySet()) { + testTimes.add(new Timing<>(e.getKey(), e.getValue())); + } + classTimes.sort(Collections.reverseOrder()); + testTimes.sort(Collections.reverseOrder()); + + System.out.println(); + System.out.printf("%d longest running test classes:%n", TIMINGS_TO_PRINT); + for (int i = 0; i < TIMINGS_TO_PRINT && i < classTimes.size(); i++) { + Timing> timing = classTimes.get(i); + System.out.printf(" %,10d ms %s%n", timing.value, timing.subject.getName()); + } + System.out.printf("%d longest running tests:%n", TIMINGS_TO_PRINT); + for (int i = 0; i < TIMINGS_TO_PRINT && i < testTimes.size(); i++) { + Timing timing = testTimes.get(i); + System.out.printf(" %,10d ms %s%n", timing.value, timing.subject); + } + Object[] current = timings.getCurrentTestDuration(); + if (current != null) { + System.out.printf("Test %s not finished after %d ms%n", current[0], current[1]); + } + + } + } + + /** + * Adds the super types of {@code cls} to {@code supertypes}. + */ + private static void gatherSupertypes(Class cls, Set> supertypes) { + if (!supertypes.contains(cls)) { + supertypes.add(cls); + Class superclass = cls.getSuperclass(); + if (superclass != null) { + gatherSupertypes(superclass, supertypes); + } + for (Class iface : cls.getInterfaces()) { + gatherSupertypes(iface, supertypes); + } + } + } + + /** + * Updates modules specified in {@code AddExport} annotations on {@code classes} to export + * concealed packages to the annotation classes' declaring modules. + */ + private static void addExports(Set> classes, PrintStream out) { + Set> types = new HashSet<>(); + for (Class cls : classes) { + gatherSupertypes(cls, types); + } + for (Class cls : types) { + Annotation[] annos = cls.getAnnotations(); + for (Annotation a : annos) { + Class annotationType = a.annotationType(); + if (annotationType.getSimpleName().equals("AddExports")) { + Optional value = getElement("value", String[].class, a); + if (value.isPresent()) { + for (String export : value.get()) { + Matcher m = MODULE_PACKAGE_RE.matcher(export); + if (m.matches()) { + String moduleName = m.group(1); + String packageName = m.group(2); + JLModule module = JLModule.find(moduleName); + if (module == null) { + out.printf("%s: Cannot find module named %s specified in \"AddExports\" annotation: %s%n", cls.getName(), moduleName, a); + } else { + if (packageName.equals("*")) { + module.exportAllPackagesTo(JLModule.fromClass(cls)); + } else { + module.addExports(packageName, JLModule.fromClass(cls)); + module.addOpens(packageName, JLModule.fromClass(cls)); + } + } + } else { + out.printf("%s: Ignoring \"AddExports\" annotation with value not matching / pattern: %s%n", cls.getName(), a); + } + } + } else { + out.printf("%s: Ignoring \"AddExports\" annotation without `String value` element: %s%n", cls.getName(), a); + } + } + } + } + } + + /** + * Gets the value of the element named {@code name} of type {@code type} from {@code annotation} + * if present. + * + * @return the requested element value wrapped in an {@link Optional} or + * {@link Optional#empty()} if {@code annotation} has no element named {@code name} + * @throws AssertionError if {@code annotation} has an element of the given name but whose type + * is not {@code type} or if there's some problem reading the value via reflection + */ + private static Optional getElement(String name, Class type, Annotation annotation) { + Class annotationType = annotation.annotationType(); + Method valueAccessor; + try { + valueAccessor = annotationType.getMethod(name); + if (!valueAccessor.getReturnType().equals(type)) { + throw new AssertionError(String.format("Element %s of %s is of type %s, not %s ", name, annotationType.getName(), valueAccessor.getReturnType().getName(), type.getName())); + } + } catch (NoSuchMethodException e) { + return Optional.empty(); + } + try { + return Optional.of(type.cast(valueAccessor.invoke(annotation))); + } catch (Exception e) { + throw new AssertionError(String.format("Could not read %s element from %s", name, annotation), e); + } + } + + /** + * Expand any arguments starting with @ and return the resulting argument array. + * + * @return the expanded argument array + */ + private static String[] expandArgs(String[] args) { + List result = null; + for (int i = 0; i < args.length; i++) { + String arg = args[i]; + if (arg.length() > 0 && arg.charAt(0) == '@') { + if (result == null) { + result = new ArrayList<>(); + for (int j = 0; j < i; j++) { + result.add(args[j]); + } + expandArg(arg.substring(1), result); + } + } else if (result != null) { + result.add(arg); + } + } + return result != null ? result.toArray(new String[0]) : args; + } + + /** + * Add each line from {@code filename} to the list {@code args}. + */ + private static void expandArg(String filename, List args) { + BufferedReader br = null; + try { + br = new BufferedReader(new FileReader(filename)); + + String buf; + while ((buf = br.readLine()) != null) { + args.add(buf); + } + br.close(); + } catch (IOException ioe) { + ioe.printStackTrace(); + System.exit(2); + } finally { + try { + if (br != null) { + br.close(); + } + } catch (IOException ioe) { + ioe.printStackTrace(); + System.exit(3); + } + } + } +} diff --git a/test/hotspot/jtreg/compiler/graalunit/com.oracle.mxtool.junit/com/oracle/mxtool/junit/MxRunListener.java b/test/hotspot/jtreg/compiler/graalunit/com.oracle.mxtool.junit/com/oracle/mxtool/junit/MxRunListener.java new file mode 100644 index 00000000000..8b5be3ac052 --- /dev/null +++ b/test/hotspot/jtreg/compiler/graalunit/com.oracle.mxtool.junit/com/oracle/mxtool/junit/MxRunListener.java @@ -0,0 +1,147 @@ +/* + * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.mxtool.junit; + +import java.io.*; + +import org.junit.internal.*; +import org.junit.runner.*; +import org.junit.runner.notification.*; + +interface MxRunListener { + + /** + * Called before any tests have been run. + * + * @param description describes the tests to be run + */ + default void testRunStarted(Description description) { + } + + /** + * Called when all tests have finished. + * + * @param result the summary of the test run, including all the tests that failed + */ + default void testRunFinished(Result result) { + } + + /** + * Called when a test class is about to be started. + * + * @param clazz the test class + */ + default void testClassStarted(Class clazz) { + } + + /** + * Called when all tests of a test class have finished. + * + * @param clazz the test class + * @param numPassed number of tests in {@code clazz} that passed + * @param numFailed number of tests in {@code clazz} that failed + */ + default void testClassFinished(Class clazz, int numPassed, int numFailed) { + } + + /** + * Called when an atomic test is about to be started. This is also called for ignored tests. + * + * @param description the description of the test that is about to be run (generally a class and + * method name) + */ + default void testStarted(Description description) { + } + + /** + * Called when an atomic test has finished, whether the test succeeds, fails or is ignored. + * + * @param description the description of the test that just ran + */ + default void testFinished(Description description) { + } + + /** + * Called when an atomic test fails. + * + * @param failure describes the test that failed and the exception that was thrown + */ + default void testFailed(Failure failure) { + } + + /** + * Called when a test will not be run, generally because a test method is annotated with + * {@link org.junit.Ignore}. + * + * @param description describes the test that will not be run + */ + default void testIgnored(Description description) { + } + + /** + * Called when an atomic test succeeds. + * + * @param description describes the test that will not be run + */ + default void testSucceeded(Description description) { + } + + /** + * Called when an atomic test flags that it assumes a condition that is false. + * + * @param failure describes the test that failed and the {@link AssumptionViolatedException} + * that was thrown + */ + default void testAssumptionFailure(Failure failure) { + } + + /** + * Called after {@link #testClassFinished(Class, int, int)}. + */ + default void testClassFinishedDelimiter() { + } + + /** + * Called after {@link #testClassStarted(Class)}. + */ + default void testClassStartedDelimiter() { + } + + /** + * Called after {@link #testStarted(Description)}. + */ + default void testStartedDelimiter() { + } + + /** + * Called after {@link #testFailed(Failure)}. + */ + default void testFinishedDelimiter() { + } + + default boolean beVerbose() { + return false; + } + + PrintStream getWriter(); +} diff --git a/test/hotspot/jtreg/compiler/graalunit/com.oracle.mxtool.junit/com/oracle/mxtool/junit/MxRunListenerDecorator.java b/test/hotspot/jtreg/compiler/graalunit/com.oracle.mxtool.junit/com/oracle/mxtool/junit/MxRunListenerDecorator.java new file mode 100644 index 00000000000..2aa3809488a --- /dev/null +++ b/test/hotspot/jtreg/compiler/graalunit/com.oracle.mxtool.junit/com/oracle/mxtool/junit/MxRunListenerDecorator.java @@ -0,0 +1,113 @@ +/* + * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.mxtool.junit; + +import java.io.*; + +import org.junit.runner.*; +import org.junit.runner.notification.*; + +abstract class MxRunListenerDecorator implements MxRunListener { + + private final MxRunListener l; + + MxRunListenerDecorator(MxRunListener l) { + this.l = l; + } + + @Override + public void testRunStarted(Description description) { + l.testRunStarted(description); + } + + @Override + public void testRunFinished(Result result) { + l.testRunFinished(result); + } + + @Override + public void testAssumptionFailure(Failure failure) { + l.testAssumptionFailure(failure); + } + + @Override + public void testIgnored(Description description) { + l.testIgnored(description); + } + + @Override + public void testClassStarted(Class clazz) { + l.testClassStarted(clazz); + } + + @Override + public void testClassFinished(Class clazz, int numPassed, int numFailed) { + l.testClassFinished(clazz, numPassed, numFailed); + } + + @Override + public void testStarted(Description description) { + l.testStarted(description); + } + + @Override + public void testFinished(Description description) { + l.testFinished(description); + } + + @Override + public void testFailed(Failure failure) { + l.testFailed(failure); + } + + @Override + public void testSucceeded(Description description) { + l.testSucceeded(description); + } + + @Override + public PrintStream getWriter() { + return l.getWriter(); + } + + public void testClassFinishedDelimiter() { + l.testClassFinishedDelimiter(); + } + + public void testClassStartedDelimiter() { + l.testClassStartedDelimiter(); + } + + public void testStartedDelimiter() { + l.testStartedDelimiter(); + } + + public void testFinishedDelimiter() { + l.testFinishedDelimiter(); + } + + public boolean beVerbose() { + return l.beVerbose(); + } + +} diff --git a/test/hotspot/jtreg/compiler/graalunit/com.oracle.mxtool.junit/com/oracle/mxtool/junit/TestResultLoggerDecorator.java b/test/hotspot/jtreg/compiler/graalunit/com.oracle.mxtool.junit/com/oracle/mxtool/junit/TestResultLoggerDecorator.java new file mode 100644 index 00000000000..2229acfdcb0 --- /dev/null +++ b/test/hotspot/jtreg/compiler/graalunit/com.oracle.mxtool.junit/com/oracle/mxtool/junit/TestResultLoggerDecorator.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.mxtool.junit; + +import java.io.PrintStream; + +import org.junit.runner.Result; + +class TestResultLoggerDecorator extends MxRunListenerDecorator { + + private final PrintStream passed; + private final PrintStream failed; + + TestResultLoggerDecorator(PrintStream passed, PrintStream failed, MxRunListener l) { + super(l); + this.passed = passed; + this.failed = failed; + } + + @Override + public void testClassFinished(Class clazz, int numPassed, int numFailed) { + super.testClassFinished(clazz, numPassed, numFailed); + if (numFailed != 0) { + failed.println(clazz.getName()); + } else { + passed.println(clazz.getName()); + } + } + + @Override + public void testRunFinished(Result result) { + super.testRunFinished(result); + passed.close(); + failed.close(); + } +} diff --git a/test/hotspot/jtreg/compiler/graalunit/com.oracle.mxtool.junit/com/oracle/mxtool/junit/TextRunListener.java b/test/hotspot/jtreg/compiler/graalunit/com.oracle.mxtool.junit/com/oracle/mxtool/junit/TextRunListener.java new file mode 100644 index 00000000000..ee7204a9889 --- /dev/null +++ b/test/hotspot/jtreg/compiler/graalunit/com.oracle.mxtool.junit/com/oracle/mxtool/junit/TextRunListener.java @@ -0,0 +1,148 @@ +/* + * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.mxtool.junit; + +import java.io.PrintStream; + +import org.junit.internal.JUnitSystem; +import org.junit.internal.TextListener; +import org.junit.runner.Description; +import org.junit.runner.Result; +import org.junit.runner.notification.Failure; +import org.junit.runner.notification.RunListener; + +class TextRunListener implements MxRunListener { + + private final PrintStream fWriter; + protected Failure lastFailure; + + TextRunListener(JUnitSystem system) { + this(system.out()); + } + + TextRunListener(PrintStream writer) { + fWriter = writer; + } + + public boolean beVerbose() { + return false; + } + + @Override + public PrintStream getWriter() { + return fWriter; + } + + public Failure getLastFailure() { + return lastFailure; + } + + @Override + public void testStarted(Description description) { + getWriter().print('.'); + } + + @Override + public void testFailed(Failure failure) { + getWriter().print('E'); + lastFailure = failure; + } + + @Override + public void testIgnored(Description description) { + getWriter().print('I'); + } + + public static RunListener createRunListener(MxRunListener l) { + return new TextListener(l.getWriter()) { + private Class lastClass; + private int passedInLastClass; + private int failedInLastClass; + private boolean failed; + + @Override + public void testStarted(Description description) { + Class currentClass = description.getTestClass(); + if (currentClass != lastClass) { + if (lastClass != null) { + l.testClassFinished(lastClass, passedInLastClass, failedInLastClass); + l.testClassFinishedDelimiter(); + } + lastClass = currentClass; + passedInLastClass = 0; + failedInLastClass = 0; + l.testClassStarted(currentClass); + l.testClassStartedDelimiter(); + } + failed = false; + l.testStarted(description); + l.testStartedDelimiter(); + } + + @Override + public void testFailure(Failure failure) { + failed = true; + failedInLastClass++; + l.testFailed(failure); + } + + @Override + public void testFinished(Description description) { + // we have to do this because there is no callback for successful tests + if (!failed) { + l.testSucceeded(description); + passedInLastClass++; + } + l.testFinished(description); + l.testFinishedDelimiter(); + } + + @Override + public void testIgnored(Description description) { + testStarted(description); + l.testIgnored(description); + l.testFinished(description); + l.testFinishedDelimiter(); + } + + @Override + public void testRunStarted(Description description) { + l.testRunStarted(description); + } + + @Override + public void testRunFinished(Result result) { + if (lastClass != null) { + l.testClassFinished(lastClass, passedInLastClass, failedInLastClass); + } + l.testRunFinished(result); + super.testRunFinished(result); + } + + @Override + public void testAssumptionFailure(Failure failure) { + l.testAssumptionFailure(failure); + } + }; + } +} diff --git a/test/hotspot/jtreg/compiler/graalunit/com.oracle.mxtool.junit/com/oracle/mxtool/junit/TimingDecorator.java b/test/hotspot/jtreg/compiler/graalunit/com.oracle.mxtool.junit/com/oracle/mxtool/junit/TimingDecorator.java new file mode 100644 index 00000000000..3e0123a66b0 --- /dev/null +++ b/test/hotspot/jtreg/compiler/graalunit/com.oracle.mxtool.junit/com/oracle/mxtool/junit/TimingDecorator.java @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.mxtool.junit; + +import java.util.HashMap; +import java.util.Map; + +import org.junit.runner.Description; + +/** + * Timing support for JUnit test runs. + */ +class TimingDecorator extends MxRunListenerDecorator { + + private long startTime; + private long classStartTime; + private Description currentTest; + final Map, Long> classTimes; + final Map testTimes; + + TimingDecorator(MxRunListener l) { + super(l); + this.classTimes = new HashMap<>(); + this.testTimes = new HashMap<>(); + } + + @Override + public void testClassStarted(Class clazz) { + classStartTime = System.nanoTime(); + super.testClassStarted(clazz); + } + + @Override + public void testClassFinished(Class clazz, int numPassed, int numFailed) { + long totalTime = System.nanoTime() - classStartTime; + super.testClassFinished(clazz, numPassed, numFailed); + if (beVerbose()) { + getWriter().print(' ' + valueToString(totalTime)); + } + classTimes.put(clazz, totalTime / 1_000_000); + } + + @Override + public void testStarted(Description description) { + currentTest = description; + startTime = System.nanoTime(); + super.testStarted(description); + } + + @Override + public void testFinished(Description description) { + long totalTime = System.nanoTime() - startTime; + super.testFinished(description); + if (beVerbose()) { + getWriter().print(" " + valueToString(totalTime)); + } + currentTest = null; + testTimes.put(description, totalTime / 1_000_000); + } + + private static String valueToString(long valueNS) { + long timeWholeMS = valueNS / 1_000_000; + long timeFractionMS = (valueNS / 100_000) % 10; + return String.format("%d.%d ms", timeWholeMS, timeFractionMS); + } + + /** + * Gets the test currently starting but not yet completed along with the number of milliseconds + * it has been executing. + * + * @return {@code null} if there is no test currently executing + */ + public Object[] getCurrentTestDuration() { + Description current = currentTest; + if (current != null) { + long timeMS = (System.nanoTime() - startTime) / 1_000_000; + return new Object[]{current, timeMS}; + } + return null; + } +} diff --git a/test/hotspot/jtreg/compiler/graalunit/com.oracle.mxtool.junit/com/oracle/mxtool/junit/VerboseTextListener.java b/test/hotspot/jtreg/compiler/graalunit/com.oracle.mxtool.junit/com/oracle/mxtool/junit/VerboseTextListener.java new file mode 100644 index 00000000000..db581b41845 --- /dev/null +++ b/test/hotspot/jtreg/compiler/graalunit/com.oracle.mxtool.junit/com/oracle/mxtool/junit/VerboseTextListener.java @@ -0,0 +1,132 @@ +/* + * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.mxtool.junit; + +import java.io.*; + +import org.junit.internal.*; +import org.junit.runner.*; +import org.junit.runner.notification.*; + +class VerboseTextListener extends TextRunListener { + + private static final int DEFAULT_MAX_TEST_PER_CLASS = 50; + public static final int SHOW_ALL_TESTS = Integer.MAX_VALUE; + private final int classesCount; + private final int maxTestsPerClass; + private int currentClassNum; + private int currentTestNum; + + VerboseTextListener(JUnitSystem system, int classesCount) { + this(system.out(), classesCount, DEFAULT_MAX_TEST_PER_CLASS); + } + + VerboseTextListener(JUnitSystem system, int classesCount, int maxTests) { + this(system.out(), classesCount, maxTests); + } + + VerboseTextListener(PrintStream writer, int classesCount, int maxTests) { + super(writer); + maxTestsPerClass = maxTests; + this.classesCount = classesCount; + } + + @Override + public boolean beVerbose() { + return currentTestNum < maxTestsPerClass; + } + + @Override + public void testClassStarted(Class clazz) { + ++currentClassNum; + getWriter().printf("%s started (%d of %d)", clazz.getName(), currentClassNum, classesCount); + currentTestNum = 0; + } + + @Override + public void testClassFinished(Class clazz, int numPassed, int numFailed) { + getWriter().print(clazz.getName() + " finished"); + } + + @Override + public void testStarted(Description description) { + if (beVerbose()) { + getWriter().print(" " + description.getMethodName() + ": "); + currentTestNum++; + } else { + super.testStarted(description); + } + } + + @Override + public void testIgnored(Description description) { + if (beVerbose()) { + getWriter().print("Ignored"); + } else { + super.testIgnored(description); + } + } + + @Override + public void testSucceeded(Description description) { + if (beVerbose()) { + getWriter().print("Passed"); + } else { + super.testSucceeded(description); + } + } + + @Override + public void testAssumptionFailure(Failure failure) { + if (beVerbose()) { + getWriter().printf("(%s) ", failure.getMessage()); + } else { + super.testAssumptionFailure(failure); + } + } + + @Override + public void testFailed(Failure failure) { + getWriter().print("FAILED"); + lastFailure = failure; + } + + @Override + public void testClassFinishedDelimiter() { + getWriter().println(); + } + + @Override + public void testClassStartedDelimiter() { + getWriter().println(); + } + + @Override + public void testFinishedDelimiter() { + if (beVerbose()) { + getWriter().println(); + } else { + super.testFinishedDelimiter(); + } + } +} diff --git a/test/hotspot/jtreg/compiler/graalunit/common/GraalUnitTestLauncher.java b/test/hotspot/jtreg/compiler/graalunit/common/GraalUnitTestLauncher.java new file mode 100644 index 00000000000..13dabeb49e0 --- /dev/null +++ b/test/hotspot/jtreg/compiler/graalunit/common/GraalUnitTestLauncher.java @@ -0,0 +1,266 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package compiler.graalunit.common; + +import java.io.File; +import java.io.IOException; +import java.util.*; +import java.nio.file.*; +import java.util.stream.Collectors; + +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; + +/* + * This is helper class used to run Graal unit tests. + * It accepts two arguments: + * -prefix TEST_PREFIX_TO_DEFINE_SET_OF_TESTS_TO_RUN (Ex: -prefix org.graalvm.compiler.api.test) + * -exclude EXCLUDED_TESTS_FILE_NAME + */ +public class GraalUnitTestLauncher { + + static final String MXTOOL_JARFILE = "com.oracle.mxtool.junit.jar"; + static final String GRAAL_UNITTESTS_JARFILE = "jdk.vm.compiler.tests.jar"; + + static final String[] GRAAL_EXTRA_JARS = {"junit-4.12.jar", "asm-5.0.4.jar", "asm-tree-5.0.4.jar", + "hamcrest-core-1.3.jar", "java-allocation-instrumenter.jar"}; + + static final String GENERATED_TESTCLASSES_FILENAME = "list.testclasses"; + + // Library dir used to find Graal specific jar files. + static String libsDir; + static { + libsDir = System.getProperty("graalunit.libs"); + if (libsDir == null || libsDir.isEmpty()) { + libsDir = System.getenv("TEST_IMAGE_GRAAL_DIR"); + } + + if (libsDir == null || libsDir.isEmpty()) + throw new RuntimeException("ERROR: Graal library directory is not specified, use -Dgraalunit.libs or TEST_IMAGE_GRAAL_DIR environment variable."); + + System.out.println("INFO: graal libs dir is '" + libsDir + "'"); + } + + /* + * Generates --add-exports /= flags and + * returns them as array list. + * + * @param moduleName + * Name of the module to update export data + * + * @param targetModule + * Name of the module to whom to export + */ + static ArrayList getModuleExports(String moduleName, String targetModule) { + ArrayList exports = new ArrayList(); + + Optional mod = ModuleLayer.boot().findModule(moduleName); + Set packages; + if (mod.isPresent()) { + packages = mod.get().getPackages(); + + for (String pName : packages) { + exports.add("--add-exports"); + exports.add(moduleName + "/" + pName + "=" + targetModule); + } + } + + return exports; + } + + /* + * Return list of tests which match specified prefix + * + * @param testPrefix + * String prefix to select tests + */ + static ArrayList getListOfTestsByPrefix(String testPrefix, Set excludeTests) throws Exception { + ArrayList classes = new ArrayList(); + + final String testAnnotationName = "@Test"; + + // return empty list in case no selection prefix specified + if (testPrefix == null || testPrefix.isEmpty()) + return classes; + + // replace "." by "\." in test pattern + testPrefix = testPrefix.replaceAll("\\.", "\\\\.") + ".*"; + System.out.println("INFO: use following pattern to find tests: " + testPrefix); + + String graalUnitTestFilePath = String.join(File.separator, libsDir, GRAAL_UNITTESTS_JARFILE); + String classPath = String.join(File.pathSeparator, System.getProperty("java.class.path"), + String.join(File.separator, libsDir, MXTOOL_JARFILE)); + + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(false, + "-cp", classPath, + "com.oracle.mxtool.junit.FindClassesByAnnotatedMethods", graalUnitTestFilePath, testAnnotationName); + + System.out.println("INFO: run command " + String.join(" ", pb.command())); + + OutputAnalyzer out = new OutputAnalyzer(pb.start()); + int exitCode = out.getExitValue(); + if (exitCode != 0) { + throw new Exception("Failed to find tests, VM crashed with exit code " + exitCode); + } + + String[] lines = out.getStdout().split(" "); + if (lines.length > 1) { // first line contains jar file name + for (int i = 1; i < lines.length; i++) { + String className = lines[i]; + + if (testPrefix.equals(".*") || className.matches(testPrefix)) { + // add the test only in case it is not in exclude list + if (excludeTests!= null && excludeTests.contains(className)) { + System.out.println("INFO: excluded test: " + className); + } else { + classes.add(className); + } + } + } + } + + return classes; + } + + /* + * Return set of excluded tests + * + * @param excludeFileName + * Name of the file to read excluded test list + */ + static Set loadExcludeList(String excludeFileName) { + Set excludeTests; + + Path excludeFilePath = Paths.get(excludeFileName); + try { + excludeTests = Files.readAllLines(excludeFilePath).stream() + .filter(l -> !l.trim().isEmpty()) + .filter(l -> !l.trim().startsWith("#")) + .map(l -> l.split(" ")[0]) + .collect(Collectors.toSet()); + + } catch (IOException ioe) { + throw new Error("TESTBUG: failed to read " + excludeFilePath); + } + + return excludeTests; + } + + static String getUsageString() { + return "Usage: " + GraalUnitTestLauncher.class.getName() + " " + + "-prefix (org.graalvm.compiler.api.test) " + + "-exclude " + System.lineSeparator(); + } + + public static void main(String... args) throws Exception { + + String testPrefix = null; + String excludeFileName = null; + + int i=0; + String arg, val; + while (i+1 < args.length) { + arg = args[i++]; + val = args[i++]; + + switch (arg) { + case "-prefix": + testPrefix = val; + break; + + case "-exclude": + excludeFileName = val; + break; + + default: + System.out.println("WARN: illegal option " + arg); + break; + } + } + + if (testPrefix == null) + throw new Error("TESTBUG: no tests to run specified." + System.lineSeparator() + getUsageString()); + + + Set excludeTests = null; + if (excludeFileName != null) { + excludeTests = loadExcludeList(excludeFileName); + } + + // Find list of tests which match provided predicate and write into GENERATED_TESTCLASSES_FILENAME file + ArrayList tests = getListOfTestsByPrefix(testPrefix, excludeTests); + if (tests.size() > 0) { + Files.write(Paths.get(GENERATED_TESTCLASSES_FILENAME), String.join(System.lineSeparator(), tests).getBytes()); + } else { + throw new Error("TESTBUG: no tests found for prefix " + testPrefix); + } + + ArrayList javaFlags = new ArrayList(); + + // add modules and exports + javaFlags.add("--add-modules"); + javaFlags.add("jdk.internal.vm.compiler,jdk.internal.vm.ci"); + javaFlags.add("--add-exports"); + javaFlags.add("java.base/jdk.internal.module=ALL-UNNAMED"); + javaFlags.addAll(getModuleExports("jdk.internal.vm.compiler", "ALL-UNNAMED")); + javaFlags.addAll(getModuleExports("jdk.internal.vm.ci", "ALL-UNNAMED,jdk.internal.vm.compiler")); + + + // add VM flags + javaFlags.add("-XX:+UnlockExperimentalVMOptions"); + javaFlags.add("-XX:+EnableJVMCI"); + javaFlags.add("-Djava.awt.headless=true"); + javaFlags.add("-esa"); + javaFlags.add("-ea"); + + + // generate class path + ArrayList graalJars = new ArrayList(Arrays.asList(GRAAL_EXTRA_JARS)); + graalJars.add(MXTOOL_JARFILE); + graalJars.add(GRAAL_UNITTESTS_JARFILE); + + String graalJarsCP = graalJars.stream() + .map(s -> String.join(File.separator, libsDir, s)) + .collect(Collectors.joining(File.pathSeparator)); + + javaFlags.add("-cp"); + javaFlags.add(String.join(File.pathSeparator, System.getProperty("java.class.path"), graalJarsCP)); + + // + javaFlags.add("com.oracle.mxtool.junit.MxJUnitWrapper"); + javaFlags.add("-JUnitVerbose"); + javaFlags.add("-JUnitEagerStackTrace"); + javaFlags.add("-JUnitEnableTiming"); + + javaFlags.add("@"+GENERATED_TESTCLASSES_FILENAME); + + ProcessBuilder javaPB = ProcessTools.createJavaProcessBuilder(true, + javaFlags.toArray(new String[javaFlags.size()])); + System.out.println("INFO: run command: " + String.join(" ", javaPB.command())); + + OutputAnalyzer outputAnalyzer = new OutputAnalyzer(javaPB.start()); + System.out.println("INFO: execution result: " + outputAnalyzer.getOutput()); + outputAnalyzer.shouldHaveExitValue(0); + } +} diff --git a/test/hotspot/jtreg/compiler/graalunit/generateTests.sh b/test/hotspot/jtreg/compiler/graalunit/generateTests.sh new file mode 100644 index 00000000000..c673295af99 --- /dev/null +++ b/test/hotspot/jtreg/compiler/graalunit/generateTests.sh @@ -0,0 +1,72 @@ +#!/bin/bash +# +# Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + +while read -r fName pName requireInfo +do + fName="${fName}Test.java" + echo "Generate $fName for $pName ..." + + cat << EOF | sed 's/[[:blank:]]*$//' > $fName +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @summary + * @requires vm.opt.final.EnableJVMCI + * $requireInfo + * @modules jdk.internal.vm.compiler + * + * @library /test/lib /compiler/graalunit / + * + * @build compiler.graalunit.common.GraalUnitTestLauncher + * + * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt + * + * @run main/othervm compiler.graalunit.common.GraalUnitTestLauncher -prefix $pName -exclude ExcludeList.txt + */ +EOF + +done < TestPackages.txt + diff --git a/test/jtreg-ext/requires/VMProps.java b/test/jtreg-ext/requires/VMProps.java index 9f67b531523..bc83bf37362 100644 --- a/test/jtreg-ext/requires/VMProps.java +++ b/test/jtreg-ext/requires/VMProps.java @@ -257,11 +257,12 @@ public class VMProps implements Callable> { /** * Selected sets of final flags. - * @param map -property-value pairs + * @param map - property-value pairs */ protected void vmOptFinalFlags(Map map) { vmOptFinalFlag(map, "ClassUnloading"); vmOptFinalFlag(map, "UseCompressedOops"); + vmOptFinalFlag(map, "EnableJVMCI"); } /**