MCPcopy Create free account
hub / github.com/prometheus/procfs / TestRoot

Function TestRoot

proc_test.go:171–197  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

169}
170
171func TestRoot(t *testing.T) {
172 for _, tt := range []struct {
173 process int
174 want string
175 brokenLink bool
176 }{
177 {process: 26231, want: "/"},
178 {process: 26232, want: "/does/not/exist", brokenLink: true},
179 {process: 26233, want: ""},
180 } {
181 p, err := getProcFixtures(t).Proc(tt.process)
182 if err != nil {
183 t.Fatal(err)
184 }
185 rdir, err := p.RootDir()
186 if err != nil {
187 t.Fatal(err)
188 }
189 if diff := cmp.Diff(tt.want, rdir); diff != "" {
190 if rdir == "" && tt.brokenLink {
191 // Allow the result to be empty when can't os.Readlink broken links
192 continue
193 }
194 t.Fatalf("unexpected absolute path to rootdir (-want +got):\n%s", diff)
195 }
196 }
197}
198
199func TestFileDescriptors(t *testing.T) {
200 p1, err := getProcFixtures(t).Proc(26231)

Callers

nothing calls this directly

Calls 3

getProcFixturesFunction · 0.85
ProcMethod · 0.80
RootDirMethod · 0.80

Tested by

no test coverage detected