From: Kir Kolyshkin Date: Fri, 1 Sep 2023 21:59:27 +0000 (-0700) Subject: syscall: inline TestUseCgroupFDHelper X-Git-Tag: go1.22rc1~1003 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=e7fbd28a4dbf92721f040dfb2c877153333054d1;p=gostls13.git 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 Auto-Submit: Tobias Klauser TryBot-Result: Gopher Robot Run-TryBot: Tobias Klauser Reviewed-by: Dmitri Shuralyov LUCI-TryBot-Result: Go LUCI Reviewed-by: Tobias Klauser Auto-Submit: Ian Lance Taylor --- diff --git a/src/syscall/exec_linux_test.go b/src/syscall/exec_linux_test.go index 33fa79a81d..4a6c34e6e6 100644 --- a/src/syscall/exec_linux_test.go +++ b/src/syscall/exec_linux_test.go @@ -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)