1
0
mirror of https://git.tukaani.org/xz.git synced 2026-10-31 19:34:55 +00:00

299 Commits

Author SHA1 Message Date
LinkTheOperatorMatrix
299eb5c3f5
CMake: Fix wrong variable name in the MicroLZMA test condition
tests.cmake checked DECODERS instead of XZ_DECODERS. With
XZ_MICROLZMA_DECODER=OFF, test_microlzma was incorrectly added
to the list of tests, which resulted in a build failure.

Closes: https://github.com/tukaani-project/xz/pull/255
2026-10-16 16:21:02 +03:00
Lasse Collin
b355a31140
Tests: Add test file bad-1-powerpc-1.xz 2026-10-10 16:59:30 +03:00
Lasse Collin
3b1efb04d1
Tests: Fix test_files.sh failure with --disable-xz
Reported-by: Otto Kekäläinen
Fixes: 7f539d14484e ("Tests: Test that integer overflow in xz --list totals is caught")
Fixes: https://github.com/tukaani-project/xz/issues/244
2026-09-09 22:37:17 +03:00
Lasse Collin
df5bfb4547
Tests: Add a fuzzer for .xz Index decoding
Normal .xz decoding uses lzma_index_hash, so this new fuzzer doesn't
overlap with the existing fuzzers.
2026-09-09 14:35:57 +03:00
Lasse Collin
65198524f0
Tests: Make some memory allocations fail in fuzzers 2026-09-09 14:35:57 +03:00
Lasse Collin
d4217668a7
Tests: Reinitialize decoders twice in fuzzers 2026-09-09 14:35:57 +03:00
Lasse Collin
9c3661926e
Tests: fuzz_common.h: Reset next_out and avail_out
It matters if the same lzma_stream is reused.
2026-09-09 14:35:57 +03:00
Lasse Collin
16f3093144
Tests: Adjust coding style in fuzzers 2026-09-09 14:35:57 +03:00
Lasse Collin
ff834f25ae
Tests: Test lzma_alone_decoder() reuse after dictionary allocation failure
This test crashes if both of the two previous commits are reverted.
2026-09-09 14:35:46 +03:00
Lasse Collin
5121d1aed8
Tests: Add tests for single-call .xz encoding
Thanks-to: GitHub user androvonx95
Closes: https://github.com/tukaani-project/xz/pull/231
2026-09-04 12:56:07 +03:00
Lasse Collin
7f539d1448
Tests: Test that integer overflow in xz --list totals is caught 2026-08-15 19:56:09 +03:00
Lasse Collin
490ca91153
Tests: Add test file bad-1-index-huge-uncomp.xz 2026-08-15 19:56:09 +03:00
Lasse Collin
18769dd692
CMake: Don't put test binaries in a subdirectory
This can matter on Windows:

 - MSVC puts the binaries into subdirectories based on build type
   (like "Debug" or "Release"), and then the test executables won't
   find liblzma.dll because it's not in the working directory from
   which the tests are run.

 - With mingw-w64, liblzma.dll was in the working directory so the test
   executables worked. However, the if the system happened to have
   liblzma.dll in, for example, the Windows directory, then the DLL
   search order might pick that instead.

Putting the shared library and test executables in the same directory
avoids these problems.

Reported-by: Frank <mail@franku.nl>
Fixes: https://github.com/tukaani-project/xz/pull/239
2026-08-15 19:41:29 +03:00
Lasse Collin
1a4a4df366
Tests: test_index: Test lzma_index_memusage(STREAMS_MAX, 1) 2026-08-09 16:11:13 +03:00
Lasse Collin
93372479ec
Tests: test_index: Extend _dup + _cat testing 2026-08-07 12:16:55 +03:00
Darren Carreras
d16c31196e
Tests: Add a test for the lzma_index_dup() + lzma_index_checks bug()
Link: https://github.com/tukaani-project/xz/pull/238
2026-08-07 12:16:55 +03:00
Lasse Collin
d4edae32b6
Tests: Fix test_index.c when encoding support is disabled
Fixes: 10dfae83fd3b ("Tests: test_index: Add a test for the Index decoder memusage bug")
2026-07-20 22:34:32 +03:00
Lasse Collin
47c44e9008
Tests: test_index: Test the stricter Number of Records condition 2026-07-20 21:16:17 +03:00
Lasse Collin
a9c92328bd
Tests: Add test file bad-0-index-1.xz 2026-07-20 21:16:17 +03:00
Lasse Collin
10dfae83fd
Tests: test_index: Add a test for the Index decoder memusage bug 2026-07-20 21:16:17 +03:00
Lasse Collin
2187b27c64
Tests: test_index: Fix testing of _locate() with concatenated lzma_index 2026-07-20 21:16:11 +03:00
Lasse Collin
f3b5688159
Tests: Comment that a sanitizer may be needed for lzma_index_append() bug
Fixes: a3ea8832bec1 ("Tests: Add a test for the lzma_index_prealloc() + lzma_index_append() bug")
Link: https://github.com/tukaani-project/xz/issues/233
2026-07-03 16:55:03 +03:00
Lasse Collin
6566e6251a
Tests: tuktest.h: Fix a comment 2026-05-27 13:00:10 +03:00
Lasse Collin
29584cdaf3
Tests: Add a test for the lzma_stream_buffer_decode() bug 2026-05-27 13:00:10 +03:00
Lasse Collin
a3ea8832be
Tests: Add a test for the lzma_index_prealloc() + lzma_index_append() bug 2026-03-30 21:37:11 +03:00
Lasse Collin
524f6a7384
Tests: Remove an unwanted semicolon from a macro definition
It didn't affect control flow.

Fixes: fe3bd438fb11 ("Tests: Fix memory leaks in test_block_header.")
2025-12-09 17:18:22 +02:00
Lasse Collin
41a421dbad
tests/test_suffix.sh: Avoid variables in printf format string 2025-09-29 17:50:46 +03:00
Lasse Collin
dbfb925c81
Tests: Silence a warning from GCC 15.1
It was (probably) intentionally without the null terminator, but the test
works with null terminator too (the test still fails with xz <= 5.0.3),
so simply omit one character to silence the warning.

tests/test_bcj_exact_size.c:30:32: error: initializer-string for array of ‘unsigned char’ truncates NUL terminator but destination lacks ‘nonstring’ attribute (17 chars into 16 available) [-Werror=unterminated-string-initialization]
   30 |         const uint8_t in[16] = "0123456789ABCDEF";
      |                                ^~~~~~~~~~~~~~~~~~

Fixes: d8db706acb83 ("liblzma: Fix possibility of incorrect LZMA_BUF_ERROR.")
Fixes: https://github.com/tukaani-project/xz/issues/176
2025-05-03 12:37:28 +03:00
Lasse Collin
1176a19df6
Tests: Add fuzz_decode_stream_mt.options 2025-04-04 20:08:37 +03:00
Lasse Collin
513cabcf7f
Tests: Call lzma_code() in smaller chunks in fuzz_common.h
This makes it easy to crash fuzz_decode_stream_mt when tested
against the code from 5.8.0.

Obviously this might make it harder to reach some other code path now.
The previous code has been in use since 2018 when fuzzing was added
in 106d1a663d4b ("Tests: Add a fuzz test program and a config file
for OSS-Fuzz.").
2025-04-03 14:34:43 +03:00
Lasse Collin
48440e24a2
Tests: Add a fuzzing target for the multithreaded .xz decoder
It doesn't seem possible to trigger the CVE-2025-31115 bug with this
fuzzing target at the moment. It's because the code in fuzz_common.h
passes the whole input buffer to lzma_code() at once.
2025-04-03 14:34:43 +03:00
Lasse Collin
74702ee00e Tests/Windows: Add the application manifest to the test programs
This ensures that the test programs get executed the same way as
the binaries that are installed.
2024-10-01 12:10:23 +03:00
Lasse Collin
47aaa92516 CMake: Don't install scripts if the xz tool isn't built
The scripts need the xz tool.
2024-06-20 21:53:07 +03:00
Lasse Collin
96abfe98c1 CMake: Refactor ADDITIONAL_CHECK_TYPES to XZ_CHECKS
Now "crc32" is in the list too for completeness but it doesn't
actually have any effect. The description of the cache variable
says that "crc32 is always built" so it should be clear enough.
2024-06-20 15:00:05 +03:00
Lasse Collin
e5c0eb2e50 CMake: Rename ENCODERS and DECODERS to use XZ_ prefix 2024-06-20 15:00:05 +03:00
Lasse Collin
b56273ae57 CMake: Rename LZIP_DECODER to XZ_LZIP_DECODER 2024-06-20 15:00:05 +03:00
Lasse Collin
2343992fcb CMake: Rename MICROLZMA_ENCODER/DECODER to XZ_MICROLZMA_ENCODER/DECODER 2024-06-20 15:00:05 +03:00
Lasse Collin
89e9f12e03 Tests: Improve the CRC32 test
A similar one was already there for CRC64 but nowadays also CRC32
has a CLMUL implementation, so it's good to test it better too.
2024-06-11 22:44:44 +03:00
RainRat
9e73918a4f Fix typos
Closes: https://github.com/tukaani-project/xz/pull/124
2024-06-07 16:01:27 +03:00
Lasse Collin
9ae2ebc1e5 Add SPDX license identifiers to files under tests/ossfuzz 2024-05-22 15:18:42 +03:00
Lasse Collin
56f1d5ed68 Tests: Make the config.h grep patterns Meson compatible
Now the test scripts detect both

    #define HAVE_DECODER_ARM
    #define HAVE_DECODER_ARM 1

as support for the ARM filter without confusing it with these:

    #define HAVE_DECODER_ARM64
    #define HAVE_DECODER_ARM64 1

Previously only the ones ending with " 1" were accepted for
the macros where this kind of confusion was possible.

This should help with Meson support because Meson's built-in
features produce config.h entries that are either

    #define FOO 1
    #define FOO 0

or:

    #define FOO
    #undef FOO

The former method has a benefit that one can use "#if FOO" and -Wundef
will catch if a #define is missing (for example, it helps catching
typos). But XZ Utils has to use the latter since it has been
convenient with Autoconf's default behavior.[*] While it's easy to
emulate the Autoconf style (#define FOO 1 vs. no #define at all)
in Meson, it results in clumsy code. Thus it's better to change
the few places in the tests where this difference matters.

[*] While most checks in Autoconf default to the second style above,
    a few things use the first style (like AC_CHECK_DECLS). The mix
    of both styles is the most confusing as one has to remember which
    macro needs #ifdef and which #if. Currently HAVE_VISIBILITY is
    only such config.h entry that is 1 or 0. It comes unmodified
    from Gnulib's visibility.m4.
2024-05-20 16:55:00 +03:00
Lasse Collin
9d997d6f9d CMake: Add comments 2024-05-20 16:55:00 +03:00
Lasse Collin
dc232d5846 CMake: Add support for test_files.sh 2024-05-20 16:55:00 +03:00
Lasse Collin
a7e9230af9 Tests: Make test_files.sh more flexible
Add a new optional argument to specify the directory of the xz and
xzdec executables.

If ../config.h doesn't exist, assume that all encoders and decoders
are available.
2024-05-20 16:55:00 +03:00
Lasse Collin
b40e6efbb4 CMake: Add support for test_compress.sh tests 2024-05-20 16:55:00 +03:00
Lasse Collin
ac3222d2cb Tests: Make test_compress.sh more flexible
Add a new optional second argument: directory of the xz and xzdec
executables. This is need with the CMake build where the binaries
end up in the top-level build directory.

If ../config.h doesn't exist, assume that all encoders and decoders
are available. This will make this script usable from CMake in the
most common build configuration.

NOTE: Since the existence of ../config.h is checked, the working
directory of the test script must be a subdir in the build tree!
Otherwise ../config.h would look outside the build tree.

Use the default check type instead of forcing CRC32 or CRC64.
Now the script doesn't need to check if CRC64 is available.
2024-05-20 16:55:00 +03:00
Lasse Collin
006040b29c CMake: Prepare to support the test_*.sh tests
This is a bit hacky since the scripts grep config.h to know which
features were built but the CMake build doesn't create config.h.
So instead those test scripts will be run only when all relevant
features have been enabled.
2024-05-20 16:55:00 +03:00
Lasse Collin
6167607a6e Tests: test_suffix.sh: Add a comment 2024-05-20 16:55:00 +03:00
Lasse Collin
7da488cb93 CMake: Add test_suffix.sh to the tests 2024-05-06 22:56:31 +03:00
Lasse Collin
a805594ed0 Test: Add CMake support to test_suffix.sh
It needs to find the xz executable from a different directory
and work without config.h.
2024-05-06 22:55:54 +03:00