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

Function newTestSystem

pkg/sentry/fsimpl/sys/sys_integration_test.go:36–61  ·  view source on GitHub ↗
(t *testing.T, pciTestDir string)

Source from the content-addressed store, hash-verified

34)
35
36func newTestSystem(t *testing.T, pciTestDir string) *testutil.System {
37 k, err := testutil.Boot()
38 if err != nil {
39 t.Fatalf("Failed to create test kernel: %v", err)
40 }
41 ctx := k.SupervisorContext()
42 creds := auth.CredentialsFromContext(ctx)
43 k.VFS().MustRegisterFilesystemType(sys.Name, sys.FilesystemType{}, &vfs.RegisterFilesystemTypeOptions{
44 AllowUserMount: true,
45 })
46
47 mountOpts := &vfs.MountOptions{
48 GetFilesystemOptions: vfs.GetFilesystemOptions{
49 InternalData: &sys.InternalData{
50 EnableTPUProxyPaths: pciTestDir != "",
51 TestSysfsPathPrefix: pciTestDir,
52 },
53 },
54 }
55
56 mns, err := k.VFS().NewMountNamespace(ctx, creds, "", sys.Name, mountOpts, nil)
57 if err != nil {
58 t.Fatalf("Failed to create new mount namespace: %v", err)
59 }
60 return testutil.NewSystem(ctx, t, k.VFS(), mns)
61}
62
63func TestReadCPUFile(t *testing.T) {
64 s := newTestSystem(t, "" /*pciTestDir*/)

Callers 6

TestReadCPUFileFunction · 0.70

Calls 8

BootFunction · 0.92
CredentialsFromContextFunction · 0.92
NewSystemFunction · 0.92
SupervisorContextMethod · 0.80
VFSMethod · 0.80
NewMountNamespaceMethod · 0.80
FatalfMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…