]> Cypherpunks repositories - gostls13.git/commitdiff
syscall: use t.TempDir in tests
authorKir Kolyshkin <kolyshkin@gmail.com>
Fri, 30 Aug 2024 06:22:21 +0000 (23:22 -0700)
committerGopher Robot <gobot@golang.org>
Tue, 3 Sep 2024 20:16:07 +0000 (20:16 +0000)
Change-Id: Ibeb00306ee8f038c11f261abd99c05324bf2ab51
Reviewed-on: https://go-review.googlesource.com/c/go/+/609837
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

src/syscall/exec_pdeathsig_test.go
src/syscall/syscall_linux_test.go

index a907afd900a0021fce82e0502351d3b352624b03..22bb2b44749956079cdb58987225010c1478d942 100644 (file)
@@ -34,11 +34,7 @@ func TestDeathSignalSetuid(t *testing.T) {
        //
        // TODO(bcmills): Why do we believe that another users will be able to
        // execute a binary in this directory? (It could be mounted noexec.)
-       tempDir, err := os.MkdirTemp("", "TestDeathSignal")
-       if err != nil {
-               t.Fatalf("cannot create temporary directory: %v", err)
-       }
-       defer os.RemoveAll(tempDir)
+       tempDir := t.TempDir()
        os.Chmod(tempDir, 0755)
 
        tmpBinary := filepath.Join(tempDir, filepath.Base(os.Args[0]))
index 43c0ba0ce3b34c4e852d8a1fe0f8c5d978bf7879..a150ab15bef1206ef186786008e72e4ba49b177f 100644 (file)
@@ -213,12 +213,8 @@ func TestSyscallNoError(t *testing.T) {
        }
 
        // Copy the test binary to a location that a non-root user can read/execute
-       // after we drop privileges
-       tempDir, err := os.MkdirTemp("", "TestSyscallNoError")
-       if err != nil {
-               t.Fatalf("cannot create temporary directory: %v", err)
-       }
-       defer os.RemoveAll(tempDir)
+       // after we drop privileges.
+       tempDir := t.TempDir()
        os.Chmod(tempDir, 0755)
 
        tmpBinary := filepath.Join(tempDir, filepath.Base(os.Args[0]))