annotate test/testlibrary/com/oracle/java/testlibrary/Platform.java @ 12416:9ad59f7fd57e

ConstantNode methods should not throw InternalError
author twisti
date Mon, 14 Oct 2013 19:46:29 -0700
parents c1fbf21c7397
children bbfe3ac1471d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10971
1e9094165098 8015324: Create tests for CDS feature
ctornqvi
parents:
diff changeset
1 /*
1e9094165098 8015324: Create tests for CDS feature
ctornqvi
parents:
diff changeset
2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
1e9094165098 8015324: Create tests for CDS feature
ctornqvi
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1e9094165098 8015324: Create tests for CDS feature
ctornqvi
parents:
diff changeset
4 *
1e9094165098 8015324: Create tests for CDS feature
ctornqvi
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
1e9094165098 8015324: Create tests for CDS feature
ctornqvi
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
1e9094165098 8015324: Create tests for CDS feature
ctornqvi
parents:
diff changeset
7 * published by the Free Software Foundation.
1e9094165098 8015324: Create tests for CDS feature
ctornqvi
parents:
diff changeset
8 *
1e9094165098 8015324: Create tests for CDS feature
ctornqvi
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
1e9094165098 8015324: Create tests for CDS feature
ctornqvi
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1e9094165098 8015324: Create tests for CDS feature
ctornqvi
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
1e9094165098 8015324: Create tests for CDS feature
ctornqvi
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
1e9094165098 8015324: Create tests for CDS feature
ctornqvi
parents:
diff changeset
13 * accompanied this code).
1e9094165098 8015324: Create tests for CDS feature
ctornqvi
parents:
diff changeset
14 *
1e9094165098 8015324: Create tests for CDS feature
ctornqvi
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
1e9094165098 8015324: Create tests for CDS feature
ctornqvi
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
1e9094165098 8015324: Create tests for CDS feature
ctornqvi
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1e9094165098 8015324: Create tests for CDS feature
ctornqvi
parents:
diff changeset
18 *
1e9094165098 8015324: Create tests for CDS feature
ctornqvi
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1e9094165098 8015324: Create tests for CDS feature
ctornqvi
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
1e9094165098 8015324: Create tests for CDS feature
ctornqvi
parents:
diff changeset
21 * questions.
1e9094165098 8015324: Create tests for CDS feature
ctornqvi
parents:
diff changeset
22 */
1e9094165098 8015324: Create tests for CDS feature
ctornqvi
parents:
diff changeset
23
1e9094165098 8015324: Create tests for CDS feature
ctornqvi
parents:
diff changeset
24 package com.oracle.java.testlibrary;
1e9094165098 8015324: Create tests for CDS feature
ctornqvi
parents:
diff changeset
25
1e9094165098 8015324: Create tests for CDS feature
ctornqvi
parents:
diff changeset
26 public class Platform {
12315
c1fbf21c7397 8024492: [TESTBUG] Test library class Platform.java needs to include methods for missing OS's and architectures
ctornqvi
parents: 11994
diff changeset
27 private static final String osName = System.getProperty("os.name");
c1fbf21c7397 8024492: [TESTBUG] Test library class Platform.java needs to include methods for missing OS's and architectures
ctornqvi
parents: 11994
diff changeset
28 private static final String dataModel = System.getProperty("sun.arch.data.model");
c1fbf21c7397 8024492: [TESTBUG] Test library class Platform.java needs to include methods for missing OS's and architectures
ctornqvi
parents: 11994
diff changeset
29 private static final String vmVersion = System.getProperty("java.vm.version");
c1fbf21c7397 8024492: [TESTBUG] Test library class Platform.java needs to include methods for missing OS's and architectures
ctornqvi
parents: 11994
diff changeset
30 private static final String osArch = System.getProperty("os.arch");
10971
1e9094165098 8015324: Create tests for CDS feature
ctornqvi
parents:
diff changeset
31
12315
c1fbf21c7397 8024492: [TESTBUG] Test library class Platform.java needs to include methods for missing OS's and architectures
ctornqvi
parents: 11994
diff changeset
32 public static boolean is32bit() {
c1fbf21c7397 8024492: [TESTBUG] Test library class Platform.java needs to include methods for missing OS's and architectures
ctornqvi
parents: 11994
diff changeset
33 return dataModel.equals("32");
c1fbf21c7397 8024492: [TESTBUG] Test library class Platform.java needs to include methods for missing OS's and architectures
ctornqvi
parents: 11994
diff changeset
34 }
c1fbf21c7397 8024492: [TESTBUG] Test library class Platform.java needs to include methods for missing OS's and architectures
ctornqvi
parents: 11994
diff changeset
35
c1fbf21c7397 8024492: [TESTBUG] Test library class Platform.java needs to include methods for missing OS's and architectures
ctornqvi
parents: 11994
diff changeset
36 public static boolean is64bit() {
c1fbf21c7397 8024492: [TESTBUG] Test library class Platform.java needs to include methods for missing OS's and architectures
ctornqvi
parents: 11994
diff changeset
37 return dataModel.equals("64");
c1fbf21c7397 8024492: [TESTBUG] Test library class Platform.java needs to include methods for missing OS's and architectures
ctornqvi
parents: 11994
diff changeset
38 }
c1fbf21c7397 8024492: [TESTBUG] Test library class Platform.java needs to include methods for missing OS's and architectures
ctornqvi
parents: 11994
diff changeset
39
c1fbf21c7397 8024492: [TESTBUG] Test library class Platform.java needs to include methods for missing OS's and architectures
ctornqvi
parents: 11994
diff changeset
40 public static boolean isSolaris() {
c1fbf21c7397 8024492: [TESTBUG] Test library class Platform.java needs to include methods for missing OS's and architectures
ctornqvi
parents: 11994
diff changeset
41 return isOs("sunos");
c1fbf21c7397 8024492: [TESTBUG] Test library class Platform.java needs to include methods for missing OS's and architectures
ctornqvi
parents: 11994
diff changeset
42 }
10971
1e9094165098 8015324: Create tests for CDS feature
ctornqvi
parents:
diff changeset
43
12315
c1fbf21c7397 8024492: [TESTBUG] Test library class Platform.java needs to include methods for missing OS's and architectures
ctornqvi
parents: 11994
diff changeset
44 public static boolean isWindows() {
c1fbf21c7397 8024492: [TESTBUG] Test library class Platform.java needs to include methods for missing OS's and architectures
ctornqvi
parents: 11994
diff changeset
45 return isOs("win");
c1fbf21c7397 8024492: [TESTBUG] Test library class Platform.java needs to include methods for missing OS's and architectures
ctornqvi
parents: 11994
diff changeset
46 }
c1fbf21c7397 8024492: [TESTBUG] Test library class Platform.java needs to include methods for missing OS's and architectures
ctornqvi
parents: 11994
diff changeset
47
c1fbf21c7397 8024492: [TESTBUG] Test library class Platform.java needs to include methods for missing OS's and architectures
ctornqvi
parents: 11994
diff changeset
48 public static boolean isOSX() {
c1fbf21c7397 8024492: [TESTBUG] Test library class Platform.java needs to include methods for missing OS's and architectures
ctornqvi
parents: 11994
diff changeset
49 return isOs("mac");
c1fbf21c7397 8024492: [TESTBUG] Test library class Platform.java needs to include methods for missing OS's and architectures
ctornqvi
parents: 11994
diff changeset
50 }
10971
1e9094165098 8015324: Create tests for CDS feature
ctornqvi
parents:
diff changeset
51
12315
c1fbf21c7397 8024492: [TESTBUG] Test library class Platform.java needs to include methods for missing OS's and architectures
ctornqvi
parents: 11994
diff changeset
52 public static boolean isLinux() {
c1fbf21c7397 8024492: [TESTBUG] Test library class Platform.java needs to include methods for missing OS's and architectures
ctornqvi
parents: 11994
diff changeset
53 return isOs("linux");
c1fbf21c7397 8024492: [TESTBUG] Test library class Platform.java needs to include methods for missing OS's and architectures
ctornqvi
parents: 11994
diff changeset
54 }
10971
1e9094165098 8015324: Create tests for CDS feature
ctornqvi
parents:
diff changeset
55
12315
c1fbf21c7397 8024492: [TESTBUG] Test library class Platform.java needs to include methods for missing OS's and architectures
ctornqvi
parents: 11994
diff changeset
56 private static boolean isOs(String osname) {
c1fbf21c7397 8024492: [TESTBUG] Test library class Platform.java needs to include methods for missing OS's and architectures
ctornqvi
parents: 11994
diff changeset
57 return osName.toLowerCase().startsWith(osname.toLowerCase());
c1fbf21c7397 8024492: [TESTBUG] Test library class Platform.java needs to include methods for missing OS's and architectures
ctornqvi
parents: 11994
diff changeset
58 }
c1fbf21c7397 8024492: [TESTBUG] Test library class Platform.java needs to include methods for missing OS's and architectures
ctornqvi
parents: 11994
diff changeset
59
c1fbf21c7397 8024492: [TESTBUG] Test library class Platform.java needs to include methods for missing OS's and architectures
ctornqvi
parents: 11994
diff changeset
60 public static String getOsName() {
c1fbf21c7397 8024492: [TESTBUG] Test library class Platform.java needs to include methods for missing OS's and architectures
ctornqvi
parents: 11994
diff changeset
61 return osName;
c1fbf21c7397 8024492: [TESTBUG] Test library class Platform.java needs to include methods for missing OS's and architectures
ctornqvi
parents: 11994
diff changeset
62 }
10971
1e9094165098 8015324: Create tests for CDS feature
ctornqvi
parents:
diff changeset
63
12315
c1fbf21c7397 8024492: [TESTBUG] Test library class Platform.java needs to include methods for missing OS's and architectures
ctornqvi
parents: 11994
diff changeset
64 public static boolean isDebugBuild() {
c1fbf21c7397 8024492: [TESTBUG] Test library class Platform.java needs to include methods for missing OS's and architectures
ctornqvi
parents: 11994
diff changeset
65 return vmVersion.toLowerCase().contains("debug");
c1fbf21c7397 8024492: [TESTBUG] Test library class Platform.java needs to include methods for missing OS's and architectures
ctornqvi
parents: 11994
diff changeset
66 }
c1fbf21c7397 8024492: [TESTBUG] Test library class Platform.java needs to include methods for missing OS's and architectures
ctornqvi
parents: 11994
diff changeset
67
c1fbf21c7397 8024492: [TESTBUG] Test library class Platform.java needs to include methods for missing OS's and architectures
ctornqvi
parents: 11994
diff changeset
68 public static String getVMVersion() {
c1fbf21c7397 8024492: [TESTBUG] Test library class Platform.java needs to include methods for missing OS's and architectures
ctornqvi
parents: 11994
diff changeset
69 return vmVersion;
c1fbf21c7397 8024492: [TESTBUG] Test library class Platform.java needs to include methods for missing OS's and architectures
ctornqvi
parents: 11994
diff changeset
70 }
10971
1e9094165098 8015324: Create tests for CDS feature
ctornqvi
parents:
diff changeset
71
12315
c1fbf21c7397 8024492: [TESTBUG] Test library class Platform.java needs to include methods for missing OS's and architectures
ctornqvi
parents: 11994
diff changeset
72 // Returns true for sparc and sparcv9.
c1fbf21c7397 8024492: [TESTBUG] Test library class Platform.java needs to include methods for missing OS's and architectures
ctornqvi
parents: 11994
diff changeset
73 public static boolean isSparc() {
c1fbf21c7397 8024492: [TESTBUG] Test library class Platform.java needs to include methods for missing OS's and architectures
ctornqvi
parents: 11994
diff changeset
74 return isArch("sparc");
c1fbf21c7397 8024492: [TESTBUG] Test library class Platform.java needs to include methods for missing OS's and architectures
ctornqvi
parents: 11994
diff changeset
75 }
10971
1e9094165098 8015324: Create tests for CDS feature
ctornqvi
parents:
diff changeset
76
12315
c1fbf21c7397 8024492: [TESTBUG] Test library class Platform.java needs to include methods for missing OS's and architectures
ctornqvi
parents: 11994
diff changeset
77 public static boolean isARM() {
c1fbf21c7397 8024492: [TESTBUG] Test library class Platform.java needs to include methods for missing OS's and architectures
ctornqvi
parents: 11994
diff changeset
78 return isArch("arm");
c1fbf21c7397 8024492: [TESTBUG] Test library class Platform.java needs to include methods for missing OS's and architectures
ctornqvi
parents: 11994
diff changeset
79 }
10971
1e9094165098 8015324: Create tests for CDS feature
ctornqvi
parents:
diff changeset
80
12315
c1fbf21c7397 8024492: [TESTBUG] Test library class Platform.java needs to include methods for missing OS's and architectures
ctornqvi
parents: 11994
diff changeset
81 public static boolean isPPC() {
c1fbf21c7397 8024492: [TESTBUG] Test library class Platform.java needs to include methods for missing OS's and architectures
ctornqvi
parents: 11994
diff changeset
82 return isArch("ppc");
c1fbf21c7397 8024492: [TESTBUG] Test library class Platform.java needs to include methods for missing OS's and architectures
ctornqvi
parents: 11994
diff changeset
83 }
c1fbf21c7397 8024492: [TESTBUG] Test library class Platform.java needs to include methods for missing OS's and architectures
ctornqvi
parents: 11994
diff changeset
84
c1fbf21c7397 8024492: [TESTBUG] Test library class Platform.java needs to include methods for missing OS's and architectures
ctornqvi
parents: 11994
diff changeset
85 public static boolean isX86() {
c1fbf21c7397 8024492: [TESTBUG] Test library class Platform.java needs to include methods for missing OS's and architectures
ctornqvi
parents: 11994
diff changeset
86 // On Linux it's 'i386', Windows 'x86'
c1fbf21c7397 8024492: [TESTBUG] Test library class Platform.java needs to include methods for missing OS's and architectures
ctornqvi
parents: 11994
diff changeset
87 return (isArch("i386") || isArch("x86"));
c1fbf21c7397 8024492: [TESTBUG] Test library class Platform.java needs to include methods for missing OS's and architectures
ctornqvi
parents: 11994
diff changeset
88 }
11994
b67604b59546 7073961: [TESTBUG] closed/runtime/4845371/DBB.java failed on solaris 10 X65
hseigel
parents: 10971
diff changeset
89
12315
c1fbf21c7397 8024492: [TESTBUG] Test library class Platform.java needs to include methods for missing OS's and architectures
ctornqvi
parents: 11994
diff changeset
90 public static boolean isX64() {
c1fbf21c7397 8024492: [TESTBUG] Test library class Platform.java needs to include methods for missing OS's and architectures
ctornqvi
parents: 11994
diff changeset
91 // On OSX it's 'x86_64' and on other (Linux, Windows and Solaris) platforms it's 'amd64'
c1fbf21c7397 8024492: [TESTBUG] Test library class Platform.java needs to include methods for missing OS's and architectures
ctornqvi
parents: 11994
diff changeset
92 return (isArch("amd64") || isArch("x86_64"));
c1fbf21c7397 8024492: [TESTBUG] Test library class Platform.java needs to include methods for missing OS's and architectures
ctornqvi
parents: 11994
diff changeset
93 }
11994
b67604b59546 7073961: [TESTBUG] closed/runtime/4845371/DBB.java failed on solaris 10 X65
hseigel
parents: 10971
diff changeset
94
12315
c1fbf21c7397 8024492: [TESTBUG] Test library class Platform.java needs to include methods for missing OS's and architectures
ctornqvi
parents: 11994
diff changeset
95 private static boolean isArch(String archname) {
c1fbf21c7397 8024492: [TESTBUG] Test library class Platform.java needs to include methods for missing OS's and architectures
ctornqvi
parents: 11994
diff changeset
96 return osArch.toLowerCase().startsWith(archname.toLowerCase());
c1fbf21c7397 8024492: [TESTBUG] Test library class Platform.java needs to include methods for missing OS's and architectures
ctornqvi
parents: 11994
diff changeset
97 }
c1fbf21c7397 8024492: [TESTBUG] Test library class Platform.java needs to include methods for missing OS's and architectures
ctornqvi
parents: 11994
diff changeset
98
c1fbf21c7397 8024492: [TESTBUG] Test library class Platform.java needs to include methods for missing OS's and architectures
ctornqvi
parents: 11994
diff changeset
99 public static String getOsArch() {
c1fbf21c7397 8024492: [TESTBUG] Test library class Platform.java needs to include methods for missing OS's and architectures
ctornqvi
parents: 11994
diff changeset
100 return osArch;
c1fbf21c7397 8024492: [TESTBUG] Test library class Platform.java needs to include methods for missing OS's and architectures
ctornqvi
parents: 11994
diff changeset
101 }
11994
b67604b59546 7073961: [TESTBUG] closed/runtime/4845371/DBB.java failed on solaris 10 X65
hseigel
parents: 10971
diff changeset
102
10971
1e9094165098 8015324: Create tests for CDS feature
ctornqvi
parents:
diff changeset
103 }