@@ -258,12 +258,14 @@ func TestGroupCleanup(t *testing.T) {
258
258
t .Fatalf ("Cmd failed with err %v, output: %s" , err , out )
259
259
}
260
260
strOut := strings .TrimSpace (string (out ))
261
+ t .Logf ("id: %s" , strOut )
262
+
261
263
expected := "uid=0(root) gid=0(root)"
262
264
// Just check prefix because some distros reportedly output a
263
265
// context parameter; see https://golang.org/issue/16224.
264
266
// Alpine does not output groups; see https://golang.org/issue/19938.
265
267
if ! strings .HasPrefix (strOut , expected ) {
266
- t .Errorf ("id command output: %q, expected prefix: %q" , strOut , expected )
268
+ t .Errorf ("expected prefix: %q" , expected )
267
269
}
268
270
}
269
271
@@ -292,23 +294,14 @@ func TestGroupCleanupUserNamespace(t *testing.T) {
292
294
t .Fatalf ("Cmd failed with err %v, output: %s" , err , out )
293
295
}
294
296
strOut := strings .TrimSpace (string (out ))
297
+ t .Logf ("id: %s" , strOut )
295
298
296
- // Strings we've seen in the wild.
297
- expected := []string {
298
- "uid=0(root) gid=0(root) groups=0(root)" ,
299
- "uid=0(root) gid=0(root) groups=0(root),65534(nobody)" ,
300
- "uid=0(root) gid=0(root) groups=0(root),65534(nogroup)" ,
301
- "uid=0(root) gid=0(root) groups=0(root),65534" ,
302
- "uid=0(root) gid=0(root) groups=0(root),65534(nobody),65534(nobody),65534(nobody),65534(nobody),65534(nobody),65534(nobody),65534(nobody),65534(nobody),65534(nobody),65534(nobody)" , // Alpine; see https://golang.org/issue/19938
303
- "uid=0(root) gid=0(root) groups=0(root) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023" , // CentOS with SELinux context, see https://golang.org/issue/34547
304
- "uid=0(root) gid=0(root) groups=0(root),65534(nobody) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023" , // Fedora with SElinux context, see https://golang.org/issue/46752
305
- }
306
- for _ , e := range expected {
307
- if strOut == e {
308
- return
309
- }
299
+ // As in TestGroupCleanup, just check prefix.
300
+ // The actual groups and contexts seem to vary from one distro to the next.
301
+ expected := "uid=0(root) gid=0(root) groups=0(root)"
302
+ if ! strings .HasPrefix (strOut , expected ) {
303
+ t .Errorf ("expected prefix: %q" , expected )
310
304
}
311
- t .Errorf ("id command output: %q, expected one of %q" , strOut , expected )
312
305
}
313
306
314
307
// TestUnshareHelperProcess isn't a real test. It's used as a helper process
0 commit comments