syscall: inline TestUseCgroupFDHelper

This way, the test case is self-contained, and the test output no longer
has useless lines related to TestUseCgroupFDHelper.

Change-Id: I575a03b678c8c08a87353f6dc00c35a90ec561ca
Reviewed-on: https://go-review.googlesource.com/c/go/+/525196
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
This commit is contained in:
Kir Kolyshkin 2023-09-01 14:59:27 -07:00 committed by Gopher Robot
parent 0cd473d97a
commit e7fbd28a4d

View file

@ -433,6 +433,18 @@ func prepareCgroupFD(t *testing.T) (int, string) {
func TestUseCgroupFD(t *testing.T) {
testenv.MustHaveExec(t)
if os.Getenv("GO_WANT_HELPER_PROCESS") == "1" {
// Read and print own cgroup path.
selfCg, err := os.ReadFile("/proc/self/cgroup")
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(2)
}
fmt.Print(string(selfCg))
os.Exit(0)
}
exe, err := os.Executable()
if err != nil {
t.Fatal(err)
@ -440,7 +452,7 @@ func TestUseCgroupFD(t *testing.T) {
fd, suffix := prepareCgroupFD(t)
cmd := testenv.Command(t, exe, "-test.run=TestUseCgroupFDHelper")
cmd := testenv.Command(t, exe, "-test.run=TestUseCgroupFD")
cmd.Env = append(cmd.Environ(), "GO_WANT_HELPER_PROCESS=1")
cmd.SysProcAttr = &syscall.SysProcAttr{
UseCgroupFD: true,
@ -463,20 +475,6 @@ func TestUseCgroupFD(t *testing.T) {
}
}
func TestUseCgroupFDHelper(*testing.T) {
if os.Getenv("GO_WANT_HELPER_PROCESS") != "1" {
return
}
defer os.Exit(0)
// Read and print own cgroup path.
selfCg, err := os.ReadFile("/proc/self/cgroup")
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(2)
}
fmt.Print(string(selfCg))
}
func TestCloneTimeNamespace(t *testing.T) {
testenv.MustHaveExec(t)