Commit 135f7059 authored by lch's avatar lch Committed by lchopn

fs: fix building of tests

Change-Id: Iffa5314fbe171d182a4bdef42e0ab4781cc1d221
parent 8d89f3cd
......@@ -45,7 +45,7 @@ func (ds *errDirStream) Next() (fuse.DirEntry, syscall.Errno) {
Mode: fuse.S_IFREG,
Name: "last",
Ino: 3,
}, syscall.EKEYEXPIRED
}, syscall.EBADMSG
}
panic("boom")
......@@ -76,9 +76,14 @@ func TestDirStreamError(t *testing.T) {
} else if e.Name != "first" {
t.Errorf("got %q want 'first'", e.Name)
}
if _, errno := ds.Next(); errno != syscall.EKEYEXPIRED {
t.Errorf("got errno %v, want EKEYEXPIRED", errno)
// Here we need choose a errno to test if errno could be passed and handled
// correctly by the fuse library. To build the test on different platform,
// an errno which defined on each platform should be chosen. And if the
// chosen integer number is not a valid errno, the fuse in kernel would refuse
// and throw an error, which is observed on Linux.
// Here we choose to use EBADMSG, which is defined on multiple Unix-like OSes.
if _, errno := ds.Next(); errno != syscall.EBADMSG {
t.Errorf("got errno %v, want EBADMSG", errno)
}
})
}
......
......@@ -244,7 +244,7 @@ func bdiReadahead(mnt string) int {
if err != nil {
panic(err)
}
path := fmt.Sprintf("/sys/class/bdi/%d:%d/read_ahead_kb", unix.Major(st.Dev), unix.Minor(st.Dev))
path := fmt.Sprintf("/sys/class/bdi/%d:%d/read_ahead_kb", unix.Major(uint64(st.Dev)), unix.Minor(uint64(st.Dev)))
buf, err := ioutil.ReadFile(path)
if err != nil {
panic(err)
......
......@@ -137,8 +137,7 @@ func TestDataFile(t *testing.T) {
if err := syscall.Lstat(mntDir+"/file", &st); err != nil {
t.Fatalf("Lstat: %v", err)
}
if want := uint32(syscall.S_IFREG | 0464); st.Mode != want {
if want := uint(syscall.S_IFREG | 0464); uint(st.Mode) != want {
t.Errorf("got mode %o, want %o", st.Mode, want)
}
......
......@@ -11,14 +11,14 @@ import (
"testing"
"github.com/hanwen/go-fuse/v2/fuse"
"golang.org/x/sys/unix"
)
func TestReadonlyCreate(t *testing.T) {
root := &Inode{}
mntDir, _ := testMount(t, root, nil)
_, err := syscall.Creat(mntDir+"/test", 0644)
_, err := unix.Open(mntDir+"/test", unix.O_CREAT, 0644)
if want := syscall.EROFS; want != err {
t.Fatalf("got err %v, want %v", err, want)
}
......@@ -44,7 +44,7 @@ func TestDefaultPermissions(t *testing.T) {
var st syscall.Stat_t
if err := syscall.Lstat(filepath.Join(mntDir, k), &st); err != nil {
t.Error("Lstat", err)
} else if st.Mode != v {
} else if uint(st.Mode) != uint(v) {
t.Errorf("got %o want %o", st.Mode, v)
}
}
......
......@@ -25,6 +25,7 @@ import (
"github.com/hanwen/go-fuse/v2/fuse"
"github.com/hanwen/go-fuse/v2/internal/testutil"
"github.com/hanwen/go-fuse/v2/posixtest"
"golang.org/x/sys/unix"
)
type testCase struct {
......@@ -339,7 +340,7 @@ func TestMknod(t *testing.T) {
var st syscall.Stat_t
if err := syscall.Stat(p, &st); err != nil {
got := st.Mode &^ 07777
if want := mode; got != want {
if want := uint(mode); want != uint(got) {
t.Fatalf("stat(%s): got %o want %o", nm, got, want)
}
}
......@@ -648,7 +649,7 @@ func TestStaleHardlinks(t *testing.T) {
// "link0" is original file
link0 := tc.mntDir + "/link0"
if fd, err := syscall.Creat(link0, 0600); err != nil {
if fd, err := unix.Open(link0, unix.O_CREAT, 0600); err != nil {
t.Fatal(err)
} else {
syscall.Close(fd)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment