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

Function TestReadCPUFile

pkg/sentry/fsimpl/sys/sys_integration_test.go:63–86  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

61}
62
63func TestReadCPUFile(t *testing.T) {
64 s := newTestSystem(t, "" /*pciTestDir*/)
65 defer s.Destroy()
66 k := kernel.KernelFromContext(s.Ctx)
67 maxCPUCores := k.ApplicationCores()
68
69 expected := fmt.Sprintf("0-%d\n", maxCPUCores-1)
70
71 for _, fname := range []string{"online", "possible", "present"} {
72 pop := s.PathOpAtRoot(fmt.Sprintf("devices/system/cpu/%s", fname))
73 fd, err := s.VFS.OpenAt(s.Ctx, s.Creds, pop, &vfs.OpenOptions{})
74 if err != nil {
75 t.Fatalf("OpenAt(pop:%+v) = %+v failed: %v", pop, fd, err)
76 }
77 defer fd.DecRef(s.Ctx)
78 content, err := s.ReadToEnd(fd)
79 if err != nil {
80 t.Fatalf("Read failed: %v", err)
81 }
82 if diff := cmp.Diff(expected, content); diff != "" {
83 t.Fatalf("Read returned unexpected data:\n--- want\n+++ got\n%v", diff)
84 }
85 }
86}
87
88func TestSysRootContainsExpectedEntries(t *testing.T) {
89 s := newTestSystem(t, "" /*pciTestDir*/)

Callers

nothing calls this directly

Calls 9

KernelFromContextFunction · 0.92
ApplicationCoresMethod · 0.80
PathOpAtRootMethod · 0.80
ReadToEndMethod · 0.80
newTestSystemFunction · 0.70
DestroyMethod · 0.65
OpenAtMethod · 0.65
FatalfMethod · 0.65
DecRefMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…