]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
test: fix versionsTest build for old zstd versions no_legacy 4554/head
authorYann Collet <cyan@meta.com>
Thu, 18 Dec 2025 23:36:07 +0000 (15:36 -0800)
committerYann Collet <cyan@fb.com>
Fri, 19 Dec 2025 00:13:53 +0000 (16:13 -0800)
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

index 703faa47835627ca0a5145a007b6c7750be8d6fd..57131c243497301d107e49c41f80ff930283daed 100755 (executable)
@@ -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/<TAG>/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('-----------------------------------------------')