flushFSTest.setUp.
parent
27722cb25a
commit
4ca6ed02c6
|
@ -15,19 +15,18 @@
|
||||||
package flushfs_test
|
package flushfs_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"runtime"
|
"runtime"
|
||||||
"sync"
|
|
||||||
"syscall"
|
"syscall"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/jacobsa/bazilfuse"
|
"github.com/jacobsa/bazilfuse"
|
||||||
"github.com/jacobsa/fuse"
|
"github.com/jacobsa/fuse"
|
||||||
"github.com/jacobsa/fuse/samples"
|
"github.com/jacobsa/fuse/samples"
|
||||||
"github.com/jacobsa/fuse/samples/flushfs"
|
|
||||||
. "github.com/jacobsa/oglematchers"
|
. "github.com/jacobsa/oglematchers"
|
||||||
. "github.com/jacobsa/ogletest"
|
. "github.com/jacobsa/ogletest"
|
||||||
)
|
)
|
||||||
|
@ -39,21 +38,11 @@ func TestFlushFS(t *testing.T) { RunTests(t) }
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
type flushFSTest struct {
|
type flushFSTest struct {
|
||||||
samples.SampleTest
|
samples.SubprocessTest
|
||||||
|
|
||||||
// File handles that are closed in TearDown if non-nil.
|
// File handles that are closed in TearDown if non-nil.
|
||||||
f1 *os.File
|
f1 *os.File
|
||||||
f2 *os.File
|
f2 *os.File
|
||||||
|
|
||||||
mu sync.Mutex
|
|
||||||
|
|
||||||
// GUARDED_BY(mu)
|
|
||||||
flushes []string
|
|
||||||
flushErr error
|
|
||||||
|
|
||||||
// GUARDED_BY(mu)
|
|
||||||
fsyncs []string
|
|
||||||
fsyncErr error
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *flushFSTest) setUp(
|
func (t *flushFSTest) setUp(
|
||||||
|
@ -62,27 +51,26 @@ func (t *flushFSTest) setUp(
|
||||||
fsyncErr bazilfuse.Errno) {
|
fsyncErr bazilfuse.Errno) {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
// Set up a file system.
|
// Set up files to receive flush and fsync reports.
|
||||||
reportTo := func(slice *[]string, err *error) func(string) error {
|
panic("TODO")
|
||||||
return func(s string) error {
|
|
||||||
t.mu.Lock()
|
|
||||||
defer t.mu.Unlock()
|
|
||||||
|
|
||||||
*slice = append(*slice, s)
|
// Set up test config.
|
||||||
return *err
|
t.MountType = "flushfs"
|
||||||
}
|
t.MountFlags = []string{
|
||||||
|
"--flushfs.flushes_file",
|
||||||
|
t.flushes.Name(),
|
||||||
|
|
||||||
|
"--flushfs.fsyncs_file",
|
||||||
|
t.fsyncs.Name(),
|
||||||
|
|
||||||
|
"--flushfs.flush_error",
|
||||||
|
fmt.Sprintf("%d", int(flushErr)),
|
||||||
|
|
||||||
|
"--fsyncfs.fsync_error",
|
||||||
|
fmt.Sprintf("%d", int(fsyncErr)),
|
||||||
}
|
}
|
||||||
|
|
||||||
t.FileSystem, err = flushfs.NewFileSystem(
|
t.SubprocessTest.SetUp(ti)
|
||||||
reportTo(&t.flushes, &t.flushErr),
|
|
||||||
reportTo(&t.fsyncs, &t.fsyncErr))
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Mount it.
|
|
||||||
t.SampleTest.SetUp(ti)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *FlushFSTest) TearDown() {
|
func (t *FlushFSTest) TearDown() {
|
||||||
|
|
Loading…
Reference in New Issue