Skip to content

Commit

Permalink
8252532: use Utils.TEST_NATIVE_PATH instead of System.getProperty("te…
Browse files Browse the repository at this point in the history
…st.nativepath")

Reviewed-by: phh
Backport-of: 4fe6a3d
  • Loading branch information
GoeLin committed Feb 27, 2023
1 parent efe4481 commit 83456c6
Show file tree
Hide file tree
Showing 8 changed files with 114 additions and 108 deletions.
2 changes: 1 addition & 1 deletion test/hotspot/jtreg/gtest/GTestWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public class GTestWrapper {
public static void main(String[] args) throws Throwable {
// gtestLauncher is located in <test_image>/hotspot/gtest/<vm_variant>/
// nativePath points either to <test_image>/hotspot/jtreg/native or to <test_image>/hotspot/gtest
Path nativePath = Paths.get(System.getProperty("test.nativepath"));
Path nativePath = Paths.get(Utils.TEST_NATIVE_PATH);
String jvmVariantDir = getJVMVariantSubDir();
// let's assume it's <test_image>/hotspot/gtest
Path path = nativePath.resolve(jvmVariantDir);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@
*
*/

import java.io.File;
import java.nio.file.Paths;
import java.time.Duration;

import jdk.test.lib.Utils;
import jdk.test.lib.process.ProcessTools;
import jdk.test.lib.process.OutputAnalyzer;

Expand All @@ -43,11 +40,9 @@
*/

public class HandshakeTransitionTest {

public static native void someTime(int ms);

public static void main(String[] args) throws Exception {
String lib = System.getProperty("test.nativepath");
WhiteBox wb = WhiteBox.getWhiteBox();
Boolean useJVMCICompiler = wb.getBooleanVMFlag("UseJVMCICompiler");
String useJVMCICompilerStr;
Expand All @@ -60,7 +55,7 @@ public static void main(String[] args) throws Exception {
ProcessBuilder pb =
ProcessTools.createJavaProcessBuilder(
true,
"-Djava.library.path=" + lib,
"-Djava.library.path=" + Utils.TEST_NATIVE_PATH,
"-XX:+SafepointALot",
"-XX:GuaranteedSafepointInterval=20",
"-Xlog:ergo*",
Expand All @@ -71,7 +66,6 @@ public static void main(String[] args) throws Exception {
useJVMCICompilerStr,
"HandshakeTransitionTest$Test");


OutputAnalyzer output = ProcessTools.executeProcess(pb);
output.reportDiagnosticSummary();
output.shouldHaveExitValue(0);
Expand Down
11 changes: 5 additions & 6 deletions test/hotspot/jtreg/runtime/jni/CalleeSavedRegisters/FPRegs.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2020, 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 All @@ -22,7 +22,7 @@
*
*/

/**
/*
* @test
* @bug 8067744
* @comment Test uses custom launcher that starts VM in primordial thread. This is
Expand All @@ -35,7 +35,6 @@

import jdk.test.lib.Platform;
import jdk.test.lib.Utils;
import jdk.test.lib.process.ProcessTools;
import jdk.test.lib.process.OutputAnalyzer;

import java.io.File;
Expand All @@ -47,14 +46,14 @@

public class FPRegs {
public static void main(String[] args) throws IOException {
Path launcher = Paths.get(System.getProperty("test.nativepath"), "FPRegs" + (Platform.isWindows() ? ".exe" : ""));
Path launcher = Paths.get(Utils.TEST_NATIVE_PATH, "FPRegs" + (Platform.isWindows() ? ".exe" : ""));
System.out.println("Launcher = " + launcher + (Files.exists(launcher) ? " (exists)" : " (not exists)"));
Path jvmLib = findJVM();
ProcessBuilder pb = new ProcessBuilder(launcher.toString(), jvmLib.toString());
// bin as working directory to let Windows load dll
pb.directory(jvmLib.getParent().getParent().toFile());
OutputAnalyzer outputf = new OutputAnalyzer(pb.start());
outputf.shouldHaveExitValue(0);
OutputAnalyzer oa = new OutputAnalyzer(pb.start());
oa.shouldHaveExitValue(0);
}

static Path findJVM() throws IOException {
Expand Down
4 changes: 3 additions & 1 deletion test/hotspot/jtreg/runtime/jni/atExit/TestAtExit.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

import jdk.test.lib.Utils;
import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.process.ProcessTools;

Expand Down Expand Up @@ -57,7 +59,7 @@ public static void main(String[] args) throws Exception {
// We mustn't load Tester in this VM so we exec by name.
String main = "TestAtExit$Tester";

String jlp = "-Djava.library.path=" + System.getProperty("test.nativepath");
String jlp = "-Djava.library.path=" + Utils.TEST_NATIVE_PATH;
// First run will terminate via DestroyJavaVM
OutputAnalyzer output = ProcessTools.executeTestJvm(jlp, main);
output.shouldNotContain("Unexpected");
Expand Down
15 changes: 8 additions & 7 deletions test/hotspot/jtreg/runtime/signal/SigTestDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public static void main(String[] args) {
}

// At least one argument should be specified
if ( (args == null) || (args.length < 1) ) {
if ((args == null) || (args.length < 1)) {
throw new IllegalArgumentException("At lease one argument should be specified, the signal name");
}

Expand All @@ -65,7 +65,7 @@ public static void main(String[] args) {
}
}

Path test = Paths.get(System.getProperty("test.nativepath"))
Path test = Paths.get(Utils.TEST_NATIVE_PATH)
.resolve("sigtest")
.toAbsolutePath();
String envVar = Platform.sharedLibraryPathVariableName();
Expand All @@ -87,16 +87,17 @@ public static void main(String[] args) {
cmd.addAll(vmargs());

// add test specific arguments w/o signame
cmd.addAll(Arrays.asList(args)
.subList(1, args.length));
var argList = Arrays.asList(args)
.subList(1, args.length);
cmd.addAll(argList);

boolean passed = true;

for (String mode : new String[]{"sigset", "sigaction"}) {
for (String mode : new String[] {"sigset", "sigaction"}) {
for (String scenario : new String[] {"nojvm", "prepre", "prepost", "postpre", "postpost"}) {
cmd.set(modeIdx, mode);
cmd.set(scenarioIdx, scenario);
System.out.printf("START TESTING: SIGNAL = %s, MODE = %s, SCENARIO=%s%n",signame, mode, scenario);
System.out.printf("START TESTING: SIGNAL = %s, MODE = %s, SCENARIO=%s%n", signame, mode, scenario);
System.out.printf("Do execute: %s%n", cmd.toString());

ProcessBuilder pb = new ProcessBuilder(cmd);
Expand All @@ -117,7 +118,7 @@ public static void main(String[] args) {
oa.reportDiagnosticSummary();
int exitCode = oa.getExitValue();
if (exitCode == 0) {
System.out.println("PASSED with exit code 0");
System.out.println("PASSED with exit code 0");
} else {
System.out.println("FAILED with exit code " + exitCode);
passed = false;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2020, 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 All @@ -20,9 +20,15 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import java.nio.file.Paths;
import jdk.test.lib.dcmd.*;

import jdk.test.lib.Platform;
import jdk.test.lib.Utils;
import jdk.test.lib.dcmd.CommandExecutor;
import jdk.test.lib.dcmd.JMXExecutor;
import jdk.test.lib.dcmd.PidJcmdExecutor;

import java.nio.file.Paths;

import org.testng.annotations.Test;

public abstract class AttachFailedTestBase {
Expand All @@ -42,18 +48,18 @@ public static String getSharedObjectPath(String name) {
libname = "lib" + name + ".so";
}

return Paths.get(System.getProperty("test.nativepath"), libname)
return Paths.get(Utils.TEST_NATIVE_PATH, libname)
.toAbsolutePath()
.toString();
}

@Test
public void jmx() throws Throwable {
public void jmx() {
run(new JMXExecutor());
}

@Test
public void cli() throws Throwable {
public void cli() {
run(new PidJcmdExecutor());
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2020, 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 All @@ -24,6 +24,7 @@
package nsk.jvmti;

import jdk.test.lib.Platform;
import jdk.test.lib.Utils;

import java.io.IOException;
import java.nio.file.Files;
Expand All @@ -32,7 +33,7 @@

public class NativeLibraryCopier {
public static void main(String[] args) {
Path src = Paths.get( System.getProperty("test.nativepath", "."))
Path src = Paths.get(Utils.TEST_NATIVE_PATH)
.resolve(libname(args[0]))
.toAbsolutePath();

Expand Down
Loading

1 comment on commit 83456c6

@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.