8246387: switch to jtreg 5.1

Reviewed-by: dholmes, erikj
This commit is contained in:
Igor Ignatyev 2020-06-10 10:47:40 -07:00
parent bf22f82207
commit e47b2bc8c3
10 changed files with 23 additions and 134 deletions

View File

@ -1045,10 +1045,10 @@ var getJibProfilesDependencies = function (input, common) {
jtreg: {
server: "jpg",
product: "jtreg",
version: "5.0",
version: "5.1",
build_number: "b01",
checksum_file: "MD5_VALUES",
file: "bundles/jtreg_bin-5.0.zip",
file: "bundles/jtreg_bin-5.1.zip",
environment_name: "JT_HOME",
environment_path: input.get("jtreg", "home_path") + "/bin",
configure_args: "--with-jtreg=" + input.get("jtreg", "home_path"),

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 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
@ -121,29 +121,4 @@ public class GatherDiagnosticInfoObserver implements Harness.Observer {
compileJdk = rp.getCompileJDK().getAbsoluteFile().toPath();
testJdk = rp.getTestJDK().getAbsoluteFile().toPath();
}
@Override
public void startingTest(TestResult tr) {
// no-op
}
@Override
public void stoppingTestRun() {
// no-op
}
@Override
public void finishedTesting() {
// no-op
}
@Override
public void finishedTestRun(boolean allOK) {
// no-op
}
@Override
public void error(String msg) {
// no-op
}
}

View File

@ -75,7 +75,7 @@ requires.properties= \
test.vm.gc.nvdimm
# Minimum jtreg version
requiredVersion=5.0 b1
requiredVersion=5.1 b1
# Path to libraries in the topmost test directory. This is needed so @library
# does not need ../../../ notation to reach them

View File

@ -40,13 +40,14 @@ public class TestInitException {
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("Example");
OutputAnalyzer oa = new OutputAnalyzer(pb.start());
// First call stack trace
oa.shouldContain("at Example.$jacocoInit(Example.jasm)");
// shouldMatch is used to workaround CODETOOLS-7902686
oa.shouldMatch("^\tat Example\\.\\$jacocoInit\\(.*Example\\.jasm\\)$");
oa.shouldContain("Caused by: java.lang.RuntimeException");
oa.shouldContain("at StaticInit.<clinit>(StaticInit.java:27)");
// Second call stack trace, with the message
oa.shouldContain("java.lang.ExceptionInInitializerError: $jacocoData");
oa.shouldContain("at Example.foo(Example.jasm)");
oa.shouldContain("at Example.main(Example.jasm)");
oa.shouldMatch("^\tat Example\\.foo\\(.*Example\\.jasm\\)$");
oa.shouldMatch("^\tat Example\\.main\\(.*Example\\.jasm\\)$");
oa.shouldHaveExitValue(1);
}
}

View File

@ -23,7 +23,7 @@ modules=java.xml
groups=TEST.groups
# Minimum jtreg version
requiredVersion=5.0 b1
requiredVersion=5.1 b1
# Path to libraries in the topmost test directory. This is needed so @library
# does not need ../../ notation to reach them

View File

@ -59,7 +59,7 @@ requires.properties= \
release.implementor
# Minimum jtreg version
requiredVersion=5.0 b1
requiredVersion=5.1 b1
# Path to libraries in the topmost test directory. This is needed so @library
# does not need ../../ notation to reach them

View File

@ -15,7 +15,7 @@ keys=intermittent randomness
groups=TEST.groups
# Minimum jtreg version
requiredVersion=5.0 b1
requiredVersion=5.1 b1
# Use new module options
useNewOptions=true

View File

@ -2,7 +2,7 @@
# It also contains test-suite configuration information.
# Minimum jtreg version
requiredVersion=5.0 b1
requiredVersion=5.1 b1
# Path to libraries in the topmost test directory. This is needed so @library
# does not need ../../ notation to reach them

View File

@ -113,6 +113,11 @@ public final class Utils {
public static final String TEST_CLASSES = System.getProperty("test.classes", ".");
/**
* Returns the value of 'test.name' system property
*/
public static final String TEST_NAME = System.getProperty("test.name", ".");
/**
* Defines property name for seed value.
*/
public static final String SEED_PROPERTY_NAME = "jdk.test.lib.random.seed";
@ -824,87 +829,6 @@ public final class Utils {
}
}
// This method is intended to be called from a jtreg test.
// It will identify the name of the test by means of stack walking.
// It can handle both jtreg tests and a testng tests wrapped inside jtreg tests.
// For jtreg tests the name of the test will be searched by stack-walking
// until the method main() is found; the class containing that method is the
// main test class and will be returned as the name of the test.
// Special handling is used for testng tests.
@SuppressWarnings("unchecked")
public static String getTestName() {
String result = null;
// If we are using testng, then we should be able to load the "Test" annotation.
Class<? extends Annotation> testClassAnnotation, junitTestClassAnnotation;
try {
testClassAnnotation = (Class<? extends Annotation>)Class.forName("org.testng.annotations.Test");
} catch (ClassNotFoundException e) {
testClassAnnotation = null;
}
// If we are using junit, then we should be able to load the "Test" annotation.
try {
junitTestClassAnnotation = (Class<? extends Annotation>)Class.forName("org.junit.Test");
} catch (ClassNotFoundException e) {
junitTestClassAnnotation = null;
}
StackTraceElement[] elms = (new Throwable()).getStackTrace();
for (StackTraceElement n: elms) {
String className = n.getClassName();
// If this is a "main" method, then use its class name, but only
// if we are not using testng or junit.
if (testClassAnnotation == null && junitTestClassAnnotation == null &&
"main".equals(n.getMethodName())) {
result = className;
break;
}
// If this is a testng test, the test will have no "main" method. We can
// detect a testng test class by looking for the org.testng.annotations.Test
// annotation. If present, then use the name of this class.
if (testClassAnnotation != null) {
try {
Class<?> c = Class.forName(className);
if (c.isAnnotationPresent(testClassAnnotation)) {
result = className;
break;
}
} catch (ClassNotFoundException e) {
throw new RuntimeException("Unexpected exception: " + e, e);
}
}
// If this is a junit test, the test will have no "main" method. We can
// detect a junit test class by going through all the methods and
// check if the method has the org.junit.Test annotation. If present,
// then use the name of this class.
if (junitTestClassAnnotation != null) {
try {
Class<?> c = Class.forName(className);
Method[] methods = c.getMethods();
for (Method method : methods) {
if (method.getName().equals(n.getMethodName()) &&
method.isAnnotationPresent(junitTestClassAnnotation)) {
result = className;
break;
}
}
} catch (ClassNotFoundException e) {
throw new RuntimeException("Unexpected exception: " + e, e);
}
}
}
if (result == null) {
throw new RuntimeException("Couldn't find main test class in stack trace");
}
return result;
}
/**
* Creates an empty file in "user.dir" if the property set.
* <p>

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 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
@ -499,7 +499,7 @@ public class CDSTestUtils {
// create file containing the specified class list
public static File makeClassList(String classes[])
throws Exception {
return makeClassList(getTestName() + "-", classes);
return makeClassList(testName + "-", classes);
}
// create file containing the specified class list
@ -529,18 +529,7 @@ public class CDSTestUtils {
}
}
// Optimization for getting a test name.
// Test name does not change during execution of the test,
// but getTestName() uses stack walking hence it is expensive.
// Therefore cache it and reuse it.
private static String testName;
public static String getTestName() {
if (testName == null) {
testName = Utils.getTestName();
}
return testName;
}
private static String testName = Utils.TEST_NAME.replace('/', '.');
private static final SimpleDateFormat timeStampFormat =
new SimpleDateFormat("HH'h'mm'm'ss's'SSS");
@ -549,7 +538,7 @@ public class CDSTestUtils {
// Call this method to start new archive with new unique name
public static void startNewArchiveName() {
defaultArchiveName = getTestName() +
defaultArchiveName = testName +
timeStampFormat.format(new Date()) + ".jsa";
}
@ -561,7 +550,7 @@ public class CDSTestUtils {
// ===================== FILE ACCESS convenience methods
public static File getOutputFile(String name) {
File dir = new File(System.getProperty("test.classes", "."));
return new File(dir, getTestName() + "-" + name);
return new File(dir, testName + "-" + name);
}
@ -582,7 +571,7 @@ public class CDSTestUtils {
long started = System.currentTimeMillis();
OutputAnalyzer output = new OutputAnalyzer(pb.start());
String outputFileNamePrefix =
getTestName() + "-" + String.format("%04d", getNextLogCounter()) + "-" + logName;
testName + "-" + String.format("%04d", getNextLogCounter()) + "-" + logName;
writeFile(getOutputFile(outputFileNamePrefix + ".stdout"), output.getStdout());
writeFile(getOutputFile(outputFileNamePrefix + ".stderr"), output.getStderr());