Mercurial > hg > openjdk > jdk9
changeset 2327:281a14e87a3b
8168414: Various timeouthandler fixes
Reviewed-by: mlarsson
author | sla |
---|---|
date | Mon, 24 Oct 2016 09:12:40 +0200 |
parents | 49aa366f9afc |
children | eeb794d72bbf |
files | test/failure_handler/Makefile test/failure_handler/src/share/classes/jdk/test/failurehandler/action/ActionHelper.java |
diffstat | 2 files changed, 23 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/test/failure_handler/Makefile Fri Oct 21 15:40:47 2016 +0200 +++ b/test/failure_handler/Makefile Mon Oct 24 09:12:40 2016 +0200 @@ -86,7 +86,7 @@ test: require_env build rm -rf "${RUN_DIR}" mkdir -p "${RUN_DIR}" - "${JTREG_HOME}"/bin/jtreg \ + "${JTREG_HOME}"/bin/jtreg \ -jdk:"${JAVA_HOME}" \ ${JTREG_TEST_OPTS} \ -timeout:0.1 -va -retain:all \ @@ -94,6 +94,7 @@ -agentvm \ -thd:"${TARGET_JAR}" \ -th:jdk.test.failurehandler.jtreg.GatherProcessInfoTimeoutHandler \ + -thtimeout:0 \ -od:"${TARGET_JAR}" \ -o:jdk.test.failurehandler.jtreg.GatherDiagnosticInfoObserver \ -w:"${RUN_DIR}/JTwork" \
--- a/test/failure_handler/src/share/classes/jdk/test/failurehandler/action/ActionHelper.java Fri Oct 21 15:40:47 2016 +0200 +++ b/test/failure_handler/src/share/classes/jdk/test/failurehandler/action/ActionHelper.java Mon Oct 24 09:12:40 2016 +0200 @@ -164,7 +164,8 @@ Stopwatch stopwatch = new Stopwatch(); stopwatch.start(); - log.printf("%s%n[%tF %<tT] %s%n%1$s%n", line, new Date(), pb.command()); + log.printf("%s%n[%tF %<tT] %s timeout=%s%n%1$s%n", line, new Date(), pb.command(), params.timeout); + Process process; KillerTask killer; @@ -178,30 +179,28 @@ out); try { result = new ExitCode(process.waitFor()); + } catch (InterruptedException e) { + log.println("WARNING: interrupted when waiting for the tool:%n"); + e.printStackTrace(log); + } finally { killer.cancel(); - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - if (!killer.cancel()) { - log.println( - "WARNING: interrupted when waiting for the tool:"); - e.printStackTrace(log); - } } if (killer.hasTimedOut()) { log.printf( "WARNING: tool timed out: killed process after %d ms%n", - TimeUnit.MILLISECONDS.toMicros(params.timeout)); + params.timeout); result = ExitCode.TIMED_OUT; } } catch (IOException e) { + log.printf("WARNING: caught IOException while running tool%n"); e.printStackTrace(log); result = ExitCode.LAUNCH_ERROR; } stopwatch.stop(); - log.printf("%s%n[%tF %<tT] exit code : %d time : %d ms%n%1$s%n", + log.printf("%s%n[%tF %<tT] exit code: %d time: %d ms%n%1$s%n", line, new Date(), result.value, - TimeUnit.MILLISECONDS.toSeconds(stopwatch.getElapsedTimeNs())); + TimeUnit.NANOSECONDS.toMillis(stopwatch.getElapsedTimeNs())); return result; } @@ -247,7 +246,7 @@ log.printf("WARNING: can't run jps : %s%n", e.getMessage()); e.printStackTrace(log); } catch (InterruptedException e) { - Thread.currentThread().interrupt(); + log.printf("WARNING: interrupted%n"); e.printStackTrace(log); } return result; @@ -266,8 +265,7 @@ try { process.exitValue(); } catch (IllegalThreadStateException e) { - // !prepareProcess.isAlive() - process.destroy(); + process.destroyForcibly(); timedOut = true; } } @@ -301,11 +299,15 @@ exitCode.value); break; } - try { - Thread.sleep(params.pause); - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - e.printStackTrace(sectionWriter); + // sleep, if this is not the last iteration + if (i < n - 1) { + try { + Thread.sleep(params.pause); + } catch (InterruptedException e) { + sectionWriter.printf( + "WARNING: interrupted while sleeping between invocations"); + e.printStackTrace(sectionWriter); + } } } } else {