def test_10_rename(self): v = hw3.mkdir('dir1', 0o000755) v = hw3.create('dir1/file.A', 0o100777) v = hw3.create('dir1/file.C', 0o100777) print "Test 10a - rename a file:" v = hw3.rename('dir1/file.A', 'dir1/file.B') v, sb = hw3.getattr('dir1/file.A') self.assertTrue(v == -hw3.ENOENT) v, sb = hw3.getattr('dir1/file.B') self.assertTrue(v == 0) print "Test 10b - rename a directory:" v = hw3.rename('dir1', 'dir2') v, sb = hw3.getattr('dir1') self.assertTrue(v == -hw3.ENOENT) v, sb = hw3.getattr('dir2') self.assertTrue(v == 0) print "Test 10c - cannot a rename to a current:" v = hw3.rename('dir2/file.B', 'dir2/file.C') self.assertTrue(v == -hw3.EEXIST) print "Test 10d - rename a bogus name fails:" v = hw3.rename('dir2/file.D', 'dir2/file.E') self.assertTrue(v == -hw3.ENOENT) self.fsck()
def test_rename_bad(self): v = hw3.rename("/dir2", "/dir3") self.assertEqual(v, -hw3.ENOENT) v = hw3.rename("/file.A", "/file.10") self.assertEqual(v, -hw3.EEXIST) v = hw3.rename("/file.A", "/dir1") self.assertEqual(v, -hw3.EEXIST) v = hw3.mkdir("/dir2", 0) self.assertEqual(v, 0) v = hw3.rename("/dir1", "/dir2") self.assertEqual(v, -hw3.EEXIST) v = hw3.rename("/dir1", "/file.A") self.assertEqual(v, -hw3.EEXIST)
def test_rename_good(self): v = hw3.rename("/dir1", "/dir5") self.assertEqual(v, 0) v, attr = hw3.getattr("/dir5") self.assertEqual(v, 0) v, attr = hw3.getattr("/dir1") self.assertEqual(v, -hw3.ENOENT) v = hw3.rename("/dir5/file.270", "/bigfile") self.assertEqual(v, 0) v, attr = hw3.getattr("/bigfile") self.assertEqual(v, 0) v, attr = hw3.getattr("/dir5/file.270") self.assertEqual(v, -hw3.ENOENT)
def test_27_rename(self): val = hw3.rename("/dir22", "/dir2") self.assertTrue(val == 0)
def test_24_rename(self): val = hw3.rename("/dir3/subdir2", "/dir3/subdir") self.assertTrue(val == 0)
def test_21_rename(self): val = hw3.rename("/dir2/file.3k+", "/dir2/file.4k+") self.assertTrue(val == 0)
def test_18_rename(self): val = hw3.rename("/file.11k+", "/file.1k") self.assertTrue(val == 0)
def test_15_rename(self): val = hw3.rename("/file.1k", "/dir2/file.5k+") self.assertTrue(val == -hw3.EINVAL)
def test_14_rename(self): val = hw3.rename("/file.122k", "/file.11") self.assertTrue(val == -hw3.ENOENT)
def test_13_rename(self): val = hw3.rename("/file.1k", "/file.10") self.assertTrue(val == -hw3.EEXIST)