8211977: move testlibrary tests into one place

Reviewed-by: erikj, dholmes, ihse
This commit is contained in:
Igor Ignatyev 2020-06-16 09:50:45 -07:00
parent 5073b8c163
commit e7f8e1fdb5
35 changed files with 243 additions and 605 deletions

View File

@ -640,6 +640,18 @@ $(eval $(call SetupTarget, test-image-jdk-jtreg-native, \
DEPS := build-test-jdk-jtreg-native, \
))
$(eval $(call SetupTarget, build-test-libtest-jtreg-native, \
MAKEFILE := test/JtregNativeLibTest, \
TARGET := build-test-libtest-jtreg-native, \
DEPS := buildtools-jdk, \
))
$(eval $(call SetupTarget, test-image-libtest-jtreg-native, \
MAKEFILE := test/JtregNativeLibTest, \
TARGET := test-image-libtest-jtreg-native, \
DEPS := build-test-libtest-jtreg-native, \
))
$(eval $(call SetupTarget, build-test-hotspot-jtreg-graal, \
MAKEFILE := test/JtregGraalUnit, \
TARGET := build-test-hotspot-jtreg-graal, \
@ -982,6 +994,7 @@ else
interim-image: $(INTERIM_JMOD_TARGETS)
build-test-hotspot-jtreg-native: hotspot-$(JVM_VARIANT_MAIN)-libs
build-test-libtest-jtreg-native: hotspot-$(JVM_VARIANT_MAIN)-libs
endif
@ -1105,7 +1118,7 @@ endif
docs-image: docs-jdk
# This target builds the test image
test-image: prepare-test-image test-image-jdk-jtreg-native test-image-demos-jdk
test-image: prepare-test-image test-image-jdk-jtreg-native test-image-demos-jdk test-image-libtest-jtreg-native
ifneq ($(JVM_TEST_IMAGE_TARGETS), )
# If JVM_TEST_IMAGE_TARGETS is externally defined, use it instead of the

View File

@ -342,11 +342,13 @@ hotspot_JTREG_MAX_MEM := 0
hotspot_JTREG_ASSERT := false
hotspot_JTREG_NATIVEPATH := $(TEST_IMAGE_DIR)/hotspot/jtreg/native
jdk_JTREG_NATIVEPATH := $(TEST_IMAGE_DIR)/jdk/jtreg/native
lib-test_JTREG_NATIVEPATH := $(TEST_IMAGE_DIR)/lib-test/jtreg/native
jdk_JTREG_PROBLEM_LIST += $(TOPDIR)/test/jdk/ProblemList.txt
jaxp_JTREG_PROBLEM_LIST += $(TOPDIR)/test/jaxp/ProblemList.txt
langtools_JTREG_PROBLEM_LIST += $(TOPDIR)/test/langtools/ProblemList.txt
hotspot_JTREG_PROBLEM_LIST += $(TOPDIR)/test/hotspot/jtreg/ProblemList.txt
lib-test_JTREG_PROBLEM_LIST += $(TOPDIR)/test/lib-test/ProblemList.txt
langtools_JTREG_MAX_MEM := 768m

View File

@ -43,7 +43,7 @@ $(eval $(call IncludeCustomExtension, common/FindTests.gmk))
TEST_BASEDIRS += $(TOPDIR)/test $(TOPDIR)
# JTREG_TESTROOTS might have been set by a custom extension
JTREG_TESTROOTS += $(addprefix $(TOPDIR)/test/, hotspot/jtreg jdk langtools jaxp)
JTREG_TESTROOTS += $(addprefix $(TOPDIR)/test/, hotspot/jtreg jdk langtools jaxp lib-test)
# Extract the names of the Jtreg group files from the TEST.ROOT files. The
# TEST.ROOT files being properties files can be interpreted as makefiles so

View File

@ -872,10 +872,8 @@ BUILD_HOTSPOT_JTREG_EXECUTABLES_LIBS_exesigtest := -ljvm
ifeq ($(call isTargetOs, windows), true)
BUILD_HOTSPOT_JTREG_EXECUTABLES_CFLAGS_exeFPRegs := -MT
BUILD_HOTSPOT_JTREG_EXCLUDE += exesigtest.c libterminatedThread.c
BUILD_HOTSPOT_JTREG_EXECUTABLES_LIBS_exejvm-test-launcher := jvm.lib
BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libatExit := jvm.lib
else
BUILD_HOTSPOT_JTREG_EXECUTABLES_LIBS_exejvm-test-launcher := -ljvm
BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libbootclssearch_agent += -lpthread
BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libsystemclssearch_agent += -lpthread
BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libgetsysprop001 += -lpthread

View File

@ -0,0 +1,94 @@
#
# Copyright (c) 2020, 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 the native component of the JTReg tests for testlibrary.
# 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 TestFilesCompilation.gmk
$(eval $(call IncludeCustomExtension, test/JtregNativeLibTest.gmk))
################################################################################
# Targets for building the native tests themselves.
################################################################################
# This might have been added to by a custom extension.
BUILD_LIBTEST_JTREG_NATIVE_SRC += $(TOPDIR)/test/lib-test
BUILD_LIBTEST_JTREG_OUTPUT_DIR := $(OUTPUTDIR)/support/test/lib-test/jtreg/native
BUILD_LIBTEST_JTREG_IMAGE_DIR := $(TEST_IMAGE_DIR)/lib-test/jtreg
ifeq ($(call isTargetOs, windows), true)
BUILD_LIBTEST_JTREG_EXECUTABLES_LIBS_exejvm-test-launcher := jvm.lib
else
BUILD_LIBTEST_JTREG_EXECUTABLES_LIBS_exejvm-test-launcher := -ljvm
endif
# This evaluation is expensive and should only be done if this target was
# explicitly called.
ifneq ($(filter build-test-libtest-jtreg-native, $(MAKECMDGOALS)), )
$(eval $(call SetupTestFilesCompilation, BUILD_LIBTEST_JTREG_LIBRARIES, \
TYPE := LIBRARY, \
SOURCE_DIRS := $(BUILD_LIBTEST_JTREG_NATIVE_SRC), \
OUTPUT_DIR := $(BUILD_LIBTEST_JTREG_OUTPUT_DIR), \
EXCLUDE := $(BUILD_LIBTEST_JTREG_EXCLUDE), \
))
$(eval $(call SetupTestFilesCompilation, BUILD_LIBTEST_JTREG_EXECUTABLES, \
TYPE := PROGRAM, \
SOURCE_DIRS := $(BUILD_LIBTEST_JTREG_NATIVE_SRC), \
OUTPUT_DIR := $(BUILD_LIBTEST_JTREG_OUTPUT_DIR), \
EXCLUDE := $(BUILD_LIBTEST_JTREG_EXCLUDE), \
))
endif
build-test-libtest-jtreg-native: $(BUILD_LIBTEST_JTREG_LIBRARIES) $(BUILD_LIBTEST_JTREG_EXECUTABLES)
################################################################################
# Targets for building test-image.
################################################################################
# Copy to lib-test jtreg test image
$(eval $(call SetupCopyFiles, COPY_LIBTEST_JTREG_NATIVE, \
SRC := $(BUILD_LIBTEST_JTREG_OUTPUT_DIR), \
DEST := $(TEST_IMAGE_DIR)/lib-test/jtreg/native, \
FILES := $(wildcard $(addprefix $(BUILD_LIBTEST_JTREG_OUTPUT_DIR), /bin/* /lib/*)), \
FLATTEN := true, \
))
test-image-libtest-jtreg-native: $(COPY_LIBTEST_JTREG_NATIVE)
all: build-test-libtest-jtreg-native
test-image: test-image-libtest-jtreg-native
.PHONY: default all build-test-libtest-jtreg-native test-image-libtest-jtreg-native test-image

View File

@ -309,7 +309,6 @@ tier1_runtime = \
-runtime/Thread/TestThreadDumpMonitorContention.java \
-runtime/Unsafe/RangeCheck.java \
sanity/ \
testlibrary_tests/TestMutuallyExclusivePlatformPredicates.java \
-:tier1_runtime_appcds_exclude \
-runtime/signal

View File

@ -22,7 +22,7 @@
*/
/*
* A simple way to test JVMTI ClassFileLoadHook. See ../testlibrary_tests/SimpleClassFileLoadHookTest.java
* A simple way to test JVMTI ClassFileLoadHook. See ../testlibrary_tests/jvmti/SimpleClassFileLoadHookTest.java
* for an example.
*/
#include <stdio.h>

View File

@ -1,238 +0,0 @@
/*
* Copyright (c) 2013, 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.
*/
import static jdk.test.lib.Asserts.*;
/* @test
* @summary Tests the different assertions in the Assert class
* @modules java.base/jdk.internal.misc
* @library /test/lib
*/
public class AssertsTest {
private static class Foo implements Comparable<Foo> {
final int id;
public Foo(int id) {
this.id = id;
}
public int compareTo(Foo f) {
return new Integer(id).compareTo(new Integer(f.id));
}
}
public static void main(String[] args) throws Exception {
testLessThan();
testLessThanOrEqual();
testEquals();
testGreaterThanOrEqual();
testGreaterThan();
testNotEquals();
testNull();
testNotNull();
testTrue();
testFalse();
}
private static void testLessThan() throws Exception {
expectPass(Assertion.LT, 1, 2);
expectFail(Assertion.LT, 2, 2);
expectFail(Assertion.LT, 2, 1);
expectFail(Assertion.LT, null, 2);
expectFail(Assertion.LT, 2, null);
}
private static void testLessThanOrEqual() throws Exception {
expectPass(Assertion.LTE, 1, 2);
expectPass(Assertion.LTE, 2, 2);
expectFail(Assertion.LTE, 3, 2);
expectFail(Assertion.LTE, null, 2);
expectFail(Assertion.LTE, 2, null);
}
private static void testEquals() throws Exception {
expectPass(Assertion.EQ, 1, 1);
expectPass(Assertion.EQ, null, null);
Foo f1 = new Foo(1);
expectPass(Assertion.EQ, f1, f1);
Foo f2 = new Foo(1);
expectFail(Assertion.EQ, f1, f2);
expectFail(Assertion.LTE, null, 2);
expectFail(Assertion.LTE, 2, null);
}
private static void testGreaterThanOrEqual() throws Exception {
expectPass(Assertion.GTE, 1, 1);
expectPass(Assertion.GTE, 2, 1);
expectFail(Assertion.GTE, 1, 2);
expectFail(Assertion.GTE, null, 2);
expectFail(Assertion.GTE, 2, null);
}
private static void testGreaterThan() throws Exception {
expectPass(Assertion.GT, 2, 1);
expectFail(Assertion.GT, 1, 1);
expectFail(Assertion.GT, 1, 2);
expectFail(Assertion.GT, null, 2);
expectFail(Assertion.GT, 2, null);
}
private static void testNotEquals() throws Exception {
expectPass(Assertion.NE, null, 1);
expectPass(Assertion.NE, 1, null);
Foo f1 = new Foo(1);
Foo f2 = new Foo(1);
expectPass(Assertion.NE, f1, f2);
expectFail(Assertion.NE, null, null);
expectFail(Assertion.NE, f1, f1);
expectFail(Assertion.NE, 1, 1);
}
private static void testNull() throws Exception {
expectPass(Assertion.NULL, null);
expectFail(Assertion.NULL, 1);
}
private static void testNotNull() throws Exception {
expectPass(Assertion.NOTNULL, 1);
expectFail(Assertion.NOTNULL, null);
}
private static void testTrue() throws Exception {
expectPass(Assertion.TRUE, true);
expectFail(Assertion.TRUE, false);
}
private static void testFalse() throws Exception {
expectPass(Assertion.FALSE, false);
expectFail(Assertion.FALSE, true);
}
private static <T extends Comparable<T>> void expectPass(Assertion assertion, T ... args)
throws Exception {
Assertion.run(assertion, args);
}
private static <T extends Comparable<T>> void expectFail(Assertion assertion, T ... args)
throws Exception {
try {
Assertion.run(assertion, args);
} catch (RuntimeException e) {
return;
}
throw new Exception("Expected " + Assertion.format(assertion, (Object[]) args) +
" to throw a RuntimeException");
}
}
enum Assertion {
LT, LTE, EQ, GTE, GT, NE, NULL, NOTNULL, FALSE, TRUE;
public static <T extends Comparable<T>> void run(Assertion assertion, T ... args) {
String msg = "Expected " + format(assertion, args) + " to pass";
switch (assertion) {
case LT:
assertLessThan(args[0], args[1], msg);
break;
case LTE:
assertLessThanOrEqual(args[0], args[1], msg);
break;
case EQ:
assertEquals(args[0], args[1], msg);
break;
case GTE:
assertGreaterThanOrEqual(args[0], args[1], msg);
break;
case GT:
assertGreaterThan(args[0], args[1], msg);
break;
case NE:
assertNotEquals(args[0], args[1], msg);
break;
case NULL:
assertNull(args == null ? args : args[0], msg);
break;
case NOTNULL:
assertNotNull(args == null ? args : args[0], msg);
break;
case FALSE:
assertFalse((Boolean) args[0], msg);
break;
case TRUE:
assertTrue((Boolean) args[0], msg);
break;
default:
// do nothing
}
}
public static String format(Assertion assertion, Object ... args) {
switch (assertion) {
case LT:
return asString("assertLessThan", args);
case LTE:
return asString("assertLessThanOrEqual", args);
case EQ:
return asString("assertEquals", args);
case GTE:
return asString("assertGreaterThanOrEquals", args);
case GT:
return asString("assertGreaterThan", args);
case NE:
return asString("assertNotEquals", args);
case NULL:
return asString("assertNull", args);
case NOTNULL:
return asString("assertNotNull", args);
case FALSE:
return asString("assertFalse", args);
case TRUE:
return asString("assertTrue", args);
default:
return "";
}
}
private static String asString(String assertion, Object ... args) {
if (args == null) {
return String.format("%s(null)", assertion);
}
if (args.length == 1) {
return String.format("%s(%s)", assertion, args[0]);
} else {
return String.format("%s(%s, %s)", assertion, args[0], args[1]);
}
}
}

View File

@ -1,126 +0,0 @@
/*
* Copyright (c) 2013, 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.
*/
/*
* @test
* @summary Test the OutputAnalyzer reporting functionality,
* such as printing additional diagnostic info
* (exit code, stdout, stderr, command line, etc.)
* @library /test/lib
* @modules java.base/jdk.internal.misc
* java.management
*/
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.process.ProcessTools;
public class OutputAnalyzerReportingTest {
public static void main(String[] args) throws Exception {
// Create the output analyzer under test
String stdout = "aaaaaa";
String stderr = "bbbbbb";
OutputAnalyzer output = new OutputAnalyzer(stdout, stderr);
// Expected summary values should be the same for all cases,
// since the outputAnalyzer object is the same
String expectedExitValue = "-1";
String expectedSummary =
" stdout: [" + stdout + "];\n" +
" stderr: [" + stderr + "]\n" +
" exitValue = " + expectedExitValue + "\n";
DiagnosticSummaryTestRunner testRunner =
new DiagnosticSummaryTestRunner();
// should have exit value
testRunner.init(expectedSummary);
int unexpectedExitValue = 2;
try {
output.shouldHaveExitValue(unexpectedExitValue);
} catch (RuntimeException e) { }
testRunner.closeAndCheckResults();
// should not contain
testRunner.init(expectedSummary);
try {
output.shouldNotContain(stdout);
} catch (RuntimeException e) { }
testRunner.closeAndCheckResults();
// should contain
testRunner.init(expectedSummary);
try {
output.shouldContain("unexpected-stuff");
} catch (RuntimeException e) { }
testRunner.closeAndCheckResults();
// should not match
testRunner.init(expectedSummary);
try {
output.shouldNotMatch("[a]");
} catch (RuntimeException e) { }
testRunner.closeAndCheckResults();
// should match
testRunner.init(expectedSummary);
try {
output.shouldMatch("[qwerty]");
} catch (RuntimeException e) { }
testRunner.closeAndCheckResults();
}
private static class DiagnosticSummaryTestRunner {
private ByteArrayOutputStream byteStream =
new ByteArrayOutputStream(10000);
private String expectedSummary = "";
private PrintStream errStream;
public void init(String expectedSummary) {
this.expectedSummary = expectedSummary;
byteStream.reset();
errStream = new PrintStream(byteStream);
System.setErr(errStream);
}
public void closeAndCheckResults() {
// check results
errStream.close();
String stdErrStr = byteStream.toString();
if (!stdErrStr.contains(expectedSummary)) {
throw new RuntimeException("The output does not contain "
+ "the diagnostic message, or the message is incorrect");
}
}
}
}

View File

@ -1,195 +0,0 @@
/*
* Copyright (c) 2013, 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.
*/
/*
* @test
* @summary Test the OutputAnalyzer utility class
* @library /test/lib
* @modules java.base/jdk.internal.misc
* java.management
*/
import jdk.test.lib.process.OutputAnalyzer;
public class OutputAnalyzerTest {
public static void main(String args[]) throws Exception {
String stdout = "aaaaaa";
String stderr = "bbbbbb";
// Regexps used for testing pattern matching of the test input
String stdoutPattern = "[a]";
String stderrPattern = "[b]";
String nonExistingPattern = "[c]";
OutputAnalyzer output = new OutputAnalyzer(stdout, stderr);
if (!stdout.equals(output.getStdout())) {
throw new Exception("getStdout() returned '" + output.getStdout() + "', expected '" + stdout + "'");
}
if (!stderr.equals(output.getStderr())) {
throw new Exception("getStderr() returned '" + output.getStderr() + "', expected '" + stderr + "'");
}
try {
output.shouldContain(stdout);
output.stdoutShouldContain(stdout);
output.shouldContain(stderr);
output.stderrShouldContain(stderr);
} catch (RuntimeException e) {
throw new Exception("shouldContain() failed", e);
}
try {
output.shouldContain("cccc");
throw new Exception("shouldContain() failed to throw exception");
} catch (RuntimeException e) {
// expected
}
try {
output.stdoutShouldContain(stderr);
throw new Exception("stdoutShouldContain() failed to throw exception");
} catch (RuntimeException e) {
// expected
}
try {
output.stderrShouldContain(stdout);
throw new Exception("stdoutShouldContain() failed to throw exception");
} catch (RuntimeException e) {
// expected
}
try {
output.shouldNotContain("cccc");
output.stdoutShouldNotContain("cccc");
output.stderrShouldNotContain("cccc");
} catch (RuntimeException e) {
throw new Exception("shouldNotContain() failed", e);
}
try {
output.shouldNotContain(stdout);
throw new Exception("shouldContain() failed to throw exception");
} catch (RuntimeException e) {
// expected
}
try {
output.stdoutShouldNotContain(stdout);
throw new Exception("shouldContain() failed to throw exception");
} catch (RuntimeException e) {
// expected
}
try {
output.stderrShouldNotContain(stderr);
throw new Exception("shouldContain() failed to throw exception");
} catch (RuntimeException e) {
// expected
}
// Should match
try {
output.shouldMatch(stdoutPattern);
output.stdoutShouldMatch(stdoutPattern);
output.shouldMatch(stderrPattern);
output.stderrShouldMatch(stderrPattern);
} catch (RuntimeException e) {
throw new Exception("shouldMatch() failed", e);
}
try {
output.shouldMatch(nonExistingPattern);
throw new Exception("shouldMatch() failed to throw exception");
} catch (RuntimeException e) {
// expected
}
try {
output.stdoutShouldMatch(stderrPattern);
throw new Exception(
"stdoutShouldMatch() failed to throw exception");
} catch (RuntimeException e) {
// expected
}
try {
output.stderrShouldMatch(stdoutPattern);
throw new Exception(
"stderrShouldMatch() failed to throw exception");
} catch (RuntimeException e) {
// expected
}
// Should not match
try {
output.shouldNotMatch(nonExistingPattern);
output.stdoutShouldNotMatch(nonExistingPattern);
output.stderrShouldNotMatch(nonExistingPattern);
} catch (RuntimeException e) {
throw new Exception("shouldNotMatch() failed", e);
}
try {
output.shouldNotMatch(stdoutPattern);
throw new Exception("shouldNotMatch() failed to throw exception");
} catch (RuntimeException e) {
// expected
}
try {
output.stdoutShouldNotMatch(stdoutPattern);
throw new Exception("shouldNotMatch() failed to throw exception");
} catch (RuntimeException e) {
// expected
}
try {
output.stderrShouldNotMatch(stderrPattern);
throw new Exception("shouldNotMatch() failed to throw exception");
} catch (RuntimeException e) {
// expected
}
{
String aaaa = "aaaa";
String result = output.firstMatch(aaaa);
if (!aaaa.equals(result)) {
throw new Exception("firstMatch(String) faild to match. Expected: " + aaaa + " got: " + result);
}
}
{
String aa = "aa";
String aa_grouped_aa = aa + "(" + aa + ")";
String result = output.firstMatch(aa_grouped_aa, 1);
if (!aa.equals(result)) {
throw new Exception("firstMatch(String, int) failed to match. Expected: " + aa + " got: " + result);
}
}
}
}

View File

@ -1,28 +0,0 @@
/*
* Copyright (c) 2020, 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.
*/
public class Test {
public static void test() {
System.out.println ("Hello Test");
}
}

View File

@ -0,0 +1,40 @@
#
# Copyright (c) 2020, 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.
#
#############################################################################
#
# List of quarantined tests -- tests that should not be run by default, because
# they may fail due to known reason. The reason (CR#) must be mandatory specified.
#
# List items are testnames followed by labels, all MUST BE commented
# as to why they are here and use a label:
# generic-all Problems on all platforms
# generic-ARCH Where ARCH is one of: x64, i586, ppc64, ppc64le, s390x etc.
# OSNAME-all Where OSNAME is one of: linux, windows, macosx, aix
# OSNAME-ARCH Specific on to one OSNAME and ARCH, e.g. macosx-x64
# OSNAME-REV Specific on to one OSNAME and REV, e.g. macosx-10.7.4
#
# More than one label is allowed but must be on the same line.
#
#############################################################################

View File

@ -1,9 +1,38 @@
#
# Copyright (c) 2020, 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.
#
# This file identifies the root of the test-suite hierarchy.
# It also contains test-suite configuration information.
# The list of keywords supported in this test suite
# randomness: test uses randomness, test cases differ from run to run
keys=randomness
# Minimum jtreg version
requiredVersion=5.1 b1
# Path to libraries in the topmost test directory. This is needed so @library
# does not need ../../ notation to reach them
external.lib.roots = ../../
groups=TEST.groups

24
test/lib-test/TEST.groups Normal file
View File

@ -0,0 +1,24 @@
#
# Copyright (c) 2020, 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.
#
tier1 = .

View File

@ -24,9 +24,9 @@
/*
* @test
* @summary Unit test for LingeredApp
* @compile LingeredAppTest.java
* @compile LingeredApp.java
* @run main LingeredAppTest
* @library /test/lib
* @build jdk.test.lib.apps.LingeredAppTest jdk.test.lib.apps.LingeredApp
* @run main jdk.test.lib.apps.LingeredAppTest
*/
package jdk.test.lib.apps;
@ -52,13 +52,13 @@ public class LingeredAppTest {
cmd.add("-XX:+PrintFlagsFinal");
LingeredApp a = LingeredApp.startApp(cmd.toArray(new String[cmd.length]);
LingeredApp a = LingeredApp.startApp(cmd.toArray(new String[cmd.size()]));
System.out.printf("App pid: %d\n", a.getPid());
a.stopApp();
System.out.println("App output:");
int count = 0;
for (String line : a.getAppOutput()) {
for (String line : a.getOutput().getStdoutAsList()) {
count += 1;
}
System.out.println("Found " + count + " lines in VM output");

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2020, 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
@ -199,6 +199,23 @@ public class OutputAnalyzerTest {
} catch (RuntimeException e) {
// expected
}
{
String aaaa = "aaaa";
String result = output.firstMatch(aaaa);
if (!aaaa.equals(result)) {
throw new Exception("firstMatch(String) failed to match. Expected: " + aaaa + " got: " + result);
}
}
{
String aa = "aa";
String aa_grouped_aa = aa + "(" + aa + ")";
String result = output.firstMatch(aa_grouped_aa, 1);
if (!aa.equals(result)) {
throw new Exception("firstMatch(String, int) failed to match. Expected: " + aa + " got: " + result);
}
}
}
}

View File

@ -25,7 +25,6 @@
* @test
* @summary Test the native process builder API.
* @library /test/lib
* @build Test
* @run main/native TestNativeProcessBuilder
*/
@ -39,6 +38,13 @@ public class TestNativeProcessBuilder {
ProcessBuilder pb = ProcessTools.createNativeTestProcessBuilder("jvm-test-launcher");
pb.environment().put("CLASSPATH", Utils.TEST_CLASS_PATH);
new OutputAnalyzer(pb.start())
.shouldHaveExitValue(0);
.shouldHaveExitValue(0)
.stdoutShouldContain("Hello Test");
}
public static class Test {
public static void test() {
System.out.println("Hello Test");
}
}
}

View File

@ -42,8 +42,9 @@ JNIEnv* create_vm(JavaVM **jvm)
args.ignoreUnrecognized = 0;
int ret = JNI_CreateJavaVM(jvm, (void**)&env, &args);
if (ret < 0)
if (ret < 0) {
exit(10);
}
return env;
}
@ -53,13 +54,15 @@ void run(JNIEnv *env) {
jclass test_class;
jmethodID test_method;
test_class = (*env)->FindClass(env, "Test");
if (test_class == NULL)
test_class = (*env)->FindClass(env, "TestNativeProcessBuilder$Test");
if (test_class == NULL) {
exit(11);
}
test_method = (*env)->GetStaticMethodID(env, test_class, "test", "()V");
if (test_method == NULL)
if (test_method == NULL) {
exit(12);
}
(*env)->CallStaticVoidMethod(env, test_class, test_method);
}