forked from bazil/fuse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptions_daemon_timeout_test.go
66 lines (57 loc) · 1.42 KB
/
options_daemon_timeout_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Test for adjustable timeout between a FUSE request and the daemon's response.
//
// +build darwin
package fuse_test
import (
"context"
"os"
"runtime"
"syscall"
"testing"
"time"
"bazil.org/fuse"
"bazil.org/fuse/fs"
"bazil.org/fuse/fs/fstestutil"
)
type slowCreaterDir struct {
fstestutil.Dir
}
var _ fs.NodeCreater = slowCreaterDir{}
func (c slowCreaterDir) Create(ctx context.Context, req *fuse.CreateRequest, resp *fuse.CreateResponse) (fs.Node, fs.Handle, error) {
time.Sleep(10 * time.Second)
// pick a really distinct error, to identify it later
return nil, nil, fuse.Errno(syscall.ENAMETOOLONG)
}
func TestMountOptionDaemonTimeout(t *testing.T) {
if runtime.GOOS != "darwin" {
return
}
if testing.Short() {
t.Skip("skipping time-based test in short mode")
}
maybeParallel(t)
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
mnt, err := fstestutil.MountedT(t,
fstestutil.SimpleFS{slowCreaterDir{}},
nil,
fuse.DaemonTimeout("2"),
)
if err != nil {
t.Fatal(err)
}
defer mnt.Close()
control := openErrHelper.Spawn(ctx, t)
defer control.Close()
// This should fail by the kernel timing out the request.
req := openRequest{
Path: mnt.Dir + "/child",
Flags: os.O_WRONLY | os.O_CREATE,
Perm: 0,
WantErrno: syscall.ENOTCONN,
}
var nothing struct{}
if err := control.JSON("/").Call(ctx, req, ¬hing); err != nil {
t.Fatalf("calling helper: %v", err)
}
}