Beispiel #1
0
 def test_disk_devt(self):
     for disk in for_each_disk(self.prog):
         path = os.path.join(b"/sys/block", disk_name(disk), b"dev")
         with open(path, "r") as f:
             expected = f.read().strip()
         devt = disk_devt(disk).value_()
         self.assertEqual(f"{MAJOR(devt)}:{MINOR(devt)}", expected)
Beispiel #2
0
 def test_loop_disk(self):
     if not self.loop:
         self.skipTest("could not create loop device")
     rdev = os.stat(self.loop.fileno()).st_rdev
     devt = MKDEV(os.major(rdev), os.minor(rdev))
     for disk in for_each_disk(self.prog):
         if disk_devt(disk) == devt:
             break
     else:
         self.fail("loop disk not found")
     self.assertEqual(disk_name(disk), os.path.basename(self.loop.name).encode())
Beispiel #3
0
 def test_for_each_disk(self):
     self.assertEqual(
         {disk_name(disk).decode() for disk in for_each_disk(self.prog)},
         set(os.listdir("/sys/block")),
     )