1 | #
|
---|
2 | # Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved.
|
---|
3 | # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
---|
4 | #
|
---|
5 | # This code is free software; you can redistribute it and/or modify it
|
---|
6 | # under the terms of the GNU General Public License version 2 only, as
|
---|
7 | # published by the Free Software Foundation.
|
---|
8 | #
|
---|
9 | # This code is distributed in the hope that it will be useful, but WITHOUT
|
---|
10 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
---|
11 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
---|
12 | # version 2 for more details (a copy is included in the LICENSE file that
|
---|
13 | # accompanied this code).
|
---|
14 | #
|
---|
15 | # You should have received a copy of the GNU General Public License version
|
---|
16 | # 2 along with this work; if not, write to the Free Software Foundation,
|
---|
17 | # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
---|
18 | #
|
---|
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.
|
---|
22 | #
|
---|
23 |
|
---|
24 | # @test
|
---|
25 | # @bug 4894330 4810347 6277269
|
---|
26 | # @run shell ChangeDataModel.sh
|
---|
27 | # @summary Verify -d32 and -d64 options are accepted(rejected) on all platforms
|
---|
28 | # @author Joseph D. Darcy
|
---|
29 |
|
---|
30 | OS=`uname -s`;
|
---|
31 |
|
---|
32 | case "$OS" in
|
---|
33 | Windows* | CYGWIN* )
|
---|
34 | PATHSEP=";"
|
---|
35 | ;;
|
---|
36 |
|
---|
37 | * )
|
---|
38 | PATHSEP=":"
|
---|
39 | ;;
|
---|
40 | esac
|
---|
41 |
|
---|
42 | # Verify directory context variables are set
|
---|
43 | if [ "${TESTJAVA}" = "" ]
|
---|
44 | then
|
---|
45 | echo "TESTJAVA not set. Test cannot execute. Failed."
|
---|
46 | exit 1
|
---|
47 | fi
|
---|
48 |
|
---|
49 | if [ "${TESTSRC}" = "" ]
|
---|
50 | then
|
---|
51 | echo "TESTSRC not set. Test cannot execute. Failed."
|
---|
52 | exit 1
|
---|
53 | fi
|
---|
54 |
|
---|
55 | if [ "${TESTCLASSES}" = "" ]
|
---|
56 | then
|
---|
57 | echo "TESTCLASSES not set. Test cannot execute. Failed."
|
---|
58 | exit 1
|
---|
59 | fi
|
---|
60 |
|
---|
61 | # Construct paths to default Java executables
|
---|
62 | JAVA="$TESTJAVA/bin/java -classpath $TESTCLASSES${PATHSEP}."
|
---|
63 | JAVAC="$TESTJAVA/bin/javac"
|
---|
64 |
|
---|
65 |
|
---|
66 | # Create our little Java test on the fly
|
---|
67 | ( printf "public class GetDataModel {"
|
---|
68 | printf " public static void main(String argv[]) {"
|
---|
69 | printf " System.out.println(System.getProperty(\"sun.arch.data.model\", \"none\"));"
|
---|
70 | printf " }"
|
---|
71 | printf "}"
|
---|
72 | ) > GetDataModel.java
|
---|
73 |
|
---|
74 | $JAVAC GetDataModel.java
|
---|
75 |
|
---|
76 |
|
---|
77 | # All preconditions are met; run the tests.
|
---|
78 |
|
---|
79 |
|
---|
80 | # Verify data model flag for default data model is accepted
|
---|
81 |
|
---|
82 | DM=`$JAVA GetDataModel`
|
---|
83 | case "$DM" in
|
---|
84 | 32 )
|
---|
85 | DM2=`${JAVA} -d32 GetDataModel`
|
---|
86 | if [ "${DM2}" != "32" ]
|
---|
87 | then
|
---|
88 | echo "Data model flag -d32 not accepted or had improper effect."
|
---|
89 | exit 1
|
---|
90 | fi
|
---|
91 | ;;
|
---|
92 |
|
---|
93 | 64 )
|
---|
94 | DM2=`${JAVA} -d64 GetDataModel`
|
---|
95 | if [ "${DM2}" != "64" ]
|
---|
96 | then
|
---|
97 | echo "Data model flag -d64 not accepted or had improper effect."
|
---|
98 | exit 1
|
---|
99 | fi
|
---|
100 | ;;
|
---|
101 |
|
---|
102 | * )
|
---|
103 | echo "Unrecognized data model: $DM"
|
---|
104 | exit 1
|
---|
105 | ;;
|
---|
106 | esac
|
---|
107 |
|
---|
108 | # Determine if platform might be dual-mode capable.
|
---|
109 |
|
---|
110 | case "$OS" in
|
---|
111 | SunOS )
|
---|
112 | # ARCH should be sparc or i386
|
---|
113 | ARCH=`uname -p`
|
---|
114 | case "${ARCH}" in
|
---|
115 | sparc )
|
---|
116 | DUALMODE=true
|
---|
117 | PATH64=sparcv9
|
---|
118 | ;;
|
---|
119 |
|
---|
120 | i386 )
|
---|
121 | DUALMODE=true
|
---|
122 | PATH64=amd64
|
---|
123 | ;;
|
---|
124 |
|
---|
125 | * )
|
---|
126 | DUALMODE=false
|
---|
127 | ;;
|
---|
128 | esac
|
---|
129 | ;;
|
---|
130 |
|
---|
131 |
|
---|
132 | Linux )
|
---|
133 | # ARCH should be ia64, x86_64, or i*86
|
---|
134 | ARCH=`uname -m`
|
---|
135 | case "${ARCH}" in
|
---|
136 | ia64 )
|
---|
137 | DUALMODE=false
|
---|
138 | ;;
|
---|
139 |
|
---|
140 | x86_64 )
|
---|
141 | DUALMODE=true
|
---|
142 | PATH64=amd64
|
---|
143 | ;;
|
---|
144 |
|
---|
145 | * )
|
---|
146 | DUALMODE=false;
|
---|
147 | ;;
|
---|
148 | esac
|
---|
149 | ;;
|
---|
150 |
|
---|
151 | Windows* | CYGWIN* )
|
---|
152 | ARCH=`uname -m`
|
---|
153 | case "${ARCH}" in
|
---|
154 | * )
|
---|
155 | DUALMODE=false;
|
---|
156 | ;;
|
---|
157 | esac
|
---|
158 | ;;
|
---|
159 |
|
---|
160 | * )
|
---|
161 | echo "Warning: unknown environment."
|
---|
162 | DUALMODE=false
|
---|
163 | ;;
|
---|
164 | esac
|
---|
165 |
|
---|
166 | if [ "${DUALMODE}" = "true" ]
|
---|
167 | then
|
---|
168 | # Construct path to 64-bit Java executable, might not exist
|
---|
169 | JAVA64FILE="${TESTJAVA}/bin/${PATH64}/java"
|
---|
170 | JAVA64="${JAVA64FILE} -classpath ${TESTCLASSES}${PATHSEP}."
|
---|
171 |
|
---|
172 | if [ -f ${JAVA64FILE} ]; then
|
---|
173 | # Verify that, at least on Solaris, only one exec is
|
---|
174 | # used to change data models
|
---|
175 | if [ "${OS}" = "SunOS" ]
|
---|
176 | then
|
---|
177 | rm -f truss.out
|
---|
178 | truss -texec ${JAVA} -d64 GetDataModel > /dev/null 2> truss.out
|
---|
179 | execCount=`grep -c execve truss.out`
|
---|
180 | if [ "${execCount}" -gt 2 ]
|
---|
181 | then
|
---|
182 | echo "Maximum exec count of 2 exceeded: got $execCount."
|
---|
183 | exit 1
|
---|
184 | fi
|
---|
185 |
|
---|
186 | rm -f truss.out
|
---|
187 | truss -texec ${JAVA64} -d32 GetDataModel > /dev/null 2> truss.out
|
---|
188 | execCount=`grep -c execve truss.out`
|
---|
189 | if [ "${execCount}" -gt 2 ]
|
---|
190 | then
|
---|
191 | echo "Maximum exec count of 2 exceeded: got $execCount."
|
---|
192 | exit 1
|
---|
193 | fi
|
---|
194 | fi
|
---|
195 |
|
---|
196 | DM2=`${JAVA} -d64 GetDataModel`
|
---|
197 | if [ "${DM2}" != "64" ]
|
---|
198 | then
|
---|
199 | echo "Data model flag -d64 not accepted or had improper effect."
|
---|
200 | exit 1
|
---|
201 | fi
|
---|
202 |
|
---|
203 | DM2=`${JAVA64} GetDataModel`
|
---|
204 | if [ "${DM2}" != "64" ]
|
---|
205 | then
|
---|
206 | echo "Improper data model returned."
|
---|
207 | exit 1
|
---|
208 | fi
|
---|
209 |
|
---|
210 | DM2=`${JAVA64} -d64 GetDataModel`
|
---|
211 | if [ "${DM2}" != "64" ]
|
---|
212 | then
|
---|
213 | echo "Data model flag -d64 not accepted or had improper effect."
|
---|
214 | exit 1
|
---|
215 | fi
|
---|
216 |
|
---|
217 | DM2=`${JAVA64} -d32 GetDataModel`
|
---|
218 | if [ "${DM2}" != "32" ]
|
---|
219 | then
|
---|
220 | echo "Data model flag -d32 not accepted or had improper effect."
|
---|
221 | exit 1
|
---|
222 | fi
|
---|
223 |
|
---|
224 | else
|
---|
225 | echo "Warning: no 64-bit components found; only one data model tested."
|
---|
226 | fi
|
---|
227 | else
|
---|
228 | # Negative tests for non-dual mode platforms to ensure the other data model is
|
---|
229 | # rejected
|
---|
230 | DM=`$JAVA GetDataModel`
|
---|
231 | case "$DM" in
|
---|
232 | 32 )
|
---|
233 | DM2=`${JAVA} -d64 GetDataModel`
|
---|
234 | if [ "x${DM2}" != "x" ]
|
---|
235 | then
|
---|
236 | echo "Data model flag -d64 was accepted."
|
---|
237 | exit 1
|
---|
238 | fi
|
---|
239 | ;;
|
---|
240 |
|
---|
241 | 64 )
|
---|
242 | DM2=`${JAVA} -d32 GetDataModel`
|
---|
243 | if [ "x${DM2}" != "x" ]
|
---|
244 | then
|
---|
245 | echo "Data model flag -d32 was accepted."
|
---|
246 | exit 1
|
---|
247 | fi
|
---|
248 | ;;
|
---|
249 |
|
---|
250 | * )
|
---|
251 | echo "Unrecognized data model: $DM"
|
---|
252 | exit 1
|
---|
253 | ;;
|
---|
254 | esac
|
---|
255 | fi
|
---|
256 |
|
---|
257 | exit 0;
|
---|