(t *testing.T)
| 243 | } |
| 244 | |
| 245 | func 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 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…