1 // Copyright 2017 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
5 // +build darwin dragonfly freebsd linux netbsd openbsd solaris
17 func TestCredentialNoSetGroups(t
*testing
.T
) {
18 u
, err
:= user
.Current()
20 t
.Fatalf("error getting current user: %v", err
)
23 uid
, err
:= strconv
.Atoi(u
.Uid
)
25 t
.Fatalf("error converting Uid=%s to integer: %v", u
.Uid
, err
)
28 gid
, err
:= strconv
.Atoi(u
.Gid
)
30 t
.Fatalf("error converting Gid=%s to integer: %v", u
.Gid
, err
)
33 // If NoSetGroups is true, setgroups isn't called and cmd.Run should succeed
34 cmd
:= helperCommand(t
, "echo", "foo")
35 cmd
.SysProcAttr
= &syscall
.SysProcAttr
{
36 Credential
: &syscall
.Credential
{
43 if err
= cmd
.Run(); err
!= nil {
44 t
.Errorf("Failed to run command: %v", err
)
48 // For issue #19314: make sure that SIGSTOP does not cause the process
50 func TestWaitid(t
*testing
.T
) {
53 cmd
:= helperCommand(t
, "sleep")
54 if err
:= cmd
.Start(); err
!= nil {
58 // The sleeps here are unnecessary in the sense that the test
59 // should still pass, but they are useful to make it more
60 // likely that we are testing the expected state of the child.
61 time
.Sleep(100 * time
.Millisecond
)
63 if err
:= cmd
.Process
.Signal(syscall
.SIGSTOP
); err
!= nil {
68 ch
:= make(chan error
)
73 time
.Sleep(100 * time
.Millisecond
)
75 if err
:= cmd
.Process
.Signal(syscall
.SIGCONT
); err
!= nil {
77 syscall
.Kill(cmd
.Process
.Pid
, syscall
.SIGCONT
)