Support flush/fsync errors.
parent
4eda8330e8
commit
a932a6549e
|
@ -28,10 +28,10 @@ import (
|
||||||
//
|
//
|
||||||
// The file may be opened for reading and/or writing. Its initial contents are
|
// The file may be opened for reading and/or writing. Its initial contents are
|
||||||
// empty. Whenever a flush or fsync is received, the supplied function will be
|
// empty. Whenever a flush or fsync is received, the supplied function will be
|
||||||
// called with the current contents of the file.
|
// called with the current contents of the file and its status returned.
|
||||||
func NewFileSystem(
|
func NewFileSystem(
|
||||||
reportFlush func(string),
|
reportFlush func(string) error,
|
||||||
reportFsync func(string)) (fs fuse.FileSystem, err error) {
|
reportFsync func(string) error) (fs fuse.FileSystem, err error) {
|
||||||
fs = &flushFS{}
|
fs = &flushFS{}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,10 +41,12 @@ type FlushFSTest struct {
|
||||||
mu sync.Mutex
|
mu sync.Mutex
|
||||||
|
|
||||||
// GUARDED_BY(mu)
|
// GUARDED_BY(mu)
|
||||||
flushes []string
|
flushes []string
|
||||||
|
flushErr error
|
||||||
|
|
||||||
// GUARDED_BY(mu)
|
// GUARDED_BY(mu)
|
||||||
fsyncs []string
|
fsyncs []string
|
||||||
|
fsyncErr error
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() { RegisterTestSuite(&FlushFSTest{}) }
|
func init() { RegisterTestSuite(&FlushFSTest{}) }
|
||||||
|
@ -53,17 +55,19 @@ func (t *FlushFSTest) SetUp(ti *TestInfo) {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
// Set up a file system.
|
// Set up a file system.
|
||||||
reportTo := func(slice *[]string) func(string) {
|
reportTo := func(slice *[]string, err *error) func(string) error {
|
||||||
return func(s string) {
|
return func(s string) error {
|
||||||
t.mu.Lock()
|
t.mu.Lock()
|
||||||
defer t.mu.Unlock()
|
defer t.mu.Unlock()
|
||||||
|
|
||||||
*slice = append(*slice, s)
|
*slice = append(*slice, s)
|
||||||
|
return *err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
t.FileSystem, err = flushfs.NewFileSystem(
|
t.FileSystem, err = flushfs.NewFileSystem(
|
||||||
reportTo(&t.flushes),
|
reportTo(&t.flushes, &t.flushErr),
|
||||||
reportTo(&t.fsyncs))
|
reportTo(&t.fsyncs, &t.fsyncErr))
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
|
Loading…
Reference in New Issue