unix: use ByteSliceToString in TestMountUnmount on zos
Use the existing ByteSliceToString implementation instead of duplicating
it in TestMountUnmount.
Change-Id: Ia47510ac1ac8094a7e9265edf8a452bcacf06032
Reviewed-on: https://go-review.googlesource.com/c/sys/+/411379
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
diff --git a/unix/syscall_zos_test.go b/unix/syscall_zos_test.go
index f022525..42ae5ba 100644
--- a/unix/syscall_zos_test.go
+++ b/unix/syscall_zos_test.go
@@ -8,7 +8,6 @@
package unix_test
import (
- "bytes"
"flag"
"fmt"
"io/ioutil"
@@ -608,14 +607,6 @@
}
func TestMountUnmount(t *testing.T) {
- b2s := func(arr []byte) string {
- nulli := bytes.IndexByte(arr, 0)
- if nulli == -1 {
- return string(arr)
- } else {
- return string(arr[:nulli])
- }
- }
// use an available fs
var buffer struct {
header unix.W_Mnth
@@ -632,7 +623,7 @@
var mountpoint string
var available bool = false
for i := 0; i < fsCount; i++ {
- err = unix.Unmount(b2s(buffer.fsinfo[i].Mountpoint[:]), unix.MTM_RDWR)
+ err = unix.Unmount(unix.ByteSliceToString(buffer.fsinfo[i].Mountpoint[:]), unix.MTM_RDWR)
if err != nil {
// Unmount and Mount require elevated privilege
// If test is run without such permission, skip test
@@ -646,9 +637,9 @@
}
} else {
available = true
- fs = b2s(buffer.fsinfo[i].Fsname[:])
- fstype = b2s(buffer.fsinfo[i].Fstname[:])
- mountpoint = b2s(buffer.fsinfo[i].Mountpoint[:])
+ fs = unix.ByteSliceToString(buffer.fsinfo[i].Fsname[:])
+ fstype = unix.ByteSliceToString(buffer.fsinfo[i].Fstname[:])
+ mountpoint = unix.ByteSliceToString(buffer.fsinfo[i].Mountpoint[:])
t.Logf("using file system = %s; fstype = %s and mountpoint = %s\n", fs, fstype, mountpoint)
break
}
@@ -663,7 +654,7 @@
t.Fatalf("W_Getmntent_A returns with error: %s", err.Error())
}
for i := 0; i < fsCount; i++ {
- if b2s(buffer.fsinfo[i].Fsname[:]) == fs {
+ if unix.ByteSliceToString(buffer.fsinfo[i].Fsname[:]) == fs {
t.Fatalf("File system found after unmount")
}
}
@@ -679,7 +670,8 @@
}
fsMounted := false
for i := 0; i < fsCount; i++ {
- if b2s(buffer.fsinfo[i].Fsname[:]) == fs && b2s(buffer.fsinfo[i].Mountpoint[:]) == mountpoint {
+ if unix.ByteSliceToString(buffer.fsinfo[i].Fsname[:]) == fs &&
+ unix.ByteSliceToString(buffer.fsinfo[i].Mountpoint[:]) == mountpoint {
fsMounted = true
}
}