append_filter: Verify that bidder and filter match
Make sure that appending a filter always matches its supposed bidder. Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
This commit is contained in:
1 parent
e893064acf
commit
bf1f5ba79e
3 files changed
+56
No files matched your search
@@ -404,6 +404,7 @@ libarchive_test_SOURCES= \
|
||||
libarchive/test/test_archive_pathmatch_oob.c \
|
||||
libarchive/test/test_archive_read.c \
|
||||
libarchive/test/test_archive_read_add_passphrase.c \
|
||||
libarchive/test/test_archive_read_append_filter.c \
|
||||
libarchive/test/test_archive_read_close_twice.c \
|
||||
libarchive/test/test_archive_read_multiple_data_objects.c \
|
||||
libarchive/test/test_archive_read_next_header_empty.c \
|
||||
|
||||
@@ -33,6 +33,7 @@ IF(ENABLE_TEST)
|
||||
test_archive_pathmatch_oob.c
|
||||
test_archive_read.c
|
||||
test_archive_read_add_passphrase.c
|
||||
test_archive_read_append_filter.c
|
||||
test_archive_read_close_twice.c
|
||||
test_archive_read_multiple_data_objects.c
|
||||
test_archive_read_next_header_empty.c
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
/*-
|
||||
* Copyright (c) 2026 Tobias Stoeckmann
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "archive.h"
|
||||
#include "test.h"
|
||||
|
||||
DEFINE_TEST(test_archive_read_append_filter)
|
||||
{
|
||||
struct archive *a;
|
||||
int r;
|
||||
|
||||
a = archive_read_new();
|
||||
assert(a != NULL);
|
||||
|
||||
/* Append a program bidder (without filter). */
|
||||
assertEqualIntA(a, ARCHIVE_OK,
|
||||
archive_read_support_filter_program(a, "prog1"));
|
||||
|
||||
/* Append a filter program which comes with its own bidder. */
|
||||
r = archive_read_append_filter_program(a, "prog2");
|
||||
|
||||
/* Verify that filter uses its own bidder. */
|
||||
if (r == ARCHIVE_FATAL) {
|
||||
assertEqualStringA(a, "Can't initialize filter; unable to run program \"prog2\"",
|
||||
archive_error_string(a));
|
||||
} else {
|
||||
assertEqualIntA(a, ARCHIVE_OK, r);
|
||||
assertEqualStringA(a, "Program: prog2", archive_filter_name(a, 0));
|
||||
}
|
||||
|
||||
archive_read_free(a);
|
||||
}
|
||||
Reference in new issue
Block a user