Skip to content

Commit 5e1b6c8

Browse files
committed
fs: remove testonly methods from mapIdentityTable
Change-Id: I22d43d80e53f37149d8a8699d67a86f86a6a6964
1 parent fb5ceb9 commit 5e1b6c8

3 files changed

Lines changed: 8 additions & 18 deletions

File tree

fs/forget_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,9 @@ func TestForget(t *testing.T) {
106106
time.Sleep(ttl)
107107

108108
bridge := rawFS.(*rawBridge)
109-
l := bridge.ids.nodeCount()
109+
bridge.ids.mu.Lock()
110+
l := len(bridge.ids.nodes)
111+
bridge.ids.mu.Unlock()
110112
if l != 1 {
111113
t.Fatalf("got %d live nodes, want 1", l)
112114
}

fs/identitytable.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -285,19 +285,3 @@ func (t *mapIdentityTable) recycleFile(fh uint32) {
285285
defer t.mu.Unlock()
286286
t.freeFiles = append(t.freeFiles, fh)
287287
}
288-
289-
// nodeCount returns the number of currently registered nodes. Used by
290-
// tests.
291-
func (t *mapIdentityTable) nodeCount() int {
292-
t.mu.Lock()
293-
defer t.mu.Unlock()
294-
return len(t.nodes)
295-
}
296-
297-
// fileCount returns the size of the file handle table (including
298-
// unallocated/free slots). Used by tests.
299-
func (t *mapIdentityTable) fileCount() int {
300-
t.mu.Lock()
301-
defer t.mu.Unlock()
302-
return len(t.files)
303-
}

fs/simple_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,12 @@ func TestFileFdLeak(t *testing.T) {
190190
bridge := tc.rawFS.(*rawBridge)
191191
tc = nil
192192

193+
bridge.ids.mu.Lock()
194+
got := len(bridge.ids.files)
195+
bridge.ids.mu.Unlock()
196+
193197
// posixtest.FdLeak also uses 15 as a limit.
194-
if got, want := bridge.ids.fileCount(), 15; got > want {
198+
if want := 15; got > want {
195199
t.Errorf("found %d used file handles, should be <= %d", got, want)
196200
}
197201
}

0 commit comments

Comments
 (0)