2121 * questions.
2222 */
2323
24+ import jdk .test .lib .Container ;
2425import jdk .test .lib .containers .docker .Common ;
2526import jdk .test .lib .containers .docker .DockerTestUtils ;
2627import jdk .test .lib .containers .docker .DockerRunOptions ;
@@ -46,6 +47,19 @@ public class TestMemoryWithSubgroups {
4647
4748 private static final String imageName = Common .imageName ("subgroup" );
4849
50+ static String getEngineInfo (String format ) throws Exception {
51+ return DockerTestUtils .execute (Container .ENGINE_COMMAND , "info" , "-f" , format )
52+ .getStdout ();
53+ }
54+
55+ static boolean isRootless () throws Exception {
56+ // Docker and Podman have different INFO structures.
57+ // The node path for Podman is .Host.Security.Rootless, that also holds for
58+ // Podman emulating Docker CLI. The node path for Docker is .SecurityOptions.
59+ return (getEngineInfo ("{{.Host.Security.Rootless}}" ).contains ("true" ) ||
60+ getEngineInfo ("{{.SecurityOptions}}" ).contains ("name=rootless" ));
61+ }
62+
4963 public static void main (String [] args ) throws Exception {
5064 Metrics metrics = Metrics .systemMetrics ();
5165 if (metrics == null ) {
@@ -56,6 +70,9 @@ public static void main(String[] args) throws Exception {
5670 System .out .println ("Unable to run docker tests." );
5771 return ;
5872 }
73+ if (isRootless ()) {
74+ throw new SkippedException ("Test skipped in rootless mode" );
75+ }
5976 Common .prepareWhiteBox ();
6077 DockerTestUtils .buildJdkContainerImage (imageName );
6178
0 commit comments