comparison test/runtime/XCheckJniJsig/XCheckJSig.java @ 14185:a9683a647c9f

8023735: [TESTBUG] runtime/XCheckJniJsig/XCheckJSig.java fails on MacOS X Summary: Look for libjsig in correct locations and do not fail if it's not found Reviewed-by: zgu, ccheung
author hseigel
date Mon, 23 Dec 2013 18:44:59 -0500
parents e567d5afd4dd
children 4ca6dc0799b6
comparison
equal deleted inserted replaced
14184:5b0fbe224dff 14185:a9683a647c9f
20 * or visit www.oracle.com if you need additional information or have any 20 * or visit www.oracle.com if you need additional information or have any
21 * questions. 21 * questions.
22 */ 22 */
23 23
24 /* 24 /*
25 * @ignore 8023735
26 * @test 25 * @test
27 * @bug 7051189 8023393 26 * @bug 7051189 8023393
28 * @summary Need to suppress info message if -Xcheck:jni is used with libjsig.so 27 * @summary Need to suppress info message if -Xcheck:jni is used with libjsig.so
29 * @library /testlibrary 28 * @library /testlibrary
30 * @run main XCheckJSig 29 * @run main XCheckJSig
31 */ 30 */
32 31
33 import java.util.*; 32 import java.io.File;
33 import java.util.Map;
34 import com.oracle.java.testlibrary.*; 34 import com.oracle.java.testlibrary.*;
35 35
36 public class XCheckJSig { 36 public class XCheckJSig {
37 public static void main(String args[]) throws Throwable { 37 public static void main(String args[]) throws Throwable {
38 38
45 String jdk_path = System.getProperty("test.jdk"); 45 String jdk_path = System.getProperty("test.jdk");
46 String os_arch = Platform.getOsArch(); 46 String os_arch = Platform.getOsArch();
47 String libjsig; 47 String libjsig;
48 String env_var; 48 String env_var;
49 if (Platform.isOSX()) { 49 if (Platform.isOSX()) {
50 libjsig = jdk_path + "/jre/lib/server/libjsig.dylib";
51 env_var = "DYLD_INSERT_LIBRARIES"; 50 env_var = "DYLD_INSERT_LIBRARIES";
51 libjsig = jdk_path + "/jre/lib/libjsig.dylib"; // jdk location
52 if (!(new File(libjsig).exists())) {
53 libjsig = jdk_path + "/lib/libjsig.dylib"; // jre location
54 }
52 } else { 55 } else {
53 libjsig = jdk_path + "/jre/lib/" + os_arch + "/libjsig.so";
54 env_var = "LD_PRELOAD"; 56 env_var = "LD_PRELOAD";
55 } 57 libjsig = jdk_path + "/jre/lib/" + os_arch + "/libjsig.so"; // jdk location
56 String java_program; 58 if (!(new File(libjsig).exists())) {
57 if (Platform.isSolaris()) { 59 libjsig = jdk_path + "/lib/" + os_arch + "/libjsig.so"; // jre location
58 // On Solaris, need to call the 64-bit Java directly in order for 60 }
59 // LD_PRELOAD to work because libjsig.so is 64-bit.
60 java_program = jdk_path + "/jre/bin/" + os_arch + "/java";
61 } else {
62 java_program = JDKToolFinder.getJDKTool("java");
63 } 61 }
64 // If this test fails, these might be useful to know. 62 // If this test fails, these might be useful to know.
65 System.out.println("libjsig: " + libjsig); 63 System.out.println("libjsig: " + libjsig);
66 System.out.println("osArch: " + os_arch); 64 System.out.println("osArch: " + os_arch);
67 System.out.println("java_program: " + java_program);
68 65
69 ProcessBuilder pb = new ProcessBuilder(java_program, "-Xcheck:jni", "-version"); 66 // Make sure the libjsig file exists.
67 if (!(new File(libjsig).exists())) {
68 System.out.println("File " + libjsig + " not found, skipping");
69 return;
70 }
71
72 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xcheck:jni", "-version");
70 Map<String, String> env = pb.environment(); 73 Map<String, String> env = pb.environment();
71 env.put(env_var, libjsig); 74 env.put(env_var, libjsig);
72 OutputAnalyzer output = new OutputAnalyzer(pb.start()); 75 OutputAnalyzer output = new OutputAnalyzer(pb.start());
73 output.shouldNotContain("libjsig is activated"); 76 output.shouldNotContain("libjsig is activated");
74 output.shouldHaveExitValue(0); 77 output.shouldHaveExitValue(0);
75 78
76 pb = new ProcessBuilder(java_program, "-Xcheck:jni", "-verbose:jni", "-version"); 79 pb = ProcessTools.createJavaProcessBuilder("-Xcheck:jni", "-verbose:jni", "-version");
77 env = pb.environment(); 80 env = pb.environment();
78 env.put(env_var, libjsig); 81 env.put(env_var, libjsig);
79 output = new OutputAnalyzer(pb.start()); 82 output = new OutputAnalyzer(pb.start());
80 output.shouldContain("libjsig is activated"); 83 output.shouldContain("libjsig is activated");
81 output.shouldHaveExitValue(0); 84 output.shouldHaveExitValue(0);