Skip to content

Commit

Permalink
7903325: jtreg check for macos version should take into account the p…
Browse files Browse the repository at this point in the history
…rocess exit code

Reviewed-by: iris
  • Loading branch information
jonathan-gibbons committed Sep 23, 2022
1 parent 77650ff commit aeb552e
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/share/classes/com/sun/javatest/regtest/tool/Tool.java
Expand Up @@ -183,21 +183,29 @@ public static void main(String[] args) {
private static void checkJavaOSVersion() {
String osName = System.getProperty("os.name");
if (osName != null && osName.equals("Mac OS X")) {
var command = List.of("sw_vers", "-productVersion");
try {
String expectVersion;
Process p = new ProcessBuilder("sw_vers", "-productVersion")
Process p = new ProcessBuilder(command)
.redirectErrorStream(true)
.start();
try (InputStream in = p.getInputStream();
BufferedReader r = new BufferedReader(new InputStreamReader(in))) {
expectVersion = r.lines().collect(Collectors.joining());
}
p.waitFor();
int rc = p.exitValue();
if (rc != 0) {
System.err.println("Error getting OS version: "
+ String.join(" ", command) + ": rc=" + rc);
System.exit(99);
}

checkJavaOSVersion(expectVersion);

} catch (IOException | InterruptedException e) {
System.err.println("Error getting OS version: " + e);
System.err.println("Error getting OS version: "
+ String.join(" ", command) + ": " + e);
System.exit(99);
}
}
Expand Down

0 comments on commit aeb552e

Please sign in to comment.