(t *testing.T, sizeBytes int64, tester func(ctx context.Context, r, w *vfs.FileDescription))
| 27 | ) |
| 28 | |
| 29 | func runTest(t *testing.T, sizeBytes int64, tester func(ctx context.Context, r, w *vfs.FileDescription)) { |
| 30 | ctx := contexttest.Context(t) |
| 31 | vfsObj := &vfs.VirtualFilesystem{} |
| 32 | if err := vfsObj.Init(ctx); err != nil { |
| 33 | t.Fatalf("VFS init: %v", err) |
| 34 | } |
| 35 | vd := vfsObj.NewAnonVirtualDentry("pipe") |
| 36 | defer vd.DecRef(ctx) |
| 37 | |
| 38 | vp := NewVFSPipe(false /* isNamed */, sizeBytes) |
| 39 | r, w, err := vp.ReaderWriterPair(ctx, vd.Mount(), vd.Dentry(), 0) |
| 40 | if err != nil { |
| 41 | t.Fatalf("ReaderWriterPair failed: %v", err) |
| 42 | } |
| 43 | defer r.DecRef(ctx) |
| 44 | defer w.DecRef(ctx) |
| 45 | |
| 46 | tester(ctx, r, w) |
| 47 | } |
| 48 | |
| 49 | func TestPipeRW(t *testing.T) { |
| 50 | runTest(t, 65536, func(ctx context.Context, r *vfs.FileDescription, w *vfs.FileDescription) { |
no test coverage detected
searching dependent graphs…