1
0
Fork 0
mirror of https://git.tukaani.org/xz.git synced 2024-04-04 12:36:23 +02:00
Commit graph

211 commits

Author SHA1 Message Date
Lasse Collin
cce7330b9f Tests: tuktest.h: Add a missing word to a comment. 2024-02-14 21:11:03 +02:00
Lasse Collin
5dd8fc9452 Tests: tuktest.h: Fix the comment about STest. 2024-02-14 21:10:10 +02:00
Lasse Collin
22af94128b Add SPDX license identifier into 0BSD source code files. 2024-02-14 18:31:16 +02:00
Lasse Collin
689e0228ba Change most public domain parts to 0BSD.
Translations and doc/xz-file-format.txt and doc/lzma-file-format.txt
were not touched.

COPYING.0BSD was added.
2024-02-14 18:31:12 +02:00
Jia Tan
89ea1a22f4 Tests: Add RISC-V filter support in a few places. 2024-02-13 23:33:27 +08:00
Jia Tan
3060e1070b Tests: Use smaller dictionary size in RISC-V test files. 2024-01-23 23:55:44 +08:00
Jia Tan
44ff2fa5c9 Tests: Skip RISC-V test files if decoder was not built. 2024-01-23 23:55:39 +08:00
Jia Tan
e2870db5be Tests: Add two RISC-V Filter test files.
These test files achieve 100% code coverage in
src/liblzma/simple/riscv.c. They contain all of the instructions that
should be filtered and a few cases that should not.
2024-01-23 23:05:47 +08:00
Jia Tan
ac3691ccca Tests: Add RISC-V Filter test in test_compress.sh. 2024-01-23 23:05:47 +08:00
Jia Tan
d0b24efe6c Tests: Silence -Wsign-conversion warning on GCC version < 10.
Since GCC version 10, GCC no longer complains about simple implicit
integer conversions with Arithmetic operators.

For instance:

    uint8_t a = 5;
    uint32_t b = a + 5;

Give a warning on GCC 9 and earlier but this:

    uint8_t a = 5;
    uint32_t b = (a + 5) * 2;

Gives a warning with GCC 10+.
2023-12-07 21:48:07 +08:00
Jia Tan
ee2f483500 Tests: Minor cleanups to OSS-Fuzz files.
Most of these fixes are small typos and tweaks. A few were caused by bad
advice from me. Here is the summary of what is changed:

- Author line edits

- Small comment changes/additions

- Using the return value in the error messages in the fuzz targets'
  coder initialization code

- Removed fuzz_encode_stream.options. This set a max length, which may
  prevent some worthwhile code paths from being properly exercised.

- Removed the max_len option from fuzz_decode_stream.options for the
  same reason as fuzz_encode_stream. The alone decoder fuzz target still
  has this restriction.

- Altered the dictionary contents for fuzz_lzma.dict. Instead of keeping
  the properties static and varying the dictionary size, the properties
  are varied and the dictionary size is kept small. The dictionary size
  doesn't have much impact on the code paths but the properties do.

Closes: https://github.com/tukaani-project/xz/pull/73
2023-12-07 20:06:57 +08:00
Maksym Vatsyk
483bb90eec Tests: Add fuzz_encode_stream ossfuzz target.
This fuzz target handles .xz stream encoding. The first byte of input
is used to dynamically set the preset level in order to increase the
fuzz coverage of complex critical code paths.
2023-12-07 20:06:57 +08:00
Maksym Vatsyk
7ca8c9869d Tests: Add fuzz_decode_alone OSS-Fuzz target
This fuzz target that handles LZMA alone decoding. A new fuzz
dictionary .dict was also created with common LZMA header values to
help speed up the discovery of valid headers.
2023-12-07 20:06:57 +08:00
Maksym Vatsyk
37581a77ad Tests: Update OSS-Fuzz Makefile.
All .c files can be built as separate fuzz targets. This simplifies
the Makefile by allowing us to use wildcards instead of having a
Makefile target for each fuzz target.
2023-12-07 20:06:54 +08:00
Maksym Vatsyk
28ce6a1c2a Tests: Move common OSS-Fuzz target code to .h file. 2023-12-07 20:06:54 +08:00
Maksym Vatsyk
bf0521ea15 Tests: Rename OSS-Fuzz files. 2023-12-07 20:06:51 +08:00
Kian-Meng Ang
3b3023e00b Tests: Fix typos 2023-11-30 23:08:05 +08:00
Jia Tan
ca278eb2b7 Tests: Create test_suffix.sh.
This tests some complicated interactions with the --suffix= option.
The suffix option must be used with --format=raw, but can optionally
be used to override the default .xz suffix.

This test also verifies some recent bugs have been correctly solved
and to hopefully avoid further regressions in the future.
2023-11-18 01:56:05 +08:00
Jia Tan
299920bab9 Tests: Fix typo in a comment. 2023-11-17 20:04:58 +08:00
Jia Tan
bbb42412da Build: Remove Gnulib dependency from tests.
The tests do not use any Gnulib replacements so they do not need to link
libgnu.a or have /lib in the include path.
2023-09-26 00:47:26 +08:00
Jia Tan
74c3449d8b Tests: Improve invalid unpadded size check in test_lzma_index_append().
This check was extended to test the code added to fix a failing assert
in ae5c07b22a.
2023-08-28 23:14:45 +08:00
Jia Tan
2544274a8b Tests: Improve comments in test_index.c. 2023-08-28 23:05:55 +08:00
Jia Tan
cd678a6077 Tests: Style fixes to test_lzip_decoder.c. 2023-08-03 20:10:21 +08:00
Dimitri Papadopoulos Orfanos
42df7c7aa1
Docs: Fix typos found by codespell 2023-07-31 20:02:21 +08:00
Jia Tan
39a32d36fc Tests: Skip .lz files in test_files.sh if not configured.
Previously if the lzip decoder was not configured then test_files.sh
would pass the lzip tests instead of skipping them.
2023-07-21 18:05:44 +08:00
Jia Tan
194d12724b Tests: Add ARM64 filter test to test_compress.sh. 2023-07-20 22:11:13 +08:00
Jia Tan
a6583726e5 Tests: Use new --filters option in test_compress.sh 2023-07-17 23:34:55 +08:00
Jia Tan
2c189bb00a Tests: Improve feature testing for skipping.
Fixed a bug where test_compress_* would all fail if arm64 or armthumb
filters were enabled for compression but arm was disabled. Since the
grep tests only checked for "define HAVE_ENCODER_ARM", this would match
on HAVE_ENCODER_ARM64 or HAVE_ENCODER_ARMTHUMB.

Now the config.h feature test requires " 1" at the end to prevent the
prefix problem. have_feature() was also updated for this even though
there were known current bugs affecting it. This is just in case future
features have a similar prefix problem.
2023-07-14 21:30:25 +08:00
Jia Tan
66bdcfa85f Tests: Fix memory leaks in test_index.
Several tests were missing calls to lzma_index_end() to clean up the
lzma_index structs. The memory leaks were discovered by using
-fsanitize=address with GCC.
2023-06-29 00:07:16 +08:00
Jia Tan
fe3bd438fb Tests: Fix memory leaks in test_block_header.
test_block_header was not properly freeing the filter options between
calls to lzma_block_header_decode(). The memory leaks were discovered by
using -fsanitize=address with GCC.
2023-06-29 00:07:05 +08:00
Jia Tan
1b7661faa4 Tests: Remove unused macros and functions. 2023-03-13 20:49:53 +08:00
Jia Tan
af55191102 liblzma: Defines masks for return values from lzma_index_checks(). 2023-03-13 20:49:53 +08:00
Jia Tan
8f38cdd9ab Tests: Refactors existing lzma_index tests.
Converts the existing lzma_index tests into tuktests and covers every
API function from index.h except for lzma_file_info_decoder, which can
be tested in the future.
2023-03-13 20:49:53 +08:00
Jia Tan
9aa7fdeb04 Tests: Small tweak to test-vli.c.
The static global variables can be disabled if encoders and decoders
are not built. If they are not disabled and -Werror is used, it will
cause an usused warning as an error.
2023-02-24 21:11:18 +08:00
Jia Tan
e01f01b9af Tests: Create test_filter_str.c.
Tests lzma_str_to_filters(), lzma_str_from_filters(), and
lzma_str_list_filters() API functions.
2023-02-03 00:42:27 +08:00
Lasse Collin
bfc3a0a8ac Tests: Fix warnings from clang --Wassign-enum.
Explicitly casting the integer to lzma_check silences the warning.
Since such an invalid value is needed in multiple tests, a constant
INVALID_LZMA_CHECK_ID was added to tests.h.

The use of 0x1000 for lzma_block.check wasn't optimal as if
the underlying type is a char then 0x1000 will be truncated to 0.
However, in these test cases the value is ignored, thus even with
such truncation the test would have passed.
2023-01-12 04:14:18 +02:00
Lasse Collin
49245bb31e Tests: Silence warnings from -Wsign-conversion.
Note that assigning an unsigned int to lzma_check doesn't warn
on GNU/Linux x86-64 since the enum type is unsigned on that
platform. The enum can be signed on some other platform though
so it's best to use enumeration type lzma_check in these situations.
2023-01-12 03:56:24 +02:00
Lasse Collin
a0e7fb1c1e Tests: test_lzip_decoder: Remove trailing white-space. 2023-01-12 03:04:28 +02:00
Lasse Collin
c0f8d6782f Tests: test_lzip_decoder: Silence warnings from -Wsign-conversion. 2023-01-12 03:03:55 +02:00
Jia Tan
8c0f115cc4 Tests: Fix test_filter_flags copy/paste error. 2023-01-11 20:58:31 +08:00
Jia Tan
25035813d1 Tests: Fix type-limits warning in test_filter_flags.
This only occurs in test_filter_flags when the BCJ filters are not
configured and built. In this case, ARRAY_SIZE() returns 0 and causes a
type-limits warning with the loop variable since an unsigned number will
always be >= 0.
2023-01-11 20:42:29 +08:00
Jia Tan
765354b50c Tests: Fix unused function warning in test_block_header.
One of the global arrays of filters was only used in a test that
required both encoders and decoders to be configured in the build.
2023-01-11 01:18:50 +08:00
Jia Tan
7c23c05bef Tests: Fix unused function warning in test_index_hash.
test_index_hash does not use fill_index_hash() unless both encoders
and decoders are configured in the build.
2023-01-11 01:08:03 +08:00
Lasse Collin
0c210ca7f4 Tests: test_filter_flags: Clean up minor issues.
Here are the list of the most significant issues addressed:
- Avoid using internal common.h header. It's not good to copy the
constants like this but common.h cannot be included for use outside
of liblzma. This is the quickest thing to do that could be fixed later.

- Omit the INIT_FILTER macro. Initialization should be done with just
regular designated initializers.

- Use start_offset = 257 for BCJ tests. It demonstrates that Filter
Flags encoder and decoder don't validate the options thoroughly.
257 is valid only for the x86 filter. This is a bit silly but
not a significant problem in practice because the encoder and
decoder initialization functions will catch bad alignment still.
Perhaps this should be fixed but it's not urgent and doesn't need
to be in 5.4.x.

- Various tweaks to comments such as filter id -> Filter ID
2023-01-09 20:35:20 +08:00
Jia Tan
5c9fdd3bf5 Tests: Refactors existing filter flags tests.
Converts the existing filter flags tests into tuktests.
2023-01-09 20:35:20 +08:00
Lasse Collin
0e1545fea3 Tests: tuktest.h: Support tuktest_malloc(0).
It's not needed in XZ Utils at least for now. It's good to support
it still because if such use is needed later, it wouldn't be
caught on GNU/Linux since malloc(0) from glibc returns non-NULL.
2023-01-08 00:32:29 +02:00
Jia Tan
6fd39664de
Merge pull request #7 from tukaani-project/tuktest_index_hash
Tuktest index hash
2023-01-07 00:10:50 +08:00
Lasse Collin
fc0c788469 Tests: test_index_hash: Add an assert_uint_eq(). 2023-01-06 17:58:48 +02:00
Lasse Collin
d550304f53 Tests: test_index_hash: Fix a memory leak. 2023-01-06 17:55:06 +02:00
Lasse Collin
02608f74ea Tests: test_index_hash: Don't treat pointers as booleans. 2023-01-06 17:53:03 +02:00