diff options
| author | Shulhan <m.shulhan@gmail.com> | 2025-07-20 12:45:21 +0700 |
|---|---|---|
| committer | Shulhan <m.shulhan@gmail.com> | 2026-02-03 18:04:31 +0700 |
| commit | ad5e43b7b4ec99a8dc203d77e0b56d93fe2fd53d (patch) | |
| tree | 0c37b79ed7158acfc9521d8eccfd68c19650b73b | |
| parent | 98ec439c5103ff1e711593c8b164b0a0d3741700 (diff) | |
| download | go-makepkg.tar.xz | |
internal/testenv: exclude GOMAXPROCS when building test programmakepkg
In the environment where GOMAXPROCS set explicitly, for example to 3 in
shell profile, the runtime tests will fail with the following error,
----
ok regexp/syntax 0.428s
--- FAIL: TestCgroupGOMAXPROCS (0.81s)
crash_test.go:186: running /home/ms/src/go/bin/go build -o /tmp/go-build1753772192/testprog.exe
crash_test.go:208: built testprog in 796.664277ms
--- FAIL: TestCgroupGOMAXPROCS/containermaxprocs=0 (0.00s)
cgroup_linux_test.go:60: /tmp/go-build1753772192/testprog.exe PrintGOMAXPROCS (907.06µs): ok
cgroup_linux_test.go:63: output got "3\n" want "4\n"
--- FAIL: TestCgroupGOMAXPROCSNoLimit (0.00s)
cgroup_linux_test.go:82: /tmp/go-build1753772192/testprog.exe PrintGOMAXPROCS (879.194µs): ok
cgroup_linux_test.go:85: output got "3\n" want "4\n"
--- FAIL: TestCgroupGOMAXPROCSHigherThanNumCPU (0.00s)
cgroup_linux_test.go:102: /tmp/go-build1753772192/testprog.exe PrintGOMAXPROCS (852.396µs): ok
cgroup_linux_test.go:105: output got "3\n" want "4\n"
--- FAIL: TestCgroupGOMAXPROCSRound (0.01s)
--- FAIL: TestCgroupGOMAXPROCSRound/50000 (0.00s)
cgroup_linux_test.go:156: /tmp/go-build1753772192/testprog.exe PrintGOMAXPROCS (852.099µs): ok
cgroup_linux_test.go:159: output got "3\n" want "2\n"
--- FAIL: TestCgroupGOMAXPROCSRound/100000 (0.00s)
cgroup_linux_test.go:156: /tmp/go-build1753772192/testprog.exe PrintGOMAXPROCS (894.001µs): ok
cgroup_linux_test.go:159: output got "3\n" want "2\n"
--- FAIL: TestCgroupGOMAXPROCSRound/150000 (0.00s)
cgroup_linux_test.go:156: /tmp/go-build1753772192/testprog.exe PrintGOMAXPROCS (850.897µs): ok
cgroup_linux_test.go:159: output got "3\n" want "2\n"
--- FAIL: TestCgroupGOMAXPROCSSchedAffinity (0.00s)
cgroup_linux_test.go:229: /tmp/go-build1753772192/testprog.exe PrintGOMAXPROCS (867.987µs): ok
cgroup_linux_test.go:232: output got "3\n" want "2\n"
FAIL
FAIL runtime 23.088s
----
This changes exclude the GOMAXPROCS when building program for testing so it
does not affect the tests.
| -rw-r--r-- | src/internal/testenv/exec.go | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/internal/testenv/exec.go b/src/internal/testenv/exec.go index 7b251b6022..1ad77fe21a 100644 --- a/src/internal/testenv/exec.go +++ b/src/internal/testenv/exec.go @@ -137,6 +137,10 @@ func CleanCmdEnv(cmd *exec.Cmd) *exec.Cmd { if strings.HasPrefix(env, "GOTRACEBACK=") { continue } + // Exclude for TestCgroupGOMAXPROCSXxx. + if strings.HasPrefix(env, "GOMAXPROCS=") { + continue + } cmd.Env = append(cmd.Env, env) } return cmd |
