aboutsummaryrefslogtreecommitdiff
path: root/src/os/executable_test.go
AgeCommit message (Collapse)Author
2023-01-19os: clean up testsBryan C. Mills
- Use testenv.Command instead of exec.Command to try to get more useful timeout behavior. - Parallelize tests that appear not to require global state. (And add explanatory comments for a few that are not parallelizable for subtle reasons.) - Consolidate some “Helper” tests with their parent tests. - Use t.TempDir instead of os.MkdirTemp when appropriate. - Factor out subtests for repeated test helpers. For #36107. Updates #22315. Change-Id: Ic24b6957094dcd40908a59f48e44c8993729222b Reviewed-on: https://go-review.googlesource.com/c/go/+/458015 Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Bryan Mills <bcmills@google.com> Auto-Submit: Bryan Mills <bcmills@google.com>
2022-11-17os: use testenv.Command instead of exec.Command in testscui fliter
testenv.Command sets a default timeout based on the test's deadline and sends SIGQUIT (where supported) in case of a hang. Change-Id: I32ea9ca11c30d8af3d5490f2db1674314962cc80 Reviewed-on: https://go-review.googlesource.com/c/go/+/451195 Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Joedian Reid <joedian@golang.org> Auto-Submit: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com>
2021-05-04os: skip TestExecutableDeleted on plan9Richard Miller
This test deletes the running executable file, which is not safe on Plan 9. The test was working by accident prior to commit 02ab8d1, which must have changed the page reference ordering just enough to cause a new demand page-in after deletion of the file. Fixes #45941 Change-Id: Ic13d8032c21cee603e3afc3c5c4da6093fc37bf4 Reviewed-on: https://go-review.googlesource.com/c/go/+/316829 Reviewed-by: David du Colombier <0intro@gmail.com> Reviewed-by: Bryan C. Mills <bcmills@google.com> Trust: David du Colombier <0intro@gmail.com> Run-TryBot: David du Colombier <0intro@gmail.com> TryBot-Result: Go Bot <gobot@golang.org>
2021-04-23os: skip TestExecutableDeleted on aixEgon Elbre
aix does not support reading deleted executable name. Change-Id: I955ed2c22bd0693440e2c889a4d3132d0a375c48 Reviewed-on: https://go-review.googlesource.com/c/go/+/312392 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Than McIntosh <thanm@google.com>
2021-04-22os: depend on Readlink only when necessaryEgon Elbre
Currently Readlink gets linked into the binary even when Executable is not needed. This reduces a simple "os.Stdout.Write([]byte("hello"))" by ~10KiB. Previously the executable path was read during init time, because deleting the executable would make "Readlink" return "(deleted)" suffix. There's probably a slight chance that the init time reading would return it anyways. Updates #6853 Change-Id: Ic76190c5b64d9320ceb489cd6a553108614653d1 Reviewed-on: https://go-review.googlesource.com/c/go/+/311790 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Trust: Tobias Klauser <tobias.klauser@gmail.com>
2019-10-09all: remove the nacl port (part 1)Brad Fitzpatrick
You were a useful port and you've served your purpose. Thanks for all the play. A subsequent CL will remove amd64p32 (including assembly files and toolchain bits) and remaining bits. The amd64p32 removal will be separated into its own CL in case we want to support the Linux x32 ABI in the future and want our old amd64p32 support as a starting point. Updates #30439 Change-Id: Ia3a0c7d49804adc87bf52a4dea7e3d3007f2b1cd Reviewed-on: https://go-review.googlesource.com/c/go/+/199499 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-10-26os: fix tests for AIXClément Chigot
This commits fixes tests for AIX inside os package. "hostname" command on AIX returns "name.domain" and not only "name". So, "hostname -s" must be called. Change-Id: I75e193bcb6ad607ce54ad99aabbed9839012f707 Reviewed-on: https://go-review.googlesource.com/c/144537 Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-12-09os: fix typo in TestExecutable commentTobias Klauser
Change-Id: I2ad5d73deaee57ccbb2c75378dcc2884e43be3bb Reviewed-on: https://go-review.googlesource.com/82899 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-06-22os: run more of TestExecutable on OpenBSDMichael Hendricks
On OpenBSD, Executable relies on Args[0]. Removing the forgery on that OS allows the rest of the test to run. See #19453 Change-Id: Idf99f86894de5c702893791bc3684f8665f4019d Reviewed-on: https://go-review.googlesource.com/46398 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-06-17os: on OpenBSD implement Executable using Args[0]Ian Lance Taylor
OpenBSD no longer has procfs. Based on a patch by Matthieu Sarter. Fixes #19453. Change-Id: Ia09d16f8a1cbef2f8cc1c5f49e9c61ec7d026a40 Reviewed-on: https://go-review.googlesource.com/46004 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-11-07os: add Executable() (string, error)Shenghou Ma
// Executable returns the path name for the executable that started // the current process. There is no guarantee that the path is still // pointing to the correct executable. If a symlink was used to start // the process, depending on the operating system, the result might // be the symlink or the path it pointed to. If a stable result is // needed, path/filepath.EvalSymlinks might help. // // Executable returns an absolute path unless an error occurred. // // The main use case is finding resources located relative to an // executable. // // Executable is not supported on nacl or OpenBSD (unless procfs is // mounted.) func Executable() (string, error) { return executable() } Fixes #12773. Change-Id: I469738d905b12f0b633ea4d88954f8859227a88c Reviewed-on: https://go-review.googlesource.com/16551 Run-TryBot: Minux Ma <minux@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>