# HG changeset patch # User erikj # Date 1460639622 -7200 # Node ID e90042bf422d5cfb90b58bf0f113d1a8031b2572 # Parent e047c2f3f5101048f8aa1d583987217430aa836f 8149777: Enable enhanced failure handler for "make test" Reviewed-by: ihse diff -r e047c2f3f510 -r e90042bf422d make/Main.gmk --- a/make/Main.gmk Wed Apr 13 18:11:29 2016 +0200 +++ b/make/Main.gmk Thu Apr 14 15:13:42 2016 +0200 @@ -385,9 +385,25 @@ build-test-lib: +($(CD) $(TOPDIR)/make/test && $(MAKE) $(MAKE_ARGS) -f BuildTestLib.gmk) +# Builds the failure handler jtreg extension +build-test-failure-handler: + +($(CD) $(TOPDIR)/make/test && $(MAKE) $(MAKE_ARGS) \ + -f BuildFailureHandler.gmk build) + +# Runs the tests for the failure handler jtreg extension +test-failure-handler: + +($(CD) $(TOPDIR)/make/test && $(MAKE) $(MAKE_ARGS) \ + -f BuildFailureHandler.gmk test) + +# Copies the failure handler jtreg extension into the test image +test-image-failure-handler: + +($(CD) $(TOPDIR)/make/test && $(MAKE) $(MAKE_ARGS) \ + -f BuildFailureHandler.gmk images) + 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 + test-image-jdk-jtreg-native build-test-lib build-test-failure-handler \ + test-failure-handler test-image-failure-handler ################################################################################ # Run tests @@ -582,6 +598,12 @@ build-test-lib: java + build-test-failure-handler: interim-langtools + + test-failure-handler: build-test-failure-handler + + test-image-failure-handler: build-test-failure-handler + build-test-hotspot-jtreg-native: buildtools-jdk build-test-jdk-jtreg-native: buildtools-jdk @@ -671,7 +693,7 @@ # This target builds the test image test-image: prepare-test-image test-image-hotspot-jtreg-native \ - test-image-jdk-jtreg-native + test-image-jdk-jtreg-native test-image-failure-handler # all-images is the top-most target, it builds all our deliverables ("images"). all-images: product-images test-image docs-image diff -r e047c2f3f510 -r e90042bf422d make/test/BuildFailureHandler.gmk --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/make/test/BuildFailureHandler.gmk Thu Apr 14 15:13:42 2016 +0200 @@ -0,0 +1,128 @@ +# +# 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. 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. +# + +default: build + +include $(SPEC) +include MakeBase.gmk +include JavaCompilation.gmk +include SetupJavaCompilers.gmk +include NativeCompilation.gmk + +TARGETS := + +################################################################################ + +FH_BASEDIR := $(SRC_ROOT)/test/failure_handler +FH_SUPPORT := $(SUPPORT_OUTPUTDIR)/test/failure_handler +FH_JAR := $(FH_SUPPORT)/jtregFailureHandler.jar + +JTREG_JAR := $(JT_HOME)/lib/jtreg.jar +ifeq ($(wildcard $(JTREG_JAR)), ) + $(error Cannot build failure handler without jtreg) +endif +# tools.jar is only needed if it exists in the boot jdk +TOOLS_JAR := $(wildcard $(BOOT_JDK)/lib/tools.jar) + +FH_CLASSPATH := $(call PathList, $(JTREG_JAR) $(TOOLS_JAR)) + +$(eval $(call SetupJavaCompilation, BUILD_FAILURE_HANDLER, \ + SETUP := GENERATE_OLDBYTECODE, \ + SRC := $(FH_BASEDIR)/src/share/classes $(FH_BASEDIR)/src/share/conf, \ + BIN := $(FH_SUPPORT)/classes, \ + COPY := .properties, \ + CLASSPATH := $(JTREG_JAR) $(TOOLS_JAR), \ + JAR := $(FH_JAR), \ +)) + +TARGETS += $(BUILD_FAILURE_HANDLER) + +################################################################################ + +ifeq ($(OPENJDK_TARGET_OS), windows) + + $(eval $(call SetupNativeCompilation, BUILD_LIBTIMEOUT_HANDLER, \ + LIBRARY := timeoutHandler, \ + SRC := $(FH_BASEDIR)/src/windows/native/libtimeoutHandler, \ + OBJECT_DIR := $(FH_SUPPORT)/libtimeoutHandler, \ + OUTPUT_DIR := $(FH_SUPPORT), \ + CFLAGS := $(CFLAGS_JDKLIB), \ + LDFLAGS := $(LDFLAGS_JDKLIB), \ + OPTIMIZATION := LOW, \ + )) + + TARGETS += $(BUILD_LIBTIMEOUT_HANDLER) + +endif + +################################################################################ +# Targets for building test-image. +################################################################################ + +# Copy to hotspot jtreg test image +$(eval $(call SetupCopyFiles, COPY_FH, \ + SRC := $(FH_SUPPORT), \ + DEST := $(TEST_IMAGE_DIR)/failure_handler, \ + FILES := $(FH_JAR) $(BUILD_LIBTIMEOUT_HANDLER), \ +)) + +IMAGES_TARGETS += $(COPY_FH) + +################################################################################ +# Test the failure handler itself +################################################################################ +# +# Use JTREG_TEST_OPTS for test VM options +# Use JTREG_TESTS for jtreg tests parameter +# +RUN_DIR := $(FH_SUPPORT)/test +# Add the dir of the dll to the path on windows +ifeq ($(OPENJDK_TARGET_OS), windows) + export PATH := $(PATH);$(FH_SUPPORT) +endif + +test: + $(RM) -r $(RUN_DIR) + $(MKDIR) -p $(RUN_DIR) + $(CD) $(FH_BASEDIR)/test && JT_JAVA=$(BOOT_JDK) $(JTREGEXE) \ + -jdk:$(BOOT_JDK) \ + $(JTREG_TEST_OPTS) \ + -timeout:0.1 -va -retain:all \ + -noreport \ + -agentvm \ + -thd:$(FH_JAR) \ + -th:jdk.test.failurehandler.jtreg.GatherProcessInfoTimeoutHandler \ + -od:$(FH_JAR) \ + -o:jdk.test.failurehandler.jtreg.GatherDiagnosticInfoObserver \ + -w:$(RUN_DIR)/JTwork -r:$(RUN_DIR)/JTreport \ + $(if $(JTREG_TESTS), $(JTREG_TESTS), .) \ + || true + +################################################################################ + +build: $(TARGETS) +images: $(IMAGES_TARGETS) + +.PHONY: all images test diff -r e047c2f3f510 -r e90042bf422d test/failure_handler/README --- a/test/failure_handler/README Wed Apr 13 18:11:29 2016 +0200 +++ b/test/failure_handler/README Thu Apr 14 15:13:42 2016 +0200 @@ -36,11 +36,9 @@ BUILDING -To build a library, one should simply run make with 'JTREG_HOME' and -'JAVA_HOME' environment variables set. 'JAVA_HOME' should contain path to JDK, -'JTREG_HOME' -- path to jtreg. - -'image/lib/jtregFailureHandler.jar' is created on successful build. +The library is built using the top level build-test-failure-handler target and +is automatically included in the test image and picked up by hotspot and jdk +test makefiles. CONFIGURATION diff -r e047c2f3f510 -r e90042bf422d test/failure_handler/src/windows/native/jdk/test/failurehandler/jtreg/GatherProcessInfoTimeoutHandler.c --- a/test/failure_handler/src/windows/native/jdk/test/failurehandler/jtreg/GatherProcessInfoTimeoutHandler.c Wed Apr 13 18:11:29 2016 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2015, 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. - */ - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -JNIEXPORT jlong JNICALL Java_jdk_test_failurehandler_jtreg_GatherProcessInfoTimeoutHandler_getWin32Pid - (JNIEnv* env, jobject o, jlong handle) { - return GetProcessId(handle); -} -#ifdef __cplusplus -} -#endif diff -r e047c2f3f510 -r e90042bf422d test/failure_handler/src/windows/native/libtimeoutHandler/GatherProcessInfoTimeoutHandler.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/failure_handler/src/windows/native/libtimeoutHandler/GatherProcessInfoTimeoutHandler.c Thu Apr 14 15:13:42 2016 +0200 @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2015, 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. + */ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +JNIEXPORT jlong JNICALL Java_jdk_test_failurehandler_jtreg_GatherProcessInfoTimeoutHandler_getWin32Pid + (JNIEnv* env, jobject o, jlong handle) { + return GetProcessId((HANDLE) handle); +} +#ifdef __cplusplus +} +#endif