MCPcopy
hub / github.com/google/gvisor / runTest

Function runTest

pkg/sentry/kernel/fd_table_test.go:55–79  ·  view source on GitHub ↗
(t testing.TB, fn func(ctx context.Context, fdTable *FDTable, fd *vfs.FileDescription, limitSet *limits.LimitSet))

Source from the content-addressed store, hash-verified

53}
54
55func 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

Callers 10

TestFDTableManyFunction · 0.70
TestFDTableOverLimitFunction · 0.70
TestFDTableFunction · 0.70
TestDescriptorFlagsFunction · 0.70
BenchmarkNewFDAtFunction · 0.70
BenchmarkForkFunction · 0.70
BenchmarkCreateWithMaxFDFunction · 0.70
TestSetFlagsForRangeFunction · 0.70

Calls 12

SetMethod · 0.95
InitMethod · 0.95
NewLimitSetFunction · 0.92
WithLimitSetFunction · 0.92
ContextFunction · 0.92
newTestFDFunction · 0.70
HelperMethod · 0.65
FatalfMethod · 0.65
DecRefMethod · 0.65
StoreMethod · 0.65
newFunction · 0.50
initMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…