author | prr |
Tue, 01 Jul 2014 10:20:56 -0700 | |
changeset 25211 | 2476da7d73bf |
parent 22066 | f2133b498789 |
child 45062 | 37ed4313c8c1 |
permissions | -rw-r--r-- |
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
1 |
/* |
20201
50cc2d25a60b
8020552: [launcher] changes to support removal of Solaris 32-bit distribution
ksrini
parents:
11687
diff
changeset
|
2 |
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. |
11687
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 |
22066
f2133b498789
8029388: java.exe consumes argument intended for launched java class
ksrini
parents:
20201
diff
changeset
|
26 |
* @bug 4894330 4810347 6277269 8029388 |
11687
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; |
22066
f2133b498789
8029388: java.exe consumes argument intended for launched java class
ksrini
parents:
20201
diff
changeset
|
33 |
import java.util.ArrayList; |
f2133b498789
8029388: java.exe consumes argument intended for launched java class
ksrini
parents:
20201
diff
changeset
|
34 |
import java.util.List; |
11687
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); |
22066
f2133b498789
8029388: java.exe consumes argument intended for launched java class
ksrini
parents:
20201
diff
changeset
|
38 |
private static final String OptionName = "Args"; |
f2133b498789
8029388: java.exe consumes argument intended for launched java class
ksrini
parents:
20201
diff
changeset
|
39 |
private static final File TestOptionJar = new File(OptionName + JAR_FILE_EXT); |
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
40 |
private static final String OPT_PREFIX = "ARCH_OPT:"; |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
41 |
|
22066
f2133b498789
8029388: java.exe consumes argument intended for launched java class
ksrini
parents:
20201
diff
changeset
|
42 |
static void createTestJar() throws Exception { |
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
43 |
String[] code = { |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
44 |
" public static void main(String argv[]) {", |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
45 |
" System.out.println(\"" + OPT_PREFIX + "-d\" + System.getProperty(\"sun.arch.data.model\", \"none\"));", |
22066
f2133b498789
8029388: java.exe consumes argument intended for launched java class
ksrini
parents:
20201
diff
changeset
|
46 |
" }",}; |
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
47 |
createJar(TestJar, code); |
22066
f2133b498789
8029388: java.exe consumes argument intended for launched java class
ksrini
parents:
20201
diff
changeset
|
48 |
} |
f2133b498789
8029388: java.exe consumes argument intended for launched java class
ksrini
parents:
20201
diff
changeset
|
49 |
public static void main(String... args) throws Exception { |
f2133b498789
8029388: java.exe consumes argument intended for launched java class
ksrini
parents:
20201
diff
changeset
|
50 |
createTestJar(); |
f2133b498789
8029388: java.exe consumes argument intended for launched java class
ksrini
parents:
20201
diff
changeset
|
51 |
createOptionsJar(); |
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
52 |
|
22066
f2133b498789
8029388: java.exe consumes argument intended for launched java class
ksrini
parents:
20201
diff
changeset
|
53 |
// verify if data model flag for default data model is accepted, also |
f2133b498789
8029388: java.exe consumes argument intended for launched java class
ksrini
parents:
20201
diff
changeset
|
54 |
// verify if the complimentary data model is rejected. |
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
55 |
if (is32Bit) { |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
56 |
checkAcceptance(javaCmd, "-d32"); |
22066
f2133b498789
8029388: java.exe consumes argument intended for launched java class
ksrini
parents:
20201
diff
changeset
|
57 |
checkRejection(javaCmd, "-d64"); |
f2133b498789
8029388: java.exe consumes argument intended for launched java class
ksrini
parents:
20201
diff
changeset
|
58 |
checkOption(javaCmd, "-d64"); |
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
59 |
} else if (is64Bit) { |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
60 |
checkAcceptance(javaCmd, "-d64"); |
20201
50cc2d25a60b
8020552: [launcher] changes to support removal of Solaris 32-bit distribution
ksrini
parents:
11687
diff
changeset
|
61 |
checkRejection(javaCmd, "-d32"); |
22066
f2133b498789
8029388: java.exe consumes argument intended for launched java class
ksrini
parents:
20201
diff
changeset
|
62 |
checkOption(javaCmd, "-d32"); |
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
63 |
} else { |
20201
50cc2d25a60b
8020552: [launcher] changes to support removal of Solaris 32-bit distribution
ksrini
parents:
11687
diff
changeset
|
64 |
throw new Error("unsupported data model"); |
11687
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 |
} |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
67 |
|
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
68 |
static void checkAcceptance(String cmd, String dmodel) { |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
69 |
TestResult tr = doExec(cmd, dmodel, "-jar", TestJar.getAbsolutePath()); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
70 |
if (!tr.contains(OPT_PREFIX + dmodel)) { |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
71 |
System.out.println(tr); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
72 |
String message = "Data model flag " + dmodel + |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
73 |
" not accepted or had improper effect."; |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
74 |
throw new RuntimeException(message); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
75 |
} |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
76 |
} |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
77 |
|
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
78 |
static void checkRejection(String cmd, String dmodel) { |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
79 |
TestResult tr = doExec(cmd, dmodel, "-jar", TestJar.getAbsolutePath()); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
80 |
if (tr.contains(OPT_PREFIX + dmodel)) { |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
81 |
System.out.println(tr); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
82 |
String message = "Data model flag " + dmodel + " was accepted."; |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
83 |
throw new RuntimeException(message); |
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 |
} |
22066
f2133b498789
8029388: java.exe consumes argument intended for launched java class
ksrini
parents:
20201
diff
changeset
|
86 |
|
f2133b498789
8029388: java.exe consumes argument intended for launched java class
ksrini
parents:
20201
diff
changeset
|
87 |
static void checkOption(String cmd, String dmodel) throws Exception { |
f2133b498789
8029388: java.exe consumes argument intended for launched java class
ksrini
parents:
20201
diff
changeset
|
88 |
TestResult tr = doExec(cmd, "-jar", TestOptionJar.getAbsolutePath(), dmodel); |
f2133b498789
8029388: java.exe consumes argument intended for launched java class
ksrini
parents:
20201
diff
changeset
|
89 |
verifyOption(tr, dmodel); |
f2133b498789
8029388: java.exe consumes argument intended for launched java class
ksrini
parents:
20201
diff
changeset
|
90 |
|
f2133b498789
8029388: java.exe consumes argument intended for launched java class
ksrini
parents:
20201
diff
changeset
|
91 |
tr = doExec(cmd, "-cp", ".", OptionName, dmodel); |
f2133b498789
8029388: java.exe consumes argument intended for launched java class
ksrini
parents:
20201
diff
changeset
|
92 |
verifyOption(tr, dmodel); |
f2133b498789
8029388: java.exe consumes argument intended for launched java class
ksrini
parents:
20201
diff
changeset
|
93 |
} |
f2133b498789
8029388: java.exe consumes argument intended for launched java class
ksrini
parents:
20201
diff
changeset
|
94 |
|
f2133b498789
8029388: java.exe consumes argument intended for launched java class
ksrini
parents:
20201
diff
changeset
|
95 |
static void verifyOption(TestResult tr, String dmodel) { |
f2133b498789
8029388: java.exe consumes argument intended for launched java class
ksrini
parents:
20201
diff
changeset
|
96 |
if (!tr.contains(OPT_PREFIX + dmodel)) { |
f2133b498789
8029388: java.exe consumes argument intended for launched java class
ksrini
parents:
20201
diff
changeset
|
97 |
System.out.println(tr); |
f2133b498789
8029388: java.exe consumes argument intended for launched java class
ksrini
parents:
20201
diff
changeset
|
98 |
String message = "app argument: " + dmodel + " not found."; |
f2133b498789
8029388: java.exe consumes argument intended for launched java class
ksrini
parents:
20201
diff
changeset
|
99 |
throw new RuntimeException(message); |
f2133b498789
8029388: java.exe consumes argument intended for launched java class
ksrini
parents:
20201
diff
changeset
|
100 |
} |
f2133b498789
8029388: java.exe consumes argument intended for launched java class
ksrini
parents:
20201
diff
changeset
|
101 |
if (!tr.isOK()) { |
f2133b498789
8029388: java.exe consumes argument intended for launched java class
ksrini
parents:
20201
diff
changeset
|
102 |
System.out.println(tr); |
f2133b498789
8029388: java.exe consumes argument intended for launched java class
ksrini
parents:
20201
diff
changeset
|
103 |
String message = "app argument: " + dmodel + " interpreted ?"; |
f2133b498789
8029388: java.exe consumes argument intended for launched java class
ksrini
parents:
20201
diff
changeset
|
104 |
throw new RuntimeException(message); |
f2133b498789
8029388: java.exe consumes argument intended for launched java class
ksrini
parents:
20201
diff
changeset
|
105 |
} |
f2133b498789
8029388: java.exe consumes argument intended for launched java class
ksrini
parents:
20201
diff
changeset
|
106 |
} |
f2133b498789
8029388: java.exe consumes argument intended for launched java class
ksrini
parents:
20201
diff
changeset
|
107 |
|
f2133b498789
8029388: java.exe consumes argument intended for launched java class
ksrini
parents:
20201
diff
changeset
|
108 |
static void createOptionsJar() throws Exception { |
f2133b498789
8029388: java.exe consumes argument intended for launched java class
ksrini
parents:
20201
diff
changeset
|
109 |
List<String> code = new ArrayList<>(); |
f2133b498789
8029388: java.exe consumes argument intended for launched java class
ksrini
parents:
20201
diff
changeset
|
110 |
code.add("public class Args {"); |
f2133b498789
8029388: java.exe consumes argument intended for launched java class
ksrini
parents:
20201
diff
changeset
|
111 |
code.add(" public static void main(String argv[]) {"); |
f2133b498789
8029388: java.exe consumes argument intended for launched java class
ksrini
parents:
20201
diff
changeset
|
112 |
code.add(" for (String x : argv)"); |
f2133b498789
8029388: java.exe consumes argument intended for launched java class
ksrini
parents:
20201
diff
changeset
|
113 |
code.add(" System.out.println(\"" + OPT_PREFIX + "\" + x);"); |
f2133b498789
8029388: java.exe consumes argument intended for launched java class
ksrini
parents:
20201
diff
changeset
|
114 |
code.add(" }"); |
f2133b498789
8029388: java.exe consumes argument intended for launched java class
ksrini
parents:
20201
diff
changeset
|
115 |
code.add("}"); |
f2133b498789
8029388: java.exe consumes argument intended for launched java class
ksrini
parents:
20201
diff
changeset
|
116 |
File optionsJava = new File(OptionName + JAVA_FILE_EXT); |
f2133b498789
8029388: java.exe consumes argument intended for launched java class
ksrini
parents:
20201
diff
changeset
|
117 |
createFile(optionsJava, code); |
f2133b498789
8029388: java.exe consumes argument intended for launched java class
ksrini
parents:
20201
diff
changeset
|
118 |
File optionsClass = new File(OptionName + CLASS_FILE_EXT); |
f2133b498789
8029388: java.exe consumes argument intended for launched java class
ksrini
parents:
20201
diff
changeset
|
119 |
|
f2133b498789
8029388: java.exe consumes argument intended for launched java class
ksrini
parents:
20201
diff
changeset
|
120 |
compile(optionsJava.getName()); |
f2133b498789
8029388: java.exe consumes argument intended for launched java class
ksrini
parents:
20201
diff
changeset
|
121 |
createJar("cvfe", |
f2133b498789
8029388: java.exe consumes argument intended for launched java class
ksrini
parents:
20201
diff
changeset
|
122 |
TestOptionJar.getName(), |
f2133b498789
8029388: java.exe consumes argument intended for launched java class
ksrini
parents:
20201
diff
changeset
|
123 |
OptionName, |
f2133b498789
8029388: java.exe consumes argument intended for launched java class
ksrini
parents:
20201
diff
changeset
|
124 |
optionsClass.getName()); |
f2133b498789
8029388: java.exe consumes argument intended for launched java class
ksrini
parents:
20201
diff
changeset
|
125 |
} |
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
126 |
} |