unix: add tests for *xattr functions
Based on the tests in github.com/pkg/xattr
Change-Id: I3af73ad538877da042602708248063c218260a2e
Reviewed-on: https://go-review.googlesource.com/114135
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
diff --git a/unix/syscall_darwin_test.go b/unix/syscall_darwin_test.go
new file mode 100644
index 0000000..65691d5
--- /dev/null
+++ b/unix/syscall_darwin_test.go
@@ -0,0 +1,19 @@
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package unix_test
+
+// stringsFromByteSlice converts a sequence of attributes to a []string.
+// On Darwin, each entry is a NULL-terminated string.
+func stringsFromByteSlice(buf []byte) []string {
+ var result []string
+ off := 0
+ for i, b := range buf {
+ if b == 0 {
+ result = append(result, string(buf[off:i]))
+ off = i + 1
+ }
+ }
+ return result
+}