Mercurial > hg > truffle
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 |
rev | line source |
---|---|
10971 | 1 /* |
2 * Copyright (c) 2013, 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 package com.oracle.java.testlibrary; | |
25 | |
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 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | 103 } |