Commit 1bba2c11 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

nodefs: suppress verbose output for some tests

This reduces the debug output from 25k lines to ~1k
parent c97ee8e6
...@@ -17,7 +17,7 @@ import ( ...@@ -17,7 +17,7 @@ import (
) )
func TestRenameExchange(t *testing.T) { func TestRenameExchange(t *testing.T) {
tc := newTestCase(t, true, true) tc := newTestCase(t, &testOptions{attrCache: true, entryCache: true})
defer tc.Clean() defer tc.Clean()
if err := os.Mkdir(tc.origDir+"/dir", 0755); err != nil { if err := os.Mkdir(tc.origDir+"/dir", 0755); err != nil {
...@@ -74,7 +74,7 @@ func TestRenameExchange(t *testing.T) { ...@@ -74,7 +74,7 @@ func TestRenameExchange(t *testing.T) {
} }
func TestRenameNoOverwrite(t *testing.T) { func TestRenameNoOverwrite(t *testing.T) {
tc := newTestCase(t, true, true) tc := newTestCase(t, &testOptions{attrCache: true, entryCache: true})
defer tc.Clean() defer tc.Clean()
if err := os.Mkdir(tc.origDir+"/dir", 0755); err != nil { if err := os.Mkdir(tc.origDir+"/dir", 0755); err != nil {
...@@ -102,7 +102,7 @@ func TestRenameNoOverwrite(t *testing.T) { ...@@ -102,7 +102,7 @@ func TestRenameNoOverwrite(t *testing.T) {
} }
func TestXAttr(t *testing.T) { func TestXAttr(t *testing.T) {
tc := newTestCase(t, true, true) tc := newTestCase(t, &testOptions{attrCache: true, entryCache: true})
defer tc.Clean() defer tc.Clean()
tc.writeOrig("file", "", 0644) tc.writeOrig("file", "", 0644)
...@@ -137,7 +137,7 @@ func TestXAttr(t *testing.T) { ...@@ -137,7 +137,7 @@ func TestXAttr(t *testing.T) {
} }
func TestCopyFileRange(t *testing.T) { func TestCopyFileRange(t *testing.T) {
tc := newTestCase(t, true, true) tc := newTestCase(t, &testOptions{attrCache: true, entryCache: true})
defer tc.Clean() defer tc.Clean()
if !tc.server.KernelSettings().SupportsVersion(7, 28) { if !tc.server.KernelSettings().SupportsVersion(7, 28) {
......
...@@ -47,7 +47,16 @@ func (tc *testCase) Clean() { ...@@ -47,7 +47,16 @@ func (tc *testCase) Clean() {
} }
} }
func newTestCase(t *testing.T, entryCache bool, attrCache bool) *testCase { type testOptions struct {
entryCache bool
attrCache bool
suppressDebug bool
}
func newTestCase(t *testing.T, opts *testOptions) *testCase {
if opts == nil {
opts = &testOptions{}
}
tc := &testCase{ tc := &testCase{
dir: testutil.TempDir(), dir: testutil.TempDir(),
T: t, T: t,
...@@ -70,11 +79,11 @@ func newTestCase(t *testing.T, entryCache bool, attrCache bool) *testCase { ...@@ -70,11 +79,11 @@ func newTestCase(t *testing.T, entryCache bool, attrCache bool) *testCase {
oneSec := time.Second oneSec := time.Second
attrDT := &oneSec attrDT := &oneSec
if !attrCache { if !opts.attrCache {
attrDT = nil attrDT = nil
} }
entryDT := &oneSec entryDT := &oneSec
if !entryCache { if !opts.entryCache {
entryDT = nil entryDT = nil
} }
tc.rawFS = NewNodeFS(tc.loopback, &Options{ tc.rawFS = NewNodeFS(tc.loopback, &Options{
...@@ -82,10 +91,11 @@ func newTestCase(t *testing.T, entryCache bool, attrCache bool) *testCase { ...@@ -82,10 +91,11 @@ func newTestCase(t *testing.T, entryCache bool, attrCache bool) *testCase {
AttrTimeout: attrDT, AttrTimeout: attrDT,
}) })
tc.server, err = fuse.NewServer(tc.rawFS, tc.mntDir, mOpts := &fuse.MountOptions{}
&fuse.MountOptions{ if !opts.suppressDebug {
Debug: testutil.VerboseTest(), mOpts.Debug = testutil.VerboseTest()
}) }
tc.server, err = fuse.NewServer(tc.rawFS, tc.mntDir, mOpts)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
...@@ -98,7 +108,7 @@ func newTestCase(t *testing.T, entryCache bool, attrCache bool) *testCase { ...@@ -98,7 +108,7 @@ func newTestCase(t *testing.T, entryCache bool, attrCache bool) *testCase {
} }
func TestBasic(t *testing.T) { func TestBasic(t *testing.T) {
tc := newTestCase(t, true, true) tc := newTestCase(t, &testOptions{attrCache: true, entryCache: true})
defer tc.Clean() defer tc.Clean()
tc.writeOrig("file", "hello", 0644) tc.writeOrig("file", "hello", 0644)
...@@ -128,21 +138,25 @@ func TestBasic(t *testing.T) { ...@@ -128,21 +138,25 @@ func TestBasic(t *testing.T) {
} }
func TestFileBasic(t *testing.T) { func TestFileBasic(t *testing.T) {
tc := newTestCase(t, true, true) tc := newTestCase(t, &testOptions{attrCache: true, entryCache: true})
defer tc.Clean() defer tc.Clean()
posixtest.FileBasic(t, tc.mntDir) posixtest.FileBasic(t, tc.mntDir)
} }
func TestFileTruncate(t *testing.T) { func TestFileTruncate(t *testing.T) {
tc := newTestCase(t, true, true) tc := newTestCase(t, &testOptions{attrCache: true, entryCache: true})
defer tc.Clean() defer tc.Clean()
posixtest.TruncateFile(t, tc.mntDir) posixtest.TruncateFile(t, tc.mntDir)
} }
func TestFileFdLeak(t *testing.T) { func TestFileFdLeak(t *testing.T) {
tc := newTestCase(t, true, true) tc := newTestCase(t, &testOptions{
suppressDebug: true,
attrCache: true,
entryCache: true,
})
defer func() { defer func() {
if tc != nil { if tc != nil {
tc.Clean() tc.Clean()
...@@ -161,14 +175,14 @@ func TestFileFdLeak(t *testing.T) { ...@@ -161,14 +175,14 @@ func TestFileFdLeak(t *testing.T) {
} }
func TestMkdir(t *testing.T) { func TestMkdir(t *testing.T) {
tc := newTestCase(t, true, true) tc := newTestCase(t, &testOptions{attrCache: true, entryCache: true})
defer tc.Clean() defer tc.Clean()
posixtest.MkdirRmdir(t, tc.mntDir) posixtest.MkdirRmdir(t, tc.mntDir)
} }
func testRenameOverwrite(t *testing.T, destExists bool) { func testRenameOverwrite(t *testing.T, destExists bool) {
tc := newTestCase(t, true, true) tc := newTestCase(t, &testOptions{attrCache: true, entryCache: true})
defer tc.Clean() defer tc.Clean()
posixtest.RenameOverwrite(t, tc.mntDir, destExists) posixtest.RenameOverwrite(t, tc.mntDir, destExists)
} }
...@@ -183,35 +197,35 @@ func TestRenameDestNoExist(t *testing.T) { ...@@ -183,35 +197,35 @@ func TestRenameDestNoExist(t *testing.T) {
func TestNlinkZero(t *testing.T) { func TestNlinkZero(t *testing.T) {
// xfstest generic/035. // xfstest generic/035.
tc := newTestCase(t, true, true) tc := newTestCase(t, &testOptions{attrCache: true, entryCache: true})
defer tc.Clean() defer tc.Clean()
posixtest.NlinkZero(t, tc.mntDir) posixtest.NlinkZero(t, tc.mntDir)
} }
func TestParallelFileOpen(t *testing.T) { func TestParallelFileOpen(t *testing.T) {
tc := newTestCase(t, true, true) tc := newTestCase(t, &testOptions{suppressDebug: true, attrCache: true, entryCache: true})
defer tc.Clean() defer tc.Clean()
posixtest.ParallelFileOpen(t, tc.mntDir) posixtest.ParallelFileOpen(t, tc.mntDir)
} }
func TestSymlink(t *testing.T) { func TestSymlink(t *testing.T) {
tc := newTestCase(t, true, true) tc := newTestCase(t, &testOptions{attrCache: true, entryCache: true})
defer tc.Clean() defer tc.Clean()
posixtest.SymlinkReadlink(t, tc.mntDir) posixtest.SymlinkReadlink(t, tc.mntDir)
} }
func TestLink(t *testing.T) { func TestLink(t *testing.T) {
tc := newTestCase(t, true, true) tc := newTestCase(t, &testOptions{attrCache: true, entryCache: true})
defer tc.Clean() defer tc.Clean()
posixtest.Link(t, tc.mntDir) posixtest.Link(t, tc.mntDir)
} }
func TestNotifyEntry(t *testing.T) { func TestNotifyEntry(t *testing.T) {
tc := newTestCase(t, true, true) tc := newTestCase(t, &testOptions{attrCache: true, entryCache: true})
defer tc.Clean() defer tc.Clean()
orig := tc.origDir + "/file" orig := tc.origDir + "/file"
...@@ -244,14 +258,18 @@ func TestNotifyEntry(t *testing.T) { ...@@ -244,14 +258,18 @@ func TestNotifyEntry(t *testing.T) {
} }
func TestReadDir(t *testing.T) { func TestReadDir(t *testing.T) {
tc := newTestCase(t, true, true) tc := newTestCase(t, &testOptions{
suppressDebug: true,
attrCache: true,
entryCache: true,
})
defer tc.Clean() defer tc.Clean()
posixtest.ReadDir(t, tc.mntDir) posixtest.ReadDir(t, tc.mntDir)
} }
func TestReadDirStress(t *testing.T) { func TestReadDirStress(t *testing.T) {
tc := newTestCase(t, true, true) tc := newTestCase(t, &testOptions{suppressDebug: true, attrCache: true, entryCache: true})
defer tc.Clean() defer tc.Clean()
// (ab)use posixtest.ReadDir to create 110 test files // (ab)use posixtest.ReadDir to create 110 test files
posixtest.ReadDir(t, tc.mntDir) posixtest.ReadDir(t, tc.mntDir)
...@@ -286,7 +304,7 @@ func TestReadDirStress(t *testing.T) { ...@@ -286,7 +304,7 @@ func TestReadDirStress(t *testing.T) {
// This test is racy. If an external process consumes space while this // This test is racy. If an external process consumes space while this
// runs, we may see spurious differences between the two statfs() calls. // runs, we may see spurious differences between the two statfs() calls.
func TestStatFs(t *testing.T) { func TestStatFs(t *testing.T) {
tc := newTestCase(t, true, true) tc := newTestCase(t, &testOptions{attrCache: true, entryCache: true})
defer tc.Clean() defer tc.Clean()
empty := syscall.Statfs_t{} empty := syscall.Statfs_t{}
...@@ -314,7 +332,7 @@ func TestGetAttrParallel(t *testing.T) { ...@@ -314,7 +332,7 @@ func TestGetAttrParallel(t *testing.T) {
// can be handled correctly. Here, test that closing and // can be handled correctly. Here, test that closing and
// (f)stat in parallel don't lead to fstat on closed files. // (f)stat in parallel don't lead to fstat on closed files.
// We can only test that if we switch off caching // We can only test that if we switch off caching
tc := newTestCase(t, false, false) tc := newTestCase(t, &testOptions{suppressDebug: true})
defer tc.Clean() defer tc.Clean()
N := 100 N := 100
...@@ -355,7 +373,7 @@ func TestGetAttrParallel(t *testing.T) { ...@@ -355,7 +373,7 @@ func TestGetAttrParallel(t *testing.T) {
} }
func TestMknod(t *testing.T) { func TestMknod(t *testing.T) {
tc := newTestCase(t, false, false) tc := newTestCase(t, &testOptions{})
defer tc.Clean() defer tc.Clean()
modes := map[string]uint32{ modes := map[string]uint32{
...@@ -390,7 +408,7 @@ func TestMknod(t *testing.T) { ...@@ -390,7 +408,7 @@ func TestMknod(t *testing.T) {
} }
func TestTruncate(t *testing.T) { func TestTruncate(t *testing.T) {
tc := newTestCase(t, false, false) tc := newTestCase(t, &testOptions{})
defer tc.Clean() defer tc.Clean()
posixtest.TruncateNoFile(t, tc.mntDir) posixtest.TruncateNoFile(t, tc.mntDir)
......
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