Ejemplo n.º 1
0
 def test_hardlink_cluster(self):
     with tempfile.TemporaryDirectory() as root:
         self.create_files(root)
         sys.argv = ["hardlink.py", "-Y", "-v", "0", "-q", root]
         hardlink.main()
         self.verify_file_contents()
         self.assertEqual(os.lstat("1a").st_ino, os.lstat("1b").st_ino)
         self.assertEqual(os.lstat("1a").st_ino, os.lstat("2a").st_ino)
         self.assertEqual(os.lstat("1a").st_ino, os.lstat("2b").st_ino)
         self.assertEqual(os.lstat("1a").st_ino, os.lstat("2c").st_ino)
         self.assertEqual(os.lstat("1a").st_ino, os.lstat("2d").st_ino)
         self.assertEqual(os.lstat("1a").st_ino, os.lstat("2e").st_ino)
Ejemplo n.º 2
0
    def test_hardlink_tree_filenames_equal(self):
        sys.argv = ["hardlink.py", "-v", "0", "--no-stats", "--filenames-equal", self.root]
        hardlink.main()

        self.verify_file_contents()

        self.assertNotEqual(get_inode("dir1/name1.ext"), get_inode("dir1/name2.ext"))
        self.assertEqual(get_inode("dir1/name1.ext"), get_inode("dir2/name1.ext"))
        self.assertNotEqual(get_inode("dir1/name1.ext"), get_inode("dir3/name1.noext"))

        self.assertNotEqual(get_inode("dir1/name3.ext"), get_inode("dir3/name1.ext"))

        self.assertNotEqual(get_inode("dir1/name1.ext"), get_inode("dir4/name1.ext"))
Ejemplo n.º 3
0
    def test_hardlink_tree_dryrun(self):
        sys.argv = ["hardlink.py", "-v", "0", "--no-stats", "--dry-run", self.root]
        hardlink.main()

        self.verify_file_contents()

        self.assertEqual(os.lstat("dir1/name1.ext").st_nlink, 2)  # Existing link
        self.assertEqual(os.lstat("dir1/name2.ext").st_nlink, 1)
        self.assertEqual(os.lstat("dir1/name3.ext").st_nlink, 1)
        self.assertEqual(os.lstat("dir2/name1.ext").st_nlink, 1)
        self.assertEqual(os.lstat("dir3/name1.ext").st_nlink, 1)
        self.assertEqual(os.lstat("dir3/name1.noext").st_nlink, 1)
        self.assertEqual(os.lstat("dir4/name1.ext").st_nlink, 1)
Ejemplo n.º 4
0
 def test_basic_test(self):
     with tempfile.TemporaryDirectory() as root:
         self.create_files(root)
         sys.argv = ["hardlink.py", "-Y", "-v", "0", "-q", root]
         hardlink.main()
         self.verify_file_contents()
         self.assertEqual(os.lstat("a/A1").st_ino, os.lstat("a/B1").st_ino)
         self.assertEqual(os.lstat("a/C2").st_ino, os.lstat("b/E2").st_ino)
         self.assertNotEqual(
             os.lstat("a/A1").st_ino,
             os.lstat("a/C2").st_ino)
         self.assertEqual(os.lstat("a/A1").st_mtime,
                          self.now)  # latest attributes
         self.assertEqual(os.lstat("b/E2").st_mtime,
                          self.now)  # latest attributes
Ejemplo n.º 5
0
 def test_hardlink_tree_dryrun(self):
     with tempfile.TemporaryDirectory() as root:
         self.create_temporary_files(root)
         sys.argv = [
             "hardlink.py", "-Y", "-v", "0", "-q", "--dry-run", root
         ]
         hardlink.main()
         self.verify_file_contents()
         self.assertEqual(os.lstat("dir1/name1.ext").st_nlink,
                          2)  # Existing link
         self.assertEqual(os.lstat("dir1/name2.ext").st_nlink, 1)
         self.assertEqual(os.lstat("dir1/name3.ext").st_nlink, 1)
         self.assertEqual(os.lstat("dir2/name1.ext").st_nlink, 1)
         self.assertEqual(os.lstat("dir3/name1.ext").st_nlink, 1)
         self.assertEqual(os.lstat("dir3/name1.noext").st_nlink, 1)
         self.assertEqual(os.lstat("dir4/name1.ext").st_nlink, 1)
Ejemplo n.º 6
0
    def test_hardlink_tree_dryrun(self):
        sys.argv = [
            "hardlink.py", "-v", "0", "--no-stats", "--dry-run", self.root
        ]
        hardlink.main()

        self.verify_file_contents()

        self.assertEqual(os.lstat("dir1/name1.ext").st_nlink,
                         2)  # Existing link
        self.assertEqual(os.lstat("dir1/name2.ext").st_nlink, 1)
        self.assertEqual(os.lstat("dir1/name3.ext").st_nlink, 1)
        self.assertEqual(os.lstat("dir2/name1.ext").st_nlink, 1)
        self.assertEqual(os.lstat("dir3/name1.ext").st_nlink, 1)
        self.assertEqual(os.lstat("dir3/name1.noext").st_nlink, 1)
        self.assertEqual(os.lstat("dir4/name1.ext").st_nlink, 1)
Ejemplo n.º 7
0
    def test_hardlink_tree(self):
        sys.argv = ["hardlink.py", "-v", "0", "--no-stats", self.root]
        hardlink.main()

        self.verify_file_contents()

        self.assertEqual(get_inode("dir1/name1.ext"),
                         get_inode("dir1/name2.ext"))
        self.assertEqual(get_inode("dir1/name1.ext"),
                         get_inode("dir2/name1.ext"))
        self.assertEqual(get_inode("dir1/name1.ext"),
                         get_inode("dir3/name1.noext"))

        self.assertEqual(get_inode("dir1/name3.ext"),
                         get_inode("dir3/name1.ext"))

        self.assertNotEqual(get_inode("dir1/name1.ext"),
                            get_inode("dir4/name1.ext"))
Ejemplo n.º 8
0
 def test_hardlink_tree_timestamp(self):
     with tempfile.TemporaryDirectory() as root:
         self.create_temporary_files(root)
         sys.argv = ["hardlink.py", "-Y", "-v", "0", "-q", "-T", root]
         hardlink.main()
         self.verify_file_contents()
         self.assertEqual(
             os.lstat("dir1/name1.ext").st_ino,
             os.lstat("dir1/name2.ext").st_ino)
         self.assertEqual(
             os.lstat("dir1/name1.ext").st_ino,
             os.lstat("dir2/name1.ext").st_ino)
         self.assertEqual(
             os.lstat("dir1/name1.ext").st_ino,
             os.lstat("dir3/name1.noext").st_ino)
         self.assertEqual(
             os.lstat("dir1/name3.ext").st_ino,
             os.lstat("dir3/name1.ext").st_ino)
         self.assertNotEqual(
             os.lstat("dir1/name1.ext").st_ino,
             os.lstat("dir4/name1.ext").st_ino)