newTestConnection creates a fuse connection that the sentry can communicate with and the FD for the server to communicate with.
(system *testutil.System, maxActiveRequests uint64)
| 49 | // newTestConnection creates a fuse connection that the sentry can communicate with |
| 50 | // and the FD for the server to communicate with. |
| 51 | func newTestConnection(system *testutil.System, maxActiveRequests uint64) (*connection, *vfs.FileDescription, error) { |
| 52 | fuseDev := &DeviceFD{} |
| 53 | |
| 54 | vd := system.VFS.NewAnonVirtualDentry("fuse") |
| 55 | defer vd.DecRef(system.Ctx) |
| 56 | if err := fuseDev.vfsfd.Init(fuseDev, linux.O_RDWR, auth.CredentialsFromContext(system.Ctx), vd.Mount(), vd.Dentry(), &vfs.FileDescriptionOptions{}); err != nil { |
| 57 | return nil, nil, err |
| 58 | } |
| 59 | |
| 60 | fsopts := filesystemOptions{ |
| 61 | maxActiveRequests: maxActiveRequests, |
| 62 | } |
| 63 | fuseDev.mu.Lock() |
| 64 | conn, err := newFUSEConnection(system.Ctx, fuseDev, &fsopts) |
| 65 | if err != nil { |
| 66 | return nil, nil, err |
| 67 | } |
| 68 | fuseDev.conn = conn |
| 69 | fuseDev.mu.Unlock() |
| 70 | |
| 71 | // Fake the connection being properly initialized for testing purposes. |
| 72 | conn.mu.Lock() |
| 73 | conn.connInitSuccess = true |
| 74 | conn.mu.Unlock() |
| 75 | return conn, &fuseDev.vfsfd, nil |
| 76 | } |
| 77 | |
| 78 | // newTestFilesystem creates a filesystem that the sentry can communicate with |
| 79 | // and the FD for the server to communicate with. |
no test coverage detected
searching dependent graphs…