< prev index next >

test/testlibrary/com/oracle/java/testlibrary/Platform.java

Print this page
rev 7604 : 8068013: [TESTBUG] Aix support in hotspot jtreg tests
   1 /*
   2  * Copyright (c) 2013, 2014, 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  */


  51     public static boolean isMinimal() {
  52         return vmName.endsWith(" Minimal VM");
  53     }
  54 
  55     public static boolean isEmbedded() {
  56         return vmName.contains("Embedded");
  57     }
  58 
  59     public static boolean isTieredSupported() {
  60         return compiler.contains("Tiered Compilers");
  61     }
  62 
  63     public static boolean is32bit() {
  64         return dataModel.equals("32");
  65     }
  66 
  67     public static boolean is64bit() {
  68         return dataModel.equals("64");
  69     }
  70 
  71     public static boolean isSolaris() {
  72         return isOs("sunos");
  73     }
  74 
  75     public static boolean isWindows() {
  76         return isOs("win");
  77     }
  78 
  79     public static boolean isOSX() {
  80         return isOs("mac");
  81     }
  82 
  83     public static boolean isLinux() {
  84         return isOs("linux");




  85     }
  86 
  87     private static boolean isOs(String osname) {
  88         return osName.toLowerCase().startsWith(osname.toLowerCase());
  89     }
  90 
  91     public static String getOsName() {
  92         return osName;
  93     }
  94 
  95     public static boolean isDebugBuild() {
  96         return (vmVersion.toLowerCase().contains("debug") ||
  97                 javaVersion.toLowerCase().contains("debug"));
  98     }
  99 
 100     public static String getVMVersion() {
 101         return vmVersion;
 102     }
 103 
 104     // Returns true for sparc and sparcv9.


 123         // On OSX it's 'x86_64' and on other (Linux, Windows and Solaris) platforms it's 'amd64'
 124         return isArch("(amd64)|(x86_64)");
 125     }
 126 
 127     private static boolean isArch(String archnameRE) {
 128         return Pattern.compile(archnameRE, Pattern.CASE_INSENSITIVE)
 129                 .matcher(osArch)
 130                 .matches();
 131     }
 132 
 133     public static String getOsArch() {
 134         return osArch;
 135     }
 136 
 137     /**
 138      * Return a boolean for whether we expect to be able to attach
 139      * the SA to our own processes on this system.
 140      */
 141     public static boolean shouldSAAttach() throws Exception {
 142 
 143         if (isLinux()) {


 144             return canPtraceAttachLinux();
 145         } else if (isOSX()) {
 146             return canAttachOSX();
 147         } else {
 148             // Other platforms expected to work:
 149             return true;
 150         }
 151     }
 152 
 153     /**
 154      * On Linux, first check the SELinux boolean "deny_ptrace" and return false
 155      * as we expect to be denied if that is "1".  Then expect permission to attach
 156      * if we are root, so return true.  Then return false for an expected denial
 157      * if "ptrace_scope" is 1, and true otherwise.
 158      */
 159     public static boolean canPtraceAttachLinux() throws Exception {
 160 
 161         // SELinux deny_ptrace:
 162         String deny_ptrace = Utils.fileAsString("/sys/fs/selinux/booleans/deny_ptrace");
 163         if (deny_ptrace != null && deny_ptrace.contains("1")) {


   1 /*
   2  * Copyright (c) 2013, 2015, 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  */


  51     public static boolean isMinimal() {
  52         return vmName.endsWith(" Minimal VM");
  53     }
  54 
  55     public static boolean isEmbedded() {
  56         return vmName.contains("Embedded");
  57     }
  58 
  59     public static boolean isTieredSupported() {
  60         return compiler.contains("Tiered Compilers");
  61     }
  62 
  63     public static boolean is32bit() {
  64         return dataModel.equals("32");
  65     }
  66 
  67     public static boolean is64bit() {
  68         return dataModel.equals("64");
  69     }
  70 
  71     public static boolean isAix() {
  72         return isOs("aix");
  73     }
  74 
  75     public static boolean isLinux() {
  76         return isOs("linux");
  77     }
  78 
  79     public static boolean isOSX() {
  80         return isOs("mac");
  81     }
  82 
  83     public static boolean isSolaris() {
  84         return isOs("sunos");
  85     }
  86 
  87     public static boolean isWindows() {
  88         return isOs("win");
  89     }
  90 
  91     private static boolean isOs(String osname) {
  92         return osName.toLowerCase().startsWith(osname.toLowerCase());
  93     }
  94 
  95     public static String getOsName() {
  96         return osName;
  97     }
  98 
  99     public static boolean isDebugBuild() {
 100         return (vmVersion.toLowerCase().contains("debug") ||
 101                 javaVersion.toLowerCase().contains("debug"));
 102     }
 103 
 104     public static String getVMVersion() {
 105         return vmVersion;
 106     }
 107 
 108     // Returns true for sparc and sparcv9.


 127         // On OSX it's 'x86_64' and on other (Linux, Windows and Solaris) platforms it's 'amd64'
 128         return isArch("(amd64)|(x86_64)");
 129     }
 130 
 131     private static boolean isArch(String archnameRE) {
 132         return Pattern.compile(archnameRE, Pattern.CASE_INSENSITIVE)
 133                 .matcher(osArch)
 134                 .matches();
 135     }
 136 
 137     public static String getOsArch() {
 138         return osArch;
 139     }
 140 
 141     /**
 142      * Return a boolean for whether we expect to be able to attach
 143      * the SA to our own processes on this system.
 144      */
 145     public static boolean shouldSAAttach() throws Exception {
 146 
 147         if (isAix()) {
 148             return false;   // SA not implemented.
 149         } else if (isLinux()) {
 150             return canPtraceAttachLinux();
 151         } else if (isOSX()) {
 152             return canAttachOSX();
 153         } else {
 154             // Other platforms expected to work:
 155             return true;
 156         }
 157     }
 158 
 159     /**
 160      * On Linux, first check the SELinux boolean "deny_ptrace" and return false
 161      * as we expect to be denied if that is "1".  Then expect permission to attach
 162      * if we are root, so return true.  Then return false for an expected denial
 163      * if "ptrace_scope" is 1, and true otherwise.
 164      */
 165     public static boolean canPtraceAttachLinux() throws Exception {
 166 
 167         // SELinux deny_ptrace:
 168         String deny_ptrace = Utils.fileAsString("/sys/fs/selinux/booleans/deny_ptrace");
 169         if (deny_ptrace != null && deny_ptrace.contains("1")) {


< prev index next >