8319571: Update jni/nullCaller/NullCallerTest.java to accept flags or mark as flagless

Reviewed-by: mchung
This commit is contained in:
Tim Prinzing 2024-01-11 17:37:30 +00:00 committed by Mandy Chung
parent e10d14004f
commit b78896b9aa

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -37,17 +37,15 @@
// Test disabled on AIX since we cannot invoke the JVM on the primordial thread. // Test disabled on AIX since we cannot invoke the JVM on the primordial thread.
import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.List; import java.util.List;
import java.util.Properties;
import jdk.test.lib.Platform; import jdk.test.lib.Platform;
import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.compiler.CompilerUtils; import jdk.test.lib.compiler.CompilerUtils;
import jdk.test.lib.process.ProcessTools;
public class NullCallerTest { public class NullCallerTest {
@ -87,28 +85,10 @@ public class NullCallerTest {
// build the module used for the test // build the module used for the test
compileTestModule(); compileTestModule();
var launcher = Path.of(System.getProperty("test.nativepath"), "NullCallerTest"); ProcessBuilder pb = ProcessTools.createNativeTestProcessBuilder("NullCallerTest");
var pb = new ProcessBuilder(launcher.toString()); System.out.println("Launching: " + pb.command() + " shared library path: " +
var env = pb.environment(); pb.environment().get(Platform.sharedLibraryPathVariableName()));
ProcessTools.executeProcess(pb).shouldHaveExitValue(0);
var libDir = Platform.libDir().toString();
var vmDir = Platform.jvmLibDir().toString();
// set up shared library path
var sharedLibraryPathEnvName = Platform.sharedLibraryPathVariableName();
env.compute(sharedLibraryPathEnvName,
(k, v) -> (v == null) ? libDir : v + File.pathSeparator + libDir);
env.compute(sharedLibraryPathEnvName,
(k, v) -> (v == null) ? vmDir : v + File.pathSeparator + vmDir);
// launch the actual test
System.out.println("Launching: " + launcher + " shared library path: " +
env.get(sharedLibraryPathEnvName));
new OutputAnalyzer(pb.start())
.outputTo(System.out)
.errorTo(System.err)
.shouldHaveExitValue(0);
} }
} }