Commit 437ab542 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Use testing.Log for test progress messages.

parent ab5078a6
......@@ -104,7 +104,6 @@ func (me *DefaultFsNode) OpenDir(context *Context) (chan DirEntry, Status) {
for name, child := range ch {
fi, code := child.FsNode().GetAttr(nil, context)
if code.Ok() {
log.Printf("mode %o", fi.Mode)
s <- DirEntry{Name: name, Mode: fi.Mode}
}
}
......
package fuse
import (
"fmt"
"io/ioutil"
"log"
"os"
"syscall"
"testing"
......@@ -121,7 +119,7 @@ func NewFile() *MutableDataFile {
return &MutableDataFile{}
}
func setupFAttrTest(fs FileSystem) (dir string, clean func()) {
func setupFAttrTest(t *testing.T, fs FileSystem) (dir string, clean func()) {
dir, err := ioutil.TempDir("", "go-fuse")
CheckSuccess(err)
state, _, err := MountPathFileSystem(dir, fs, nil)
......@@ -133,7 +131,7 @@ func setupFAttrTest(fs FileSystem) (dir string, clean func()) {
// Trigger INIT.
os.Lstat(dir)
if state.KernelSettings().Flags&CAP_FILE_OPS == 0 {
log.Println("Mount does not support file operations")
t.Log("Mount does not support file operations")
}
return dir, func() {
......@@ -145,7 +143,7 @@ func setupFAttrTest(fs FileSystem) (dir string, clean func()) {
func TestFSetAttr(t *testing.T) {
fs := &FSetAttrFs{}
dir, clean := setupFAttrTest(fs)
dir, clean := setupFAttrTest(t, fs)
defer clean()
fn := dir + "/file"
......@@ -159,7 +157,6 @@ func TestFSetAttr(t *testing.T) {
_, err = f.WriteString("hello")
CheckSuccess(err)
fmt.Println("Ftruncate")
code := syscall.Ftruncate(f.Fd(), 3)
if code != 0 {
t.Error("truncate retval", os.NewSyscallError("Ftruncate", code))
......
......@@ -23,7 +23,7 @@ func TestHandleMapDoubleRegister(t *testing.T) {
t.Log("skipping test for 32 bits")
return
}
log.Println("TestDoubleRegister")
t.Log("TestDoubleRegister")
defer markSeen("already has a handle")
hm := NewHandleMap(false)
obj := &Handled{}
......@@ -69,7 +69,7 @@ func TestHandleMapBasic(t *testing.T) {
v := new(Handled)
hm := NewHandleMap(portable)
h := hm.Register(v, v)
log.Printf("Got handle 0x%x", h)
t.Logf("Got handle 0x%x", h)
if !hm.Has(h) {
t.Fatal("Does not have handle")
}
......
......@@ -8,7 +8,6 @@ import (
var _ = fmt.Println
func TestLatencyMap(t *testing.T) {
fmt.Println("TestLatencyMap")
m := NewLatencyMap()
m.Add("foo", "", 0.1e9)
m.Add("foo", "", 0.2e9)
......
......@@ -120,7 +120,6 @@ func TestTouch(t *testing.T) {
ts := NewTestCase(t)
defer ts.Cleanup()
log.Println("testTouch")
err := ioutil.WriteFile(ts.origFile, []byte(contents), 0700)
CheckSuccess(err)
err = os.Chtimes(ts.mountFile, 42e9, 43e9)
......@@ -139,11 +138,9 @@ func (me *testCase) TestReadThrough(t *testing.T) {
err := ioutil.WriteFile(ts.origFile, []byte(contents), 0700)
CheckSuccess(err)
fmt.Println("Testing chmod.")
err = os.Chmod(ts.mountFile, mode)
CheckSuccess(err)
fmt.Println("Testing Lstat.")
fi, err := os.Lstat(ts.mountFile)
CheckSuccess(err)
if (fi.Mode & 0777) != mode {
......@@ -151,12 +148,10 @@ func (me *testCase) TestReadThrough(t *testing.T) {
}
// Open (for read), read.
fmt.Println("Testing open.")
f, err := os.Open(ts.mountFile)
CheckSuccess(err)
defer f.Close()
fmt.Println("Testing read.")
var buf [1024]byte
slice := buf[:]
n, err := f.Read(slice)
......@@ -164,7 +159,6 @@ func (me *testCase) TestReadThrough(t *testing.T) {
if len(slice[:n]) != len(contents) {
t.Errorf("Content error %v", slice)
}
fmt.Println("Testing close.")
}
func TestRemove(t *testing.T) {
......@@ -676,8 +670,7 @@ func TestIoctl(t *testing.T) {
os.O_WRONLY|os.O_CREATE, 0777)
defer f.Close()
CheckSuccess(err)
v, e := ioctl(f.Fd(), 0x5401, 42)
fmt.Println("ioctl", v, e)
ioctl(f.Fd(), 0x5401, 42)
}
// This test is racy. If an external process consumes space while this
......
......@@ -142,7 +142,6 @@ func (me *memNodeFile) Flush() Status {
fi, _ := me.LoopbackFile.GetAttr()
me.node.info.Size = fi.Size
me.node.info.Blocks = fi.Blocks
log.Println("reset size", me.node.info.Size, me.node.Inode().nodeId)
return code
}
......
......@@ -54,7 +54,6 @@ func TestMemNodeFs(t *testing.T) {
}
entries, err := ioutil.ReadDir(wd)
log.Println(entries)
if len(entries) != 1 || entries[0].Name != "test" {
t.Fatalf("Readdir got %v, expected 1 file named 'test'", entries)
}
......
package fuse
import (
"log"
"os"
"testing"
"time"
......@@ -86,7 +85,7 @@ func TestRecursiveMount(t *testing.T) {
f, err := os.Open(filepath.Join(submnt, "hello.txt"))
CheckSuccess(err)
log.Println("Attempting unmount, should fail")
t.Log("Attempting unmount, should fail")
code = ts.pathFs.Unmount("mnt")
if code != EBUSY {
t.Error("expect EBUSY")
......@@ -94,10 +93,10 @@ func TestRecursiveMount(t *testing.T) {
f.Close()
log.Println("Waiting for kernel to flush file-close to fuse...")
t.Log("Waiting for kernel to flush file-close to fuse...")
time.Sleep(1.5e9 * testTtl)
log.Println("Attempting unmount, should succeed")
t.Log("Attempting unmount, should succeed")
code = ts.pathFs.Unmount("mnt")
if code != OK {
t.Error("umount failed.", code)
......@@ -117,11 +116,11 @@ func TestDeletedUnmount(t *testing.T) {
f, err := os.Create(filepath.Join(submnt, "hello.txt"))
CheckSuccess(err)
log.Println("Removing")
t.Log("Removing")
err = os.Remove(filepath.Join(submnt, "hello.txt"))
CheckSuccess(err)
log.Println("Removing")
t.Log("Removing")
_, err = f.Write([]byte("bla"))
CheckSuccess(err)
......
......@@ -12,6 +12,7 @@ import (
var _ = log.Print
type XAttrTestFs struct {
tester *testing.T
filename string
attrs map[string][]byte
......@@ -39,7 +40,7 @@ func (me *XAttrTestFs) GetAttr(name string, context *Context) (*os.FileInfo, Sta
}
func (me *XAttrTestFs) SetXAttr(name string, attr string, data []byte, flags int, context *Context) Status {
log.Println("SetXAttr", name, attr, string(data), flags)
me.tester.Log("SetXAttr", name, attr, string(data), flags)
if name != me.filename {
return ENOENT
}
......@@ -57,7 +58,7 @@ func (me *XAttrTestFs) GetXAttr(name string, attr string, context *Context) ([]b
if !ok {
return nil, ENODATA
}
log.Println("GetXAttr", string(v))
me.tester.Log("GetXAttr", string(v))
return v, OK
}
......@@ -77,7 +78,7 @@ func (me *XAttrTestFs) RemoveXAttr(name string, attr string, context *Context) S
return ENOENT
}
_, ok := me.attrs[attr]
log.Println("RemoveXAttr", name, attr, ok)
me.tester.Log("RemoveXAttr", name, attr, ok)
if !ok {
return ENODATA
}
......@@ -92,6 +93,7 @@ func TestXAttrRead(t *testing.T) {
"user.attr1": []byte("val1"),
"user.attr2": []byte("val2")}
xfs := NewXAttrFs(nm, golden)
xfs.tester = t
mountPoint, err := ioutil.TempDir("", "go-fuse")
CheckSuccess(err)
defer os.RemoveAll(mountPoint)
......
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