Skip to content

Commit

Permalink
8216265: [testbug] Introduce Platform.sharedLibraryPathVariableName()…
Browse files Browse the repository at this point in the history
… and adapt all tests.

Also cleanup some switches over OSes and use File.pathSeparator.

Reviewed-by: mdoerr
Backport-of: 084f0b7
  • Loading branch information
GoeLin committed May 3, 2022
1 parent ed29dca commit 2787100
Show file tree
Hide file tree
Showing 60 changed files with 134 additions and 167 deletions.
11 changes: 4 additions & 7 deletions test/hotspot/jtreg/gtest/GTestWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import java.util.stream.Stream;
import java.util.stream.Collectors;

import java.io.File;
import java.nio.file.Paths;
import java.nio.file.Path;

Expand Down Expand Up @@ -70,14 +71,10 @@ public static void main(String[] args) throws Throwable {
// may have set LD_LIBRARY_PATH or LIBPATH to point to the jdk libjvm. In
// that case, prepend the path with the location of the gtest library."

String ldLibraryPath = System.getenv("LD_LIBRARY_PATH");
String pathVar = Platform.sharedLibraryPathVariableName();
String ldLibraryPath = System.getenv(pathVar);
if (ldLibraryPath != null) {
env.put("LD_LIBRARY_PATH", path + ":" + ldLibraryPath);
}

String libPath = System.getenv("LIBPATH");
if (libPath != null) {
env.put("LIBPATH", path + ":" + libPath);
env.put(pathVar, path + File.pathSeparator + ldLibraryPath);
}

pb.command(new String[] {
Expand Down
5 changes: 2 additions & 3 deletions test/hotspot/jtreg/runtime/signal/SigTestDriver.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2019, 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 @@ -68,8 +68,7 @@ public static void main(String[] args) {
Path test = Paths.get(System.getProperty("test.nativepath"))
.resolve("sigtest")
.toAbsolutePath();
String envVar = Platform.isWindows() ? "PATH" :
(Platform.isOSX() ? "DYLD_LIBRARY_PATH" : "LD_LIBRARY_PATH");
String envVar = Platform.sharedLibraryPathVariableName();

List<String> cmd = new ArrayList<>();
Collections.addAll(cmd,
Expand Down
6 changes: 2 additions & 4 deletions test/hotspot/jtreg/vmTestbase/ExecDriver.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2019, 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 @@ -103,7 +103,7 @@ public static void main(String[] args) throws IOException, InterruptedException
if (launcher) {
Path dir = Paths.get(Utils.TEST_JDK);
String value;
String name;
String name = Platform.sharedLibraryPathVariableName();
if (Platform.isWindows()) {
value = dir.resolve("bin")
.resolve(variant())
Expand All @@ -113,13 +113,11 @@ public static void main(String[] args) throws IOException, InterruptedException
value += dir.resolve("bin")
.toAbsolutePath()
.toString();
name = "PATH";
} else {
value = dir.resolve("lib")
.resolve(variant())
.toAbsolutePath()
.toString();
name = Platform.isOSX() ? "DYLD_LIBRARY_PATH" : "LD_LIBRARY_PATH";
}

System.out.println(" with " + name + " = " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,7 @@ public static void main(String[] args) throws Exception {
nsk.jvmti.RetransformClasses.retransform003.class.getName()
);

String envName;
if (Platform.isWindows()) {
envName = "PATH";
} else if (Platform.isOSX()) {
envName = "DYLD_LIBRARY_PATH";
} else if (Platform.isAix()) {
envName = "LIBPATH";
} else {
envName = "LD_LIBRARY_PATH";
}

String envName = Platform.sharedLibraryPathVariableName();
pb.environment()
.merge(envName, ".", (x, y) -> y + File.pathSeparator + x);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,7 @@ public static void main(String[] args) throws Exception {
nsk.jvmti.SetNativeMethodPrefix.SetNativeMethodPrefix002.class.getName()
);

String envName;
if (Platform.isWindows()) {
envName = "PATH";
} else if (Platform.isOSX()) {
envName = "DYLD_LIBRARY_PATH";
} else if (Platform.isAix()) {
envName = "LIBPATH";
} else {
envName = "LD_LIBRARY_PATH";
}

String envName = Platform.sharedLibraryPathVariableName();
pb.environment()
.merge(envName, ".", (x, y) -> y + File.pathSeparator + x);

Expand Down
17 changes: 5 additions & 12 deletions test/jdk/com/sun/jdi/PrivateTransportTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2019, 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 @@ -33,10 +33,12 @@
* @run main/othervm PrivateTransportTest
*/

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

import java.io.IOException;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
Expand Down Expand Up @@ -71,17 +73,8 @@ private PrivateTransportTest() throws IOException {
}
transportLib = foundLib.get();
}
if (System.getProperty("os.name").startsWith("Windows")) {
pathSep = ";";
pathEnvVar = "PATH";
} else {
pathSep = ":";
if (System.getProperty("os.name").equals("AIX")) {
pathEnvVar = "LIBPATH";
} else {
pathEnvVar = "LD_LIBRARY_PATH";
}
}
pathEnvVar = Platform.sharedLibraryPathVariableName();
pathSep = File.pathSeparator;
}

private void test() throws Throwable {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2018 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2019, 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 @@ -67,7 +67,7 @@ public class InheritedChannelTest {
private static final String ARCH = System.getProperty("os.arch");
private static final String OS_ARCH = ARCH.equals("i386") ? "i586" : ARCH;

private static final Path LD_LIBRARY_PATH
private static final Path libraryPath
= Paths.get(System.getProperty("java.library.path"));

@DataProvider
Expand Down Expand Up @@ -97,7 +97,8 @@ public Object[][] testCases() {

@Test(dataProvider = "testCases")
public void test(String desc, List<String> opts) throws Throwable {
System.out.println("LD_LIBRARY_PATH=" + LD_LIBRARY_PATH);
String pathVar = Platform.sharedLibraryPathVariableName();
System.out.println(pathVar + "=" + libraryPath);

List<String> args = new ArrayList<>();
args.add(JDKToolFinder.getJDKTool("java"));
Expand All @@ -110,9 +111,8 @@ public void test(String desc, List<String> opts) throws Throwable {

Map<String, String> env = pb.environment();
env.put("CLASSPATH", TEST_CLASSES);
env.put("LD_LIBRARY_PATH", LD_LIBRARY_PATH.toString());
env.put(pathVar, libraryPath.toString());

ProcessTools.executeCommand(pb)
.shouldHaveExitValue(0);
ProcessTools.executeCommand(pb).shouldHaveExitValue(0);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2019, 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 @@ -26,7 +26,7 @@
* @bug 8043758
* @summary Testing DTLS buffer overflow and underflow status when dealing with
* application data.
* @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon
* @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon /test/lib
* @modules java.security.jgss
* jdk.security.auth
* java.base/sun.security.util
Expand Down
4 changes: 2 additions & 2 deletions test/jdk/javax/net/ssl/DTLS/DTLSDataExchangeTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2019, 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 @@ -26,7 +26,7 @@
* @bug 8043758
* @summary Testing DTLS application data exchange using each of the supported
* cipher suites.
* @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon
* @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon /test/lib
* @modules java.security.jgss
* jdk.security.auth
* java.security.jgss/sun.security.jgss.krb5
Expand Down
4 changes: 2 additions & 2 deletions test/jdk/javax/net/ssl/DTLS/DTLSEnginesClosureTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2019, 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 @@ -26,7 +26,7 @@
* @bug 8043758
* @summary Testing DTLS engines closing using each of the supported
* cipher suites.
* @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon
* @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon /test/lib
* @modules java.security.jgss
* jdk.security.auth
* java.security.jgss/sun.security.jgss.krb5
Expand Down
4 changes: 2 additions & 2 deletions test/jdk/javax/net/ssl/DTLS/DTLSHandshakeTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2019, 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 @@ -26,7 +26,7 @@
* @bug 8043758
* @summary Testing DTLS engines handshake using each of the supported
* cipher suites.
* @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon
* @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon /test/lib
* @modules java.security.jgss
* jdk.security.auth
* java.security.jgss/sun.security.jgss.krb5
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2019, 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 @@ -26,7 +26,7 @@
* @bug 8043758
* @summary Testing DTLS engines handshake using each of the supported
* cipher suites with replicated packets check.
* @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon
* @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon /test/lib
* @modules java.security.jgss
* jdk.security.auth
* java.security.jgss/sun.security.jgss.krb5
Expand Down
4 changes: 2 additions & 2 deletions test/jdk/javax/net/ssl/DTLS/DTLSMFLNTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2019, 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 @@ -27,7 +27,7 @@
* @summary Testing DTLS engines handshake using each of the supported
* cipher suites with different maximum fragment length. Testing of
* MFLN extension.
* @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon
* @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon /test/lib
* @modules java.security.jgss
* jdk.security.auth
* java.security.jgss/sun.security.jgss.krb5
Expand Down
4 changes: 2 additions & 2 deletions test/jdk/javax/net/ssl/DTLS/DTLSNotEnabledRC4Test.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2019, 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 @@ -25,7 +25,7 @@
* @test
* @bug 8043758
* @summary Testing DTLS engines do not enable RC4 ciphers by default.
* @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon
* @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon /test/lib
* @modules java.security.jgss
* java.security.jgss/sun.security.jgss.krb5
* java.security.jgss/sun.security.krb5:+open
Expand Down
4 changes: 2 additions & 2 deletions test/jdk/javax/net/ssl/DTLS/DTLSRehandshakeTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2019, 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 @@ -26,7 +26,7 @@
* @bug 8043758
* @summary Testing DTLS engines re-handshaking using each of the supported
* cipher suites.
* @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon
* @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon /test/lib
* @modules java.security.jgss
* jdk.security.auth
* java.security.jgss/sun.security.jgss.krb5
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2019, 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 @@ -27,7 +27,7 @@
* @summary Testing DTLS engines re-handshaking using each of the supported
* cipher suites with application data exchange before and after
* re-handshake and closing of the engines.
* @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon
* @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon /test/lib
* @modules java.security.jgss
* jdk.security.auth
* java.security.jgss/sun.security.jgss.krb5
Expand Down
4 changes: 2 additions & 2 deletions test/jdk/javax/net/ssl/DTLS/DTLSUnsupportedCiphersTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2019, 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 @@ -26,7 +26,7 @@
* @bug 8043758
* @summary Testing that try to enable unsupported ciphers
* causes IllegalArgumentException.
* @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon
* @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon /test/lib
* @modules java.security.jgss
* java.security.jgss/sun.security.jgss.krb5
* java.security.jgss/sun.security.krb5:+open
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2019, 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 @@ -26,7 +26,7 @@
* @bug 8043758
* @summary Testing DTLS buffer overflow and underflow status when dealing with
* application data.
* @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon
* @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon /test/lib
* @modules java.security.jgss
* jdk.security.auth
* java.security.jgss/sun.security.jgss.krb5
Expand Down
4 changes: 2 additions & 2 deletions test/jdk/javax/net/ssl/DTLSv10/DTLSv10DataExchangeTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2019, 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 @@ -26,7 +26,7 @@
* @bug 8043758
* @summary Testing DTLS application data exchange using each of the supported
* cipher suites.
* @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon
* @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon /test/lib
* @modules java.security.jgss
* jdk.security.auth
* java.security.jgss/sun.security.jgss.krb5
Expand Down
4 changes: 2 additions & 2 deletions test/jdk/javax/net/ssl/DTLSv10/DTLSv10EnginesClosureTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2019, 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 @@ -26,7 +26,7 @@
* @bug 8043758
* @summary Testing DTLS engines closing using each of the supported
* cipher suites.
* @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon
* @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon /test/lib
* @modules java.security.jgss
* jdk.security.auth
* java.security.jgss/sun.security.jgss.krb5
Expand Down
Loading

1 comment on commit 2787100

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