changeset 5348:c1fbf21c7397

8024492: [TESTBUG] Test library class Platform.java needs to include methods for missing OS's and architectures Summary: Added methods for 32bit, arm, ppc, x64 and x86 Reviewed-by: zgu, hseigel, mseledtsov
author ctornqvi
date Wed, 25 Sep 2013 17:47:51 +0200
parents 5b1191bf0b4b
children 190899198332 de059a14e159
files test/testlibrary/com/oracle/java/testlibrary/Platform.java
diffstat 1 files changed, 65 insertions(+), 35 deletions(-) [+]
line wrap: on
line diff
--- a/test/testlibrary/com/oracle/java/testlibrary/Platform.java	Wed Sep 25 17:47:22 2013 +0200
+++ b/test/testlibrary/com/oracle/java/testlibrary/Platform.java	Wed Sep 25 17:47:51 2013 +0200
@@ -24,50 +24,80 @@
 package com.oracle.java.testlibrary;
 
 public class Platform {
-  private static final String osName = System.getProperty("os.name");
-  private static final String dataModel = System.getProperty("sun.arch.data.model");
-  private static final String vmVersion = System.getProperty("java.vm.version");
-  private static final String osArch = System.getProperty("os.arch");
+    private static final String osName      = System.getProperty("os.name");
+    private static final String dataModel   = System.getProperty("sun.arch.data.model");
+    private static final String vmVersion   = System.getProperty("java.vm.version");
+    private static final String osArch      = System.getProperty("os.arch");
 
-  public static boolean is64bit() {
-    return dataModel.equals("64");
-  }
+    public static boolean is32bit() {
+        return dataModel.equals("32");
+    }
 
-  public static boolean isSolaris() {
-    return osName.toLowerCase().startsWith("sunos");
-  }
+    public static boolean is64bit() {
+        return dataModel.equals("64");
+    }
 
-  public static boolean isWindows() {
-    return osName.toLowerCase().startsWith("win");
-  }
+    public static boolean isSolaris() {
+        return isOs("sunos");
+    }
 
-  public static boolean isOSX() {
-    return osName.toLowerCase().startsWith("mac");
-  }
+    public static boolean isWindows() {
+        return isOs("win");
+    }
 
-  public static boolean isLinux() {
-    return osName.toLowerCase().startsWith("linux");
-  }
+    public static boolean isOSX() {
+        return isOs("mac");
+    }
 
-  public static String getOsName() {
-    return osName;
-  }
+    public static boolean isLinux() {
+        return isOs("linux");
+    }
 
-  public static boolean isDebugBuild() {
-    return vmVersion.toLowerCase().contains("debug");
-  }
+    private static boolean isOs(String osname) {
+        return osName.toLowerCase().startsWith(osname.toLowerCase());
+    }
 
-  public static String getVMVersion() {
-    return vmVersion;
-  }
+    public static String getOsName() {
+        return osName;
+    }
 
-  // Returns true for sparc and sparcv9.
-  public static boolean isSparc() {
-    return osArch.toLowerCase().startsWith("sparc");
-  }
+    public static boolean isDebugBuild() {
+        return vmVersion.toLowerCase().contains("debug");
+    }
 
-  public static String getOsArch() {
-    return osArch;
-  }
+    public static String getVMVersion() {
+        return vmVersion;
+    }
+
+    // Returns true for sparc and sparcv9.
+    public static boolean isSparc() {
+        return isArch("sparc");
+    }
+
+    public static boolean isARM() {
+        return isArch("arm");
+    }
+
+    public static boolean isPPC() {
+        return isArch("ppc");
+    }
+
+    public static boolean isX86() {
+        // On Linux it's 'i386', Windows 'x86'
+        return (isArch("i386") || isArch("x86"));
+    }
+
+    public static boolean isX64() {
+        // On OSX it's 'x86_64' and on other (Linux, Windows and Solaris) platforms it's 'amd64'
+        return (isArch("amd64") || isArch("x86_64"));
+    }
+
+    private static boolean isArch(String archname) {
+        return osArch.toLowerCase().startsWith(archname.toLowerCase());
+    }
+
+    public static String getOsArch() {
+        return osArch;
+    }
 
 }