From dceee2e983f5dab65c3905ecf40e70e15cf41b7d Mon Sep 17 00:00:00 2001 From: qmuntal Date: Mon, 24 Feb 2025 09:43:41 +0100 Subject: all: use testenv.Executable instead of os.Executable and os.Args[0] In test files, using testenv.Executable is more reliable than os.Executable or os.Args[0]. Change-Id: I88e577efeabc20d02ada27bf706ae4523129128e Reviewed-on: https://go-review.googlesource.com/c/go/+/651955 Reviewed-by: Cherry Mui LUCI-TryBot-Result: Go LUCI Reviewed-by: Ian Lance Taylor --- src/crypto/internal/fips140test/check_test.go | 2 +- src/crypto/internal/sysrand/rand_linux_test.go | 2 +- src/crypto/internal/sysrand/rand_test.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/crypto/internal') diff --git a/src/crypto/internal/fips140test/check_test.go b/src/crypto/internal/fips140test/check_test.go index c014fff2a6..f516455fb4 100644 --- a/src/crypto/internal/fips140test/check_test.go +++ b/src/crypto/internal/fips140test/check_test.go @@ -35,7 +35,7 @@ func TestIntegrityCheck(t *testing.T) { t.Skipf("skipping: %v", err) } - cmd := testenv.Command(t, os.Args[0], "-test.v", "-test.run=TestIntegrityCheck") + cmd := testenv.Command(t, testenv.Executable(t), "-test.v", "-test.run=TestIntegrityCheck") cmd.Env = append(cmd.Environ(), "GODEBUG=fips140=on") out, err := cmd.CombinedOutput() if err != nil { diff --git a/src/crypto/internal/sysrand/rand_linux_test.go b/src/crypto/internal/sysrand/rand_linux_test.go index ab43904f91..ee28ebe135 100644 --- a/src/crypto/internal/sysrand/rand_linux_test.go +++ b/src/crypto/internal/sysrand/rand_linux_test.go @@ -49,7 +49,7 @@ func TestNoGetrandom(t *testing.T) { return } - cmd := testenv.Command(t, os.Args[0], "-test.v") + cmd := testenv.Command(t, testenv.Executable(t), "-test.v") cmd.Env = append(os.Environ(), "GO_GETRANDOM_DISABLED=1") out, err := cmd.CombinedOutput() if err != nil { diff --git a/src/crypto/internal/sysrand/rand_test.go b/src/crypto/internal/sysrand/rand_test.go index 2b9620c2fb..55b11a929b 100644 --- a/src/crypto/internal/sysrand/rand_test.go +++ b/src/crypto/internal/sysrand/rand_test.go @@ -105,7 +105,7 @@ func TestReadError(t *testing.T) { return } - cmd := testenv.Command(t, os.Args[0], "-test.run=TestReadError") + cmd := testenv.Command(t, testenv.Executable(t), "-test.run=TestReadError") cmd.Env = append(os.Environ(), "GO_TEST_READ_ERROR=1") out, err := cmd.CombinedOutput() if err == nil { -- cgit v1.3-5-g9baa