add a borg create/extract timestamp test for y2261.

in y2262, nanoseconds as signed int64 will overflow.
This commit is contained in:
Thomas Waldmann 2026-03-02 23:34:27 +01:00
parent eca66a0e3e
commit 7b69bed8c4
No known key found for this signature in database
GPG key ID: 243ACFA951F78E01

View file

@ -825,3 +825,19 @@ def test_extract_existing_directory(archivers, request):
cmd(archiver, "extract", "test")
st2 = os.stat("input/dir")
assert st1.st_ino == st2.st_ino
@pytest.mark.skipif(not is_utime_fully_supported(), reason="cannot properly setup and execute test without utime")
def test_extract_y2261(archivers, request):
# test if roundtripping of timestamps well beyond y2038 works
archiver = request.getfixturevalue(archivers)
create_regular_file(archiver.input_path, "file_y2261", contents=b"post y2038 test")
# 2261-01-01 00:00:00 UTC as a Unix timestamp (seconds).
time_y2261 = 9183110400
os.utime("input/file_y2261", (time_y2261, time_y2261))
cmd(archiver, "repo-create", RK_ENCRYPTION)
cmd(archiver, "create", "test", "input")
with changedir("output"):
cmd(archiver, "extract", "test")
sto = os.stat("output/input/file_y2261")
assert same_ts_ns(sto.st_mtime_ns, time_y2261 * 10**9)