def wrapper_method(*args): self = args[0] system("rm test.img") v = system("./mkfs-hw3 -size " + str(size) + " test.img") self.assertEqual(v, 0) hw3.init("test.img") method(*args)
def setUp(self): system("./mktest -extra test.img") hw3.init("test.img")
self.assertEqual(v1, 1000) self.assertEqual(len(data1), 1000) v2, data2 = hw3.read("/dir2/file.4k+", 17, 1000) # offset = 0 self.assertEqual(v2, 17) self.assertEqual(len(data2), 17) v3, data3 = hw3.read("/dir2/file.4k+", 100, 1017) # offset = 0 self.assertEqual(v3, 100) self.assertEqual(len(data3), 100) v4, data4 = hw3.read("/dir2/file.4k+", 1000, 1117) # offset = 0 self.assertEqual(v4, 1000) self.assertEqual(len(data4), 1000) v5, data5 = hw3.read("/dir2/file.4k+", 1024, 2117) # offset = 0 self.assertEqual(v5, 1024) self.assertEqual(len(data5), 1024) v6, data6 = hw3.read("/dir2/file.4k+", 1970, 3141) # offset = 0 self.assertEqual(v6, 957) self.assertEqual(len(data6), 957) v7, data7 = hw3.read("/dir2/file.4k+", 3000, 5111) # offset = 0 self.assertEqual(v7, 0) self.assertEqual(len(data7), 0) total_data = data1 + data2 + data3 + data4 + data5 + data6 + data7 v_total = v1 + v2 + v3 + v4 + v5 + v6 + v7 self.assertEqual(v_total, 4098) self.assertEqual(len(total_data), 4098) self.assertEqual(cksum(total_data), 799580753) if __name__ == '__main__': hw3.init('test.img') unittest.main()