]> Cypherpunks repositories - gostls13.git/commitdiff
os: skip atime checks in TestRootChtimes on plan9
authorDamien Neil <dneil@google.com>
Thu, 20 Mar 2025 16:30:19 +0000 (09:30 -0700)
committerGopher Robot <gobot@golang.org>
Thu, 20 Mar 2025 18:23:35 +0000 (11:23 -0700)
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 <iant@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

src/os/root_test.go

index b91d85d176a2e32fa210a0a6fb081a76cab14e73..4ca6f9c834ab558ae5ad118a9e8add54b149f323 100644 (file)
@@ -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)
                                        }