(t testing.TB, fn func(ctx context.Context, fdTable *FDTable, fd *vfs.FileDescription, limitSet *limits.LimitSet))
| 53 | } |
| 54 | |
| 55 | func runTest(t testing.TB, fn func(ctx context.Context, fdTable *FDTable, fd *vfs.FileDescription, limitSet *limits.LimitSet)) { |
| 56 | t.Helper() // Don't show in stacks. |
| 57 | |
| 58 | // Create the limits and context. |
| 59 | limitSet := limits.NewLimitSet() |
| 60 | limitSet.Set(limits.NumberOfFiles, limits.Limit{maxFD, maxFD}, true) |
| 61 | ctx := contexttest.WithLimitSet(contexttest.Context(t), limitSet) |
| 62 | |
| 63 | vfsObj := &vfs.VirtualFilesystem{} |
| 64 | if err := vfsObj.Init(ctx); err != nil { |
| 65 | t.Fatalf("VFS init: %v", err) |
| 66 | } |
| 67 | |
| 68 | fd := newTestFD(ctx, vfsObj) |
| 69 | defer fd.DecRef(ctx) |
| 70 | |
| 71 | // Create the table. |
| 72 | fdTable := new(FDTable) |
| 73 | fdTable.k = &Kernel{} |
| 74 | fdTable.k.MaxFDLimit.Store(MaxFdLimit) |
| 75 | fdTable.init() |
| 76 | |
| 77 | // Run the test. |
| 78 | fn(ctx, fdTable, fd, limitSet) |
| 79 | } |
| 80 | |
| 81 | // TestFDTableMany allocates maxFD FDs, i.e. maxes out the FDTable, until there |
| 82 | // is no room, then makes sure that NewFDAt works and also that if we remove |
no test coverage detected
searching dependent graphs…