Skip to content

Commit d2d58dd

Browse files
committedJan 10, 2024
8322324: java/foreign/TestStubAllocFailure.java times out while waiting for forked process
8322637: java/foreign/critical/TestCriticalUpcall.java timed out Reviewed-by: mcimadamore
1 parent b2a39c5 commit d2d58dd

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed
 

‎test/jdk/java/foreign/UpcallTestHelper.java

+16-13
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -29,8 +29,9 @@
2929
import java.util.ArrayList;
3030
import java.util.List;
3131
import java.util.concurrent.TimeUnit;
32+
import java.util.concurrent.TimeoutException;
3233

33-
import static org.testng.Assert.assertTrue;
34+
import static org.testng.Assert.fail;
3435

3536
public class UpcallTestHelper extends NativeTestHelper {
3637

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

53-
Process process = ProcessTools.createTestJavaProcessBuilder(command).start();
54-
55-
long timeOut = (long) (Utils.TIMEOUT_FACTOR * 1L);
56-
boolean completed = process.waitFor(timeOut, TimeUnit.MINUTES);
57-
assertTrue(completed, "Time out while waiting for process");
58-
59-
OutputAnalyzer output = new OutputAnalyzer(process);
60-
output.outputTo(System.out);
61-
output.errorTo(System.err);
62-
63-
return output;
54+
try {
55+
ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(command);
56+
// note that it's important to use ProcessTools.startProcess here since this makes sure output streams of the
57+
// fork don't fill up, which could make the process stall while writing to stdout/stderr
58+
Process process = ProcessTools.startProcess(target.getName(), pb, null, null, 1L, TimeUnit.MINUTES);
59+
OutputAnalyzer output = new OutputAnalyzer(process);
60+
output.outputTo(System.out);
61+
output.errorTo(System.err);
62+
return output;
63+
} catch (TimeoutException e) {
64+
fail("Timeout while waiting for forked process");
65+
return null;
66+
}
6467
}
6568
}

0 commit comments

Comments
 (0)
Please sign in to comment.