Commit Graph

128 Commits

Author SHA1 Message Date
Lasse Collin 2d2201bc63 Tests: Add the .lzma files to test_files.sh. 2022-07-14 20:33:05 +03:00
Lasse Collin ce5549a591 Tests: Add .lzma test files. 2022-07-14 19:37:42 +03:00
Jia Tan d1bfa3dc70 Created script to generate code coverage reports.
The script uses lcov and genhtml after running the tests
to show the code coverage statistics. The script will create
a coverage directory where it is run. It can be run both in
and out of the source directory.
2022-07-10 22:42:22 +03:00
Jia Tan 86a30b0255 Tests: Add more tests into test_check. 2022-06-16 17:39:59 +03:00
Lasse Collin 82e30fed66 Tests: Use char[][24] array for enum_strings_lzma_ret.
Array of pointers to short strings is a bit pointless here
and now it's fully const.
2022-06-16 15:02:57 +03:00
Lasse Collin 5ba9459e6c Tests: tuktest.h: Add tuktest_error_impl to help with error conditions. 2022-06-16 14:12:14 +03:00
Lasse Collin b339892668 Tests: tuktest.h: Rename file_from_* and use tuktest_malloc there. 2022-06-16 13:29:59 +03:00
Lasse Collin d8b63a0ad6 Tests: tuktest.h: Add malloc wrapper with automatic freeing. 2022-06-16 13:08:19 +03:00
Lasse Collin 1d51536a4b Tests: tuktest.h: Move a function. 2022-06-16 11:47:37 +03:00
Lasse Collin 70c7555f64 Tests: test_vli: Remove an invalid test-assertion.
lzma_vli is unsigned so trying a signed value results in
a compiler warning from -Wsign-conversion. (lzma_vli)-1
equals to LZMA_VLI_UNKNOWN anyway which is the next assertion.
2022-06-14 22:21:15 +03:00
Lasse Collin 154b73c5a1 Tests: test_vli: Add const where appropriate. 2022-06-14 22:17:01 +03:00
Jia Tan a08f5ccf6b Created tests for all functions exported in vli.h
Achieved 100% code coverage vli_encoder.c, vli_decoder.c, and vli_size.c
2022-06-14 22:00:34 +03:00
Lasse Collin 00e3613f12 Tests: Use good-1-empty-bcj-lzma2.xz in test_bcj_exact_size.
It's much nicer this way so that the test data isn't a hardcoded
table inside the C file.
2022-06-14 21:29:21 +03:00
Lasse Collin 86bab755be Tests: Add file reading helpers to tuktest.h. 2022-06-14 21:26:13 +03:00
Lasse Collin 83d2337b72 Tests: tuktest.h: Move a printf from a macro to a helper function. 2022-06-14 18:21:57 +03:00
Lasse Collin f9e8176ea7 Tests: Add test file good-1-empty-bcj-lzma2.xz.
This is from test_bcj_exact_size.c.
It's good to have it as a standalone file.
2022-06-14 17:20:49 +03:00
Jia Tan aa75c5563a Tests: Created tests for hardware functions.
Created tests for all API functions exported in
src/liblzma/api/lzma/hardware.h. The tests are fairly trivial
but are helpful because they will inform users if their machines
cannot support these functions. They also improve the code
coverage metrics.
2022-06-10 16:58:47 +03:00
Lasse Collin 5c8ffdca20 Tests: Convert test_check to tuktest.
Thanks to Jia Tan for help with all the tests.
2022-06-02 21:06:58 +03:00
Lasse Collin faf5ff8899 Tests: Convert test_block_header to tuktest. 2022-06-02 20:45:05 +03:00
Lasse Collin 754d39fbeb Tests: Convert test_bcj_exact_size to tuktest.
The compress() and decompress() functions were merged because
the later depends on the former so they need to be a single
test case.
2022-06-02 20:28:23 +03:00
Lasse Collin 96da21470f Tests: Include tuktest.h in tests.h.
This breaks -Werror because none of the tests so far use
tuktest.h and thus there are warnings about unused variables
and functions.
2022-06-02 20:27:00 +03:00
Lasse Collin df71ba1c99 Tests: Add tuktest.h mini-test-framework. 2022-06-02 20:25:21 +03:00
Lasse Collin 9a6dd6d46f Tests: Split test_compress.sh into separate test unit for each file.
test_compress.sh now takes one command line argument:
a filename to be tested. If it begins with "compress_generated_"
the file will be created with create_compress_files.

This will allow parallel execution of the slow tests.
2022-05-23 21:31:20 +03:00
Lasse Collin c7758ac9c7 Test: Make create_compress_files.c a little more flexible.
If a command line argument is given, then only the test file
of that type is created. It's quite dumb in sense that unknown
names don't give an error but it's good enough here.

Also use EXIT_FAILURE instead of 1 as exit status for errors.
2022-05-23 20:59:47 +03:00
Lasse Collin 4a8e4a7b0a Tests: Remove unneeded commented lines from test_compress.sh. 2022-05-23 20:17:42 +03:00
Lasse Collin 2ee50d150e Tests: Remove progress indicator from test_compress.sh.
It will be useless with Automake's parallel tests.
2022-05-23 20:16:00 +03:00
Lasse Collin 555de11873 Tests: Add bad-1-lzma2-11.xz. 2022-02-20 19:38:55 +02:00
Lasse Collin bb1d5c1fdd Tests: Add bad-1-lzma2-10.xz and also modify -9.xz. 2021-01-24 22:32:41 +02:00
Lasse Collin 939fc5ed65 Tests: Add bad-1-lzma2-9.xz. 2021-01-24 18:51:51 +02:00
Lasse Collin fdd30032f8 Tests: Add bad-1-check-crc32-2.xz. 2021-01-24 17:04:51 +02:00
Lasse Collin cf2df0f05a Use $(LIB_FUZZING_ENGINE) in tests/ossfuzz/Makefile.
https://github.com/google/oss-fuzz/pull/3219#issuecomment-573751048

Thanks to Bhargava Shastry for sending the patch.
2020-01-19 21:54:33 +02:00
Lasse Collin 7136f1735c Rename unaligned_read32ne to read32ne, and similarly for the others. 2019-12-31 00:47:49 +02:00
Lasse Collin 8b72950a6b Tests: Hopefully fix test_check.c to work on EBCDIC systems.
Thanks to Daniel Richard G.
2019-12-29 22:51:58 +02:00
Lasse Collin e873902641 Tests: Silence warnings from clang -Wassign-enum.
Also changed 999 to 99 so it fits even if lzma_check happened
to be 8 bits wide.
2019-06-25 00:08:13 +03:00
Lasse Collin c2d2ab6a9d Tests: Silence a warning from -Wsign-conversion. 2019-06-24 20:53:55 +03:00
Lasse Collin dfda7cf6af Tests: Remove a duplicate branch from tests/tests.h.
The duplication was introduced about eleven years ago and
should have been cleaned up back then already.

This was caught by -Wduplicated-branches.
2019-06-24 00:57:23 +03:00
Lasse Collin 106d1a663d Tests: Add a fuzz test program and a config file for OSS-Fuzz.
Thanks to Bhargava Shastry and Github user pdknsk.
2018-11-02 20:40:14 +02:00
Lasse Collin 372e402713 Tests: Add tests for the two bugs fixed in index.c. 2015-10-12 21:07:41 +03:00
Lasse Collin c7f4041f6b Tests: Fix a memory leak in test_bcj_exact_size.
Thanks to Cristian Rodríguez.
2015-05-13 20:57:55 +03:00
Lasse Collin d2d484647d Tests: Don't hide unexpected error messages in test_files.sh.
Hiding them makes no sense since normally there's no error
when testing the "good" files. With "bad" files errors are
expected and then it makes sense to keep the messages hidden.
2015-01-06 20:30:15 +02:00
Lasse Collin 381ac14ed7 xzgrep: List xzgrep_expected_output in tests/Makefile.am. 2014-06-13 19:21:54 +03:00
Lasse Collin 4244b65b06 xzgrep: Improve the test script.
Now it should be close to the functionality of the original
version by Pavel Raiskup.
2014-06-13 18:58:22 +03:00
Lasse Collin 1e60f2c0a0 xzgrep: Add a test for the previous fix.
This is a simplified version of Pavel Raiskup's
original patch.
2014-06-11 21:03:25 +03:00
Lasse Collin d625c7cf82 Tests: Remove tests/test_block.c that had gotten committed accidentally. 2012-07-05 07:36:28 +03:00
Lasse Collin d8db706acb liblzma: Fix possibility of incorrect LZMA_BUF_ERROR.
lzma_code() could incorrectly return LZMA_BUF_ERROR if
all of the following was true:

  - The caller knows how many bytes of output to expect
    and only provides that much output space.

  - When the last output bytes are decoded, the
    caller-provided input buffer ends right before
    the LZMA2 end of payload marker. So LZMA2 won't
    provide more output anymore, but it won't know it
    yet and thus won't return LZMA_STREAM_END yet.

  - A BCJ filter is in use and it hasn't left any
    unfiltered bytes in the temp buffer. This can happen
    with any BCJ filter, but in practice it's more likely
    with filters other than the x86 BCJ.

Another situation where the bug can be triggered happens
if the uncompressed size is zero bytes and no output space
is provided. In this case the decompression can fail even
if the whole input file is given to lzma_code().

A similar bug was fixed in XZ Embedded on 2011-09-19.
2012-05-28 20:42:11 +03:00
Lasse Collin 7db6bdf4ab Tests: Fix a compiler warning with _FORTIFY_SOURCE.
Reported here:
http://sourceforge.net/projects/lzmautils/forums/forum/708858/topic/4927385
2012-01-10 17:13:03 +02:00
Lasse Collin bd52cf150e Build: Fix "make check" on Windows. 2011-09-06 12:03:41 +03:00
Lasse Collin e9ed88126e Run the scripts with the correct shell in test_scripts.sh.
The scripts are now made executable in the build tree.
This way the scripts can be run like programs in
test_scripts.sh. Previously test_scripts.sh always
used sh but it's not correct if @POSIX_SHELL@ is set
to something else by configure.

Thanks to Jonathan Nieder for the patch.
2011-08-06 20:37:28 +03:00
Lasse Collin 1c673e5681 Fix exit status of "xzdiff foo.xz bar.xz".
xzdiff was clobbering the exit status from diff in a case
statement used to analyze the exit statuses from "xz" when
its operands were two compressed files. Save and restore
diff's exit status to fix this.

The bug is inherited from zdiff in GNU gzip and was fixed
there on 2009-10-09.

Thanks to Jonathan Nieder for the patch and
to Peter Pallinger for reporting the bug.
2011-07-31 11:01:47 +03:00
Lasse Collin 79bef85e05 Tests: Add a test file for the bug in the previous commit. 2011-05-28 08:46:04 +03:00