@@ -410,9 +410,6 @@ const (
410
410
// syscalls that execute on all OSThreads - with which to support
411
411
// POSIX semantics for security state changes.
412
412
func TestAllThreadsSyscall (t * testing.T ) {
413
- if runtime .GOARCH == "ppc64" {
414
- t .Skip ("skipping on linux/ppc64; see issue #42178" )
415
- }
416
413
if _ , _ , err := syscall .AllThreadsSyscall (syscall .SYS_PRCTL , PR_SET_KEEPCAPS , 0 , 0 ); err == syscall .ENOTSUP {
417
414
t .Skip ("AllThreadsSyscall disabled with cgo" )
418
415
}
@@ -544,7 +541,7 @@ func TestAllThreadsSyscall(t *testing.T) {
544
541
// compareStatus is used to confirm the contents of the thread
545
542
// specific status files match expectations.
546
543
func compareStatus (filter , expect string ) error {
547
- expected := filter + " \t " + expect
544
+ expected := filter + expect
548
545
pid := syscall .Getpid ()
549
546
fs , err := ioutil .ReadDir (fmt .Sprintf ("/proc/%d/task" , pid ))
550
547
if err != nil {
@@ -553,14 +550,22 @@ func compareStatus(filter, expect string) error {
553
550
for _ , f := range fs {
554
551
tf := fmt .Sprintf ("/proc/%s/status" , f .Name ())
555
552
d , err := ioutil .ReadFile (tf )
553
+ if os .IsNotExist (err ) {
554
+ // We are racing against threads dying, which
555
+ // is out of our control, so ignore the
556
+ // missing file and skip to the next one.
557
+ continue
558
+ }
556
559
if err != nil {
557
560
return fmt .Errorf ("unable to read %q: %v" , tf , err )
558
561
}
559
562
lines := strings .Split (string (d ), "\n " )
560
563
for _ , line := range lines {
564
+ // Different kernel vintages pad differently.
565
+ line = strings .TrimSpace (line )
561
566
if strings .HasPrefix (line , filter ) {
562
567
if line != expected {
563
- return fmt .Errorf ("%s %s (bad)\n " , tf , line )
568
+ return fmt .Errorf ("%q got:%q want:%q (bad)\n " , tf , line , expected )
564
569
}
565
570
break
566
571
}
@@ -580,9 +585,6 @@ func compareStatus(filter, expect string) error {
580
585
// the syscalls. Care should be taken to mirror any enhancements to
581
586
// this test here in that file too.
582
587
func TestSetuidEtc (t * testing.T ) {
583
- if runtime .GOARCH == "ppc64" {
584
- t .Skip ("skipping on linux/ppc64; see issue #42178" )
585
- }
586
588
if syscall .Getuid () != 0 {
587
589
t .Skip ("skipping root only test" )
588
590
}
@@ -591,34 +593,34 @@ func TestSetuidEtc(t *testing.T) {
591
593
fn func () error
592
594
filter , expect string
593
595
}{
594
- {call : "Setegid(1)" , fn : func () error { return syscall .Setegid (1 ) }, filter : "Gid:" , expect : "0 \t 1\t 0\t 1" },
595
- {call : "Setegid(0)" , fn : func () error { return syscall .Setegid (0 ) }, filter : "Gid:" , expect : "0 \t 0\t 0\t 0" },
596
+ {call : "Setegid(1)" , fn : func () error { return syscall .Setegid (1 ) }, filter : "Gid:" , expect : "\t 0 \t 1\t 0\t 1" },
597
+ {call : "Setegid(0)" , fn : func () error { return syscall .Setegid (0 ) }, filter : "Gid:" , expect : "\t 0 \t 0\t 0\t 0" },
596
598
597
- {call : "Seteuid(1)" , fn : func () error { return syscall .Seteuid (1 ) }, filter : "Uid:" , expect : "0 \t 1\t 0\t 1" },
598
- {call : "Setuid(0)" , fn : func () error { return syscall .Setuid (0 ) }, filter : "Uid:" , expect : "0 \t 0\t 0\t 0" },
599
+ {call : "Seteuid(1)" , fn : func () error { return syscall .Seteuid (1 ) }, filter : "Uid:" , expect : "\t 0 \t 1\t 0\t 1" },
600
+ {call : "Setuid(0)" , fn : func () error { return syscall .Setuid (0 ) }, filter : "Uid:" , expect : "\t 0 \t 0\t 0\t 0" },
599
601
600
- {call : "Setgid(1)" , fn : func () error { return syscall .Setgid (1 ) }, filter : "Gid:" , expect : "1 \t 1\t 1\t 1" },
601
- {call : "Setgid(0)" , fn : func () error { return syscall .Setgid (0 ) }, filter : "Gid:" , expect : "0 \t 0\t 0\t 0" },
602
+ {call : "Setgid(1)" , fn : func () error { return syscall .Setgid (1 ) }, filter : "Gid:" , expect : "\t 1 \t 1\t 1\t 1" },
603
+ {call : "Setgid(0)" , fn : func () error { return syscall .Setgid (0 ) }, filter : "Gid:" , expect : "\t 0 \t 0\t 0\t 0" },
602
604
603
- {call : "Setgroups([]int{0,1,2,3})" , fn : func () error { return syscall .Setgroups ([]int {0 , 1 , 2 , 3 }) }, filter : "Groups:" , expect : "0 1 2 3 " },
604
- {call : "Setgroups(nil)" , fn : func () error { return syscall .Setgroups (nil ) }, filter : "Groups:" , expect : " " },
605
- {call : "Setgroups([]int{0})" , fn : func () error { return syscall .Setgroups ([]int {0 }) }, filter : "Groups:" , expect : "0 " },
605
+ {call : "Setgroups([]int{0,1,2,3})" , fn : func () error { return syscall .Setgroups ([]int {0 , 1 , 2 , 3 }) }, filter : "Groups:" , expect : "\t 0 1 2 3" },
606
+ {call : "Setgroups(nil)" , fn : func () error { return syscall .Setgroups (nil ) }, filter : "Groups:" , expect : "" },
607
+ {call : "Setgroups([]int{0})" , fn : func () error { return syscall .Setgroups ([]int {0 }) }, filter : "Groups:" , expect : "\t 0 " },
606
608
607
- {call : "Setregid(101,0)" , fn : func () error { return syscall .Setregid (101 , 0 ) }, filter : "Gid:" , expect : "101 \t 0\t 0\t 0" },
608
- {call : "Setregid(0,102)" , fn : func () error { return syscall .Setregid (0 , 102 ) }, filter : "Gid:" , expect : "0 \t 102\t 102\t 102" },
609
- {call : "Setregid(0,0)" , fn : func () error { return syscall .Setregid (0 , 0 ) }, filter : "Gid:" , expect : "0 \t 0\t 0\t 0" },
609
+ {call : "Setregid(101,0)" , fn : func () error { return syscall .Setregid (101 , 0 ) }, filter : "Gid:" , expect : "\t 101 \t 0\t 0\t 0" },
610
+ {call : "Setregid(0,102)" , fn : func () error { return syscall .Setregid (0 , 102 ) }, filter : "Gid:" , expect : "\t 0 \t 102\t 102\t 102" },
611
+ {call : "Setregid(0,0)" , fn : func () error { return syscall .Setregid (0 , 0 ) }, filter : "Gid:" , expect : "\t 0 \t 0\t 0\t 0" },
610
612
611
- {call : "Setreuid(1,0)" , fn : func () error { return syscall .Setreuid (1 , 0 ) }, filter : "Uid:" , expect : "1 \t 0\t 0\t 0" },
612
- {call : "Setreuid(0,2)" , fn : func () error { return syscall .Setreuid (0 , 2 ) }, filter : "Uid:" , expect : "0 \t 2\t 2\t 2" },
613
- {call : "Setreuid(0,0)" , fn : func () error { return syscall .Setreuid (0 , 0 ) }, filter : "Uid:" , expect : "0 \t 0\t 0\t 0" },
613
+ {call : "Setreuid(1,0)" , fn : func () error { return syscall .Setreuid (1 , 0 ) }, filter : "Uid:" , expect : "\t 1 \t 0\t 0\t 0" },
614
+ {call : "Setreuid(0,2)" , fn : func () error { return syscall .Setreuid (0 , 2 ) }, filter : "Uid:" , expect : "\t 0 \t 2\t 2\t 2" },
615
+ {call : "Setreuid(0,0)" , fn : func () error { return syscall .Setreuid (0 , 0 ) }, filter : "Uid:" , expect : "\t 0 \t 0\t 0\t 0" },
614
616
615
- {call : "Setresgid(101,0,102)" , fn : func () error { return syscall .Setresgid (101 , 0 , 102 ) }, filter : "Gid:" , expect : "101 \t 0\t 102\t 0" },
616
- {call : "Setresgid(0,102,101)" , fn : func () error { return syscall .Setresgid (0 , 102 , 101 ) }, filter : "Gid:" , expect : "0 \t 102\t 101\t 102" },
617
- {call : "Setresgid(0,0,0)" , fn : func () error { return syscall .Setresgid (0 , 0 , 0 ) }, filter : "Gid:" , expect : "0 \t 0\t 0\t 0" },
617
+ {call : "Setresgid(101,0,102)" , fn : func () error { return syscall .Setresgid (101 , 0 , 102 ) }, filter : "Gid:" , expect : "\t 101 \t 0\t 102\t 0" },
618
+ {call : "Setresgid(0,102,101)" , fn : func () error { return syscall .Setresgid (0 , 102 , 101 ) }, filter : "Gid:" , expect : "\t 0 \t 102\t 101\t 102" },
619
+ {call : "Setresgid(0,0,0)" , fn : func () error { return syscall .Setresgid (0 , 0 , 0 ) }, filter : "Gid:" , expect : "\t 0 \t 0\t 0\t 0" },
618
620
619
- {call : "Setresuid(1,0,2)" , fn : func () error { return syscall .Setresuid (1 , 0 , 2 ) }, filter : "Uid:" , expect : "1 \t 0\t 2\t 0" },
620
- {call : "Setresuid(0,2,1)" , fn : func () error { return syscall .Setresuid (0 , 2 , 1 ) }, filter : "Uid:" , expect : "0 \t 2\t 1\t 2" },
621
- {call : "Setresuid(0,0,0)" , fn : func () error { return syscall .Setresuid (0 , 0 , 0 ) }, filter : "Uid:" , expect : "0 \t 0\t 0\t 0" },
621
+ {call : "Setresuid(1,0,2)" , fn : func () error { return syscall .Setresuid (1 , 0 , 2 ) }, filter : "Uid:" , expect : "\t 1 \t 0\t 2\t 0" },
622
+ {call : "Setresuid(0,2,1)" , fn : func () error { return syscall .Setresuid (0 , 2 , 1 ) }, filter : "Uid:" , expect : "\t 0 \t 2\t 1\t 2" },
623
+ {call : "Setresuid(0,0,0)" , fn : func () error { return syscall .Setresuid (0 , 0 , 0 ) }, filter : "Uid:" , expect : "\t 0 \t 0\t 0\t 0" },
622
624
}
623
625
624
626
for i , v := range vs {
0 commit comments