20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /*
25 * @test
26 * @bug 4780570 4731671 6354700 6367077 6670965 4882974
27 * @summary Checks for LD_LIBRARY_PATH and execution on *nixes
28 * @modules jdk.compiler
29 * jdk.zipfs
30 * @compile -XDignore.symbol.file ExecutionEnvironment.java
31 * @run main/othervm ExecutionEnvironment
32 */
33
34 /*
35 * This tests for various things as follows:
36 * Ensures that:
37 * 1. uneccessary execs do not occur
38 * 2. the environment is pristine, users environment variable wrt.
39 * LD_LIBRARY_PATH if set are not modified in any way.
40 * 3. the correct vm is chosen with -server and -client options
41 * 4. the VM on Solaris correctly interprets the LD_LIBRARY_PATH32
42 * and LD_LIBRARY_PATH64 variables if set by the user, ie.
43 * i. on 32 bit systems:
44 * a. if LD_LIBRARY_PATH32 is set it will override LD_LIBRARY_PATH
45 * b. LD_LIBRARY_PATH64 is ignored if set
46 * ii. on 64 bit systems:
47 * a. if LD_LIBRARY_PATH64 is set it will override LD_LIBRARY_PATH
48 * b. LD_LIBRARY_PATH32 is ignored if set
49 * 5. no extra symlink exists on Solaris ie.
50 * lib/$arch/libjvm.so -> client/libjvm.so
51 * TODO:
52 * a. perhaps we need to add a test to audit all environment variables are
53 * in pristine condition after the launch, there may be a few that the
54 * launcher may add as implementation details.
55 * b. add a pldd for solaris to ensure only one libjvm.so is linked
56 */
57 import java.io.File;
58 import java.io.FileNotFoundException;
59 import java.util.ArrayList;
60 import java.util.HashMap;
241 */
242 @Test
243 void testVmSelection() {
244 boolean haveSomeVM = false;
245 if (haveClientVM) {
246 tryVmOption("-client", ".*Client VM.*");
247 haveSomeVM = true;
248 }
249 if (haveServerVM) {
250 tryVmOption("-server", ".*Server VM.*");
251 haveSomeVM = true;
252 }
253 if (!haveSomeVM) {
254 String msg = "Don't have a known VM";
255 System.err.println(msg);
256 throw new RuntimeException(msg);
257 }
258 }
259
260 private void tryVmOption(String opt, String expected) {
261 TestResult tr = doExec(javaCmd, opt, "-version");
262 if (!tr.matches(expected)) {
263 flagError(tr, "the expected vm " + opt + " did not launch");
264 }
265 }
266
267 /*
268 * checks to see there is no extra libjvm.so than needed
269 */
270 @Test
271 void testNoSymLink() {
272 if (is64Bit) {
273 return;
274 }
275
276 File symLink = null;
277 String libPathPrefix = "/lib";
278 symLink = new File(JAVAHOME, libPathPrefix +
279 getJreArch() + "/" + LIBJVM);
280 if (symLink.exists()) {
281 throw new RuntimeException("symlink exists " + symLink.getAbsolutePath());
282 }
283 }
|
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /*
25 * @test
26 * @bug 4780570 4731671 6354700 6367077 6670965 4882974
27 * @summary Checks for LD_LIBRARY_PATH and execution on *nixes
28 * @modules jdk.compiler
29 * jdk.zipfs
30 * @compile -XDignore.symbol.file ExecutionEnvironment.java
31 * @run main/othervm ExecutionEnvironment
32 */
33
34 /*
35 * This tests for various things as follows:
36 * Ensures that:
37 * 1. uneccessary execs do not occur
38 * 2. the environment is pristine, users environment variable wrt.
39 * LD_LIBRARY_PATH if set are not modified in any way.
40 * 3. the correct vm is chosen with -server/--server and -client/--client
41 * options
42 * 4. the VM on Solaris correctly interprets the LD_LIBRARY_PATH32
43 * and LD_LIBRARY_PATH64 variables if set by the user, ie.
44 * i. on 32 bit systems:
45 * a. if LD_LIBRARY_PATH32 is set it will override LD_LIBRARY_PATH
46 * b. LD_LIBRARY_PATH64 is ignored if set
47 * ii. on 64 bit systems:
48 * a. if LD_LIBRARY_PATH64 is set it will override LD_LIBRARY_PATH
49 * b. LD_LIBRARY_PATH32 is ignored if set
50 * 5. no extra symlink exists on Solaris ie.
51 * lib/$arch/libjvm.so -> client/libjvm.so
52 * TODO:
53 * a. perhaps we need to add a test to audit all environment variables are
54 * in pristine condition after the launch, there may be a few that the
55 * launcher may add as implementation details.
56 * b. add a pldd for solaris to ensure only one libjvm.so is linked
57 */
58 import java.io.File;
59 import java.io.FileNotFoundException;
60 import java.util.ArrayList;
61 import java.util.HashMap;
242 */
243 @Test
244 void testVmSelection() {
245 boolean haveSomeVM = false;
246 if (haveClientVM) {
247 tryVmOption("-client", ".*Client VM.*");
248 haveSomeVM = true;
249 }
250 if (haveServerVM) {
251 tryVmOption("-server", ".*Server VM.*");
252 haveSomeVM = true;
253 }
254 if (!haveSomeVM) {
255 String msg = "Don't have a known VM";
256 System.err.println(msg);
257 throw new RuntimeException(msg);
258 }
259 }
260
261 private void tryVmOption(String opt, String expected) {
262 for (String o : new String[] { opt, "-" + opt }) {
263 TestResult tr = doExec(javaCmd, o, "-version");
264 if (!tr.matches(expected)) {
265 flagError(tr, "the expected vm " + o + " did not launch");
266 }
267 }
268 }
269
270 /*
271 * checks to see there is no extra libjvm.so than needed
272 */
273 @Test
274 void testNoSymLink() {
275 if (is64Bit) {
276 return;
277 }
278
279 File symLink = null;
280 String libPathPrefix = "/lib";
281 symLink = new File(JAVAHOME, libPathPrefix +
282 getJreArch() + "/" + LIBJVM);
283 if (symLink.exists()) {
284 throw new RuntimeException("symlink exists " + symLink.getAbsolutePath());
285 }
286 }
|