21
21
* questions.
22
22
*/
23
23
24
+ import jdk .test .lib .Container ;
24
25
import jdk .test .lib .containers .docker .Common ;
25
26
import jdk .test .lib .containers .docker .DockerTestUtils ;
26
27
import jdk .test .lib .containers .docker .DockerRunOptions ;
@@ -46,6 +47,19 @@ public class TestMemoryWithSubgroups {
46
47
47
48
private static final String imageName = Common .imageName ("subgroup" );
48
49
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
+
49
63
public static void main (String [] args ) throws Exception {
50
64
Metrics metrics = Metrics .systemMetrics ();
51
65
if (metrics == null ) {
@@ -56,6 +70,9 @@ public static void main(String[] args) throws Exception {
56
70
System .out .println ("Unable to run docker tests." );
57
71
return ;
58
72
}
73
+ if (isRootless ()) {
74
+ throw new SkippedException ("Test skipped in rootless mode" );
75
+ }
59
76
Common .prepareWhiteBox ();
60
77
DockerTestUtils .buildJdkContainerImage (imageName );
61
78
0 commit comments