runtime: fix TestUsingVDSO on Linux ARMv6 (Pi 1)

TestUsingVDSO was failing on Linux ARMv6 (Raspberry Pi 1, Raspbian
6.12 kernel, glibc with 64-bit time_t) because on ARMv6, where the
kernel VDSO does not export __vdso_clock_gettime, the test was
checking whether Go does worse than C by counting both's syscalls with
strace -e, but the strace -e filter is an exact match, not a prefix,
so "-e clock_gettime" does not match the y2038-safe clock_gettime64
syscall that 32-bit Linux glibc uses on kernels that support it.

So then the test saw what it believed to be zero syscalls from C
but 1 from Go and failed the test.

Instead, strace both -e clock_gettime,clock_gettime64 and then the
test correctly passes, seeing that Go and C both failed to use the
(non-existent) VDSO in the same way, both doing time syscalls.

Change-Id: I0ec88e041cc51bdf475edd717c538f3225929026
Reviewed-on: https://go-review.googlesource.com/c/go/+/775060
LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
Brad Fitzpatrick 2026-05-07 03:41:42 +00:00 committed by Gopher Robot
parent ea0da4047c
commit 834214f787

View file

@ -53,8 +53,13 @@ func TestUsingVDSO(t *testing.T) {
t.Skipf("skipping because Executable failed: %v", err)
}
t.Logf("GO_WANT_HELPER_PROCESS=1 %s -f -e clock_gettime %s -test.run=^TestUsingVDSO$", strace, exe)
cmd := testenv.Command(t, strace, "-f", "-e", "clock_gettime", exe, "-test.run=^TestUsingVDSO$")
// Trace both clock_gettime and clock_gettime64: 32-bit Linux glibc uses
// the y2038-safe clock_gettime64 syscall, and strace's -e filter is an
// exact match, not a prefix.
const traceFilter = "clock_gettime,clock_gettime64"
t.Logf("GO_WANT_HELPER_PROCESS=1 %s -f -e %s %s -test.run=^TestUsingVDSO$", strace, traceFilter, exe)
cmd := testenv.Command(t, strace, "-f", "-e", traceFilter, exe, "-test.run=^TestUsingVDSO$")
cmd = testenv.CleanCmdEnv(cmd)
cmd.Env = append(cmd.Env, "GO_WANT_HELPER_PROCESS=1")
out, err := cmd.CombinedOutput()
@ -107,8 +112,8 @@ func TestUsingVDSO(t *testing.T) {
t.Skipf("can't verify VDSO status, C compiled failed: %v", err)
}
t.Logf("%s -f -e clock_gettime %s", strace, cexe)
cmd = testenv.Command(t, strace, "-f", "-e", "clock_gettime", cexe)
t.Logf("%s -f -e %s %s", strace, traceFilter, cexe)
cmd = testenv.Command(t, strace, "-f", "-e", traceFilter, cexe)
cmd = testenv.CleanCmdEnv(cmd)
out, err = cmd.CombinedOutput()
if len(out) > 0 {