summaryrefslogtreecommitdiff
path: root/internal/openfiletable/inummap_test.go
diff options
context:
space:
mode:
authorJakob Unterwurzacher2020-04-12 17:15:03 +0200
committerJakob Unterwurzacher2020-04-13 14:54:04 +0200
commit488111ce390218806fca933b89279b766f7ff49c (patch)
treed75a8aac95f95767410027da14cd0231c17110a3 /internal/openfiletable/inummap_test.go
parent194030f18ae623fbf5b0bb805b780f81fe9ec7a7 (diff)
inomap: split into separate package
inomap will also be used by fusefrontend_reverse in the future. Split if off openfiletable to make it independent.
Diffstat (limited to 'internal/openfiletable/inummap_test.go')
-rw-r--r--internal/openfiletable/inummap_test.go81
1 files changed, 0 insertions, 81 deletions
diff --git a/internal/openfiletable/inummap_test.go b/internal/openfiletable/inummap_test.go
deleted file mode 100644
index 85438bd..0000000
--- a/internal/openfiletable/inummap_test.go
+++ /dev/null
@@ -1,81 +0,0 @@
-package openfiletable
-
-import (
- "sync"
- "testing"
-)
-
-func TestTranslate(t *testing.T) {
- const baseDev = 12345
- m := NewInumMap(baseDev)
-
- q := QIno{Dev: baseDev, Ino: 1}
- out := m.Translate(q)
- if out != 1 {
- t.Errorf("expected 1, got %d", out)
- }
- q.Ino = inumTranslateBase
- out = m.Translate(q)
- if out < inumTranslateBase {
- t.Errorf("got %d", out)
- }
- out2 := m.Translate(q)
- if out2 != out {
- t.Errorf("unstable mapping: %d %d", out2, out)
- }
-}
-
-func TestTranslateStress(t *testing.T) {
- const baseDev = 12345
- m := NewInumMap(baseDev)
- var wg sync.WaitGroup
- wg.Add(4)
- go func() {
- q := QIno{Dev: baseDev}
- for i := uint64(1); i <= 10000; i++ {
- q.Ino = i
- out := m.Translate(q)
- if out != i {
- t.Fail()
- }
- }
- wg.Done()
- }()
- go func() {
- q := QIno{Dev: baseDev}
- for i := uint64(1); i <= 10000; i++ {
- q.Ino = inumTranslateBase + i
- out := m.Translate(q)
- if out < inumTranslateBase {
- t.Fail()
- }
- }
- wg.Done()
- }()
- go func() {
- q := QIno{Dev: 9999999}
- for i := uint64(1); i <= 10000; i++ {
- q.Ino = i
- out := m.Translate(q)
- if out < inumTranslateBase {
- t.Fail()
- }
- }
- wg.Done()
- }()
- go func() {
- q := QIno{Dev: 4444444}
- for i := uint64(1); i <= 10000; i++ {
- q.Ino = i
- out := m.Translate(q)
- if out < inumTranslateBase {
- t.Fail()
- }
- }
- wg.Done()
- }()
- wg.Wait()
- if m.Count() != 30000 {
- t.Fail()
- }
-}