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

Function TestSysBlockDeviceRotational

blockdevice/stats_test.go:245–269  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

243}
244
245func TestSysBlockDeviceRotational(t *testing.T) {
246 blockdevice, err := NewFS("testdata/fixtures/proc", "testdata/fixtures/sys")
247 if err != nil {
248 t.Fatalf("failed to access blockdevice fs: %v", err)
249 }
250 devices, err := blockdevice.SysBlockDevices()
251 if err != nil {
252 t.Fatal(err)
253 }
254
255 // devices[11] is "sda" in the fixtures — a rotational HDD (value: 1).
256 rotational11, err := blockdevice.SysBlockDeviceRotational(devices[11])
257 if err != nil {
258 t.Fatal(err)
259 }
260 if rotational11 != 1 {
261 t.Errorf("Incorrect rotational value for %s: expected 1, got %d", devices[11], rotational11)
262 }
263
264 // devices[0] is "dm-0" — no queue/rotational file; expect an error.
265 _, err = blockdevice.SysBlockDeviceRotational(devices[0])
266 if err == nil {
267 t.Errorf("expected error reading rotational for %s (no queue dir), got nil", devices[0])
268 }
269}

Callers

nothing calls this directly

Calls 3

SysBlockDevicesMethod · 0.95
NewFSFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…