60 Commits
Author SHA1 Message Date
Tim Kientzle f833d13e6d Fix CMake-based testing 2026-05-06 22:02:15 -07:00
Tim Kientzle 2f5ed45e4c [CMake] Automatically update list.h
`list.h` contains a list of all the tests and is generated
by grepping the test source files for `DEFINE_TEST`.
Previously, it was generated at configure time.
This meant that if you added a new test to an existing
source file, you had to manually reconfigure.

This adds the necessary dependencies so that `list.h`
is regenerated whenever any C test source changes.
This ensures that new tests are always discovered automatically.

Note:  If someone wants to update the autoconf-based
build system to do this, please send a PR.
2026-05-05 20:54:12 -07:00
Tim Kientzle 96f76577d3 Rename err.h to avoid conflict with system header
Depending on header search path ordering, we can easily
confuse libarchive_fe/err.h with the system header.
Rename ours to lafe_err.h to avoid the confusion.
Rename libarchive_fe/err.c to match.
2025-09-13 12:30:03 -07:00
Tobias Stoeckmann 36bac92cd2 tools: Enforce default handling of SIGCHLD
Ignoring SIGCHLD gets passed to child processes. Doing that has
influence on waitpid, namely that zombie processes won't be
created. This means that a status can never be read.

We can't enforce this in library, but libarchive's tools can be
protected against this by enforcing default handling.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2025-06-02 23:29:49 +02:00
Zeun 4ebca5ff83 Fix -Werror=warning error and wrap some INSTALL directives with an ENABLE_INSTALL guard (#2397)
1. Fixes build when compiling without ZLIB/BZIP/LZMA `char finishing`
2. All INSTALL directives are now guarded by ENABLE_INSTALL
2024-12-27 12:53:13 -08:00
Mostyn Bramley-Moore 8ac45a813e Report skipped tests to cmake/ctest (#2429)
This plumbing is required for cmake/ctest to recognise and report
skipped tests.

Now skipped tests in cmake ci jobs are reported like so:
```
          Start   7: libarchive_test_acl_platform_posix1e_read
    7/785 Test   #7: libarchive_test_acl_platform_posix1e_read ................................***Skipped   0.02 sec
```

And there is a list of skipped tests shown at the end of the test run.
2024-12-08 18:07:49 -08:00
Emil Velikov 6287b99eb7 Convert the tools and respective tests to SPDX (#2317)
This is the first part of converting the project to use SPDX license
identifiers instead using the verbose license text.

The patches are semi-automated and I've went through manually to ensure
no license changes were made. That said, I would welcome another pair of
eyes, since I am only human.

See https://github.com/libarchive/libarchive/issues/2298

---------

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
2024-10-12 20:54:16 -07:00
Emil Velikov 8137ba17b6 cat: squash s/it/is/ typo (#2292)
Closes: https://github.com/libarchive/libarchive/issues/2128

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
2024-08-31 11:24:18 +02:00
Tobias Stoeckmann bd974e1b7b tools: Fix stack overflow with many arguments (#2122)
Supplying a lot of "-" arguments to tools can lead to stack overflow due
to recursive *_getopt function calls.

Proof of Concept:

1. Compile libarchive with Visual Studio 2022
2. Call bsdtar with insane amount of arguments
```
PS> bsdtar.exe ("- "*10000).split(" ")
```
The event log shows that bsdtar.exe failed with `0xc00000fd` (stack
overflow).

If compiled with gcc, this does not happen by default because the code
is internally optimized to use this suggested loop instead. You have to
compile with CFLAGS="-O0" to provoke it with gcc as well.
2024-04-12 22:15:53 -07:00
Emil Velikov d5713db2d4 Minor __LA_NORETURN inspired fixes (#2028)
Earlier MR https://github.com/libarchive/libarchive/pull/2000 forgot to
annotate some functions as __LA_NORETURN. While fixing that I've noticed
that the bsdcat.h header could use some fixes so I've snuck those in.

Kind of make sense to group in one PR, but can split people prefer so.

/cc @AtariDreams fyi

---------

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
2023-12-07 19:22:27 -08:00
AtariDreams 616c7dca2b Replace __LA_DEAD with __LA_NORETURN (#2000)
Also add the MSC_VER version of the macro.
2023-12-04 08:29:29 -08:00
Brooks Davis 7dde502899 VCSid removal (#2017)
The libarchive source tree is littered with `__FBSDID("$FreeBSD.*")` and
'$FreeBSD$' tags left over from extracting it from FreeBSD's Subversion
repo. They never made sense for a git repo as git doesn't expand them
and FreeBSD has now removed `$FreeBSD$` from most local source files so
these stand out.

In addition to `__FBSDID` I've removed `__RCSID` which was used once for
a `$NetBSD$` expansion. There might be more of a case to be made for
preserving this one as a diff-reduction measure, but it seems mostly
pointless.

This builds and tests pass except for
libarchive_test_read_disk_directory_traversals which failed on master as
well.
2023-11-20 17:41:49 -08:00
Martin Matuska 46063a5009 cat: fix references and variable names in cmdline.c 2023-07-30 23:27:45 +02:00
zoulasc 343642bcd2 Add printf attributes to the printflike functions used in tests and fix
the format errors.

Closes #1318
2020-01-23 00:19:32 +01:00
Martin Matuska bdea136855 Unify header style, header guard comes first
Found by LGTM.com code analysis
2020-01-13 13:42:41 +01:00
Ingo Schwarze 79d841ff93 Minor corrections to the formatting of manual page.
Found with mandoc -Tlint; fixing the following messages:

WARNING: bad NAME section content
WARNING: missing comma before name
WARNING: new sentence, new line
WARNING: parenthesis in function name
WARNING: skipping no-space macro
WARNING: skipping paragraph macro
WARNING: unusual Xr order
WARNING: unusual Xr punctuation
STYLE: no blank before trailing delimiter
STYLE: possible typo in section name
STYLE: trailing delimiter
STYLE: whitespace at end of input line

For the meaning of the messages, see:
https://man.openbsd.org/mandoc#DIAGNOSTICS
2019-09-21 09:23:10 +02:00
BenjaminTrapani 951010a2ec Add space after version to fix all unit tests besides sparse tests 2018-01-20 10:15:40 -05:00
Joerg Sonnenberger 0bec66ba5e Fix archive freeing bug in bsdcat.
(1) Do not double free a for the stdin case. Reported by Sean Purcell in
    PR #904.
(2) Do not query errors after archive_read_free either, the memory is
    gone. Split operation into close and read, reporting errors from the
    former.
2017-10-07 02:33:16 +02:00
Sean Purcell cd63bdcda5 Fix alphabetical order, other small fixes 2017-05-15 23:06:49 -04:00
Sean Purcell 0f6b9d7a70 Add zstd test suite 2017-05-15 23:06:48 -04:00
Martin Matuska bea9f9cf03 Add NFSv4 ACL support for Linux via librichacl
Richacls are interpreted as NFSv4 ACLs and stored in archive_acl (Richacl
flags and masks are not stored). Analog to mac_metadata, NFSv4 ACLs do not
get extracted when the extraction of extended attributes is enabled and the
"trusted.richacl" extended attribute is present.

RichACL masks and are calculated from file mode on extraction.

mac_metadata acl check has been moved in the code to be together with the
richacl check.
2017-03-16 11:39:08 +01:00
Martin Matuska f5d473ed0b New tar test: test_option_acls
Add sunacl_get() and setTestAcl() to common test code
Test for membership.h on Mac OS X and make it a requirement for ACLs
2017-03-02 16:10:26 +01:00
Martin Matuska 52d5a14c21 test suite: use a single main test file for all tests 2017-02-21 21:10:49 +01:00
Pavel Raiskup 47ac1b5306 testsuite: allow 'dev' in version 2017-02-21 06:16:13 +01:00
Joerg Sonnenberger 72c12f3f63 Explicitly free archive to reduce valgrind noise. 2016-12-06 15:23:26 +01:00
Graham Percival 17feb73ffc Spelling fixes (#831)
Sponsored by:	Tarsnap Backup Inc.
2016-12-04 00:00:40 +01:00
Tim Kientzle a7e130aa32 Make test output more verbose on Windows 2016-10-23 16:23:04 -07:00
Tim Kientzle b960225b84 Sync up the test harnesses, fix an "unused var" warning on Windows 2016-10-23 15:21:59 -07:00
Graham Percival 2623110256 Add chmod() after make_{dir,file} in test suites
This is the same change that
    38b3f516df
made to
    libarchive/test/main.c
, but now applied to:
    cat/test/main.c
    cpio/test/main.c
    tar/test/main.c

Sponsored by:	Tarsnap Backup Inc.
2016-09-26 12:50:29 -07:00
Graham Percival 0f14b0816b Add and use assertion_file_mode() in other tests
This adds the assertion_file_mode() function from
    libarchive/test/main.c
and applies it to
    cat/test/main.c
    cpio/test/main.c
    tar/test/main.c

Sponsored by:	Tarsnap Backup Inc.
2016-09-26 12:44:56 -07:00
Tim Kientzle daf8a7bb54 Issue 720: Allow dashes in third-party version numbers 2016-07-20 20:27:45 -07:00
Tim Kientzle 83c3e2e675 Issue 657: Allow up to 8k for the test root directory name 2016-06-02 20:17:13 -07:00
Martin Matuska 85f740c233 cat: declare static variables and fix several compiler warnings 2016-05-11 23:44:33 +02:00
Tim Kientzle 98ab8fb22a Sync up test harnesses 2016-04-29 21:49:34 -07:00
Tim Kientzle ebc67c17de Issue 695: check fwrite return value, sync up test harnesses 2016-04-28 19:44:20 -07:00
Tim Kientzle fbfe30450e Accomodate different return codes on Windows 2016-04-24 20:35:45 -07:00
Tim Kientzle 86adcf859b Bring along a trailing null when guessing the path to the program under test 2016-01-31 12:24:45 -08:00
Tim Kientzle 3526db62f4 Really sync up the test harnesses 2016-01-28 21:33:53 -08:00
Tim Kientzle 586c1f4bbb Fix two broken UU files 2016-01-28 21:25:42 -08:00
Tim Kientzle 02e017d635 Sync up the test harnesses; add error checks to the UUdecode utility 2016-01-28 21:25:25 -08:00
Hans Hinrichsen 36b7014b20 Visual Studio 2015 Changes
snprintf shouldn't be defined in a macro in VS2015 and above due to its C99 changes
2016-01-13 22:26:34 -06:00
Michihiro NAKAJIMA c62d30e5fa Avoid CMake Warning that used GET_TARGET_PROPERTY with LOCATION property,
so we should use $<TARGET_FILE> expression instead.
2014-10-13 22:02:39 +09:00
Michihiro NAKAJIMA f966682a86 Fix style. 2014-10-12 14:36:28 +09:00
Michihiro NAKAJIMA 15bcb67859 Fix build failure on Windows.
- Visual Studio does not provide unistd.h
 - Visual Studio does not provide getopt
 - Increase portability
2014-10-12 14:10:45 +09:00
Xiao-Long Chen 5432e578ac Fix incorrect CMake test directory when building as a subproject
This is an extension of e800985adb
2014-09-16 00:11:20 -04:00
Michihiro NAKAJIMA aecd3a2c3f Add additional tests for lz4 compression in front-end applications. 2014-08-18 23:42:06 +09:00
Michihiro NAKAJIMA f6b202b6e7 Add lz4 test for bsdcat.
- add test utility function canLz4()
 - fix test_write_filter_lz4 to use canLz4()
2014-08-18 22:07:48 +09:00
Sebastian Freundt 96e57afe1f Allow empty files (after filters) in bsdcat command.
This changeset fixes an issue with empty compressed files, i.e.
files that after inflating are of size 0:  bsdcat would report
unrecognized archive format for those because the raw reader is
unable to handle files of zero length.
2014-08-13 07:05:12 +00:00
Sebastian Freundt 850c3c8d37 Provide regression test case for bsdcat on empty compressed files 2014-08-12 15:26:24 +00:00
Michihiro NAKAJIMA 41c37ee3fc Add a test utility function, copy_reference_file simply coping
a sample file to the current directory of a running test.
A uudecode filter test will use it for its new test.

TODO: make a symbolic link file insted of copying a sample file.
Historically, libarchive cannot handle uuencoded files when
libarchive's test suit was made. Now libarchive can handle it
directly by uudecode filter, I think, we can reduce copying
sample files to the directory test program expects they are
on an isolated directory for their test.
2014-06-29 16:12:34 +09:00