]> Cypherpunks repositories - gostls13.git/commitdiff
os: allow for variant plan9 error messages in TestOpenError
authorRichard Miller <millerresearch@gmail.com>
Tue, 19 Nov 2024 12:15:26 +0000 (12:15 +0000)
committerGopher Robot <gobot@golang.org>
Fri, 22 Nov 2024 01:15:41 +0000 (01:15 +0000)
Different Plan 9 file servers may return different error strings
on an attempt to open a directory for writing: EISDIR, EACCES or
EPERM. TestOpenError allows for the first two, but it needs to
allow for EPERM as well.

Fixes #70440

Change-Id: I705cc086e21630ca254499ca922ede78c9901b11
Reviewed-on: https://go-review.googlesource.com/c/go/+/629635
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Bypass: Dmitri Shuralyov <dmitshur@golang.org>

src/os/os_test.go

index dbf77db99042afe3e9724c4064a3665d58e8dd3c..1e2db94dea28abf1354f6a0c7607a36033b104d2 100644 (file)
@@ -1840,9 +1840,11 @@ func testOpenError(t *testing.T, dir string, rooted bool) {
                                expectedErrStr := strings.Replace(tt.error.Error(), "file ", "", 1)
                                if !strings.HasSuffix(syscallErrStr, expectedErrStr) {
                                        // Some Plan 9 file servers incorrectly return
-                                       // EACCES rather than EISDIR when a directory is
+                                       // EPERM or EACCES rather than EISDIR when a directory is
                                        // opened for write.
-                                       if tt.error == syscall.EISDIR && strings.HasSuffix(syscallErrStr, syscall.EACCES.Error()) {
+                                       if tt.error == syscall.EISDIR &&
+                                               (strings.HasSuffix(syscallErrStr, syscall.EPERM.Error()) ||
+                                                       strings.HasSuffix(syscallErrStr, syscall.EACCES.Error())) {
                                                continue
                                        }
                                        t.Errorf("%v = _, %q; want suffix %q", name, syscallErrStr, expectedErrStr)