author | ksrini |
Sat, 28 Jan 2012 10:46:46 -0800 | |
changeset 11687 | f13cadbb0bb5 |
child 20201 | 50cc2d25a60b |
permissions | -rw-r--r-- |
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
1 |
/* |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
2 |
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
4 |
* |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
8 |
* |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
13 |
* accompanied this code). |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
14 |
* |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
18 |
* |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
21 |
* questions. |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
22 |
*/ |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
23 |
|
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
24 |
/** |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
25 |
* @test |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
26 |
* @bug 4894330 4810347 6277269 |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
27 |
* @compile -XDignore.symbol.file ChangeDataModel.java |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
28 |
* @run main ChangeDataModel |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
29 |
* @summary Verify -d32 and -d64 options are accepted(rejected) on all platforms |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
30 |
* @author Joseph D. Darcy, ksrini |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
31 |
*/ |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
32 |
import java.io.File; |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
33 |
import java.util.HashMap; |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
34 |
import java.util.Map; |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
35 |
|
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
36 |
public class ChangeDataModel extends TestHelper { |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
37 |
private static final File TestJar = new File("test" + JAR_FILE_EXT); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
38 |
private static final String OPT_PREFIX = "ARCH_OPT:"; |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
39 |
|
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
40 |
public static void main(String... args) throws Exception { |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
41 |
String[] code = { |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
42 |
" public static void main(String argv[]) {", |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
43 |
" System.out.println(\"" + OPT_PREFIX + "-d\" + System.getProperty(\"sun.arch.data.model\", \"none\"));", |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
44 |
" }", |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
45 |
}; |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
46 |
createJar(TestJar, code); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
47 |
|
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
48 |
// verify if data model flag for default data model is accepted |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
49 |
if (is32Bit) { |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
50 |
checkAcceptance(javaCmd, "-d32"); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
51 |
} else if (is64Bit) { |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
52 |
checkAcceptance(javaCmd, "-d64"); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
53 |
} else { |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
54 |
throw new Error("unsupported data model"); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
55 |
} |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
56 |
|
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
57 |
// test dual mode systems |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
58 |
if (isDualMode) { |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
59 |
// albeit dual mode we may not have the 64 bit components present |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
60 |
if (dualModePresent()) { |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
61 |
// 32-bit -> 64-bit |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
62 |
checkExecCount(javaCmd, "-d64"); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
63 |
// 64-bit -> 32-bit |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
64 |
checkExecCount(java64Cmd, "-d32"); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
65 |
|
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
66 |
checkAcceptance(javaCmd, "-d64"); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
67 |
checkAcceptance(java64Cmd, "-d32"); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
68 |
} else { |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
69 |
System.out.println("Warning: no 64-bit components found;" + |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
70 |
" only one data model tested."); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
71 |
} |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
72 |
} else { |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
73 |
// Negative tests: ensure that non-dual mode systems reject the |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
74 |
// complementary (other) data model |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
75 |
if (is32Bit) { |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
76 |
checkRejection(javaCmd, "-d64"); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
77 |
} else if (is64Bit) { |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
78 |
checkRejection(javaCmd, "-d32"); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
79 |
} else { |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
80 |
throw new Error("unsupported data model"); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
81 |
} |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
82 |
} |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
83 |
} |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
84 |
|
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
85 |
static void checkExecCount(String cmd, String dmodel) { |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
86 |
Map<String, String> envMap = new HashMap<>(); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
87 |
envMap.put(JLDEBUG_KEY, "true"); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
88 |
TestResult tr = doExec(envMap, javaCmd, "-d64", |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
89 |
"-jar", TestJar.getAbsolutePath()); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
90 |
int count = 0; |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
91 |
for (String x : tr.testOutput) { |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
92 |
if (x.contains(EXPECTED_MARKER)) { |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
93 |
count++; |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
94 |
if (count > 1) { |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
95 |
System.out.println(tr); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
96 |
throw new RuntimeException("Maximum exec count of 1 execeeded"); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
97 |
} |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
98 |
} |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
99 |
} |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
100 |
} |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
101 |
|
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
102 |
static void checkAcceptance(String cmd, String dmodel) { |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
103 |
TestResult tr = doExec(cmd, dmodel, "-jar", TestJar.getAbsolutePath()); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
104 |
if (!tr.contains(OPT_PREFIX + dmodel)) { |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
105 |
System.out.println(tr); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
106 |
String message = "Data model flag " + dmodel + |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
107 |
" not accepted or had improper effect."; |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
108 |
throw new RuntimeException(message); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
109 |
} |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
110 |
} |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
111 |
|
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
112 |
static void checkRejection(String cmd, String dmodel) { |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
113 |
TestResult tr = doExec(cmd, dmodel, "-jar", TestJar.getAbsolutePath()); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
114 |
if (tr.contains(OPT_PREFIX + dmodel)) { |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
115 |
System.out.println(tr); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
116 |
String message = "Data model flag " + dmodel + " was accepted."; |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
117 |
throw new RuntimeException(message); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
118 |
} |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
119 |
} |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
120 |
} |