Skip to content
Permalink
Browse files
8272553: several hotspot runtime/CommandLine tests don't check exit code
Backport-of: 709b5910c35ad081b2367435cbc689414098b87a
  • Loading branch information
GoeLin committed Jan 25, 2022
1 parent 6315ce3 commit 28dcaf3c2eaa533b129f0662702c5735d31b771a
Showing 7 changed files with 21 additions and 7 deletions.
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 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
@@ -48,6 +48,8 @@ public static void main(String[] args) throws Exception {

pb = ProcessTools.createJavaProcessBuilder("-XX:CompileCommandFile=hs_comp.txt", "-version");
output = new OutputAnalyzer(pb.start());
// problems in CompileCommandFile are treated as warnings
output.shouldHaveExitValue(0);
output.shouldContain("An error occurred during parsing");
output.shouldContain("Unrecognized option 'aaa'");
output.shouldContain("aaa, aaa");
@@ -60,6 +62,7 @@ public static void main(String[] args) throws Exception {

pb = ProcessTools.createJavaProcessBuilder("-version");
output = new OutputAnalyzer(pb.start());
output.shouldHaveExitValue(0);
output.shouldContain("warning: .hotspot_compiler file is present but has been ignored. Run with -XX:CompileCommandFile=.hotspot_compiler to load the file.");
}
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 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
@@ -59,6 +59,7 @@ public static void main(String[] args) throws Exception {

pb = ProcessTools.createJavaProcessBuilder("-version");
output = new OutputAnalyzer(pb.start());
output.shouldHaveExitValue(0);
output.shouldContain("warning: .hotspotrc file is present but has been ignored. Run with -XX:Flags=.hotspotrc to load the file.");
}
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 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
@@ -52,6 +52,7 @@ public static void main(String[] args) throws Exception {
"-XX:+" + flag, "-version");

OutputAnalyzer output2 = new OutputAnalyzer(pb2.start());
output2.shouldHaveExitValue(0);
output2.shouldContain("Ignoring option").shouldContain("support was removed");
output2.shouldContain(flag);
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 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
@@ -48,6 +48,7 @@ public static void main(String args[]) throws Exception {

// UnlockDiagnostic turned off, should fail
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldNotHaveExitValue(0);
output.shouldContain("Error: VM option 'LogTouchedMethods' is diagnostic and must be enabled via -XX:+UnlockDiagnosticVMOptions.");
output.shouldContain("Error: Could not create the Java Virtual Machine.");

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 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
@@ -47,6 +47,7 @@ public static void main(String args[]) throws Exception {
pb = ProcessTools.createJavaProcessBuilder(
"-XX:SharedBaseAddress=1D000000", "-version");
output = new OutputAnalyzer(pb.start());
output.shouldNotHaveExitValue(0);
output.shouldContain("Could not create the Java Virtual Machine");
}
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 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,18 +42,21 @@ public static void main(String[] args) throws Exception {
"-XX:+IgnoreUnrecognizedVMOptions",
"-XX:+PrintFlagsInitial");
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldHaveExitValue(0);
output.shouldContain("bool UseSerialGC");

pb = ProcessTools.createJavaProcessBuilder(
"-XX:-PrintVMOptions", "-version");
output = new OutputAnalyzer(pb.start());
output.shouldHaveExitValue(0);
output.shouldMatch("(openjdk|java)\\sversion");

File dir = new File(System.getProperty("test.src", "."));
File file = new File(dir, "flagfile.txt");
String s = file.getAbsolutePath();
pb = ProcessTools.createJavaProcessBuilder("-XX:Flags="+s);
output = new OutputAnalyzer(pb.start());
output.shouldNotHaveExitValue(0);
output.shouldContain("VM option '-IgnoreUnrecognizedVMOptions'");
}
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 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
@@ -39,6 +39,7 @@ public class VMOptionWarning {
public static void main(String[] args) throws Exception {
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+AlwaysSafeConstructors", "-version");
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldNotHaveExitValue(0);
output.shouldContain("Error: VM option 'AlwaysSafeConstructors' is experimental and must be enabled via -XX:+UnlockExperimentalVMOptions.");

if (Platform.isDebugBuild()) {
@@ -48,14 +49,17 @@ public static void main(String[] args) throws Exception {

pb = ProcessTools.createJavaProcessBuilder("-XX:+PrintInlining", "-version");
output = new OutputAnalyzer(pb.start());
output.shouldNotHaveExitValue(0);
output.shouldContain("Error: VM option 'PrintInlining' is diagnostic and must be enabled via -XX:+UnlockDiagnosticVMOptions.");

pb = ProcessTools.createJavaProcessBuilder("-XX:+VerifyStack", "-version");
output = new OutputAnalyzer(pb.start());
output.shouldNotHaveExitValue(0);
output.shouldContain("Error: VM option 'VerifyStack' is develop and is available only in debug version of VM.");

pb = ProcessTools.createJavaProcessBuilder("-XX:+CheckCompressedOops", "-version");
output = new OutputAnalyzer(pb.start());
output.shouldNotHaveExitValue(0);
output.shouldContain("Error: VM option 'CheckCompressedOops' is notproduct and is available only in debug version of VM.");
}
}

1 comment on commit 28dcaf3

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on 28dcaf3 Jan 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.