< prev index next >

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

Print this page
rev 6999 : 8068013: [TESTBUG] Aix support in hotspot jtreg tests
Reviewed-by: ctornqvi, fzhinkin, farvidsson
   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  */


  44     public static boolean isGraal() {
  45         return vmName.endsWith(" Graal VM");
  46     }
  47 
  48     public static boolean isMinimal() {
  49         return vmName.endsWith(" Minimal VM");
  50     }
  51 
  52     public static boolean isEmbedded() {
  53         return vmName.contains("Embedded");
  54     }
  55 
  56     public static boolean is32bit() {
  57         return dataModel.equals("32");
  58     }
  59 
  60     public static boolean is64bit() {
  61         return dataModel.equals("64");
  62     }
  63 
  64     public static boolean isSolaris() {
  65         return isOs("sunos");
  66     }
  67 
  68     public static boolean isWindows() {
  69         return isOs("win");
  70     }
  71 
  72     public static boolean isOSX() {
  73         return isOs("mac");
  74     }
  75 
  76     public static boolean isLinux() {
  77         return isOs("linux");




  78     }
  79 
  80     private static boolean isOs(String osname) {
  81         return osName.toLowerCase().startsWith(osname.toLowerCase());
  82     }
  83 
  84     public static String getOsName() {
  85         return osName;
  86     }
  87 
  88     public static boolean isDebugBuild() {
  89         return vmVersion.toLowerCase().contains("debug");
  90     }
  91 
  92     public static String getVMVersion() {
  93         return vmVersion;
  94     }
  95 
  96     // Returns true for sparc and sparcv9.
  97     public static boolean isSparc() {


 113 
 114     public static boolean isX64() {
 115         // On OSX it's 'x86_64' and on other (Linux, Windows and Solaris) platforms it's 'amd64'
 116         return (isArch("amd64") || isArch("x86_64"));
 117     }
 118 
 119     private static boolean isArch(String archname) {
 120         return osArch.toLowerCase().startsWith(archname.toLowerCase());
 121     }
 122 
 123     public static String getOsArch() {
 124         return osArch;
 125     }
 126 
 127     /**
 128      * Return a boolean for whether we expect to be able to attach
 129      * the SA to our own processes on this system.
 130      */
 131     public static boolean shouldSAAttach() throws Exception {
 132 
 133         if (isLinux()) {


 134             return canPtraceAttachLinux();
 135         } else if (isOSX()) {
 136             return canAttachOSX();
 137         } else {
 138             // Other platforms expected to work:
 139             return true;
 140         }
 141     }
 142 
 143     /**
 144      * On Linux, first check the SELinux boolean "deny_ptrace" and return false
 145      * as we expect to be denied if that is "1".  Then expect permission to attach
 146      * if we are root, so return true.  Then return false for an expected denial
 147      * if "ptrace_scope" is 1, and true otherwise.
 148      */
 149     public static boolean canPtraceAttachLinux() throws Exception {
 150 
 151         // SELinux deny_ptrace:
 152         String deny_ptrace = Utils.fileAsString("/sys/fs/selinux/booleans/deny_ptrace");
 153         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  */


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


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


< prev index next >