示例#1
0
    def test_eligibile_for_hardlink_different_mtime(self) -> None:

        # Different inodes and different GIDs
        st_file_1 = make_st_result(st_ino=100, st_mtime=1000)
        st_file_2 = make_st_result(st_ino=101, st_mtime=2000)

        # Different mtimes should be False
        self.assertFalse(
            hardlink.eligible_for_hardlink(st1=st_file_1,
                                           st2=st_file_2,
                                           args=self.args))

        self.args.content_only = True
        self.args.notimestamp = False
        # Different mtimes, content_only=True, should be True
        self.assertTrue(
            hardlink.eligible_for_hardlink(st1=st_file_1,
                                           st2=st_file_2,
                                           args=self.args))

        self.args.content_only = False
        self.args.notimestamp = True
        # Different mtimes, content_only=True, should be True
        self.assertTrue(
            hardlink.eligible_for_hardlink(st1=st_file_1,
                                           st2=st_file_2,
                                           args=self.args))
示例#2
0
    def test_eligibile_for_hardlink(self) -> None:

        # Different inodes but same device
        st_file_1 = make_st_result(st_ino=100)
        st_file_2 = make_st_result(st_ino=101)

        # Identical files except for inode
        self.assertTrue(
            hardlink.eligible_for_hardlink(st1=st_file_1,
                                           st2=st_file_2,
                                           args=self.args))

        # Files that are already hardlinked since same inode
        self.assertFalse(
            hardlink.eligible_for_hardlink(st1=st_file_1,
                                           st2=st_file_1,
                                           args=self.args))
示例#3
0
    def test_eligibile_for_hardlink_different_modes(self) -> None:

        # Different inodes and different modes
        st_file_1 = make_st_result(st_ino=100, st_mode=0o644)
        st_file_2 = make_st_result(st_ino=101, st_mode=0o755)

        # Different file modes, should be False
        self.assertFalse(
            hardlink.eligible_for_hardlink(st1=st_file_1,
                                           st2=st_file_2,
                                           args=self.args))

        self.args.content_only = True
        # Different file modes, content_only=True, should be True
        self.assertTrue(
            hardlink.eligible_for_hardlink(st1=st_file_1,
                                           st2=st_file_2,
                                           args=self.args))
示例#4
0
    def test_eligibile_for_hardlink_different_dev(self) -> None:

        # Different inodes and different devices
        st_file_1 = make_st_result(st_ino=100, st_dev=100)
        st_file_2 = make_st_result(st_ino=101, st_dev=200)

        # Different size files, should be False
        self.assertFalse(
            hardlink.eligible_for_hardlink(st1=st_file_1,
                                           st2=st_file_2,
                                           args=self.args))
示例#5
0
    def test_eligibile_for_hardlink_min_size(self) -> None:

        # File must be at least 1024 bytes in size
        self.args.min_size = 1024

        # Different inodes but size is too small
        st_small_1 = make_st_result(st_ino=100, st_size=1023)
        st_small_2 = make_st_result(st_ino=101, st_size=1023)

        self.assertFalse(
            hardlink.eligible_for_hardlink(st1=st_small_1,
                                           st2=st_small_2,
                                           args=self.args))

        # Files are large enough
        st_file_1 = make_st_result(st_ino=101, st_size=1024)
        st_file_2 = make_st_result(st_ino=102, st_size=1024)

        self.assertTrue(
            hardlink.eligible_for_hardlink(st1=st_file_1,
                                           st2=st_file_2,
                                           args=self.args))