Skip to content
Permalink
Browse files
8216265: [testbug] Introduce Platform.sharedLibraryPathVariableName()…
… 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 2787100896d83cc30282d70f24c5250cd8b6f318
Showing 60 changed files with 134 additions and 167 deletions.
@@ -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;

@@ -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[] {
@@ -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
@@ -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,
@@ -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
@@ -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())
@@ -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 + " = " +
@@ -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);

@@ -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);

@@ -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
@@ -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;
@@ -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 {
@@ -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
@@ -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
@@ -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"));
@@ -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);
}
}
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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

1 comment on commit 2787100

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on 2787100 May 3, 2022

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.