Skip to content

Commit

Permalink
8322324: java/foreign/TestStubAllocFailure.java times out while waiti…
Browse files Browse the repository at this point in the history
…ng for forked process

8322637: java/foreign/critical/TestCriticalUpcall.java timed out

Reviewed-by: mcimadamore
  • Loading branch information
JornVernee committed Jan 10, 2024
1 parent b2a39c5 commit d2d58dd
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions test/jdk/java/foreign/UpcallTestHelper.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2022, 2024, 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
Expand Down Expand Up @@ -29,8 +29,9 @@
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;

public class UpcallTestHelper extends NativeTestHelper {

Expand All @@ -50,16 +51,18 @@ public OutputAnalyzer runInNewProcess(Class<?> target, boolean useSpec, List<Str
command.add(target.getName());
command.addAll(programArgs);

Process process = ProcessTools.createTestJavaProcessBuilder(command).start();

long timeOut = (long) (Utils.TIMEOUT_FACTOR * 1L);
boolean completed = process.waitFor(timeOut, TimeUnit.MINUTES);
assertTrue(completed, "Time out while waiting for process");

OutputAnalyzer output = new OutputAnalyzer(process);
output.outputTo(System.out);
output.errorTo(System.err);

return output;
try {
ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(command);
// note that it's important to use ProcessTools.startProcess here since this makes sure output streams of the
// fork don't fill up, which could make the process stall while writing to stdout/stderr
Process process = ProcessTools.startProcess(target.getName(), pb, null, null, 1L, TimeUnit.MINUTES);
OutputAnalyzer output = new OutputAnalyzer(process);
output.outputTo(System.out);
output.errorTo(System.err);
return output;
} catch (TimeoutException e) {
fail("Timeout while waiting for forked process");
return null;
}
}
}

1 comment on commit d2d58dd

@openjdk-notifier
Copy link

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.