Commit Graph

2563 Commits

Author SHA1 Message Date
Lasse Collin 85b5595b67 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.

(cherry picked from commit a5f2aa5618)
2024-05-22 23:34:42 +03:00
Lasse Collin d8228d1ea0 Tests: test_index: Edit a misleading test
(cherry picked from commit d879686469)
2024-05-22 14:32:36 +03:00
Lasse Collin 2358ef8238 Tests: test_index: Use minimal values to test integer overflow
(cherry picked from commit 612005bbdb)
2024-05-22 14:32:36 +03:00
Lasse Collin 54f4a4162a Tests: test_index: Test lzma_index_buffer_decode() more
(cherry picked from commit 4ad88b2544)
2024-05-22 14:32:36 +03:00
Lasse Collin 85ab59a6b7 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.

(cherry picked from commit 575b11b0d2)
2024-05-22 14:32:36 +03:00
Lasse Collin fb42599e44 Tests: test_index: Test lzma_index_buffer_encode() with empty output buf
(cherry picked from commit 2c970debdb)
2024-05-22 14:32:36 +03:00
Lasse Collin 20cac20f63 Tests: test_index: Replace if-statements with tuktest assertions
(cherry picked from commit cd88423e76)
2024-05-22 14:32:36 +03:00
Lasse Collin 91e3ea8735 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.

(cherry picked from commit 7f865577a6)
2024-05-22 14:32:36 +03:00
Lasse Collin df1659a6c8 Tests: test_index: Verify also iter.block.number_in_stream
(cherry picked from commit 12313a3b65)
2024-05-22 14:32:36 +03:00
Lasse Collin e083e95dbf Tests: test_index: Check cases that aren't a multiple of 4 bytes
(cherry picked from commit ad2654010d)
2024-05-22 14:32:36 +03:00
Lasse Collin b0d3b86ecf Tests: test_index: Edit comments and white space
(cherry picked from commit 2524fcf2b6)
2024-05-22 14:32:36 +03:00
Lasse Collin bae288ea6f liblzma: index_decoder: Fix missing initializations on LZMA_PROG_ERROR
If the arguments to lzma_index_decoder() or lzma_index_buffer_decode()
were such that LZMA_PROG_ERROR was returned, the lzma_index **i
argument wasn't touched even though the API docs say that *i = NULL
is done if an error occurs. This obviously won't be done even now
if i == NULL but otherwise it is best to do it due to the wording
in the API docs.

In practice this matters very little: The problem can occur only
if the functions are called with invalid arguments, that is,
the calling application must already have a bug.

(cherry picked from commit 71eed2520e)
2024-05-22 14:32:36 +03:00
Lasse Collin f10cb93f33 CMake: Bump maximum policy version to 3.29
(cherry picked from commit 0478473953)
2024-05-22 14:32:36 +03:00
Sam James 59055d70cd ci: add NetBSD
(cherry picked from commit a607e2b40d)
2024-05-22 14:32:36 +03:00
Sam James 812c1f95f3 ci: add FreeBSD
(cherry picked from commit 72c210336d)
2024-05-22 14:32:36 +03:00
Sam James d2a4f963c2 ci: add OpenBSD
(cherry picked from commit b526ec2dbf)
2024-05-22 14:32:36 +03:00
Sam James 493bc57c33 liblzma: outqueue: add header guard
Reported by github's codeql.

(cherry picked from commit c7ef767c49)
2024-05-22 14:32:36 +03:00
Sam James cede418d4f liblzma: easy_preset: add header guard
Reported by github's codeql.

(cherry picked from commit 55dcae3056)
2024-05-22 14:32:36 +03:00
Lasse Collin 6e76a25df2 tuklib_integer: Rename bswapXX to byteswapXX
The __builtin_bswapXX from GCC and Clang are preferred when
they are available. This can allow compilers to emit the x86 MOVBE
instruction instead of doing a load + byteswap as two instructions
(which would happen if the byteswapping is done in inline asm).

bswap16, bswap32, and bswap64 exist in system headers on *BSDs
and Darwin. #defining bswap16 on NetBSD results in a warning about
macro redefinition. It's safest to avoid this namespace conflict
completely.

No OS supported by tuklib_integer.h uses byteswapXX names and
a web search doesn't immediately find any obvious danger of
namespace conflicts. So let's try these still-pretty-short names
for the macros.

Thanks to Sam James for pointing out the compiler warning on
NetBSD 10.0.

(cherry picked from commit 4ffc60f323)
2024-05-22 14:32:36 +03:00
Lasse Collin 0ca14871f3 liblzma: API doc cleanups
(cherry picked from commit 08ab0966a7)
2024-05-22 14:32:36 +03:00
Lasse Collin 94a462850b Tests: test_filter_str: Add a few assertions
(cherry picked from commit 3ac8a9bb4c)
2024-05-22 14:32:36 +03:00
Lasse Collin 72058ca22a Tests: test_filter_str: Move one assertion and add a comment
(cherry picked from commit 26c69be805)
2024-05-22 14:32:36 +03:00
Lasse Collin c59ebbe1c6 Tests: test_filter_str: Tweak comments and white space
(cherry picked from commit 4f6af853bc)
2024-05-22 14:32:36 +03:00
Lasse Collin ceda860934 Tests: test_filter_str: Add missing RISC-V case
Fixes: 89ea1a22f4
(cherry picked from commit c92663aa1b)
2024-05-22 14:32:36 +03:00
Lasse Collin 2234b7cc47 Tests: test_filter_str: Test *error_pos more thoroughly
(cherry picked from commit b0366df1d7)
2024-05-22 14:32:36 +03:00
Lasse Collin 3ba3ef57f9 liblzma: lzma_str_to_filters: Set *error_pos on all errors
The API docs clearly say that if error_pos isn't NULL then *error
is always set on any error. However, it wasn't touched if str == NULL
or filters == NULL or unsupported flags were specified.

Fixes: cedeeca2ea
(cherry picked from commit 70d12dd069)
2024-05-22 14:32:36 +03:00
Lasse Collin 57ad820e15 liblzma: Clean up white space
(cherry picked from commit ed8e552395)
2024-05-22 14:32:36 +03:00
Lasse Collin ba0b5bfe7c Tests: test_filter_flags: Edit comments and style
(cherry picked from commit 2f06920f20)
2024-05-22 14:32:36 +03:00
Lasse Collin d2ed675959 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.

(cherry picked from commit b101e1d1db)
2024-05-22 14:32:36 +03:00
Lasse Collin 9a70e93fef DOS: Omit useless defines from config.h
(cherry picked from commit f8f3a220ac)
2024-05-22 14:32:36 +03:00
Lasse Collin dc4740f720 Build: Omit useless checks for fcntl.h, limits.h, and sys/time.h
(cherry picked from commit fc1921b04b)
2024-05-22 14:32:36 +03:00
Lasse Collin 6e210d5766 liblzma: Silence a warning from Coverity static analysis
It is logical why it cannot know for sure that the value has
to be at most 4 if it is less than 16.

The x86 filter is based on a very old LZMA SDK version. Newer
ones have quite a different implementation for the same filter.

Thanks to Sam James.

(cherry picked from commit 6aa2a6deeb)
2024-05-22 14:32:36 +03:00
Lasse Collin 4019b012f2 Update .gitignore
(cherry picked from commit e89d3e83b4)
2024-05-22 14:32:36 +03:00
Lasse Collin 09a0311a1e Tests: test_lzip_decoder: Tweak coding style and comments
(cherry picked from commit 86fc4ee859)
2024-05-22 14:32:36 +03:00
Lasse Collin 3117336a02 Tests: test_lzip_decoder: Remove redundant initializations
(cherry picked from commit 38be573a27)
2024-05-22 14:32:36 +03:00
Lasse Collin f78081eb12 Tests: test_lzip_decoder: Remove unneeded tuktest_malloc() calls
(cherry picked from commit d7e4bc53ea)
2024-05-22 14:32:36 +03:00
Lasse Collin 7413383e42 xz: Fix white space error.
Thanks to xx on #tukaani.

(cherry picked from commit eeca8f7c5b)
2024-05-22 14:32:36 +03:00
Sam James eed2f26c0e xz: add missing noreturn for message_filters_help
Fixes: a165d7df19
(cherry picked from commit 462ca94099)
2024-05-22 14:32:36 +03:00
Sam James 2633d8df61 xz: signals: suppress -Wsign-conversion on macOS
On macOS, we get:
```
signals.c: In function 'signals_init':
signals.c:76:17: error: conversion to 'sigset_t' {aka 'unsigned int'} from 'int' may change the sign of the result [-Werror=sign-conversion]
   76 |                 sigaddset(&hooked_signals, sigs[i]);
      |                 ^~~~~~~~~
signals.c:81:17: error: conversion to 'sigset_t' {aka 'unsigned int'} from 'int' may change the sign of the result [-Werror=sign-conversion]
   81 |                 sigaddset(&hooked_signals, message_progress_sigs[i]);
      |                 ^~~~~~~~~
signals.c:86:9: error: conversion to 'sigset_t' {aka 'unsigned int'} from 'int' may change the sign of the result [-Werror=sign-conversion]
   86 |         sigaddset(&hooked_signals, SIGTSTP);
      |         ^~~~~~~~~
```

We use `int` for `hooked_signals` but we can't just cast to whatever
`sigset_t` is because `sigset_t` is an opaque type. It's an unsigned int
on macOS. On macOS, `sigaddset` is implemented as a macro.

Just suppress -Wsign-conversion for `signals_init` for macOS given
there's no real nice way of fixing this.

(cherry picked from commit 863f13d282)
2024-05-22 14:32:36 +03:00
Lasse Collin 50fb269c7a Tests: test_microlzma: Add a "FIXME?" about LZMA_FINISH handling
(cherry picked from commit fcbd0d1999)
2024-05-22 14:32:36 +03:00
Lasse Collin 3e2ff2d38c 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.

(cherry picked from commit 0fe2dfa683)
2024-05-22 14:32:36 +03:00
Ryan Carsten Schmidt ebc8b8de19 CI: Use only the active CPUs on macOS
hw.ncpu counts all CPUs including inactive ones. hw.activecpu counts
only the active CPUs.

(cherry picked from commit 97f0ee0f1f)
2024-05-22 14:26:59 +03:00
Sam James 1e63f7d536 ci: rename ci_build.sh -> ci_build.bash
We discussed the name and it's less cognitive load to just call it '.bash'
so you don't have an immediate question about if bashisms are OK.

(cherry picked from commit 73f629e321)
2024-05-22 14:26:59 +03:00
Sam James aea54a4724 ci: build in parallel by default
(cherry picked from commit 8709407a9e)
2024-05-22 14:26:59 +03:00
Sam James 4381fcf00b ci: default to -O2
We need this for when we're passing sanitizer flags or -gdwarf-4 for Clang
with Valgrind. Just always start with -O2 if CFLAGS isn't set in the
environment and append what was passed on the command line.

(cherry picked from commit 65bf7e0a1c)
2024-05-22 14:26:59 +03:00
Sam James 752ba5ed99 ci: make automake's test runner verbose on failures
This is a lot easier to work with than the save-logs thing the action
tries to do...

(cherry picked from commit bc899f9e07)
2024-05-22 14:26:59 +03:00
Sam James cc21af1715 ci: make UBSAN abort on errors
Unfortunately, UBSAN doesn't do this by default. See also the change
I made in Meson for this in October [0].

[0] 7b7d2e060b

(cherry picked from commit b5e3470442)
2024-05-22 14:26:59 +03:00
Sam James 2d2d5f14b3 ci: test Valgrind
Using `--trace-children=yes` has a trade-off here, as it makes
`test_scripts.sh` pretty slow when calling various non-xz utilities.

But I also feel like it's not useless to have Valgrind used there and it's
not easy to exclude Valgrind just for that one test...

I did consider using AX_VALGRIND_CHECK [0][1] but I couldn't get it working
immediately with some conditionally-built tests and I wondered if it was
worth spending time on at least while we're debating xz's future build
system situation.

[0] https://www.gnu.org/software/autoconf-archive/ax_valgrind_check.html
[1] https://tecnocode.co.uk/2014/12/23/automatically-valgrinding-code-with-ax_valgrind_check/

(cherry picked from commit 6c095a98fb)
2024-05-22 14:26:59 +03:00
Lasse Collin 5d20a61205 liblzma: CRC: Simplify table omission macros
A macro is useful to prevent a single #if directive from
getting too ugly but only one macro is needed for all archs.

(cherry picked from commit 6286c1900c)
2024-05-22 14:26:03 +03:00
Lasse Collin 2a80827e23 liblzma: ARM64 CRC: Fix omission of CRC32 table
The macro name had an odd typo so the table wasn't omitted
when it should have.

Fixes: 1940f0ec28
(cherry picked from commit 45da936c87)
2024-05-22 14:26:03 +03:00