summaryrefslogtreecommitdiff
path: root/t/t5314-pack-cycle-detection.sh
diff options
context:
space:
mode:
authorElijah Newren <newren@gmail.com>2020-03-13 20:03:02 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-03-13 20:06:47 (GMT)
commit70e24186c08a125a8714df0e3f3ce10fa7b071f1 (patch)
treeeb08c50b10cb7a274ca3ceb2cb0b48c1ef3a56e5 /t/t5314-pack-cycle-detection.sh
parent65bf820d0ee050ba6a0c8908ff1d5f58d7c7131e (diff)
downloadgit-70e24186c08a125a8714df0e3f3ce10fa7b071f1.zip
git-70e24186c08a125a8714df0e3f3ce10fa7b071f1.tar.gz
git-70e24186c08a125a8714df0e3f3ce10fa7b071f1.tar.bz2
t6022, t6046: fix flaky files-are-updated checks
Several tests wanted to verify that files were actually modified by a merge, which it would do by checking that the mtime was updated. In order to avoid problems with the merge completing so fast that the mtime at the beginning and end of the operation was the same, these tests would first set the mtime of a file to something "old". This "old" value was usually determined as current system clock minus one second, truncated to the nearest integer. Unfortunately, it appears the system clock and filesystem clock are different and comparing across the two runs into race problems resulting in flaky tests. From https://stackoverflow.com/questions/14392975/timestamp-accuracy-on-ext4-sub-millsecond: date will call the gettimeofday system call which will always return the most accurate time available based on the cached kernel time, adjusted by the CPU cycle time if available to give nanosecond resolution. The timestamps stored in the file system however, are only based on the cached kernel time. ie The time calculated at the last timer interrupt. and from https://apenwarr.ca/log/20181113: Does mtime get set to >= the current time? No, this depends on clock granularity. For example, gettimeofday() can return times in microseconds on my system, but ext4 rounds timestamps down to the previous ~10ms (but not exactly 10ms) increment, with the surprising result that a newly-created file is almost always created in the past: $ python -c " import os, time t0 = time.time() open('testfile', 'w').close() print os.stat('testfile').st_mtime - t0 " -0.00234484672546 So, instead of trying to compare across what are effectively two different clocks, just avoid using the system clock. Any new updates to files have to give an mtime at least as big as what is already in the file, so we could define "old" as one second before the mtime found in the file before the merge starts. But, to avoid problems with leap seconds, ntp updates, filesystems that only provide two second resolution, and other such weirdness, let's just pick an hour before the mtime found in the file before the merge starts. Also, clarify in one test where we check the mtime of different files that it really was intentional. I totally forgot the reasons for that and assumed it was a bug when asked. Reported-by: SZEDER Gábor <szeder.dev@gmail.com> Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t5314-pack-cycle-detection.sh')
0 files changed, 0 insertions, 0 deletions