test/jdk/jdk/internal/platform/docker/TestDockerMemoryMetrics.java
changeset 58790 5a9dba5a3eeb
parent 55485 1e4bbd6fbb2f
--- a/test/jdk/jdk/internal/platform/docker/TestDockerMemoryMetrics.java	Thu Oct 24 11:25:53 2019 -0700
+++ b/test/jdk/jdk/internal/platform/docker/TestDockerMemoryMetrics.java	Thu Oct 24 12:18:32 2019 -0700
@@ -25,6 +25,7 @@
 import jdk.test.lib.containers.docker.Common;
 import jdk.test.lib.containers.docker.DockerRunOptions;
 import jdk.test.lib.containers.docker.DockerTestUtils;
+import jdk.test.lib.process.OutputAnalyzer;
 
 /*
  * @test
@@ -119,7 +120,19 @@
                 .addJavaOpts("-cp", "/test-classes/")
                 .addJavaOpts("--add-exports", "java.base/jdk.internal.platform=ALL-UNNAMED")
                 .addClassOptions("kernelmem", value);
-        DockerTestUtils.dockerRunJava(opts).shouldHaveExitValue(0).shouldContain("TEST PASSED!!!");
+        OutputAnalyzer oa = DockerTestUtils.dockerRunJava(opts);
+
+        // Some container runtimes (e.g. runc, docker 18.09)
+        // have been built without kernel memory accounting. In
+        // that case, the runtime issues a message on stderr saying
+        // so. Skip the test in that case.
+        if (oa.getStderr().contains("kernel memory accounting disabled")) {
+            System.out.println("Kernel memory accounting disabled, " +
+                                       "skipping the test case");
+            return;
+        }
+
+        oa.shouldHaveExitValue(0).shouldContain("TEST PASSED!!!");
     }
 
     private static void testOomKillFlag(String value, boolean oomKillFlag) throws Exception {