From ba50de84299667dcaa2f4e6663078340bbae8c67 Mon Sep 17 00:00:00 2001 From: Damien Neil Date: Thu, 20 Mar 2025 09:30:19 -0700 Subject: [PATCH] os: skip atime checks in TestRootChtimes on plan9 Plan 9 doesn't permit setting arbitrary atimes. Fixes #72957 Change-Id: Ia4e14c75ed7dcdefd4669c0c21884d5ead9ab2fb Reviewed-on: https://go-review.googlesource.com/c/go/+/659615 Reviewed-by: Ian Lance Taylor Auto-Submit: Damien Neil LUCI-TryBot-Result: Go LUCI --- src/os/root_test.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/os/root_test.go b/src/os/root_test.go index b91d85d176..4ca6f9c834 100644 --- a/src/os/root_test.go +++ b/src/os/root_test.go @@ -427,6 +427,9 @@ func TestRootChmod(t *testing.T) { } func TestRootChtimes(t *testing.T) { + // Don't check atimes if the fs is mounted noatime, + // or on Plan 9 which does not permit changing atimes to arbitrary values. + checkAtimes := !hasNoatime() && runtime.GOOS != "plan9" for _, test := range rootTestCases { test.run(t, func(t *testing.T, target string, root *os.Root) { if target != "" { @@ -466,7 +469,7 @@ func TestRootChtimes(t *testing.T) { if got := st.ModTime(); !times.mtime.IsZero() && !got.Equal(times.mtime) { t.Errorf("after root.Chtimes(%q, %v, %v): got mtime=%v, want %v", test.open, times.atime, times.mtime, got, times.mtime) } - if !hasNoatime() { + if checkAtimes { if got := os.Atime(st); !times.atime.IsZero() && !got.Equal(times.atime) { t.Errorf("after root.Chtimes(%q, %v, %v): got atime=%v, want %v", test.open, times.atime, times.mtime, got, times.atime) } -- 2.51.0