Commit Graph

268 Commits

Author SHA1 Message Date
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
Lasse Collin 710a4573ef Tests: test_index: Fix failures when features are disabled
Fixes: cd88423e76
2024-04-28 01:34:50 +03:00
Lasse Collin aaff75c348 CMake: Keep the build working if the "tests" directory is missing
This moves the tests section as is from CMakeLists.txt into
tests/tests.cmake. CMakeLists.txt now includes tests/tests.cmake
if the latter file exists.

Now it's possible to delete the whole "tests" directory and
building with CMake will still work normally, just without
the tests. This way the tests are readily available for those
who want them, and those who won't run the tests anyway have
a straightforward way to ensure that nothing from the "tests"
directory can affect the build process.
2024-04-27 20:21:30 +03:00
Lasse Collin a5f2aa5618 Tests: Remove x86 and SPARC BCJ tests
These are very old but the exact test file isn't easy to reproduce
as it was compiled from a short C program (bcj_test.c) long ago.
These tests weren't very good anyway, just a little better than nothing.
2024-04-27 20:21:30 +03:00
Lasse Collin d879686469 Tests: test_index: Edit a misleading test 2024-04-27 18:30:40 +03:00
Lasse Collin 612005bbdb Tests: test_index: Use minimal values to test integer overflow 2024-04-27 16:46:01 +03:00
Lasse Collin 4ad88b2544 Tests: test_index: Test lzma_index_buffer_decode() more 2024-04-27 15:13:39 +03:00
Lasse Collin 575b11b0d2 Tests: test_index: Test that *i = NULL is done on LZMA_PROG_ERROR
On LZMA_DATA_ERROR from lzma_index_buffer_decode(), *i = NULL was
already done but this adds a test for that case too.
2024-04-27 15:08:29 +03:00
Lasse Collin 2c970debdb Tests: test_index: Test lzma_index_buffer_encode() with empty output buf 2024-04-27 15:01:25 +03:00
Lasse Collin cd88423e76 Tests: test_index: Replace if-statements with tuktest assertions 2024-04-27 14:59:55 +03:00
Lasse Collin 7f865577a6 Tests: test_index: Make it clear that my_alloc() has no integer overflows
liblzma guarantees that the product of the allocation size arguments
will fit in size_t.

Putting the pre-increment in the if-statement was clearly wrong
although in practice it didn't matter here as the function is
called only a couple of times.
2024-04-27 14:56:16 +03:00
Lasse Collin 12313a3b65 Tests: test_index: Verify also iter.block.number_in_stream 2024-04-27 14:51:52 +03:00
Lasse Collin ad2654010d Tests: test_index: Check cases that aren't a multiple of 4 bytes 2024-04-27 14:51:06 +03:00
Lasse Collin 2524fcf2b6 Tests: test_index: Edit comments and white space 2024-04-27 14:40:25 +03:00
Lasse Collin 3ac8a9bb4c Tests: test_filter_str: Add a few assertions 2024-04-23 16:35:33 +03:00
Lasse Collin 26c69be805 Tests: test_filter_str: Move one assertion and add a comment 2024-04-23 16:35:08 +03:00
Lasse Collin 4f6af853bc Tests: test_filter_str: Tweak comments and white space 2024-04-23 16:26:06 +03:00
Lasse Collin c92663aa1b Tests: test_filter_str: Add missing RISC-V case
Fixes: 89ea1a22f4
2024-04-23 16:25:22 +03:00
Lasse Collin b0366df1d7 Tests: test_filter_str: Test *error_pos more thoroughly 2024-04-22 23:01:53 +03:00
Lasse Collin 2f06920f20 Tests: test_filter_flags: Edit comments and style 2024-04-22 18:35:19 +03:00
Lasse Collin b101e1d1db Tests: Fix C99/C11 compatibility when features are disabled
The array could become empty and then the initializer would be
simply {} which is allowed only in GNU-C and C23.
2024-04-22 16:39:44 +03:00
Lasse Collin 86fc4ee859 Tests: test_lzip_decoder: Tweak coding style and comments 2024-04-19 20:53:24 +03:00
Lasse Collin 38be573a27 Tests: test_lzip_decoder: Remove redundant initializations 2024-04-19 20:51:36 +03:00
Lasse Collin d7e4bc53ea Tests: test_lzip_decoder: Remove unneeded tuktest_malloc() calls 2024-04-19 20:47:24 +03:00
Lasse Collin fcbd0d1999 Tests: test_microlzma: Add a "FIXME?" about LZMA_FINISH handling 2024-04-13 22:39:10 +03:00
Lasse Collin 0fe2dfa683 Tests: test_microlzma: Tweak comments, coding style, and minor details
A few lines were reordered, a few ARRAY_SIZE were changed to sizeof,
and a few uint32_t were changed to size_t. No real functional changes
were intended.
2024-04-13 21:01:10 +03:00
Lasse Collin 6b4c859059 tests/files/README: Update the main heading. 2024-04-09 18:22:27 +03:00
Lasse Collin 2a851e06b8 tests/files/README: Explain how to recreate the ARM64 test files. 2024-04-09 18:22:27 +03:00
Lasse Collin 408b6adb2a tests/ossfuzz: Tiny fix to a comment. 2024-04-09 18:22:27 +03:00
Lasse Collin e93e13c8b3 Remove the backdoor found in 5.6.0 and 5.6.1 (CVE-2024-3094).
While the backdoor was inactive (and thus harmless) without inserting
a small trigger code into the build system when the source package was
created, it's good to remove this anyway:

  - The executable payloads were embedded as binary blobs in
    the test files. This was a blatant violation of the
    Debian Free Software Guidelines.

  - On machines that see lots bots poking at the SSH port, the backdoor
    noticeably increased CPU load, resulting in degraded user experience
    and thus overwhelmingly negative user feedback.

  - The maintainer who added the backdoor has disappeared.

  - Backdoors are bad for security.

This reverts the following without making any other changes:

6e636819 Tests: Update two test files.
a3a29bbd Tests: Test --single-stream can decompress bad-3-corrupt_lzma2.xz.
0b4ccc91 Tests: Update RISC-V test files.
8c9b8b20 liblzma: Fix typos in crc32_fast.c and crc64_fast.c.
82ecc538 liblzma: Fix false Valgrind error report with GCC.
cf44e4b7 Tests: Add a few test files.
3060e107 Tests: Use smaller dictionary size in RISC-V test files.
e2870db5 Tests: Add two RISC-V Filter test files.

The RISC-V test files also have real content that tests the filter
but the real content would fit into much smaller files. A generator
program would need to be available as well.

Thanks to Andres Freund for finding and reporting it and making
it public quickly so others could act without a delay.
See: https://www.openwall.com/lists/oss-security/2024/03/29/4
2024-04-09 17:57:39 +03:00
Jia Tan 6e636819e8 Tests: Update two test files.
The original files were generated with random local to my machine.
To better reproduce these files in the future, a constant seed was used
to recreate these files.
2024-03-09 10:18:29 +08:00
Jia Tan a3a29bbd5d Tests: Test --single-stream can decompress bad-3-corrupt_lzma2.xz.
The first stream in this file is valid, so this tests that xz properly
stops after decompressing it.
2024-03-09 10:08:32 +08:00