8024492: [TESTBUG] Test library class Platform.java needs to include methods for missing OS's and architectures

Wed, 25 Sep 2013 17:47:51 +0200

author
ctornqvi
date
Wed, 25 Sep 2013 17:47:51 +0200
changeset 5783
c1fbf21c7397
parent 5782
5b1191bf0b4b
child 5784
190899198332
child 5787
de059a14e159

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

test/testlibrary/com/oracle/java/testlibrary/Platform.java file | annotate | diff | comparison | revisions
     1.1 --- a/test/testlibrary/com/oracle/java/testlibrary/Platform.java	Wed Sep 25 17:47:22 2013 +0200
     1.2 +++ b/test/testlibrary/com/oracle/java/testlibrary/Platform.java	Wed Sep 25 17:47:51 2013 +0200
     1.3 @@ -24,50 +24,80 @@
     1.4  package com.oracle.java.testlibrary;
     1.5  
     1.6  public class Platform {
     1.7 -  private static final String osName = System.getProperty("os.name");
     1.8 -  private static final String dataModel = System.getProperty("sun.arch.data.model");
     1.9 -  private static final String vmVersion = System.getProperty("java.vm.version");
    1.10 -  private static final String osArch = System.getProperty("os.arch");
    1.11 +    private static final String osName      = System.getProperty("os.name");
    1.12 +    private static final String dataModel   = System.getProperty("sun.arch.data.model");
    1.13 +    private static final String vmVersion   = System.getProperty("java.vm.version");
    1.14 +    private static final String osArch      = System.getProperty("os.arch");
    1.15  
    1.16 -  public static boolean is64bit() {
    1.17 -    return dataModel.equals("64");
    1.18 -  }
    1.19 +    public static boolean is32bit() {
    1.20 +        return dataModel.equals("32");
    1.21 +    }
    1.22  
    1.23 -  public static boolean isSolaris() {
    1.24 -    return osName.toLowerCase().startsWith("sunos");
    1.25 -  }
    1.26 +    public static boolean is64bit() {
    1.27 +        return dataModel.equals("64");
    1.28 +    }
    1.29  
    1.30 -  public static boolean isWindows() {
    1.31 -    return osName.toLowerCase().startsWith("win");
    1.32 -  }
    1.33 +    public static boolean isSolaris() {
    1.34 +        return isOs("sunos");
    1.35 +    }
    1.36  
    1.37 -  public static boolean isOSX() {
    1.38 -    return osName.toLowerCase().startsWith("mac");
    1.39 -  }
    1.40 +    public static boolean isWindows() {
    1.41 +        return isOs("win");
    1.42 +    }
    1.43  
    1.44 -  public static boolean isLinux() {
    1.45 -    return osName.toLowerCase().startsWith("linux");
    1.46 -  }
    1.47 +    public static boolean isOSX() {
    1.48 +        return isOs("mac");
    1.49 +    }
    1.50  
    1.51 -  public static String getOsName() {
    1.52 -    return osName;
    1.53 -  }
    1.54 +    public static boolean isLinux() {
    1.55 +        return isOs("linux");
    1.56 +    }
    1.57  
    1.58 -  public static boolean isDebugBuild() {
    1.59 -    return vmVersion.toLowerCase().contains("debug");
    1.60 -  }
    1.61 +    private static boolean isOs(String osname) {
    1.62 +        return osName.toLowerCase().startsWith(osname.toLowerCase());
    1.63 +    }
    1.64  
    1.65 -  public static String getVMVersion() {
    1.66 -    return vmVersion;
    1.67 -  }
    1.68 +    public static String getOsName() {
    1.69 +        return osName;
    1.70 +    }
    1.71  
    1.72 -  // Returns true for sparc and sparcv9.
    1.73 -  public static boolean isSparc() {
    1.74 -    return osArch.toLowerCase().startsWith("sparc");
    1.75 -  }
    1.76 +    public static boolean isDebugBuild() {
    1.77 +        return vmVersion.toLowerCase().contains("debug");
    1.78 +    }
    1.79  
    1.80 -  public static String getOsArch() {
    1.81 -    return osArch;
    1.82 -  }
    1.83 +    public static String getVMVersion() {
    1.84 +        return vmVersion;
    1.85 +    }
    1.86 +
    1.87 +    // Returns true for sparc and sparcv9.
    1.88 +    public static boolean isSparc() {
    1.89 +        return isArch("sparc");
    1.90 +    }
    1.91 +
    1.92 +    public static boolean isARM() {
    1.93 +        return isArch("arm");
    1.94 +    }
    1.95 +
    1.96 +    public static boolean isPPC() {
    1.97 +        return isArch("ppc");
    1.98 +    }
    1.99 +
   1.100 +    public static boolean isX86() {
   1.101 +        // On Linux it's 'i386', Windows 'x86'
   1.102 +        return (isArch("i386") || isArch("x86"));
   1.103 +    }
   1.104 +
   1.105 +    public static boolean isX64() {
   1.106 +        // On OSX it's 'x86_64' and on other (Linux, Windows and Solaris) platforms it's 'amd64'
   1.107 +        return (isArch("amd64") || isArch("x86_64"));
   1.108 +    }
   1.109 +
   1.110 +    private static boolean isArch(String archname) {
   1.111 +        return osArch.toLowerCase().startsWith(archname.toLowerCase());
   1.112 +    }
   1.113 +
   1.114 +    public static String getOsArch() {
   1.115 +        return osArch;
   1.116 +    }
   1.117  
   1.118  }

mercurial