author | omajid |
Tue, 14 Aug 2012 17:11:11 -0400 | |
changeset 13542 | 93873f8b6528 |
child 20201 | 50cc2d25a60b |
child 20845 | 35f65a2db142 |
permissions | -rw-r--r-- |
13542
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
1 |
/* |
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
2 |
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. |
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
4 |
* |
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
8 |
* |
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
13 |
* accompanied this code). |
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
14 |
* |
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
18 |
* |
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
21 |
* questions. |
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
22 |
*/ |
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
23 |
|
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
24 |
/* |
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
25 |
* @test |
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
26 |
* @bug 7190813 |
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
27 |
* @summary Check for extended RPATHs on *nixes |
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
28 |
* @compile -XDignore.symbol.file RunpathTest.java |
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
29 |
* @run main RunpathTest |
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
30 |
* @author ksrini |
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
31 |
*/ |
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
32 |
|
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
33 |
import java.io.File; |
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
34 |
|
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
35 |
public class RunpathTest extends TestHelper { |
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
36 |
|
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
37 |
final String elfreaderCmd; |
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
38 |
RunpathTest() { |
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
39 |
elfreaderCmd = findElfReader(); |
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
40 |
} |
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
41 |
|
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
42 |
final String findElfReader() { |
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
43 |
String[] paths = {"/bin", "/sbin", "/usr/bin", "/usr/sbin", "/usr/ccs/bin"}; |
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
44 |
final String cmd = isSolaris ? "elfdump" : "readelf"; |
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
45 |
for (String x : paths) { |
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
46 |
File p = new File(x); |
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
47 |
File e = new File(p, cmd); |
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
48 |
if (e.canExecute()) { |
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
49 |
return e.getAbsolutePath(); |
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
50 |
} |
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
51 |
} |
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
52 |
System.err.println("Warning: no suitable elf reader!"); |
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
53 |
return null; |
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
54 |
} |
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
55 |
|
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
56 |
void elfCheck(String javacmd, String expectedRpath) { |
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
57 |
final TestResult tr = doExec(elfreaderCmd, "-d", javacmd); |
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
58 |
if (!tr.matches(expectedRpath)) { |
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
59 |
System.out.println(tr); |
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
60 |
throw new RuntimeException("FAILED: RPATH strings " + |
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
61 |
expectedRpath + " not found in " + javaCmd); |
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
62 |
} |
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
63 |
System.out.println(javacmd + " contains expected RPATHS"); |
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
64 |
} |
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
65 |
|
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
66 |
void testRpath() { |
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
67 |
if (isDualMode && is64Bit) { |
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
68 |
String expectedRpath = ".*RPATH.*\\$ORIGIN/../../lib/" + getJreArch() |
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
69 |
+ ":\\$ORIGIN/../../jre/lib/" + getJreArch() + ".*"; |
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
70 |
elfCheck(java64Cmd, expectedRpath); |
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
71 |
} else { |
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
72 |
String expectedRpath = ".*RPATH.*\\$ORIGIN/../lib/" + getJreArch() |
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
73 |
+ ":\\$ORIGIN/../jre/lib/" + getJreArch() + ".*"; |
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
74 |
elfCheck(javaCmd, expectedRpath); |
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
75 |
} |
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
76 |
} |
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
77 |
|
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
78 |
public static void main(String... args) throws Exception { |
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
79 |
if (isSolaris || isLinux) { |
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
80 |
RunpathTest rp = new RunpathTest(); |
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
81 |
rp.testRpath(); |
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
82 |
} |
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
83 |
} |
93873f8b6528
7190813: (launcher) RPATH needs to have additional paths
omajid
parents:
diff
changeset
|
84 |
} |