author | lana |
Wed, 02 May 2012 10:17:29 -0700 | |
changeset 12561 | 63b05f2eabac |
parent 12527 | 22abaf748b5b |
parent 12550 | 482c64a6f825 |
child 13411 | 224a28370893 |
permissions | -rw-r--r-- |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
1 |
/* |
11520
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
11364
diff
changeset
|
2 |
* Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved. |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
4 |
* |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
8 |
* |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
13 |
* accompanied this code). |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
14 |
* |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
18 |
* |
5506 | 19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
22 |
*/ |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
23 |
|
12550 | 24 |
import java.io.StringWriter; |
25 |
import java.io.PrintWriter; |
|
12527
22abaf748b5b
7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
12301
diff
changeset
|
26 |
import java.util.Set; |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
27 |
import java.io.BufferedReader; |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
28 |
import java.io.File; |
11520
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
11364
diff
changeset
|
29 |
import java.io.FileFilter; |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
30 |
import java.io.FileNotFoundException; |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
31 |
import java.io.FileOutputStream; |
9244
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
32 |
import java.io.IOException; |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
33 |
import java.io.InputStreamReader; |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
34 |
import java.io.PrintStream; |
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11679
diff
changeset
|
35 |
import java.nio.charset.Charset; |
11520
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
11364
diff
changeset
|
36 |
import java.nio.file.attribute.BasicFileAttributes; |
9244
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
37 |
import java.nio.file.Files; |
11520
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
11364
diff
changeset
|
38 |
import java.nio.file.FileVisitResult; |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
11364
diff
changeset
|
39 |
import java.nio.file.SimpleFileVisitor; |
9244
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
40 |
import java.nio.file.Path; |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
41 |
import java.util.ArrayList; |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
42 |
import java.util.List; |
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11679
diff
changeset
|
43 |
import java.util.Locale; |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
44 |
import java.util.Map; |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
45 |
import javax.tools.JavaCompiler; |
11520
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
11364
diff
changeset
|
46 |
import javax.tools.ToolProvider; |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
47 |
|
9244
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
48 |
import static java.nio.file.StandardCopyOption.*; |
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11679
diff
changeset
|
49 |
import static java.nio.file.StandardOpenOption.*; |
9244
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
50 |
|
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
51 |
/** |
9244
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
52 |
* This class provides some common utilities for the launcher tests. |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
53 |
*/ |
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11679
diff
changeset
|
54 |
public class TestHelper { |
11679
84da476c4537
7132270: tools/launcher/DefaultLocaleTestRun.java failing (win)
ksrini
parents:
11520
diff
changeset
|
55 |
// commonly used jtreg constants |
84da476c4537
7132270: tools/launcher/DefaultLocaleTestRun.java failing (win)
ksrini
parents:
11520
diff
changeset
|
56 |
static final File TEST_CLASSES_DIR; |
84da476c4537
7132270: tools/launcher/DefaultLocaleTestRun.java failing (win)
ksrini
parents:
11520
diff
changeset
|
57 |
static final File TEST_SOURCES_DIR; |
84da476c4537
7132270: tools/launcher/DefaultLocaleTestRun.java failing (win)
ksrini
parents:
11520
diff
changeset
|
58 |
|
4340
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
59 |
static final String JAVAHOME = System.getProperty("java.home"); |
12301 | 60 |
static final String JAVA_BIN; |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
61 |
static final boolean isSDK = JAVAHOME.endsWith("jre"); |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
62 |
static final String javaCmd; |
11364
7907324fed4f
7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents:
10126
diff
changeset
|
63 |
static final String javawCmd; |
4340
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
64 |
static final String java64Cmd; |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
65 |
static final String javacCmd; |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
66 |
static final JavaCompiler compiler; |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
67 |
|
4340
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
68 |
static final boolean debug = Boolean.getBoolean("TestHelper.Debug"); |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
69 |
static final boolean isWindows = |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
70 |
System.getProperty("os.name", "unknown").startsWith("Windows"); |
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11687
diff
changeset
|
71 |
static final boolean isMacOSX = |
12538
211d6e82fe51
7130404: [macosx] "os.arch" value should be "x86_64" for compatibility with Apple JDK6
jmelvin
parents:
12301
diff
changeset
|
72 |
System.getProperty("os.name", "unknown").contains("OS X"); |
4340
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
73 |
static final boolean is64Bit = |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
74 |
System.getProperty("sun.arch.data.model").equals("64"); |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
75 |
static final boolean is32Bit = |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
76 |
System.getProperty("sun.arch.data.model").equals("32"); |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
77 |
static final boolean isSolaris = |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
78 |
System.getProperty("os.name", "unknown").startsWith("SunOS"); |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
79 |
static final boolean isLinux = |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
80 |
System.getProperty("os.name", "unknown").startsWith("Linux"); |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
81 |
static final boolean isDualMode = isSolaris; |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
82 |
static final boolean isSparc = System.getProperty("os.arch").startsWith("sparc"); |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
83 |
|
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11679
diff
changeset
|
84 |
// make a note of the golden default locale |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11679
diff
changeset
|
85 |
static final Locale DefaultLocale = Locale.getDefault(); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11679
diff
changeset
|
86 |
|
11520
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
11364
diff
changeset
|
87 |
static final String JAVA_FILE_EXT = ".java"; |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
11364
diff
changeset
|
88 |
static final String CLASS_FILE_EXT = ".class"; |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
11364
diff
changeset
|
89 |
static final String JAR_FILE_EXT = ".jar"; |
12301 | 90 |
static final String EXE_FILE_EXT = ".exe"; |
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11679
diff
changeset
|
91 |
static final String JLDEBUG_KEY = "_JAVA_LAUNCHER_DEBUG"; |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11679
diff
changeset
|
92 |
static final String EXPECTED_MARKER = "TRACER_MARKER:About to EXEC"; |
12550 | 93 |
static final String TEST_PREFIX = "###TestError###: "; |
11520
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
11364
diff
changeset
|
94 |
|
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
95 |
static int testExitValue = 0; |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
96 |
|
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
97 |
static { |
11679
84da476c4537
7132270: tools/launcher/DefaultLocaleTestRun.java failing (win)
ksrini
parents:
11520
diff
changeset
|
98 |
String tmp = System.getProperty("test.classes", null); |
84da476c4537
7132270: tools/launcher/DefaultLocaleTestRun.java failing (win)
ksrini
parents:
11520
diff
changeset
|
99 |
if (tmp == null) { |
84da476c4537
7132270: tools/launcher/DefaultLocaleTestRun.java failing (win)
ksrini
parents:
11520
diff
changeset
|
100 |
throw new Error("property test.classes not defined ??"); |
84da476c4537
7132270: tools/launcher/DefaultLocaleTestRun.java failing (win)
ksrini
parents:
11520
diff
changeset
|
101 |
} |
84da476c4537
7132270: tools/launcher/DefaultLocaleTestRun.java failing (win)
ksrini
parents:
11520
diff
changeset
|
102 |
TEST_CLASSES_DIR = new File(tmp).getAbsoluteFile(); |
84da476c4537
7132270: tools/launcher/DefaultLocaleTestRun.java failing (win)
ksrini
parents:
11520
diff
changeset
|
103 |
|
84da476c4537
7132270: tools/launcher/DefaultLocaleTestRun.java failing (win)
ksrini
parents:
11520
diff
changeset
|
104 |
tmp = System.getProperty("test.src", null); |
84da476c4537
7132270: tools/launcher/DefaultLocaleTestRun.java failing (win)
ksrini
parents:
11520
diff
changeset
|
105 |
if (tmp == null) { |
84da476c4537
7132270: tools/launcher/DefaultLocaleTestRun.java failing (win)
ksrini
parents:
11520
diff
changeset
|
106 |
throw new Error("property test.src not defined ??"); |
84da476c4537
7132270: tools/launcher/DefaultLocaleTestRun.java failing (win)
ksrini
parents:
11520
diff
changeset
|
107 |
} |
84da476c4537
7132270: tools/launcher/DefaultLocaleTestRun.java failing (win)
ksrini
parents:
11520
diff
changeset
|
108 |
TEST_SOURCES_DIR = new File(tmp).getAbsoluteFile(); |
84da476c4537
7132270: tools/launcher/DefaultLocaleTestRun.java failing (win)
ksrini
parents:
11520
diff
changeset
|
109 |
|
4340
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
110 |
if (is64Bit && is32Bit) { |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
111 |
throw new RuntimeException("arch model cannot be both 32 and 64 bit"); |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
112 |
} |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
113 |
if (!is64Bit && !is32Bit) { |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
114 |
throw new RuntimeException("arch model is not 32 or 64 bit ?"); |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
115 |
} |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
116 |
compiler = ToolProvider.getSystemJavaCompiler(); |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
117 |
File binDir = (isSDK) ? new File((new File(JAVAHOME)).getParentFile(), "bin") |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
118 |
: new File(JAVAHOME, "bin"); |
12301 | 119 |
JAVA_BIN = binDir.getAbsolutePath(); |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
120 |
File javaCmdFile = (isWindows) |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
121 |
? new File(binDir, "java.exe") |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
122 |
: new File(binDir, "java"); |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
123 |
javaCmd = javaCmdFile.getAbsolutePath(); |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
124 |
if (!javaCmdFile.canExecute()) { |
11364
7907324fed4f
7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents:
10126
diff
changeset
|
125 |
throw new RuntimeException("java <" + TestHelper.javaCmd + |
7907324fed4f
7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents:
10126
diff
changeset
|
126 |
"> must exist and should be executable"); |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
127 |
} |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
128 |
|
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
129 |
File javacCmdFile = (isWindows) |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
130 |
? new File(binDir, "javac.exe") |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
131 |
: new File(binDir, "javac"); |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
132 |
javacCmd = javacCmdFile.getAbsolutePath(); |
11364
7907324fed4f
7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents:
10126
diff
changeset
|
133 |
|
7907324fed4f
7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents:
10126
diff
changeset
|
134 |
if (isWindows) { |
7907324fed4f
7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents:
10126
diff
changeset
|
135 |
File javawCmdFile = new File(binDir, "javaw.exe"); |
7907324fed4f
7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents:
10126
diff
changeset
|
136 |
javawCmd = javawCmdFile.getAbsolutePath(); |
7907324fed4f
7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents:
10126
diff
changeset
|
137 |
if (!javawCmdFile.canExecute()) { |
7907324fed4f
7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents:
10126
diff
changeset
|
138 |
throw new RuntimeException("java <" + javawCmd + |
7907324fed4f
7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents:
10126
diff
changeset
|
139 |
"> must exist and should be executable"); |
7907324fed4f
7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents:
10126
diff
changeset
|
140 |
} |
7907324fed4f
7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents:
10126
diff
changeset
|
141 |
} else { |
7907324fed4f
7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents:
10126
diff
changeset
|
142 |
javawCmd = null; |
7907324fed4f
7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents:
10126
diff
changeset
|
143 |
} |
7907324fed4f
7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents:
10126
diff
changeset
|
144 |
|
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
145 |
if (!javacCmdFile.canExecute()) { |
11364
7907324fed4f
7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents:
10126
diff
changeset
|
146 |
throw new RuntimeException("java <" + javacCmd + |
7907324fed4f
7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents:
10126
diff
changeset
|
147 |
"> must exist and should be executable"); |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
148 |
} |
4340
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
149 |
if (isSolaris) { |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
150 |
File sparc64BinDir = new File(binDir,isSparc ? "sparcv9" : "amd64"); |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
151 |
File java64CmdFile= new File(sparc64BinDir, "java"); |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
152 |
if (java64CmdFile.exists() && java64CmdFile.canExecute()) { |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
153 |
java64Cmd = java64CmdFile.getAbsolutePath(); |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
154 |
} else { |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
155 |
java64Cmd = null; |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
156 |
} |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
157 |
} else { |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
158 |
java64Cmd = null; |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
159 |
} |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
160 |
} |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
161 |
|
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
162 |
/* |
9244
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
163 |
* is a dual mode available in the test jdk |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
164 |
*/ |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
165 |
static boolean dualModePresent() { |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
166 |
return isDualMode && java64Cmd != null; |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
167 |
} |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
168 |
|
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
169 |
/* |
4340
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
170 |
* usually the jre/lib/arch-name is the same as os.arch, except for x86. |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
171 |
*/ |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
172 |
static String getJreArch() { |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
173 |
String arch = System.getProperty("os.arch"); |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
174 |
return arch.equals("x86") ? "i386" : arch; |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
175 |
} |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
176 |
|
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
177 |
/* |
9244
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
178 |
* get the complementary jre arch ie. if sparc then return sparcv9 and |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
179 |
* vice-versa. |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
180 |
*/ |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
181 |
static String getComplementaryJreArch() { |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
182 |
String arch = System.getProperty("os.arch"); |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
183 |
if (arch != null) { |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
184 |
switch (arch) { |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
185 |
case "sparc": |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
186 |
return "sparcv9"; |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
187 |
case "sparcv9": |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
188 |
return "sparc"; |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
189 |
case "x86": |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
190 |
return "amd64"; |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
191 |
case "amd64": |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
192 |
return "i386"; |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
193 |
} |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
194 |
} |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
195 |
return null; |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
196 |
} |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
197 |
|
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
198 |
/* |
4340
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
199 |
* A convenience method to create a jar with jar file name and defs |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
200 |
*/ |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
201 |
static void createJar(File jarName, String... mainDefs) |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
202 |
throws FileNotFoundException{ |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
203 |
createJar(null, jarName, new File("Foo"), mainDefs); |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
204 |
} |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
205 |
|
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
206 |
/* |
1329
ce13b59a8401
4459600: java -jar fails to run Main-Class if classname followed by whitespace.
ksrini
parents:
1323
diff
changeset
|
207 |
* A convenience method to create a java file, compile and jar it up, using |
ce13b59a8401
4459600: java -jar fails to run Main-Class if classname followed by whitespace.
ksrini
parents:
1323
diff
changeset
|
208 |
* the sole class file name in the jar, as the Main-Class attribute value. |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
209 |
*/ |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
210 |
static void createJar(File jarName, File mainClass, String... mainDefs) |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
211 |
throws FileNotFoundException { |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
212 |
createJar(null, jarName, mainClass, mainDefs); |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
213 |
} |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
214 |
|
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
215 |
/* |
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11679
diff
changeset
|
216 |
* A convenience method to compile java files. |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11679
diff
changeset
|
217 |
*/ |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11679
diff
changeset
|
218 |
static void compile(String... compilerArgs) { |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11679
diff
changeset
|
219 |
if (compiler.run(null, null, null, compilerArgs) != 0) { |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11679
diff
changeset
|
220 |
String sarg = ""; |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11679
diff
changeset
|
221 |
for (String x : compilerArgs) { |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11679
diff
changeset
|
222 |
sarg.concat(x + " "); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11679
diff
changeset
|
223 |
} |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11679
diff
changeset
|
224 |
throw new Error("compilation failed: " + sarg); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11679
diff
changeset
|
225 |
} |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11679
diff
changeset
|
226 |
} |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11679
diff
changeset
|
227 |
|
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11679
diff
changeset
|
228 |
/* |
1329
ce13b59a8401
4459600: java -jar fails to run Main-Class if classname followed by whitespace.
ksrini
parents:
1323
diff
changeset
|
229 |
* A generic jar file creator to create a java file, compile it |
ce13b59a8401
4459600: java -jar fails to run Main-Class if classname followed by whitespace.
ksrini
parents:
1323
diff
changeset
|
230 |
* and jar it up, a specific Main-Class entry name in the |
ce13b59a8401
4459600: java -jar fails to run Main-Class if classname followed by whitespace.
ksrini
parents:
1323
diff
changeset
|
231 |
* manifest can be specified or a null to use the sole class file name |
ce13b59a8401
4459600: java -jar fails to run Main-Class if classname followed by whitespace.
ksrini
parents:
1323
diff
changeset
|
232 |
* as the Main-Class attribute value. |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
233 |
*/ |
1329
ce13b59a8401
4459600: java -jar fails to run Main-Class if classname followed by whitespace.
ksrini
parents:
1323
diff
changeset
|
234 |
static void createJar(String mEntry, File jarName, File mainClass, |
ce13b59a8401
4459600: java -jar fails to run Main-Class if classname followed by whitespace.
ksrini
parents:
1323
diff
changeset
|
235 |
String... mainDefs) throws FileNotFoundException { |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
236 |
if (jarName.exists()) { |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
237 |
jarName.delete(); |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
238 |
} |
10126
a375b8714147
7067922: (launcher) java -jar throws NPE if JAR file does not contain Main-Class attribute
ksrini
parents:
9734
diff
changeset
|
239 |
try (PrintStream ps = new PrintStream(new FileOutputStream(mainClass + ".java"))) { |
a375b8714147
7067922: (launcher) java -jar throws NPE if JAR file does not contain Main-Class attribute
ksrini
parents:
9734
diff
changeset
|
240 |
ps.println("public class Foo {"); |
a375b8714147
7067922: (launcher) java -jar throws NPE if JAR file does not contain Main-Class attribute
ksrini
parents:
9734
diff
changeset
|
241 |
if (mainDefs != null) { |
a375b8714147
7067922: (launcher) java -jar throws NPE if JAR file does not contain Main-Class attribute
ksrini
parents:
9734
diff
changeset
|
242 |
for (String x : mainDefs) { |
a375b8714147
7067922: (launcher) java -jar throws NPE if JAR file does not contain Main-Class attribute
ksrini
parents:
9734
diff
changeset
|
243 |
ps.println(x); |
a375b8714147
7067922: (launcher) java -jar throws NPE if JAR file does not contain Main-Class attribute
ksrini
parents:
9734
diff
changeset
|
244 |
} |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
245 |
} |
10126
a375b8714147
7067922: (launcher) java -jar throws NPE if JAR file does not contain Main-Class attribute
ksrini
parents:
9734
diff
changeset
|
246 |
ps.println("}"); |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
247 |
} |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
248 |
|
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
249 |
String compileArgs[] = { |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
250 |
mainClass + ".java" |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
251 |
}; |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
252 |
if (compiler.run(null, null, null, compileArgs) != 0) { |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
253 |
throw new RuntimeException("compilation failed " + mainClass + ".java"); |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
254 |
} |
1329
ce13b59a8401
4459600: java -jar fails to run Main-Class if classname followed by whitespace.
ksrini
parents:
1323
diff
changeset
|
255 |
if (mEntry == null) { |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
256 |
mEntry = mainClass.getName(); |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
257 |
} |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
258 |
String jarArgs[] = { |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
259 |
(debug) ? "cvfe" : "cfe", |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
260 |
jarName.getAbsolutePath(), |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
261 |
mEntry, |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
262 |
mainClass.getName() + ".class" |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
263 |
}; |
10126
a375b8714147
7067922: (launcher) java -jar throws NPE if JAR file does not contain Main-Class attribute
ksrini
parents:
9734
diff
changeset
|
264 |
createJar(jarArgs); |
a375b8714147
7067922: (launcher) java -jar throws NPE if JAR file does not contain Main-Class attribute
ksrini
parents:
9734
diff
changeset
|
265 |
} |
a375b8714147
7067922: (launcher) java -jar throws NPE if JAR file does not contain Main-Class attribute
ksrini
parents:
9734
diff
changeset
|
266 |
|
a375b8714147
7067922: (launcher) java -jar throws NPE if JAR file does not contain Main-Class attribute
ksrini
parents:
9734
diff
changeset
|
267 |
static void createJar(String... args) { |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
268 |
sun.tools.jar.Main jarTool = |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
269 |
new sun.tools.jar.Main(System.out, System.err, "JarCreator"); |
10126
a375b8714147
7067922: (launcher) java -jar throws NPE if JAR file does not contain Main-Class attribute
ksrini
parents:
9734
diff
changeset
|
270 |
if (!jarTool.run(args)) { |
a375b8714147
7067922: (launcher) java -jar throws NPE if JAR file does not contain Main-Class attribute
ksrini
parents:
9734
diff
changeset
|
271 |
String message = "jar creation failed with command:"; |
a375b8714147
7067922: (launcher) java -jar throws NPE if JAR file does not contain Main-Class attribute
ksrini
parents:
9734
diff
changeset
|
272 |
for (String x : args) { |
a375b8714147
7067922: (launcher) java -jar throws NPE if JAR file does not contain Main-Class attribute
ksrini
parents:
9734
diff
changeset
|
273 |
message = message.concat(" " + x); |
a375b8714147
7067922: (launcher) java -jar throws NPE if JAR file does not contain Main-Class attribute
ksrini
parents:
9734
diff
changeset
|
274 |
} |
a375b8714147
7067922: (launcher) java -jar throws NPE if JAR file does not contain Main-Class attribute
ksrini
parents:
9734
diff
changeset
|
275 |
throw new RuntimeException(message); |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
276 |
} |
10126
a375b8714147
7067922: (launcher) java -jar throws NPE if JAR file does not contain Main-Class attribute
ksrini
parents:
9734
diff
changeset
|
277 |
} |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
278 |
|
9244
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
279 |
static void copyFile(File src, File dst) throws IOException { |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
280 |
Path parent = dst.toPath().getParent(); |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
281 |
if (parent != null) { |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
282 |
Files.createDirectories(parent); |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
283 |
} |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
284 |
Files.copy(src.toPath(), dst.toPath(), COPY_ATTRIBUTES, REPLACE_EXISTING); |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
285 |
} |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
286 |
|
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11679
diff
changeset
|
287 |
static void createFile(File outFile, List<String> content) throws IOException { |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11679
diff
changeset
|
288 |
Files.write(outFile.getAbsoluteFile().toPath(), content, |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11679
diff
changeset
|
289 |
Charset.defaultCharset(), CREATE_NEW); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11679
diff
changeset
|
290 |
} |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11679
diff
changeset
|
291 |
|
9244
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
292 |
static void recursiveDelete(File target) throws IOException { |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
293 |
if (!target.exists()) { |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
294 |
return; |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
295 |
} |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
296 |
Files.walkFileTree(target.toPath(), new SimpleFileVisitor<Path>() { |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
297 |
@Override |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
298 |
public FileVisitResult postVisitDirectory(Path dir, IOException exc) { |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
299 |
try { |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
300 |
Files.deleteIfExists(dir); |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
301 |
} catch (IOException ex) { |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
302 |
System.out.println("Error: could not delete: " + dir.toString()); |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
303 |
System.out.println(ex.getMessage()); |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
304 |
return FileVisitResult.TERMINATE; |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
305 |
} |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
306 |
return FileVisitResult.CONTINUE; |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
307 |
} |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
308 |
@Override |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
309 |
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) { |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
310 |
try { |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
311 |
Files.deleteIfExists(file); |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
312 |
} catch (IOException ex) { |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
313 |
System.out.println("Error: could not delete: " + file.toString()); |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
314 |
System.out.println(ex.getMessage()); |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
315 |
return FileVisitResult.TERMINATE; |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
316 |
} |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
317 |
return FileVisitResult.CONTINUE; |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
318 |
} |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
319 |
}); |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
320 |
} |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
321 |
|
4340
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
322 |
static TestResult doExec(String...cmds) { |
12527
22abaf748b5b
7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
12301
diff
changeset
|
323 |
return doExec(null, null, cmds); |
4340
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
324 |
} |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
325 |
|
12527
22abaf748b5b
7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
12301
diff
changeset
|
326 |
static TestResult doExec(Map<String, String> envToSet, String...cmds) { |
22abaf748b5b
7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
12301
diff
changeset
|
327 |
return doExec(envToSet, null, cmds); |
22abaf748b5b
7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
12301
diff
changeset
|
328 |
} |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
329 |
/* |
1329
ce13b59a8401
4459600: java -jar fails to run Main-Class if classname followed by whitespace.
ksrini
parents:
1323
diff
changeset
|
330 |
* A method which executes a java cmd and returns the results in a container |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
331 |
*/ |
12527
22abaf748b5b
7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
12301
diff
changeset
|
332 |
static TestResult doExec(Map<String, String> envToSet, |
22abaf748b5b
7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
12301
diff
changeset
|
333 |
Set<String> envToRemove, String...cmds) { |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
334 |
String cmdStr = ""; |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
335 |
for (String x : cmds) { |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
336 |
cmdStr = cmdStr.concat(x + " "); |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
337 |
} |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
338 |
ProcessBuilder pb = new ProcessBuilder(cmds); |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
339 |
Map<String, String> env = pb.environment(); |
12527
22abaf748b5b
7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
12301
diff
changeset
|
340 |
if (envToRemove != null) { |
22abaf748b5b
7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
12301
diff
changeset
|
341 |
for (String key : envToRemove) { |
22abaf748b5b
7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
12301
diff
changeset
|
342 |
env.remove(key); |
22abaf748b5b
7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
12301
diff
changeset
|
343 |
} |
22abaf748b5b
7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
12301
diff
changeset
|
344 |
} |
4340
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
345 |
if (envToSet != null) { |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
346 |
env.putAll(envToSet); |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
347 |
} |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
348 |
BufferedReader rdr = null; |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
349 |
try { |
9244
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
350 |
List<String> outputList = new ArrayList<>(); |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
351 |
pb.redirectErrorStream(true); |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
352 |
Process p = pb.start(); |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
353 |
rdr = new BufferedReader(new InputStreamReader(p.getInputStream())); |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
354 |
String in = rdr.readLine(); |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
355 |
while (in != null) { |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
356 |
outputList.add(in); |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
357 |
in = rdr.readLine(); |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
358 |
} |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
359 |
p.waitFor(); |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
360 |
p.destroy(); |
9244
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
361 |
|
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
362 |
return new TestHelper.TestResult(cmdStr, p.exitValue(), outputList, |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
363 |
env, new Throwable("current stack of the test")); |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
364 |
} catch (Exception ex) { |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
365 |
ex.printStackTrace(); |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
366 |
throw new RuntimeException(ex.getMessage()); |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
367 |
} |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
368 |
} |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
369 |
|
11520
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
11364
diff
changeset
|
370 |
static FileFilter createFilter(final String extension) { |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
11364
diff
changeset
|
371 |
return new FileFilter() { |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
11364
diff
changeset
|
372 |
@Override |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
11364
diff
changeset
|
373 |
public boolean accept(File pathname) { |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
11364
diff
changeset
|
374 |
String name = pathname.getName(); |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
11364
diff
changeset
|
375 |
if (name.endsWith(extension)) { |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
11364
diff
changeset
|
376 |
return true; |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
11364
diff
changeset
|
377 |
} |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
11364
diff
changeset
|
378 |
return false; |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
11364
diff
changeset
|
379 |
} |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
11364
diff
changeset
|
380 |
}; |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
11364
diff
changeset
|
381 |
} |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
11364
diff
changeset
|
382 |
|
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11679
diff
changeset
|
383 |
static boolean isEnglishLocale() { |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11679
diff
changeset
|
384 |
return Locale.getDefault().getLanguage().equals("en"); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11679
diff
changeset
|
385 |
} |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11679
diff
changeset
|
386 |
|
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
387 |
/* |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
388 |
* A class to encapsulate the test results and stuff, with some ease |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
389 |
* of use methods to check the test results. |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
390 |
*/ |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
391 |
static class TestResult { |
12550 | 392 |
PrintWriter status; |
393 |
StringWriter sw; |
|
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
394 |
int exitValue; |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
395 |
List<String> testOutput; |
9244
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
396 |
Map<String, String> env; |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
397 |
Throwable t; |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
398 |
|
9244
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
399 |
public TestResult(String str, int rv, List<String> oList, |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
400 |
Map<String, String> env, Throwable t) { |
12550 | 401 |
sw = new StringWriter(); |
402 |
status = new PrintWriter(sw); |
|
403 |
status.println("Executed command: " + str + "\n"); |
|
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
404 |
exitValue = rv; |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
405 |
testOutput = oList; |
9244
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
406 |
this.env = env; |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
407 |
this.t = t; |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
408 |
} |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
409 |
|
12550 | 410 |
void appendError(String x) { |
411 |
status.println(TEST_PREFIX + x); |
|
412 |
} |
|
413 |
||
414 |
void indentStatus(String x) { |
|
415 |
status.println(" " + x); |
|
4340
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
416 |
} |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
417 |
|
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
418 |
void checkNegative() { |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
419 |
if (exitValue == 0) { |
12550 | 420 |
appendError("test must not return 0 exit value"); |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
421 |
testExitValue++; |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
422 |
} |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
423 |
} |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
424 |
|
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
425 |
void checkPositive() { |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
426 |
if (exitValue != 0) { |
12550 | 427 |
appendError("test did not return 0 exit value"); |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
428 |
testExitValue++; |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
429 |
} |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
430 |
} |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
431 |
|
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
432 |
boolean isOK() { |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
433 |
return exitValue == 0; |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
434 |
} |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
435 |
|
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
436 |
boolean isZeroOutput() { |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
437 |
if (!testOutput.isEmpty()) { |
12550 | 438 |
appendError("No message from cmd please"); |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
439 |
testExitValue++; |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
440 |
return false; |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
441 |
} |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
442 |
return true; |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
443 |
} |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
444 |
|
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
445 |
boolean isNotZeroOutput() { |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
446 |
if (testOutput.isEmpty()) { |
12550 | 447 |
appendError("Missing message"); |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
448 |
testExitValue++; |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
449 |
return false; |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
450 |
} |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
451 |
return true; |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
452 |
} |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
453 |
|
4340
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
454 |
@Override |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
455 |
public String toString() { |
12550 | 456 |
status.println("++++Begin Test Info++++"); |
457 |
status.println("++++Test Environment++++"); |
|
9244
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
458 |
for (String x : env.keySet()) { |
12550 | 459 |
indentStatus(x + "=" + env.get(x)); |
9244
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
460 |
} |
12550 | 461 |
status.println("++++Test Output++++"); |
4340
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
462 |
for (String x : testOutput) { |
12550 | 463 |
indentStatus(x); |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
464 |
} |
12550 | 465 |
status.println("++++Test Stack Trace++++"); |
466 |
status.println(t.toString()); |
|
9244
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
467 |
for (StackTraceElement e : t.getStackTrace()) { |
12550 | 468 |
indentStatus(e.toString()); |
9244
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
469 |
} |
12550 | 470 |
status.println("++++End of Test Info++++"); |
471 |
status.flush(); |
|
472 |
String out = sw.toString(); |
|
473 |
status.close(); |
|
474 |
return out; |
|
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
475 |
} |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
476 |
|
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
477 |
boolean contains(String str) { |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
478 |
for (String x : testOutput) { |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
479 |
if (x.contains(str)) { |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
480 |
return true; |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
481 |
} |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
482 |
} |
12550 | 483 |
appendError("string <" + str + "> not found"); |
4340
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
484 |
testExitValue++; |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
485 |
return false; |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
486 |
} |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
487 |
|
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
488 |
boolean matches(String stringToMatch) { |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
489 |
for (String x : testOutput) { |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
490 |
if (x.matches(stringToMatch)) { |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
491 |
return true; |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
492 |
} |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
493 |
} |
12550 | 494 |
appendError("string <" + stringToMatch + "> not found"); |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
495 |
testExitValue++; |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
496 |
return false; |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
497 |
} |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
498 |
} |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
499 |
} |