1
1
/*
2
- * Copyright (c) 2009, 2020 , Oracle and/or its affiliates. All rights reserved.
2
+ * Copyright (c) 2009, 2025 , Oracle and/or its affiliates. All rights reserved.
3
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
4
*
5
5
* This code is free software; you can redistribute it and/or modify it
24
24
/*
25
25
* @test
26
26
* @bug 4780570 4731671 6354700 6367077 6670965 4882974
27
- * @summary Checks for LD_LIBRARY_PATH and execution on *nixes
28
- * @requires os.family != "windows" & !vm.musl & os.family != "aix"
27
+ * @summary Checks for LD_LIBRARY_PATH and execution on *nixes
28
+ * @requires os.family != "windows"
29
29
* @library /test/lib
30
30
* @modules jdk.compiler
31
31
* jdk.zipfs
32
- * @compile -XDignore.symbol.file ExecutionEnvironment.java
33
- * @run main/othervm -DexpandedLdLibraryPath=false ExecutionEnvironment
34
- */
35
-
36
- /*
37
- * @test
38
- * @bug 4780570 4731671 6354700 6367077 6670965 4882974
39
- * @summary Checks for LD_LIBRARY_PATH and execution on *nixes
40
- * @requires os.family == "aix" | vm.musl
41
- * @library /test/lib
42
- * @modules jdk.compiler
43
- * jdk.zipfs
44
- * @compile -XDignore.symbol.file ExecutionEnvironment.java
45
- * @run main/othervm -DexpandedLdLibraryPath=true ExecutionEnvironment
32
+ * @run main/othervm ExecutionEnvironment
46
33
*/
47
34
48
35
/*
49
36
* This tests for various things as follows:
50
37
* Ensures that:
51
- * 1. uneccessary execs do not occur
38
+ * 1. unneccessary execs do not occur
52
39
* 2. the environment is pristine, users environment variable wrt.
53
40
* LD_LIBRARY_PATH if set are not modified in any way.
54
41
* 3. the correct vm is chosen with -server and -client options
55
- * 4. the VM on Solaris correctly interprets the LD_LIBRARY_PATH32
56
- * and LD_LIBRARY_PATH64 variables if set by the user, ie.
57
- * i. on 32 bit systems:
58
- * a. if LD_LIBRARY_PATH32 is set it will override LD_LIBRARY_PATH
59
- * b. LD_LIBRARY_PATH64 is ignored if set
60
- * ii. on 64 bit systems:
61
- * a. if LD_LIBRARY_PATH64 is set it will override LD_LIBRARY_PATH
62
- * b. LD_LIBRARY_PATH32 is ignored if set
63
- * 5. no extra symlink exists on Solaris ie.
42
+ * 4. no extra symlink exists i.e.
64
43
* lib/$arch/libjvm.so -> client/libjvm.so
65
44
* TODO:
66
- * a. perhaps we need to add a test to audit all environment variables are
67
- * in pristine condition after the launch, there may be a few that the
68
- * launcher may add as implementation details.
69
- * b. add a pldd for solaris to ensure only one libjvm.so is linked
45
+ * perhaps we need to add a test to audit all environment variables are
46
+ * in pristine condition after the launch, there may be a few that the
47
+ * launcher may add as implementation details.
70
48
*/
71
49
72
50
import jdk .test .lib .Platform ;
@@ -83,7 +61,7 @@ public class ExecutionEnvironment extends TestHelper {
83
61
static final String LD_LIBRARY_PATH_32 = LD_LIBRARY_PATH + "_32" ;
84
62
static final String LD_LIBRARY_PATH_64 = LD_LIBRARY_PATH + "_64" ;
85
63
86
- // Note: these paths need not exist on the filesytem
64
+ // Note: these paths need not exist on the filesystem
87
65
static final String LD_LIBRARY_PATH_VALUE = "/Bridge/On/The/River/Kwai" ;
88
66
static final String LD_LIBRARY_PATH_32_VALUE = "/Lawrence/Of/Arabia" ;
89
67
static final String LD_LIBRARY_PATH_64_VALUE = "/A/Passage/To/India" ;
@@ -131,8 +109,9 @@ private void flagError(TestResult tr, String message) {
131
109
System .err .println (tr );
132
110
throw new RuntimeException (message );
133
111
}
112
+
134
113
/*
135
- * tests if the launcher pollutes the LD_LIBRARY_PATH variables ie . there
114
+ * tests if the launcher pollutes the LD_LIBRARY_PATH variables i.e . there
136
115
* should not be any new variables or pollution/mutations of any kind, the
137
116
* environment should be pristine.
138
117
*/
@@ -153,19 +132,21 @@ void testEcoFriendly() {
153
132
154
133
for (String x : LD_PATH_STRINGS ) {
155
134
if (!tr .contains (x )) {
156
- if (IS_EXPANDED_LD_LIBRARY_PATH && x .startsWith (LD_LIBRARY_PATH )) {
135
+ if (( Platform . isAix () || Platform . isMusl ()) && x .startsWith (LD_LIBRARY_PATH )) {
157
136
// AIX does not support the '-rpath' linker options so the
158
137
// launchers have to prepend the jdk library path to 'LIBPATH'.
159
138
// The musl library loader requires LD_LIBRARY_PATH to be set in
160
139
// order to correctly resolve the dependency libjava.so has on libjvm.so.
140
+ String jvmroot = System .getProperty ("java.home" );
161
141
String libPath = LD_LIBRARY_PATH + "=" +
162
- System .getenv (LD_LIBRARY_PATH ) +
163
- System .getProperty ("path.separator" ) + LD_LIBRARY_PATH_VALUE ;
142
+ jvmroot + "/lib/server" + System .getProperty ("path.separator" ) +
143
+ jvmroot + "/lib" + System .getProperty ("path.separator" ) +
144
+ jvmroot + "/../lib" + System .getProperty ("path.separator" ) +
145
+ LD_LIBRARY_PATH_VALUE ;
164
146
if (!tr .matches (libPath )) {
165
147
flagError (tr , "FAIL: did not get <" + libPath + ">" );
166
148
}
167
- }
168
- else {
149
+ } else {
169
150
flagError (tr , "FAIL: did not get <" + x + ">" );
170
151
}
171
152
}
@@ -215,23 +196,6 @@ private void verifyJavaLibraryPathGeneric(TestResult tr) {
215
196
}
216
197
}
217
198
218
- private void verifyJavaLibraryPathOverride (TestResult tr ,
219
- boolean is32Bit ) {
220
- // make sure the 32/64 bit value exists
221
- if (!tr .matches ("java.library.path=.*" +
222
- (is32Bit ? LD_LIBRARY_PATH_32_VALUE : LD_LIBRARY_PATH_64_VALUE ) + ".*" )) {
223
- flagError (tr , "verifyJavaLibraryPathOverride: " +
224
- " java.library.path does not contain " +
225
- (is32Bit ? LD_LIBRARY_PATH_32_VALUE : LD_LIBRARY_PATH_64_VALUE ));
226
-
227
- }
228
- // make sure the generic value is absent
229
- if (!tr .notMatches ("java.library.path=.*" + LD_LIBRARY_PATH_VALUE + ".*" )) {
230
- flagError (tr , "verifyJavaLibraryPathOverride: " +
231
- " java.library.path contains " + LD_LIBRARY_PATH_VALUE );
232
- }
233
- }
234
-
235
199
/*
236
200
* ensures we have indeed exec'ed the correct vm of choice if it exists
237
201
*/
0 commit comments