8314330: java/foreign tests should respect vm flags when start new processes

Reviewed-by: jvernee
This commit is contained in:
Leonid Mesnik 2023-08-16 17:49:38 +00:00
parent b32d6411c4
commit 7b28d3608a

View File

@ -21,13 +21,12 @@
* questions. * questions.
*/ */
import jdk.test.lib.Utils; import jdk.test.lib.process.ProcessTools;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.nio.file.Paths;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
@ -57,22 +56,15 @@ public class UpcallTestHelper extends NativeTestHelper {
assert !target.isArray(); assert !target.isArray();
List<String> command = new ArrayList<>(List.of( List<String> command = new ArrayList<>(List.of(
Paths.get(Utils.TEST_JDK)
.resolve("bin")
.resolve("java")
.toAbsolutePath()
.toString(),
"--enable-preview", "--enable-preview",
"--enable-native-access=ALL-UNNAMED", "--enable-native-access=ALL-UNNAMED",
"-Djava.library.path=" + System.getProperty("java.library.path"), "-Djava.library.path=" + System.getProperty("java.library.path"),
"-Djdk.internal.foreign.UpcallLinker.USE_SPEC=" + useSpec, "-Djdk.internal.foreign.UpcallLinker.USE_SPEC=" + useSpec,
"-cp", Utils.TEST_CLASS_PATH,
target.getName() target.getName()
)); ));
command.addAll(Arrays.asList(programArgs)); command.addAll(Arrays.asList(programArgs));
Process process = new ProcessBuilder()
.command(command) Process process = ProcessTools.createTestJvm(command).start();
.start();
int result = process.waitFor(); int result = process.waitFor();
assertNotEquals(result, 0); assertNotEquals(result, 0);