mirror of
https://github.com/rwinkhart/sys.git
synced 2026-08-28 04:46:44 -04:00
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>
This commit is contained in:
committed by
Gopher Robot
parent
ff8c426e75
commit
4f61da869c
@@ -8,7 +8,6 @@
|
|||||||
package unix_test
|
package unix_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
@@ -608,14 +607,6 @@ func chtmpdir(t *testing.T) func() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestMountUnmount(t *testing.T) {
|
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
|
// use an available fs
|
||||||
var buffer struct {
|
var buffer struct {
|
||||||
header unix.W_Mnth
|
header unix.W_Mnth
|
||||||
@@ -632,7 +623,7 @@ func TestMountUnmount(t *testing.T) {
|
|||||||
var mountpoint string
|
var mountpoint string
|
||||||
var available bool = false
|
var available bool = false
|
||||||
for i := 0; i < fsCount; i++ {
|
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 {
|
if err != nil {
|
||||||
// Unmount and Mount require elevated privilege
|
// Unmount and Mount require elevated privilege
|
||||||
// If test is run without such permission, skip test
|
// If test is run without such permission, skip test
|
||||||
@@ -646,9 +637,9 @@ func TestMountUnmount(t *testing.T) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
available = true
|
available = true
|
||||||
fs = b2s(buffer.fsinfo[i].Fsname[:])
|
fs = unix.ByteSliceToString(buffer.fsinfo[i].Fsname[:])
|
||||||
fstype = b2s(buffer.fsinfo[i].Fstname[:])
|
fstype = unix.ByteSliceToString(buffer.fsinfo[i].Fstname[:])
|
||||||
mountpoint = b2s(buffer.fsinfo[i].Mountpoint[:])
|
mountpoint = unix.ByteSliceToString(buffer.fsinfo[i].Mountpoint[:])
|
||||||
t.Logf("using file system = %s; fstype = %s and mountpoint = %s\n", fs, fstype, mountpoint)
|
t.Logf("using file system = %s; fstype = %s and mountpoint = %s\n", fs, fstype, mountpoint)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@@ -663,7 +654,7 @@ func TestMountUnmount(t *testing.T) {
|
|||||||
t.Fatalf("W_Getmntent_A returns with error: %s", err.Error())
|
t.Fatalf("W_Getmntent_A returns with error: %s", err.Error())
|
||||||
}
|
}
|
||||||
for i := 0; i < fsCount; i++ {
|
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")
|
t.Fatalf("File system found after unmount")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -679,7 +670,8 @@ func TestMountUnmount(t *testing.T) {
|
|||||||
}
|
}
|
||||||
fsMounted := false
|
fsMounted := false
|
||||||
for i := 0; i < fsCount; i++ {
|
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
|
fsMounted = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user