From 4ae8367b4e6eb009dac9d2d0df4b6a72bf9137a3 Mon Sep 17 00:00:00 2001 From: Yelninei Date: Mon, 15 Dec 2025 15:14:15 +0000 Subject: [PATCH] tests: Fix stat tests on 32bit systems. 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 setting _FILE_OFFSET_BITS globally Co-authored-by: Edward Thomson --- CMakeLists.txt | 8 ++++++++ tests/libgit2/CMakeLists.txt | 1 - tests/util/CMakeLists.txt | 1 - 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 406d8e441..22fdc4316 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -82,6 +82,14 @@ if(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE) endif() +# +# Common settings across all projects, dependencies, etc. Always support +# 64 bit file operations, even 32 bit platforms. +# + +add_definitions(-D_FILE_OFFSET_BITS=64) + + # Modules include(FeatureSummary) diff --git a/tests/libgit2/CMakeLists.txt b/tests/libgit2/CMakeLists.txt index a05e93d71..0e44c30d0 100644 --- a/tests/libgit2/CMakeLists.txt +++ b/tests/libgit2/CMakeLists.txt @@ -19,7 +19,6 @@ add_definitions(-DCLAR_FIXTURE_PATH=\"${CLAR_FIXTURES}\") add_definitions(-DCLAR_TMPDIR=\"libgit2_tests\") add_definitions(-DCLAR_WIN32_LONGPATHS) add_definitions(-DCLAR_HAS_REALPATH) -add_definitions(-D_FILE_OFFSET_BITS=64) # Ensure that we do not use deprecated functions internally add_definitions(-DGIT_DEPRECATE_HARD) diff --git a/tests/util/CMakeLists.txt b/tests/util/CMakeLists.txt index d2c5bf268..befeabb1d 100644 --- a/tests/util/CMakeLists.txt +++ b/tests/util/CMakeLists.txt @@ -19,7 +19,6 @@ add_definitions(-DCLAR_FIXTURE_PATH=\"${CLAR_FIXTURES}\") add_definitions(-DCLAR_TMPDIR=\"libgit2_tests\") add_definitions(-DCLAR_WIN32_LONGPATHS) add_definitions(-DCLAR_HAS_REALPATH) -add_definitions(-D_FILE_OFFSET_BITS=64) # Ensure that we do not use deprecated functions internally add_definitions(-DGIT_DEPRECATE_HARD)