tests: Fix fileutils build on FreeBSD and macOS

The test needs to call `ftruncate64()` (not `ftruncate()`) to guarantee
it’s using the 64-bit version on Linux, but this doesn’t exist on other
platforms.

Test to see if it exists and, if not, skip the test.

Fixes commit cf5e371c6787747c0440c341407fe5317ea7136b, and fixes CI
failures like https://gitlab.gnome.org/GNOME/glib/-/pipelines/602930.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
This commit is contained in:
Philip Withnall 2023-11-26 22:08:46 +00:00
parent 9c9552309a
commit a8df4183e4
2 changed files with 5 additions and 1 deletions

View File

@ -1486,8 +1486,11 @@ resize_file (const gchar *filename,
#ifdef G_OS_WIN32 #ifdef G_OS_WIN32
retval = _chsize_s (fd, size); retval = _chsize_s (fd, size);
#else #elif HAVE_FTRUNCATE64
retval = ftruncate64 (fd, size); retval = ftruncate64 (fd, size);
#else
errno = ENOSYS;
retval = -1;
#endif #endif
if (retval != 0) if (retval != 0)
{ {

View File

@ -646,6 +646,7 @@ functions = [
'free_aligned_sized', 'free_aligned_sized',
'free_sized', 'free_sized',
'fsync', 'fsync',
'ftruncate64',
'getauxval', 'getauxval',
'getc_unlocked', 'getc_unlocked',
'getfsstat', 'getfsstat',