From: Kir Kolyshkin Date: Fri, 30 Aug 2024 06:22:21 +0000 (-0700) Subject: syscall: use t.TempDir in tests X-Git-Tag: go1.24rc1~1048 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=1ae6b9e31b952ad7090406475b2b0eb0e8804fcd;p=gostls13.git syscall: use t.TempDir in tests Change-Id: Ibeb00306ee8f038c11f261abd99c05324bf2ab51 Reviewed-on: https://go-review.googlesource.com/c/go/+/609837 Auto-Submit: Ian Lance Taylor Reviewed-by: Tobias Klauser Reviewed-by: Ian Lance Taylor Reviewed-by: Dmitri Shuralyov LUCI-TryBot-Result: Go LUCI --- diff --git a/src/syscall/exec_pdeathsig_test.go b/src/syscall/exec_pdeathsig_test.go index a907afd900..22bb2b4474 100644 --- a/src/syscall/exec_pdeathsig_test.go +++ b/src/syscall/exec_pdeathsig_test.go @@ -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])) diff --git a/src/syscall/syscall_linux_test.go b/src/syscall/syscall_linux_test.go index 43c0ba0ce3..a150ab15be 100644 --- a/src/syscall/syscall_linux_test.go +++ b/src/syscall/syscall_linux_test.go @@ -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]))