@@ -275,12 +275,14 @@ func TestGroupCleanup(t *testing.T) {
275
275
t .Fatalf ("Cmd failed with err %v, output: %s" , err , out )
276
276
}
277
277
strOut := strings .TrimSpace (string (out ))
278
+ t .Logf ("id: %s" , strOut )
279
+
278
280
expected := "uid=0(root) gid=0(root)"
279
281
// Just check prefix because some distros reportedly output a
280
282
// context parameter; see https://golang.org/issue/16224.
281
283
// Alpine does not output groups; see https://golang.org/issue/19938.
282
284
if ! strings .HasPrefix (strOut , expected ) {
283
- t .Errorf ("id command output: %q, expected prefix: %q" , strOut , expected )
285
+ t .Errorf ("expected prefix: %q" , expected )
284
286
}
285
287
}
286
288
@@ -309,23 +311,14 @@ func TestGroupCleanupUserNamespace(t *testing.T) {
309
311
t .Fatalf ("Cmd failed with err %v, output: %s" , err , out )
310
312
}
311
313
strOut := strings .TrimSpace (string (out ))
314
+ t .Logf ("id: %s" , strOut )
312
315
313
- // Strings we've seen in the wild.
314
- expected := []string {
315
- "uid=0(root) gid=0(root) groups=0(root)" ,
316
- "uid=0(root) gid=0(root) groups=0(root),65534(nobody)" ,
317
- "uid=0(root) gid=0(root) groups=0(root),65534(nogroup)" ,
318
- "uid=0(root) gid=0(root) groups=0(root),65534" ,
319
- "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
320
- "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
321
- "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
322
- }
323
- for _ , e := range expected {
324
- if strOut == e {
325
- return
326
- }
316
+ // As in TestGroupCleanup, just check prefix.
317
+ // The actual groups and contexts seem to vary from one distro to the next.
318
+ expected := "uid=0(root) gid=0(root) groups=0(root)"
319
+ if ! strings .HasPrefix (strOut , expected ) {
320
+ t .Errorf ("expected prefix: %q" , expected )
327
321
}
328
- t .Errorf ("id command output: %q, expected one of %q" , strOut , expected )
329
322
}
330
323
331
324
// TestUnshareHelperProcess isn't a real test. It's used as a helper process
0 commit comments