8181124: Get rid of compiler.testlibrary.rtm.predicate

Reviewed-by: kvn
This commit is contained in:
Ekaterina Pavlova 2017-06-01 17:34:34 -07:00
parent 02f3062a7f
commit ddaeb2dd0e
2 changed files with 45 additions and 2 deletions

View File

@ -37,6 +37,7 @@ import java.util.regex.Pattern;
import sun.hotspot.cpuinfo.CPUInfo;
import sun.hotspot.gc.GC;
import sun.hotspot.WhiteBox;
import jdk.test.lib.Platform;
/**
* The Class to be invoked by jtreg prior Test Suite execution to
@ -66,6 +67,8 @@ public class VMProps implements Callable<Map<String, String>> {
map.put("vm.jvmci", vmJvmci());
map.put("vm.emulatedClient", vmEmulatedClient());
map.put("vm.cpu.features", cpuFeatures());
map.put("vm.rtm.cpu", vmRTMCPU());
map.put("vm.rtm.os", vmRTMOS());
vmGC(map); // vm.gc.X = true/false
VMProps.dump(map);
@ -205,6 +208,36 @@ public class VMProps implements Callable<Map<String, String>> {
}
}
/**
* @return true if VM runs RTM supported OS and false otherwise.
*/
protected String vmRTMOS() {
boolean isRTMOS = true;
if (Platform.isAix()) {
// Actually, this works since AIX 7.1.3.30, but os.version property
// is set to 7.1.
isRTMOS = (Platform.getOsVersionMajor() > 7) ||
(Platform.getOsVersionMajor() == 7 && Platform.getOsVersionMinor() > 1);
} else if (Platform.isLinux()) {
if (Platform.isPPC()) {
isRTMOS = (Platform.getOsVersionMajor() > 4) ||
(Platform.getOsVersionMajor() == 4 && Platform.getOsVersionMinor() > 1);
}
}
return "" + isRTMOS;
}
/**
* @return true if VM runs RTM supported CPU and false otherwise.
*/
protected String vmRTMCPU() {
boolean vmRTMCPU = (Platform.isPPC() ? CPUInfo.hasFeature("tcheck") : CPUInfo.hasFeature("rtm"));
return "" + vmRTMCPU;
}
/**
* Dumps the map to the file if the file name is given as the property.
* This functionality could be helpful to know context in the real

View File

@ -23,6 +23,10 @@
package jdk.test.lib;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.regex.Pattern;
public class Platform {
@ -228,7 +232,7 @@ public class Platform {
public static boolean canPtraceAttachLinux() throws Exception {
// SELinux deny_ptrace:
String deny_ptrace = Utils.fileAsString("/sys/fs/selinux/booleans/deny_ptrace");
String deny_ptrace = fileAsString("/sys/fs/selinux/booleans/deny_ptrace");
if (deny_ptrace != null && deny_ptrace.contains("1")) {
// ptrace will be denied:
return false;
@ -239,7 +243,7 @@ public class Platform {
// 1 - restricted ptrace: a process must be a children of the inferior or user is root
// 2 - only processes with CAP_SYS_PTRACE may use ptrace or user is root
// 3 - no attach: no processes may use ptrace with PTRACE_ATTACH
String ptrace_scope = Utils.fileAsString("/proc/sys/kernel/yama/ptrace_scope");
String ptrace_scope = fileAsString("/proc/sys/kernel/yama/ptrace_scope");
if (ptrace_scope != null) {
if (ptrace_scope.startsWith("3")) {
return false;
@ -265,4 +269,10 @@ public class Platform {
.matcher(osArch)
.matches();
}
private static String fileAsString(String filename) throws IOException {
Path filePath = Paths.get(filename);
if (!Files.exists(filePath)) return null;
return new String(Files.readAllBytes(filePath));
}
}