diff options
| author | Kir Kolyshkin <kolyshkin@gmail.com> | 2023-09-01 14:59:27 -0700 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2023-09-03 13:53:50 +0000 |
| commit | e7fbd28a4dbf92721f040dfb2c877153333054d1 (patch) | |
| tree | 4d6901e2d9930c15e1a2d32476d32f625351707d /src/syscall/exec_linux_test.go | |
| parent | 0cd473d97ac9c94431aaece4baae539927d068f1 (diff) | |
| download | go-e7fbd28a4dbf92721f040dfb2c877153333054d1.tar.xz | |
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>
Diffstat (limited to 'src/syscall/exec_linux_test.go')
| -rw-r--r-- | src/syscall/exec_linux_test.go | 28 |
1 files changed, 13 insertions, 15 deletions
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) |
