]> Cypherpunks repositories - gostls13.git/commitdiff
os: skip Root.Chtimes atime check on netbsd, truncate a/mtime on plan9
authorDamien Neil <dneil@google.com>
Wed, 19 Mar 2025 23:37:16 +0000 (16:37 -0700)
committerGopher Robot <gobot@golang.org>
Thu, 20 Mar 2025 05:21:07 +0000 (22:21 -0700)
The NetBSD builder has noatime set on its filesystem.
Skip testing the atime on this builder.

Plan9 has second precision on its atime and mtimes.
Truncate the values passed to Chtimes.

For #72957

Change-Id: I963e2dd34075a9ba025e80641f0b675d5d912188
Reviewed-on: https://go-review.googlesource.com/c/go/+/659356
Auto-Submit: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
src/os/os_test.go
src/os/root_test.go

index 4c90525bb1490130be0964fdb81660ec875bfdd4..cca1b58fe7d78e1fbf4e4a1aa660f985f4fa354c 100644 (file)
@@ -1345,6 +1345,9 @@ var hasNoatime = sync.OnceValue(func() bool {
        // but the syscall is OS-specific and is not even wired into Go stdlib.
        //
        // Only used on NetBSD (which ignores explicit atime updates with noatime).
+       if runtime.GOOS != "netbsd" {
+               return false
+       }
        mounts, _ := ReadFile("/proc/mounts")
        return bytes.Contains(mounts, []byte("noatime"))
 })
index 6c8c8924297f37a24aaadd76dafdd579795d46dc..b91d85d176a2e32fa210a0a6fb081a76cab14e73 100644 (file)
@@ -449,7 +449,8 @@ func TestRootChtimes(t *testing.T) {
                                atime: time.Now(),
                                mtime: time.Time{},
                        }} {
-                               if runtime.GOOS == "js" {
+                               switch runtime.GOOS {
+                               case "js", "plan9":
                                        times.atime = times.atime.Truncate(1 * time.Second)
                                        times.mtime = times.mtime.Truncate(1 * time.Second)
                                }
@@ -465,8 +466,10 @@ 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 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)
+                               if !hasNoatime() {
+                                       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)
+                                       }
                                }
                        }
                })