Skip to content

Commit 30de352

Browse files
tklausergopherbot
authored andcommitted
unix: fix Test{Fd,}Xattr failure on NetBSD
On NetBSD the namespace of an xattr is stored separately from the name and isn't returned by Listxattr and Flistxattr. Like on FreeBSD, strip the namespace before checking the returned xattrs. Fixes golang/go#69313 Fixes golang/go#69314 Change-Id: I7f2393cc63f9860332c0e07a51f3b9d32911e892 Cq-Include-Trybots: luci.golang.try:x_sys-gotip-netbsd-arm64 Reviewed-on: https://go-review.googlesource.com/c/sys/+/611695 Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Benny Siegert <bsiegert@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Commit-Queue: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
1 parent 68ed59b commit 30de352

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

unix/xattr_test.go

+10-6
Original file line numberDiff line numberDiff line change
@@ -56,20 +56,22 @@ func TestXattr(t *testing.T) {
5656
xattrs := stringsFromByteSlice(buf[:read])
5757

5858
xattrWant := xattrName
59-
if runtime.GOOS == "freebsd" {
60-
// On FreeBSD, the namespace is stored separately from the xattr
59+
switch runtime.GOOS {
60+
case "freebsd", "netbsd":
61+
// On FreeBSD and NetBSD, the namespace is stored separately from the xattr
6162
// name and Listxattr doesn't return the namespace prefix.
6263
xattrWant = strings.TrimPrefix(xattrWant, "user.")
6364
}
6465
found := false
6566
for _, name := range xattrs {
6667
if name == xattrWant {
6768
found = true
69+
break
6870
}
6971
}
7072

7173
if !found {
72-
t.Errorf("Listxattr did not return previously set attribute '%s'", xattrName)
74+
t.Errorf("Listxattr did not return previously set attribute %q in attributes %v", xattrName, xattrs)
7375
}
7476

7577
// find size
@@ -162,20 +164,22 @@ func TestFdXattr(t *testing.T) {
162164
xattrs := stringsFromByteSlice(buf[:read])
163165

164166
xattrWant := xattrName
165-
if runtime.GOOS == "freebsd" {
166-
// On FreeBSD, the namespace is stored separately from the xattr
167+
switch runtime.GOOS {
168+
case "freebsd", "netbsd":
169+
// On FreeBSD and NetBSD, the namespace is stored separately from the xattr
167170
// name and Listxattr doesn't return the namespace prefix.
168171
xattrWant = strings.TrimPrefix(xattrWant, "user.")
169172
}
170173
found := false
171174
for _, name := range xattrs {
172175
if name == xattrWant {
173176
found = true
177+
break
174178
}
175179
}
176180

177181
if !found {
178-
t.Errorf("Flistxattr did not return previously set attribute '%s'", xattrName)
182+
t.Errorf("Flistxattr did not return previously set attribute %q in attributes %v", xattrName, xattrs)
179183
}
180184

181185
// find size

0 commit comments

Comments
 (0)