mirror of
https://github.com/openjdk/jdk.git
synced 2026-04-18 10:50:23 +00:00
8352046: Test testEcoFriendly() in jdk tools launcher ExecutionEnvironment.java for AIX and Linux/musl is brittle
Reviewed-by: clanger, mbaesken
This commit is contained in:
parent
ad48846edd
commit
196334fc39
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2009, 2025, 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
|
||||
@ -24,49 +24,27 @@
|
||||
/*
|
||||
* @test
|
||||
* @bug 4780570 4731671 6354700 6367077 6670965 4882974
|
||||
* @summary Checks for LD_LIBRARY_PATH and execution on *nixes
|
||||
* @requires os.family != "windows" & !vm.musl & os.family != "aix"
|
||||
* @summary Checks for LD_LIBRARY_PATH and execution on *nixes
|
||||
* @requires os.family != "windows"
|
||||
* @library /test/lib
|
||||
* @modules jdk.compiler
|
||||
* jdk.zipfs
|
||||
* @compile -XDignore.symbol.file ExecutionEnvironment.java
|
||||
* @run main/othervm -DexpandedLdLibraryPath=false ExecutionEnvironment
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 4780570 4731671 6354700 6367077 6670965 4882974
|
||||
* @summary Checks for LD_LIBRARY_PATH and execution on *nixes
|
||||
* @requires os.family == "aix" | vm.musl
|
||||
* @library /test/lib
|
||||
* @modules jdk.compiler
|
||||
* jdk.zipfs
|
||||
* @compile -XDignore.symbol.file ExecutionEnvironment.java
|
||||
* @run main/othervm -DexpandedLdLibraryPath=true ExecutionEnvironment
|
||||
* @run main/othervm ExecutionEnvironment
|
||||
*/
|
||||
|
||||
/*
|
||||
* This tests for various things as follows:
|
||||
* Ensures that:
|
||||
* 1. uneccessary execs do not occur
|
||||
* 1. unneccessary execs do not occur
|
||||
* 2. the environment is pristine, users environment variable wrt.
|
||||
* LD_LIBRARY_PATH if set are not modified in any way.
|
||||
* 3. the correct vm is chosen with -server and -client options
|
||||
* 4. the VM on Solaris correctly interprets the LD_LIBRARY_PATH32
|
||||
* and LD_LIBRARY_PATH64 variables if set by the user, ie.
|
||||
* i. on 32 bit systems:
|
||||
* a. if LD_LIBRARY_PATH32 is set it will override LD_LIBRARY_PATH
|
||||
* b. LD_LIBRARY_PATH64 is ignored if set
|
||||
* ii. on 64 bit systems:
|
||||
* a. if LD_LIBRARY_PATH64 is set it will override LD_LIBRARY_PATH
|
||||
* b. LD_LIBRARY_PATH32 is ignored if set
|
||||
* 5. no extra symlink exists on Solaris ie.
|
||||
* 4. no extra symlink exists i.e.
|
||||
* lib/$arch/libjvm.so -> client/libjvm.so
|
||||
* TODO:
|
||||
* a. perhaps we need to add a test to audit all environment variables are
|
||||
* in pristine condition after the launch, there may be a few that the
|
||||
* launcher may add as implementation details.
|
||||
* b. add a pldd for solaris to ensure only one libjvm.so is linked
|
||||
* perhaps we need to add a test to audit all environment variables are
|
||||
* in pristine condition after the launch, there may be a few that the
|
||||
* launcher may add as implementation details.
|
||||
*/
|
||||
|
||||
import jdk.test.lib.Platform;
|
||||
@ -83,7 +61,7 @@ public class ExecutionEnvironment extends TestHelper {
|
||||
static final String LD_LIBRARY_PATH_32 = LD_LIBRARY_PATH + "_32";
|
||||
static final String LD_LIBRARY_PATH_64 = LD_LIBRARY_PATH + "_64";
|
||||
|
||||
// Note: these paths need not exist on the filesytem
|
||||
// Note: these paths need not exist on the filesystem
|
||||
static final String LD_LIBRARY_PATH_VALUE = "/Bridge/On/The/River/Kwai";
|
||||
static final String LD_LIBRARY_PATH_32_VALUE = "/Lawrence/Of/Arabia";
|
||||
static final String LD_LIBRARY_PATH_64_VALUE = "/A/Passage/To/India";
|
||||
@ -131,8 +109,9 @@ public class ExecutionEnvironment extends TestHelper {
|
||||
System.err.println(tr);
|
||||
throw new RuntimeException(message);
|
||||
}
|
||||
|
||||
/*
|
||||
* tests if the launcher pollutes the LD_LIBRARY_PATH variables ie. there
|
||||
* tests if the launcher pollutes the LD_LIBRARY_PATH variables i.e. there
|
||||
* should not be any new variables or pollution/mutations of any kind, the
|
||||
* environment should be pristine.
|
||||
*/
|
||||
@ -153,19 +132,21 @@ public class ExecutionEnvironment extends TestHelper {
|
||||
|
||||
for (String x : LD_PATH_STRINGS) {
|
||||
if (!tr.contains(x)) {
|
||||
if (IS_EXPANDED_LD_LIBRARY_PATH && x.startsWith(LD_LIBRARY_PATH)) {
|
||||
if ((Platform.isAix() || Platform.isMusl()) && x.startsWith(LD_LIBRARY_PATH)) {
|
||||
// AIX does not support the '-rpath' linker options so the
|
||||
// launchers have to prepend the jdk library path to 'LIBPATH'.
|
||||
// The musl library loader requires LD_LIBRARY_PATH to be set in
|
||||
// order to correctly resolve the dependency libjava.so has on libjvm.so.
|
||||
String jvmroot = System.getProperty("java.home");
|
||||
String libPath = LD_LIBRARY_PATH + "=" +
|
||||
System.getenv(LD_LIBRARY_PATH) +
|
||||
System.getProperty("path.separator") + LD_LIBRARY_PATH_VALUE;
|
||||
jvmroot + "/lib/server" + System.getProperty("path.separator") +
|
||||
jvmroot + "/lib" + System.getProperty("path.separator") +
|
||||
jvmroot + "/../lib" + System.getProperty("path.separator") +
|
||||
LD_LIBRARY_PATH_VALUE;
|
||||
if (!tr.matches(libPath)) {
|
||||
flagError(tr, "FAIL: did not get <" + libPath + ">");
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
flagError(tr, "FAIL: did not get <" + x + ">");
|
||||
}
|
||||
}
|
||||
@ -215,23 +196,6 @@ public class ExecutionEnvironment extends TestHelper {
|
||||
}
|
||||
}
|
||||
|
||||
private void verifyJavaLibraryPathOverride(TestResult tr,
|
||||
boolean is32Bit) {
|
||||
// make sure the 32/64 bit value exists
|
||||
if (!tr.matches("java.library.path=.*" +
|
||||
(is32Bit ? LD_LIBRARY_PATH_32_VALUE : LD_LIBRARY_PATH_64_VALUE) + ".*")) {
|
||||
flagError(tr, "verifyJavaLibraryPathOverride: " +
|
||||
" java.library.path does not contain " +
|
||||
(is32Bit ? LD_LIBRARY_PATH_32_VALUE : LD_LIBRARY_PATH_64_VALUE));
|
||||
|
||||
}
|
||||
// make sure the generic value is absent
|
||||
if (!tr.notMatches("java.library.path=.*" + LD_LIBRARY_PATH_VALUE + ".*")) {
|
||||
flagError(tr, "verifyJavaLibraryPathOverride: " +
|
||||
" java.library.path contains " + LD_LIBRARY_PATH_VALUE);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* ensures we have indeed exec'ed the correct vm of choice if it exists
|
||||
*/
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user