MCPcopy
hub / github.com/perkeep/perkeep / pkmountTest

Function pkmountTest

pkg/fs/fs_test.go:96–164  ·  view source on GitHub ↗
(t *testing.T, fn func(env *mountEnv))

Source from the content-addressed store, hash-verified

94}
95
96func pkmountTest(t *testing.T, fn func(env *mountEnv)) {
97 dupLog := io.MultiWriter(os.Stderr, testLog{t})
98 log.SetOutput(dupLog)
99 defer log.SetOutput(os.Stderr)
100
101 w := test.GetWorld(t)
102 mountPoint := t.TempDir()
103 verbose := "false"
104 var stderrDest io.Writer = io.Discard
105 if v, _ := strconv.ParseBool(os.Getenv("VERBOSE_FUSE")); v {
106 verbose = "true"
107 stderrDest = testLog{t}
108 }
109 if v, _ := strconv.ParseBool(os.Getenv("VERBOSE_FUSE_STDERR")); v {
110 stderrDest = io.MultiWriter(stderrDest, os.Stderr)
111 }
112
113 mount := w.CmdWithEnv(
114 "pk-mount",
115 append(
116 os.Environ(),
117 "PERKEEP_CACHE_DIR="+t.TempDir(),
118 ),
119 "--debug="+verbose,
120 mountPoint,
121 )
122 mount.Stderr = stderrDest
123 mount.Env = append(mount.Env, "CAMLI_TRACK_FS_STATS=1")
124
125 stdin, err := mount.StdinPipe()
126 if err != nil {
127 t.Fatal(err)
128 }
129 if err := w.Ping(); err != nil {
130 t.Fatal(err)
131 }
132 if err := mount.Start(); err != nil {
133 t.Fatal(err)
134 }
135 waitc := make(chan error, 1)
136 go func() { waitc <- mount.Wait() }()
137 defer func() {
138 log.Printf("Sending quit")
139 stdin.Write([]byte("q\n"))
140 select {
141 case <-time.After(5 * time.Second):
142 log.Printf("timeout waiting for pk-mount to finish")
143 mount.Process.Kill()
144 Unmount(mountPoint)
145 case err := <-waitc:
146 log.Printf("pk-mount exited: %v", err)
147 }
148 if !test.WaitFor(not(isMounted(mountPoint)), 5*time.Second, 1*time.Second) {
149 // It didn't unmount. Try again.
150 Unmount(mountPoint)
151 }
152 }()
153

Callers 5

inEmptyMutDirFunction · 0.85
TestRootFunction · 0.85
TestReadFileFromRootFunction · 0.85
TestMoveAtFunction · 0.85
TestSymlinkFunction · 0.85

Calls 15

GetWorldFunction · 0.92
WaitForFunction · 0.92
UnmountFunction · 0.85
notFunction · 0.85
isMountedFunction · 0.85
dirToBeFUSEFunction · 0.85
CmdWithEnvMethod · 0.80
FatalMethod · 0.80
PingMethod · 0.80
WaitMethod · 0.80
PrintfMethod · 0.80
KillMethod · 0.80

Tested by

no test coverage detected