(archivers, request)
| 128 | |
| 129 | @pytest.mark.skipif(not is_utime_fully_supported(), reason="cannot properly setup and execute test without utime") |
| 130 | def test_atime(archivers, request): |
| 131 | archiver = request.getfixturevalue(archivers) |
| 132 | |
| 133 | def has_noatime(some_file): |
| 134 | atime_before = os.stat(some_file).st_atime_ns |
| 135 | try: |
| 136 | with open(os.open(some_file, flags_noatime)) as file: |
| 137 | file.read() |
| 138 | except PermissionError: |
| 139 | return False |
| 140 | else: |
| 141 | atime_after = os.stat(some_file).st_atime_ns |
| 142 | noatime_used = flags_noatime != flags_normal |
| 143 | return noatime_used and atime_before == atime_after |
| 144 | |
| 145 | create_test_files(archiver.input_path) |
| 146 | atime, mtime = 123456780, 234567890 |
| 147 | have_noatime = has_noatime("input/file1") |
| 148 | os.utime("input/file1", (atime, mtime)) |
| 149 | cmd(archiver, "repo-create", RK_ENCRYPTION) |
| 150 | cmd(archiver, "create", "--atime", "test", "input") |
| 151 | with changedir("output"): |
| 152 | cmd(archiver, "extract", "test") |
| 153 | sti = os.stat("input/file1") |
| 154 | sto = os.stat("output/input/file1") |
| 155 | assert same_ts_ns(sti.st_mtime_ns, sto.st_mtime_ns) |
| 156 | assert same_ts_ns(sto.st_mtime_ns, mtime * 10**9) |
| 157 | if have_noatime: |
| 158 | assert same_ts_ns(sti.st_atime_ns, sto.st_atime_ns) |
| 159 | assert same_ts_ns(sto.st_atime_ns, atime * 10**9) |
| 160 | else: |
| 161 | # it touched the input file's atime while backing it up |
| 162 | assert same_ts_ns(sto.st_atime_ns, atime * 10**9) |
| 163 | |
| 164 | |
| 165 | @pytest.mark.skipif(not is_utime_fully_supported(), reason="cannot setup and execute test without utime") |
nothing calls this directly
no test coverage detected