Commit cad36b13 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Only print debug if testing with -v.

parent ca4265a2
...@@ -38,9 +38,9 @@ func setupCacheTest() (string, *PathNodeFs, func()) { ...@@ -38,9 +38,9 @@ func setupCacheTest() (string, *PathNodeFs, func()) {
pfs := NewPathNodeFs(fs, nil) pfs := NewPathNodeFs(fs, nil)
state, conn, err := MountNodeFileSystem(dir+"/mnt", pfs, nil) state, conn, err := MountNodeFileSystem(dir+"/mnt", pfs, nil)
CheckSuccess(err) CheckSuccess(err)
state.Debug = true state.Debug = VerboseTest()
conn.Debug = true conn.Debug = VerboseTest()
pfs.Debug = true pfs.Debug = VerboseTest()
go state.Loop() go state.Loop()
return dir, pfs, func() { return dir, pfs, func() {
...@@ -123,7 +123,7 @@ func TestNonseekable(t *testing.T) { ...@@ -123,7 +123,7 @@ func TestNonseekable(t *testing.T) {
defer os.RemoveAll(dir) defer os.RemoveAll(dir)
state, _, err := MountPathFileSystem(dir, fs, nil) state, _, err := MountPathFileSystem(dir, fs, nil)
CheckSuccess(err) CheckSuccess(err)
state.Debug = true state.Debug = VerboseTest()
defer state.Unmount() defer state.Unmount()
go state.Loop() go state.Loop()
......
...@@ -126,7 +126,7 @@ func setupFAttrTest(fs FileSystem) (dir string, clean func()) { ...@@ -126,7 +126,7 @@ func setupFAttrTest(fs FileSystem) (dir string, clean func()) {
CheckSuccess(err) CheckSuccess(err)
state, _, err := MountPathFileSystem(dir, fs, nil) state, _, err := MountPathFileSystem(dir, fs, nil)
CheckSuccess(err) CheckSuccess(err)
state.Debug = true state.Debug = VerboseTest()
go state.Loop() go state.Loop()
......
...@@ -82,12 +82,11 @@ func NewTestCase(t *testing.T) *testCase { ...@@ -82,12 +82,11 @@ func NewTestCase(t *testing.T) *testCase {
rfs = me.connector rfs = me.connector
rfs = NewLockingRawFileSystem(rfs) rfs = NewLockingRawFileSystem(rfs)
me.connector.Debug = true me.connector.Debug = VerboseTest()
me.state = NewMountState(rfs) me.state = NewMountState(rfs)
me.state.Mount(me.mnt, nil) me.state.Mount(me.mnt, nil)
//me.state.Debug = false me.state.Debug = VerboseTest()
me.state.Debug = true
// Unthreaded, but in background. // Unthreaded, but in background.
go me.state.Loop() go me.state.Loop()
......
...@@ -24,12 +24,12 @@ func setupMemNodeTest(t *testing.T) (wd string, fs *MemNodeFs, clean func()) { ...@@ -24,12 +24,12 @@ func setupMemNodeTest(t *testing.T) (wd string, fs *MemNodeFs, clean func()) {
AttrTimeout: testTtl, AttrTimeout: testTtl,
NegativeTimeout: 0.0, NegativeTimeout: 0.0,
}) })
connector.Debug = true connector.Debug = VerboseTest()
state := NewMountState(connector) state := NewMountState(connector)
state.Mount(mnt, nil) state.Mount(mnt, nil)
//me.state.Debug = false //me.state.Debug = false
state.Debug = true state.Debug = VerboseTest()
// Unthreaded, but in background. // Unthreaded, but in background.
go state.Loop() go state.Loop()
......
...@@ -3,10 +3,11 @@ ...@@ -3,10 +3,11 @@
package fuse package fuse
import ( import (
"os" "flag"
"fmt" "fmt"
"log" "log"
"math" "math"
"os"
"reflect" "reflect"
"strings" "strings"
"syscall" "syscall"
...@@ -153,3 +154,8 @@ func CurrentOwner() *Owner { ...@@ -153,3 +154,8 @@ func CurrentOwner() *Owner {
Gid: uint32(os.Getgid()), Gid: uint32(os.Getgid()),
} }
} }
func VerboseTest() bool {
flag := flag.Lookup("test.v")
return flag != nil && flag.Value.String() == "true"
}
...@@ -56,7 +56,7 @@ func NewNotifyTest() *NotifyTest { ...@@ -56,7 +56,7 @@ func NewNotifyTest() *NotifyTest {
me.pathfs = NewPathNodeFs(me.fs, nil) me.pathfs = NewPathNodeFs(me.fs, nil)
me.state, me.connector, err = MountNodeFileSystem(me.dir, me.pathfs, opts) me.state, me.connector, err = MountNodeFileSystem(me.dir, me.pathfs, opts)
CheckSuccess(err) CheckSuccess(err)
me.state.Debug = true me.state.Debug = VerboseTest()
go me.state.Loop() go me.state.Loop()
return me return me
......
...@@ -98,7 +98,7 @@ func TestXAttrRead(t *testing.T) { ...@@ -98,7 +98,7 @@ func TestXAttrRead(t *testing.T) {
state, _, err := MountPathFileSystem(mountPoint, xfs, nil) state, _, err := MountPathFileSystem(mountPoint, xfs, nil)
CheckSuccess(err) CheckSuccess(err)
state.Debug = true state.Debug = VerboseTest()
defer state.Unmount() defer state.Unmount()
go state.Loop() go state.Loop()
......
...@@ -44,8 +44,8 @@ func setup(t *testing.T) (workdir string, cleanup func()) { ...@@ -44,8 +44,8 @@ func setup(t *testing.T) (workdir string, cleanup func()) {
fs := NewAutoUnionFs(wd+"/store", testAOpts) fs := NewAutoUnionFs(wd+"/store", testAOpts)
state, conn, err := fuse.MountPathFileSystem(wd+"/mount", fs, &testAOpts.FileSystemOptions) state, conn, err := fuse.MountPathFileSystem(wd+"/mount", fs, &testAOpts.FileSystemOptions)
CheckSuccess(err) CheckSuccess(err)
state.Debug = true state.Debug = fuse.VerboseTest()
conn.Debug = true conn.Debug = fuse.VerboseTest()
go state.Loop() go state.Loop()
return wd, func() { return wd, func() {
......
...@@ -58,8 +58,8 @@ func setupUfs(t *testing.T) (workdir string, cleanup func()) { ...@@ -58,8 +58,8 @@ func setupUfs(t *testing.T) (workdir string, cleanup func()) {
&fuse.PathNodeFsOptions{ClientInodes: true}) &fuse.PathNodeFsOptions{ClientInodes: true})
state, conn, err := fuse.MountNodeFileSystem(wd+"/mount", pathfs, opts) state, conn, err := fuse.MountNodeFileSystem(wd+"/mount", pathfs, opts)
CheckSuccess(err) CheckSuccess(err)
conn.Debug = true conn.Debug = fuse.VerboseTest()
state.Debug = true state.Debug = fuse.VerboseTest()
go state.Loop() go state.Loop()
return wd, func() { return wd, func() {
...@@ -871,7 +871,7 @@ func TestDisappearing(t *testing.T) { ...@@ -871,7 +871,7 @@ func TestDisappearing(t *testing.T) {
state, _, err := fuse.MountPathFileSystem(wd+"/mount", ufs, opts) state, _, err := fuse.MountPathFileSystem(wd+"/mount", ufs, opts)
CheckSuccess(err) CheckSuccess(err)
defer state.Unmount() defer state.Unmount()
state.Debug = true state.Debug = fuse.VerboseTest()
go state.Loop() go state.Loop()
log.Println("TestDisappearing2") log.Println("TestDisappearing2")
......
...@@ -22,7 +22,7 @@ func setupMzfs() (mountPoint string, cleanup func()) { ...@@ -22,7 +22,7 @@ func setupMzfs() (mountPoint string, cleanup func()) {
NegativeTimeout: 0.0, NegativeTimeout: 0.0,
}) })
CheckSuccess(err) CheckSuccess(err)
state.Debug = true state.Debug = fuse.VerboseTest()
go state.Loop() go state.Loop()
return mountPoint, func() { return mountPoint, func() {
......
...@@ -25,7 +25,7 @@ func setupZipfs() (mountPoint string, cleanup func()) { ...@@ -25,7 +25,7 @@ func setupZipfs() (mountPoint string, cleanup func()) {
mountPoint, _ = ioutil.TempDir("", "") mountPoint, _ = ioutil.TempDir("", "")
state, _, err := fuse.MountNodeFileSystem(mountPoint, zfs, nil) state, _, err := fuse.MountNodeFileSystem(mountPoint, zfs, nil)
state.Debug = true state.Debug = fuse.VerboseTest()
go state.Loop() go state.Loop()
return mountPoint, func() { return mountPoint, func() {
......
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