Skip to content

Fix ctest failures on macOS/Linux#186

Open
ludomal wants to merge 7 commits into
openitu:devfrom
ludomal:fix/ctest-portability
Open

Fix ctest failures on macOS/Linux#186
ludomal wants to merge 7 commits into
openitu:devfrom
ludomal:fix/ctest-portability

Conversation

@ludomal
Copy link
Copy Markdown
Member

@ludomal ludomal commented May 31, 2026

Fix ctest failures on macOS/Linux

Summary

Fix test infrastructure issues that cause ~280 ctest failures on macOS and Linux. Replace non-portable POSIX I/O with standard C in test utilities. All fixes are transparent to tool algorithms (tools produce identical output on all platforms).

This PR:

Changes

Component Issue Fix
basop precision tests (268) Reference CSVs have CRLF; test output has LF; cmake -E compare_files fails Use CompareTextFiles.cmake module for CRLF-tolerant comparison
freqresp-verify2 Same CRLF mismatch in asciiOut.ref Use CompareTextFiles.cmake module for CRLF-tolerant comparison
astrip tests (2) cftest1.dat corrupted by git autocrlf (binary file misidentified as text, \n\r\n adds 46 bytes) .gitattributes marks file as binary
filter tests (4) ±1 LSB FP rounding differences across platforms Add -equiv 1 tolerance (consistent with all other filter tests)
g711iplc tests (2) ±1 LSB FP rounding differences Add -abstol 1 tolerance
esdru1-verify Comparing double-precision file as 16-bit shorts (missing -double flag) Add -double flag to cf command
wmc_tool tests (10) find_package(PythonInterp) fails on modern CMake (PYTHON_EXECUTABLE is empty) Replace with find_package(Python3 COMPONENTS Interpreter)
compfile Uses POSIX read()/lseek()/fileno() — non-portable on MSVC Replace with standard C fread()/fseek() using FILE*
signal-diff Uses POSIX read()/lseek()/write() — non-portable on MSVC Replace with standard C fread()/fseek()/fwrite()
oper Uses POSIX read()/lseek()/write()/close() — non-portable on MSVC Replace with standard C fread()/fseek()/fwrite()/fclose()
test_precision.c %X format used for unsigned long args — compiler warnings Use %lX format specifier

New files

File Purpose
cmake/CompareTextFiles.cmake Reusable CMake module: reads two text files, normalises CRLF→LF, compares. Used via -P scripts in CTest.
src/basop/test_framework/compare_basop_csv.cmake CTest -P script wrapping CompareTextFiles.cmake for basop CSV refs
src/freqresp/compare_freqresp_text.cmake CTest -P script wrapping CompareTextFiles.cmake for freqresp ASCII ref
.gitattributes Marks cftest1.dat as binary

Impact

  • No algorithm or output changes for any tool
  • All tools produce bit-identical output before and after this change
  • Source file changes are limited to I/O function replacements (POSIX → standard C)

- Add cmake/CompareTextFiles.cmake: reusable line-ending-tolerant text
  file comparison for CTest scripts (CRLF vs LF transparent)

- basop/test_framework: Replace cmake -E compare_files with
  CompareTextFiles.cmake for CSV reference comparisons

- freqresp: Replace cmake -E compare_files with CompareTextFiles.cmake
  for asciiOut.ref comparison

- .gitattributes: Mark cftest1.dat as binary to prevent git from
  injecting CR bytes into the test input file

- src/fir/CMakeLists.txt: Add -equiv 1 tolerance to filter21/22/25/26/27
  verify tests (±1 LSB cross-platform floating-point rounding)

- src/g711iplc/CMakeLists.txt: Add -abstol 1 to g711iplc1/3-verify
  (same ±1 LSB rounding differences)

- src/esdru/CMakeLists.txt: Add missing -double flag to esdru1-verify

- src/wmc_tool/CMakeLists.txt: Replace deprecated find_package(PythonInterp)
  with find_package(Python3 COMPONENTS Interpreter)

All fixes are transparent: no tool source code is modified, no algorithm
behavior changes. Tools produce identical output on all platforms.
@ludomal ludomal changed the title Fix ctest failures on macOS/Linux without changing tool behaviour Fix ctest failures on macOS/Linux May 31, 2026
Ludovic Malfait added 3 commits May 31, 2026 08:31
…seek()

  compfile uses POSIX-only read()/lseek() which don't exist on MSVC.
  Replace with standard C fread()/fseek() for cross-platform builds.

  Relates to openitu#142
  - src/utl/signal-diff.c: replace read()/lseek()/write() with fread()/fseek()/fwrite()
  - src/unsup/oper.c: replace read()/lseek()/write()/close() with fread()/fseek()/fwrite()/fclose()

  Both files used POSIX-only I/O functions that don't exist on MSVC.
  Replaced with standard C FILE* operations for cross-platform builds.

  Relates to openitu#142
  Use %lX for unsigned long arguments instead of %X.

  Relates to openitu#34
@ludomal ludomal force-pushed the fix/ctest-portability branch from 4159f13 to 1e9aa7d Compare May 31, 2026 09:58
Ludovic Malfait added 3 commits May 31, 2026 15:38
On Windows, rename() cannot move files across directories. The old
get_tmp_name() created a temp file in CWD (from tmpnam), but when
the input file is an absolute path in a different directory, rename()
fails. Now creates the temp file in the same directory as the input.
Fixes sb2 test failure on Windows where:
- Source tree files may be read-only
- CTest runs tests in parallel (race condition)
- rename() fails across directories
- wmc_tool: quote glob patterns in add_test() so CTest passes them
  as literals to the Python script (which expands them internally).
  Fixes container environments where shell expansion fails.

- g726-vbr1/vbr3-verify: use signal-diff -equiv 1 instead of exact cf
  comparison. ARM32 FPU produces ±1 LSB rounding differences in
  A-law/mu-law conversion compared to x86_64 reference files.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Compiler warnings: printf numeric placeholders Use fopen, fread, fwrite, and fclose for file operations

1 participant