From dfa04520035368ac4c97a55aaf9f005d0a2da3f9 Mon Sep 17 00:00:00 2001 From: Aaron Jacobs Date: Fri, 20 Mar 2015 11:26:32 +1100 Subject: [PATCH] Implemented helpers. --- samples/flushfs/flush_fs_test.go | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/samples/flushfs/flush_fs_test.go b/samples/flushfs/flush_fs_test.go index 6c8eca4..d1b0460 100644 --- a/samples/flushfs/flush_fs_test.go +++ b/samples/flushfs/flush_fs_test.go @@ -74,12 +74,26 @@ func (t *FlushFSTest) SetUp(ti *TestInfo) { // Return a copy of the current contents of t.flushes. // // LOCKS_EXCLUDED(t.mu) -func (t *FlushFSTest) getFlushes() []string +func (t *FlushFSTest) getFlushes() (p []string) { + t.mu.Lock() + defer t.mu.Unlock() + + p = make([]string, len(t.flushes)) + copy(p, t.flushes) + return +} // Return a copy of the current contents of t.fsyncs. // // LOCKS_EXCLUDED(t.mu) -func (t *FlushFSTest) getFsyncs() []string +func (t *FlushFSTest) getFsyncs() (p []string) { + t.mu.Lock() + defer t.mu.Unlock() + + p = make([]string, len(t.fsyncs)) + copy(p, t.fsyncs) + return +} //////////////////////////////////////////////////////////////////////// // Tests