8204577: jittester generator doesn't kill processes on timeout
authoriignatyev
Thu, 07 Jun 2018 17:10:23 -0700
changeset 50454 d134badc8a42
parent 50453 f91927a2c8d3
child 50455 2b73cce96dce
8204577: jittester generator doesn't kill processes on timeout Reviewed-by: kvn, epavlova
test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/TestsGenerator.java
--- a/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/TestsGenerator.java	Thu Jun 07 16:06:49 2018 -0700
+++ b/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/TestsGenerator.java	Thu Jun 07 17:10:23 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2018, 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
@@ -37,6 +37,7 @@
 import jdk.test.lib.jittester.utils.PseudoRandom;
 
 public abstract class TestsGenerator implements BiConsumer<IRNode, IRNode> {
+    private static final int DEFAULT_JTREG_TIMEOUT = 120;
     protected static final String JAVA_BIN = getJavaPath();
     protected static final String JAVAC = Paths.get(JAVA_BIN, "javac").toString();
     protected static final String JAVA = Paths.get(JAVA_BIN, "java").toString();
@@ -73,15 +74,17 @@
         pb.redirectError(new File(name + ".err"));
         pb.redirectOutput(new File(name + ".out"));
         Process process = pb.start();
-        if (process.waitFor(Automatic.MINUTES_TO_WAIT, TimeUnit.MINUTES)) {
-            try (FileWriter file = new FileWriter(name + ".exit")) {
-                file.write(Integer.toString(process.exitValue()));
+        try {
+            if (process.waitFor(DEFAULT_JTREG_TIMEOUT, TimeUnit.SECONDS)) {
+                try (FileWriter file = new FileWriter(name + ".exit")) {
+                    file.write(Integer.toString(process.exitValue()));
+                }
+                return process.exitValue();
             }
-            return process.exitValue();
-        } else {
+        } finally {
             process.destroyForcibly();
-            return -1;
         }
+        return -1;
     }
 
     protected static void compilePrinter() {