8272305: several hotspot runtime/modules don't check exit codes
Reviewed-by: dholmes, mseledtsov
This commit is contained in:
parent
82688258f6
commit
b2c272d4e2
test/hotspot/jtreg/runtime/modules
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2021, 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
|
||||
@ -42,6 +42,7 @@ public class ClassLoaderNoUnnamedModuleTest {
|
||||
"-XX:-CreateCoredumpOnCrash",
|
||||
"ClassLoaderNoUnnamedModule");
|
||||
OutputAnalyzer oa = new OutputAnalyzer(pb.start());
|
||||
oa.shouldNotHaveExitValue(0);
|
||||
oa.shouldContain("Internal Error");
|
||||
oa.shouldContain("unnamed module");
|
||||
oa.shouldContain("null or not an instance of java.lang.Module");
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2016, 2021, 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
|
||||
@ -58,21 +58,28 @@ public class IgnoreModulePropertiesTest {
|
||||
// For options of the form "option=value", check that an exception gets thrown for
|
||||
// the illegal value and then check that its corresponding property is handled
|
||||
// correctly.
|
||||
public static void testOption(String option, String value,
|
||||
public static void testOption(boolean shouldVMFail,
|
||||
String option, String value,
|
||||
String prop, String result) throws Exception {
|
||||
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
|
||||
option + "=" + value, "-version");
|
||||
OutputAnalyzer output = new OutputAnalyzer(pb.start());
|
||||
if (shouldVMFail) {
|
||||
output.shouldNotHaveExitValue(0);
|
||||
} else {
|
||||
output.shouldHaveExitValue(0);
|
||||
}
|
||||
output.shouldContain(result);
|
||||
testProperty(prop, value);
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
testOption("--add-modules", "java.sqlx", "jdk.module.addmods.0", "java.lang.module.FindException");
|
||||
testOption("--limit-modules", "java.sqlx", "jdk.module.limitmods", "java.lang.module.FindException");
|
||||
testOption("--add-reads", "xyzz=yyzd", "jdk.module.addreads.0", "WARNING: Unknown module: xyzz");
|
||||
testOption("--add-exports", "java.base/xyzz=yyzd", "jdk.module.addexports.0",
|
||||
testOption(/*shouldVMFail=*/true, "--add-modules", "java.sqlx", "jdk.module.addmods.0", "java.lang.module.FindException");
|
||||
testOption(/*shouldVMFail=*/true, "--limit-modules", "java.sqlx", "jdk.module.limitmods", "java.lang.module.FindException");
|
||||
testOption(/*shouldVMFail=*/true, "--patch-module", "=d", "jdk.module.patch.0", "Unable to parse --patch-module");
|
||||
|
||||
testOption(/*shouldVMFail=*/false, "--add-reads", "xyzz=yyzd", "jdk.module.addreads.0", "WARNING: Unknown module: xyzz");
|
||||
testOption(/*shouldVMFail=*/false, "--add-exports", "java.base/xyzz=yyzd", "jdk.module.addexports.0",
|
||||
"WARNING: package xyzz not in java.base");
|
||||
testOption("--patch-module", "=d", "jdk.module.patch.0", "Unable to parse --patch-module");
|
||||
}
|
||||
}
|
||||
|
@ -52,6 +52,7 @@ public class PatchModuleCDS {
|
||||
"-version");
|
||||
new OutputAnalyzer(pb.start())
|
||||
// --patch-module is not supported during CDS dumping
|
||||
.shouldNotHaveExitValue(0)
|
||||
.shouldContain("Cannot use the following option when dumping the shared archive: --patch-module");
|
||||
|
||||
// Case 2: Test that directory in --patch-module is supported for CDS dumping
|
||||
@ -76,6 +77,7 @@ public class PatchModuleCDS {
|
||||
"-version");
|
||||
new OutputAnalyzer(pb.start())
|
||||
// --patch-module is not supported during CDS dumping
|
||||
.shouldNotHaveExitValue(0)
|
||||
.shouldContain("Cannot use the following option when dumping the shared archive: --patch-module");
|
||||
|
||||
// Case 3a: Test CDS dumping with jar file in --patch-module
|
||||
@ -91,6 +93,7 @@ public class PatchModuleCDS {
|
||||
"PatchModuleMain", "javax.naming.spi.NamingManager");
|
||||
new OutputAnalyzer(pb.start())
|
||||
// --patch-module is not supported during CDS dumping
|
||||
.shouldNotHaveExitValue(0)
|
||||
.shouldContain("Cannot use the following option when dumping the shared archive: --patch-module");
|
||||
|
||||
// Case 3b: Test CDS run with jar file in --patch-module
|
||||
|
@ -56,6 +56,7 @@ public class PatchModuleTraceCL {
|
||||
"-Xlog:class+load=info", "PatchModuleMain", "javax.naming.spi.NamingManager");
|
||||
|
||||
OutputAnalyzer output = new OutputAnalyzer(pb.start());
|
||||
output.shouldHaveExitValue(0);
|
||||
// "modules" jimage case.
|
||||
output.shouldContain("[class,load] java.lang.Thread source: jrt:/java.base");
|
||||
// --patch-module case.
|
||||
|
@ -75,6 +75,8 @@ public class XbootcpNoVisibility {
|
||||
new OutputAnalyzer(ProcessTools.createJavaProcessBuilder(
|
||||
"-Xbootclasspath/a:.",
|
||||
"Vis3_A")
|
||||
.start()).shouldContain("XbootcpNoVisibility PASSED");
|
||||
.start())
|
||||
.shouldHaveExitValue(0)
|
||||
.shouldContain("XbootcpNoVisibility PASSED");
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user