fusego/samples/flushfs/flush_fs_test.go

121 lines
2.7 KiB
Go
Raw Normal View History

2015-03-20 03:17:05 +03:00
// Copyright 2015 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package flushfs_test
import (
2015-03-20 03:20:29 +03:00
"sync"
2015-03-20 03:17:05 +03:00
"testing"
"github.com/jacobsa/fuse/samples"
2015-03-20 03:20:29 +03:00
"github.com/jacobsa/fuse/samples/flushfs"
2015-03-20 03:17:05 +03:00
. "github.com/jacobsa/ogletest"
)
func TestFlushFS(t *testing.T) { RunTests(t) }
////////////////////////////////////////////////////////////////////////
// Boilerplate
////////////////////////////////////////////////////////////////////////
type FlushFSTest struct {
samples.SampleTest
2015-03-20 03:20:29 +03:00
mu sync.Mutex
// GUARDED_BY(mu)
2015-03-20 03:17:05 +03:00
flushes []string
2015-03-20 03:20:29 +03:00
// GUARDED_BY(mu)
fsyncs []string
2015-03-20 03:17:05 +03:00
}
func init() { RegisterTestSuite(&FlushFSTest{}) }
2015-03-20 03:20:29 +03:00
func (t *FlushFSTest) SetUp(ti *TestInfo) {
2015-03-20 03:21:38 +03:00
var err error
2015-03-20 03:20:29 +03:00
// Set up a file system.
reportTo := func(slice *[]string) func(string) {
return func(s string) {
t.mu.Lock()
defer t.mu.Unlock()
*slice = append(*slice, s)
}
}
2015-03-20 03:21:38 +03:00
t.FileSystem, err = flushfs.NewFileSystem(
2015-03-20 03:20:29 +03:00
reportTo(&t.flushes),
reportTo(&t.fsyncs))
2015-03-20 03:21:38 +03:00
if err != nil {
panic(err)
}
// Mount it.
t.SampleTest.SetUp(ti)
2015-03-20 03:20:29 +03:00
}
2015-03-20 03:17:05 +03:00
////////////////////////////////////////////////////////////////////////
2015-03-20 03:25:15 +03:00
// Helpers
2015-03-20 03:17:05 +03:00
////////////////////////////////////////////////////////////////////////
2015-03-20 03:25:15 +03:00
// Return a copy of the current contents of t.flushes.
//
// LOCKS_EXCLUDED(t.mu)
2015-03-20 03:26:32 +03:00
func (t *FlushFSTest) getFlushes() (p []string) {
t.mu.Lock()
defer t.mu.Unlock()
p = make([]string, len(t.flushes))
copy(p, t.flushes)
return
}
2015-03-20 03:25:15 +03:00
// Return a copy of the current contents of t.fsyncs.
//
// LOCKS_EXCLUDED(t.mu)
2015-03-20 03:26:32 +03:00
func (t *FlushFSTest) getFsyncs() (p []string) {
t.mu.Lock()
defer t.mu.Unlock()
p = make([]string, len(t.fsyncs))
copy(p, t.fsyncs)
return
}
2015-03-20 03:25:15 +03:00
////////////////////////////////////////////////////////////////////////
// Tests
////////////////////////////////////////////////////////////////////////
func (t *FlushFSTest) Close_NonOverlappingFileHandles() {
AssertTrue(false, "TODO")
}
func (t *FlushFSTest) Close_OverlappingFileHandles() {
AssertTrue(false, "TODO")
}
func (t *FlushFSTest) Close_ReadOnly() {
2015-03-20 03:23:15 +03:00
AssertTrue(false, "TODO")
}
2015-03-20 03:25:15 +03:00
func (t *FlushFSTest) Close_WriteOnly() {
2015-03-20 03:23:15 +03:00
AssertTrue(false, "TODO")
}
2015-03-20 03:25:15 +03:00
func (t *FlushFSTest) Fsync() {
2015-03-20 03:17:05 +03:00
AssertTrue(false, "TODO")
}