--- a/test/jtreg-ext/requires/VMProps.java Tue Oct 10 14:38:56 2017 -0700
+++ b/test/jtreg-ext/requires/VMProps.java Tue Oct 10 19:18:36 2017 -0700
@@ -32,6 +32,7 @@
import java.util.List;
import java.util.Map;
import java.util.concurrent.Callable;
+import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -75,6 +76,7 @@
map.put("vm.cds", vmCDS());
// vm.graal.enabled is true if Graal is used as JIT
map.put("vm.graal.enabled", isGraalEnabled());
+ map.put("docker.support", dockerSupport());
vmGC(map); // vm.gc.X = true/false
VMProps.dump(map);
@@ -329,6 +331,38 @@
return "true";
}
+
+ /**
+ * A simple check for docker support
+ *
+ * @return true if docker is supported in a given environment
+ */
+ protected String dockerSupport() {
+ // currently docker testing is only supported for Linux-x64
+ if (! ( Platform.isLinux() && Platform.isX64() ) )
+ return "false";
+
+ boolean isSupported;
+ try {
+ isSupported = checkDockerSupport();
+ } catch (Exception e) {
+ isSupported = false;
+ System.err.println("dockerSupport() threw exception: " + e);
+ }
+
+ return (isSupported) ? "true" : "false";
+ }
+
+ private boolean checkDockerSupport() throws IOException, InterruptedException {
+ ProcessBuilder pb = new ProcessBuilder("docker", "ps");
+ Process p = pb.start();
+ p.waitFor(10, TimeUnit.SECONDS);
+
+ return (p.exitValue() == 0);
+ }
+
+
+
/**
* 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