From 1dae4f0188daff25cfef78de72627e7299a01b86 Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Thu, 18 Dec 2025 15:36:07 -0800 Subject: [PATCH] test: fix versionsTest build for old zstd versions Summary: Some old zstd versions (notably v0.6.x) have a bug in fileio.c where header includes check for `ZSTD_LEGACY_SUPPORT==1` but code usage checks for `ZSTD_LEGACY_SUPPORT>=1`. Using value 5 causes compilation failure because headers aren't included but the code tries to use legacy functions. Changing to `ZSTD_LEGACY_SUPPORT=1` for old version builds fixes the compilation while still enabling legacy format support. Test Plan: Run `make versionsTest` or `python3 tests/test-zstd-versions.py` to verify all old versions compile and cross-version decompression works correctly. --- tests/test-zstd-versions.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tests/test-zstd-versions.py b/tests/test-zstd-versions.py index 703faa478..57131c243 100755 --- a/tests/test-zstd-versions.py +++ b/tests/test-zstd-versions.py @@ -259,8 +259,15 @@ if __name__ == '__main__': shutil.copy2('dictBuilder', '{}/dictBuilder.{}'.format(tmp_dir, tag)) os.chdir(r_dir + '/programs') # /path/to/zstd/tests/versionsTest//programs make(['clean'], False) # separate 'clean' target to allow parallel build - # Enable legacy support for cross-version compatibility testing - make(['zstd', 'ZSTD_LEGACY_SUPPORT=5'], False) + # Enable legacy support for cross-version compatibility testing. + # Use ZSTD_LEGACY_SUPPORT=1 for v0.6.x due to a bug where headers + # check for ==1 but code checks for >=1. + # Use ZSTD_LEGACY_SUPPORT=5 for v1.2.0+ because =1 includes old + # legacy files (v01-v04) that have missing includes in newer versions. + if tag < 'v1.2.0': + make(['zstd', 'ZSTD_LEGACY_SUPPORT=1'], False) + else: + make(['zstd', 'ZSTD_LEGACY_SUPPORT=5'], False) else: os.chdir(programs_dir) print('-----------------------------------------------') -- 2.47.3