]> Cypherpunks repositories - gostls13.git/commitdiff
syscall: inline TestUseCgroupFDHelper
authorKir Kolyshkin <kolyshkin@gmail.com>
Fri, 1 Sep 2023 21:59:27 +0000 (14:59 -0700)
committerGopher Robot <gobot@golang.org>
Sun, 3 Sep 2023 13:53:50 +0000 (13:53 +0000)
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>

src/syscall/exec_linux_test.go

index 33fa79a81d9abc6867d5025069defdda32318d66..4a6c34e6e62be70e619ccc50e05b4ef7a9e2167f 100644 (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)