tests: Fix stat tests on 32bit systems#7170
Conversation
On 32bit systems the git_fs_path_lstat from libgit2 by default uses 32bit stat structs while the tests are being compiled with struct stat64 via _FILE_OFFSET_BITS=64. This discrepancy causes the "flaky" stat failures in tests. The solution is to use the same _FILE_OFFSET_BITS as the library by leaving it up to the user to define _FILE_OFFSET_BIT.
This was caused by the tests being compiled with -D_FILE_OFFSET_BITS=64 which causes incompatibilities if libgit2 itself is not. As this has been resolved the environment variable is no longer necessary and can be removed.
|
Would it be possible to run the ci on 32bit arm (which does not have the 64 bit time_t transition from debian 13) to see if this indeed fixes the issue? |
|
One of the nightly builds is on a 32 bit arm platform — https://github.com/libgit2/libgit2/actions/runs/20870863585/job/59972059810 It hasn't seemed to be flaky. But maybe it's being compiled slightly differently than yours? We build and test within containers on Linux so it may be possible to repro our environment locally and / or update the build environment to match your case. |
|
For context of how I discovered this: I caught this assert in https://github.com/libgit2/libgit2/blob/main/tests/libgit2/repo/init.c#L445 (on a 32bit hurd system, which has a different order in the stat struct than linux) Looking at the stat struct in a debugger it was completely garbled caused by enormous values in This test also has been marked as "flaky" on debian https://sources.debian.org/src/libgit2/1.9.2%2Bds-2/debian/patches/disable-flaky-stat-tests.patch probably for the same reason. The problem is that |
|
I am reading #4631 and am really confused what happened here. It seems i encounter the same issue but in reverse (casting stat32 struct to stat64) The other pr mentions that libgit2 used to be always compiled with _FILE_OFFSET_BITS=64 so putting it to the tests aswell made sense. I think the timelime is something like this: |
On 32bit systems the git_fs_path_lstat from libgit2 by default uses 32bit stat
structs while the tests are being compiled with struct stat64 via
_FILE_OFFSET_BITS=64.
This discrepancy causes the "flaky" stat failures in tests.
The solution is to use the same _FILE_OFFSET_BITS as the library by
leaving it up to the user to define _FILE_OFFSET_BIT.
Also remove GITTEST_FLAKY_STAT (in as separate commit) as it should no longer be necessary.
Fixes: #7169