Merge pull request #3207 from datauwu/tests-merge-fix-typo
tests: merge tests and fix misleading labels
(cherry picked from commit f59675ccff)
This commit is contained in:
1 parent
1bd53b6538
commit
dedf6d53d9
19 files changed
+325
-549
No files matched your search
+5
-13
@@ -404,15 +404,10 @@ libarchive_test_SOURCES= \
|
||||
libarchive/test/test_archive_read.c \
|
||||
libarchive/test/test_archive_read_add_passphrase.c \
|
||||
libarchive/test/test_archive_read_close_twice.c \
|
||||
libarchive/test/test_archive_read_close_twice_open_fd.c \
|
||||
libarchive/test/test_archive_read_close_twice_open_filename.c \
|
||||
libarchive/test/test_archive_read_multiple_data_objects.c \
|
||||
libarchive/test/test_archive_read_next_header_empty.c \
|
||||
libarchive/test/test_archive_read_next_header_raw.c \
|
||||
libarchive/test/test_archive_read_open2.c \
|
||||
libarchive/test/test_archive_read_set_filter_option.c \
|
||||
libarchive/test/test_archive_read_set_format_option.c \
|
||||
libarchive/test/test_archive_read_set_option.c \
|
||||
libarchive/test/test_archive_read_set_options.c \
|
||||
libarchive/test/test_archive_read_support.c \
|
||||
libarchive/test/test_archive_set_error.c \
|
||||
@@ -420,11 +415,8 @@ libarchive_test_SOURCES= \
|
||||
libarchive/test/test_archive_string_conversion.c \
|
||||
libarchive/test/test_archive_write_add_filter.c \
|
||||
libarchive/test/test_archive_write_add_filter_by_name.c \
|
||||
libarchive/test/test_archive_write_set_filter_option.c \
|
||||
libarchive/test/test_archive_write_set_format_by_name.c \
|
||||
libarchive/test/test_archive_write_set_format_filter_by_ext.c \
|
||||
libarchive/test/test_archive_write_set_format_option.c \
|
||||
libarchive/test/test_archive_write_set_option.c \
|
||||
libarchive/test/test_archive_write_set_options.c \
|
||||
libarchive/test/test_archive_write_set_passphrase.c \
|
||||
libarchive/test/test_bad_fd.c \
|
||||
@@ -527,16 +519,16 @@ libarchive_test_SOURCES= \
|
||||
libarchive/test/test_read_format_iso_joliet_utf16be_overflow.c \
|
||||
libarchive/test/test_read_format_iso_multi_extent.c \
|
||||
libarchive/test/test_read_format_iso_xorriso.c \
|
||||
libarchive/test/test_read_format_isojoliet_bz2.c \
|
||||
libarchive/test/test_read_format_isojoliet_compress.c \
|
||||
libarchive/test/test_read_format_isojoliet_long.c \
|
||||
libarchive/test/test_read_format_isojoliet_rr.c \
|
||||
libarchive/test/test_read_format_isojoliet_versioned.c \
|
||||
libarchive/test/test_read_format_isorr_bz2.c \
|
||||
libarchive/test/test_read_format_isorr_compress.c \
|
||||
libarchive/test/test_read_format_isorr_ce.c \
|
||||
libarchive/test/test_read_format_isorr_ce_loop.c \
|
||||
libarchive/test/test_read_format_isorr_new_bz2.c \
|
||||
libarchive/test/test_read_format_isorr_new_compress.c \
|
||||
libarchive/test/test_read_format_isorr_rr_moved.c \
|
||||
libarchive/test/test_read_format_isozisofs_bz2.c \
|
||||
libarchive/test/test_read_format_isozisofs_compress.c \
|
||||
libarchive/test/test_read_format_iso_rockridge_zf_overflow.c \
|
||||
libarchive/test/test_read_format_iso_zisofs_overflow.c \
|
||||
libarchive/test/test_read_format_lha.c \
|
||||
@@ -710,7 +702,7 @@ libarchive_test_SOURCES= \
|
||||
libarchive/test/test_write_format_zip_compression_store.c \
|
||||
libarchive/test/test_write_format_zip_compression_zstd.c \
|
||||
libarchive/test/test_write_format_zip_compression_bzip2.c \
|
||||
libarchive/test/test_write_format_zip_compression_lzmaxz.c \
|
||||
libarchive/test/test_write_format_zip_compression_lzma_xz.c \
|
||||
libarchive/test/test_write_format_zip_empty.c \
|
||||
libarchive/test/test_write_format_zip_empty_pathname.c \
|
||||
libarchive/test/test_write_format_zip_empty_zip64.c \
|
||||
|
||||
@@ -33,15 +33,10 @@ IF(ENABLE_TEST)
|
||||
test_archive_read.c
|
||||
test_archive_read_add_passphrase.c
|
||||
test_archive_read_close_twice.c
|
||||
test_archive_read_close_twice_open_fd.c
|
||||
test_archive_read_close_twice_open_filename.c
|
||||
test_archive_read_multiple_data_objects.c
|
||||
test_archive_read_next_header_empty.c
|
||||
test_archive_read_next_header_raw.c
|
||||
test_archive_read_open2.c
|
||||
test_archive_read_set_filter_option.c
|
||||
test_archive_read_set_format_option.c
|
||||
test_archive_read_set_option.c
|
||||
test_archive_read_set_options.c
|
||||
test_archive_read_support.c
|
||||
test_archive_set_error.c
|
||||
@@ -49,11 +44,8 @@ IF(ENABLE_TEST)
|
||||
test_archive_string_conversion.c
|
||||
test_archive_write_add_filter.c
|
||||
test_archive_write_add_filter_by_name.c
|
||||
test_archive_write_set_filter_option.c
|
||||
test_archive_write_set_format_by_name.c
|
||||
test_archive_write_set_format_filter_by_ext.c
|
||||
test_archive_write_set_format_option.c
|
||||
test_archive_write_set_option.c
|
||||
test_archive_write_set_options.c
|
||||
test_archive_write_set_passphrase.c
|
||||
test_bad_fd.c
|
||||
@@ -156,16 +148,16 @@ IF(ENABLE_TEST)
|
||||
test_read_format_iso_joliet_utf16be_overflow.c
|
||||
test_read_format_iso_multi_extent.c
|
||||
test_read_format_iso_xorriso.c
|
||||
test_read_format_isojoliet_bz2.c
|
||||
test_read_format_isojoliet_compress.c
|
||||
test_read_format_isojoliet_long.c
|
||||
test_read_format_isojoliet_rr.c
|
||||
test_read_format_isojoliet_versioned.c
|
||||
test_read_format_isorr_bz2.c
|
||||
test_read_format_isorr_compress.c
|
||||
test_read_format_isorr_ce.c
|
||||
test_read_format_isorr_ce_loop.c
|
||||
test_read_format_isorr_new_bz2.c
|
||||
test_read_format_isorr_new_compress.c
|
||||
test_read_format_isorr_rr_moved.c
|
||||
test_read_format_isozisofs_bz2.c
|
||||
test_read_format_isozisofs_compress.c
|
||||
test_read_format_iso_rockridge_zf_overflow.c
|
||||
test_read_format_iso_zisofs_overflow.c
|
||||
test_read_format_lha.c
|
||||
@@ -338,7 +330,7 @@ IF(ENABLE_TEST)
|
||||
test_write_format_zip64_stream.c
|
||||
test_write_format_zip_compression_store.c
|
||||
test_write_format_zip_compression_bzip2.c
|
||||
test_write_format_zip_compression_lzmaxz.c
|
||||
test_write_format_zip_compression_lzma_xz.c
|
||||
test_write_format_zip_compression_zstd.c
|
||||
test_write_format_zip_empty.c
|
||||
test_write_format_zip_empty_pathname.c
|
||||
|
||||
@@ -39,3 +39,45 @@ DEFINE_TEST(test_archive_read_close_twice)
|
||||
|
||||
archive_read_free(a);
|
||||
}
|
||||
|
||||
DEFINE_TEST(test_archive_read_close_twice_open_fd)
|
||||
{
|
||||
struct archive* a = archive_read_new();
|
||||
|
||||
assertEqualInt(ARCHIVE_OK, archive_read_support_format_empty(a));
|
||||
assertEqualInt(ARCHIVE_OK, archive_read_open_fd(a, 0, 0));
|
||||
assertEqualInt(0, archive_errno(a));
|
||||
assertEqualString(NULL, archive_error_string(a));
|
||||
|
||||
assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
|
||||
assertEqualInt(0, archive_errno(a));
|
||||
assertEqualString(NULL, archive_error_string(a));
|
||||
|
||||
assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
|
||||
assertEqualInt(0, archive_errno(a));
|
||||
assertEqualString(NULL, archive_error_string(a));
|
||||
|
||||
assertEqualInt(ARCHIVE_OK, archive_read_free(a));
|
||||
}
|
||||
|
||||
DEFINE_TEST(test_archive_read_close_twice_open_filename)
|
||||
{
|
||||
const char *filename = "empty.file";
|
||||
struct archive* a = archive_read_new();
|
||||
|
||||
assertMakeFile(filename, 0644, "");
|
||||
assertEqualInt(ARCHIVE_OK, archive_read_support_format_empty(a));
|
||||
assertEqualInt(ARCHIVE_OK, archive_read_open_filename(a, filename, 0));
|
||||
assertEqualInt(0, archive_errno(a));
|
||||
assertEqualString(NULL, archive_error_string(a));
|
||||
|
||||
assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
|
||||
assertEqualInt(0, archive_errno(a));
|
||||
assertEqualString(NULL, archive_error_string(a));
|
||||
|
||||
assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
|
||||
assertEqualInt(0, archive_errno(a));
|
||||
assertEqualString(NULL, archive_error_string(a));
|
||||
|
||||
assertEqualInt(ARCHIVE_OK, archive_read_free(a));
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
/*-
|
||||
* Copyright (c) 2011 Tim Kientzle
|
||||
* 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 "test.h"
|
||||
|
||||
DEFINE_TEST(test_archive_read_close_twice_open_fd)
|
||||
{
|
||||
struct archive* a = archive_read_new();
|
||||
|
||||
assertEqualInt(ARCHIVE_OK, archive_read_support_format_empty(a));
|
||||
assertEqualInt(ARCHIVE_OK, archive_read_open_fd(a, 0, 0));
|
||||
assertEqualInt(0, archive_errno(a));
|
||||
assertEqualString(NULL, archive_error_string(a));
|
||||
|
||||
assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
|
||||
assertEqualInt(0, archive_errno(a));
|
||||
assertEqualString(NULL, archive_error_string(a));
|
||||
|
||||
assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
|
||||
assertEqualInt(0, archive_errno(a));
|
||||
assertEqualString(NULL, archive_error_string(a));
|
||||
|
||||
assertEqualInt(ARCHIVE_OK, archive_read_free(a));
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
/*-
|
||||
* Copyright (c) 2011 Tim Kientzle
|
||||
* 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 "test.h"
|
||||
|
||||
DEFINE_TEST(test_archive_read_close_twice_open_filename)
|
||||
{
|
||||
const char *filename = "empty.file";
|
||||
struct archive* a = archive_read_new();
|
||||
|
||||
assertMakeFile(filename, 0644, "");
|
||||
assertEqualInt(ARCHIVE_OK, archive_read_support_format_empty(a));
|
||||
assertEqualInt(ARCHIVE_OK, archive_read_open_filename(a, filename, 0));
|
||||
assertEqualInt(0, archive_errno(a));
|
||||
assertEqualString(NULL, archive_error_string(a));
|
||||
|
||||
assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
|
||||
assertEqualInt(0, archive_errno(a));
|
||||
assertEqualString(NULL, archive_error_string(a));
|
||||
|
||||
assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
|
||||
assertEqualInt(0, archive_errno(a));
|
||||
assertEqualString(NULL, archive_error_string(a));
|
||||
|
||||
assertEqualInt(ARCHIVE_OK, archive_read_free(a));
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
/*-
|
||||
* Copyright (c) 2011 Tim Kientzle
|
||||
* 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 "test.h"
|
||||
|
||||
#define should(__a, __code, __m, __o, __v) \
|
||||
assertEqualInt(__code, archive_read_set_filter_option(__a, __m, __o, __v))
|
||||
|
||||
static void
|
||||
test(int pristine)
|
||||
{
|
||||
struct archive* a = archive_read_new();
|
||||
|
||||
if (!pristine)
|
||||
archive_read_support_filter_all(a);
|
||||
|
||||
should(a, ARCHIVE_OK, NULL, NULL, NULL);
|
||||
should(a, ARCHIVE_OK, "", "", "");
|
||||
|
||||
should(a, ARCHIVE_FAILED, NULL, "fubar", NULL);
|
||||
should(a, ARCHIVE_FAILED, NULL, "fubar", "snafu");
|
||||
should(a, ARCHIVE_FAILED, "fubar", "snafu", NULL);
|
||||
should(a, ARCHIVE_FAILED, "fubar", "snafu", "betcha");
|
||||
|
||||
archive_read_free(a);
|
||||
}
|
||||
|
||||
DEFINE_TEST(test_archive_read_set_filter_option)
|
||||
{
|
||||
test(1);
|
||||
test(0);
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
/*-
|
||||
* Copyright (c) 2011 Tim Kientzle
|
||||
* 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 "test.h"
|
||||
|
||||
#define should(__a, __code, __m, __o, __v) \
|
||||
assertEqualInt(__code, archive_read_set_format_option(__a, __m, __o, __v))
|
||||
|
||||
static void
|
||||
test(int pristine)
|
||||
{
|
||||
struct archive* a = archive_read_new();
|
||||
int known_option_rv = pristine ? ARCHIVE_FAILED : ARCHIVE_OK;
|
||||
|
||||
if (!pristine)
|
||||
archive_read_support_format_all(a);
|
||||
|
||||
/* NULL and "" denote `no option', so they're ok no matter
|
||||
* what, if any, formats are registered */
|
||||
should(a, ARCHIVE_OK, NULL, NULL, NULL);
|
||||
should(a, ARCHIVE_OK, "", "", "");
|
||||
|
||||
/* unknown modules and options */
|
||||
should(a, ARCHIVE_FAILED, "fubar", "snafu", NULL);
|
||||
should(a, ARCHIVE_FAILED, "fubar", "snafu", "betcha");
|
||||
|
||||
/* unknown modules and options */
|
||||
should(a, ARCHIVE_FAILED, NULL, "snafu", NULL);
|
||||
should(a, ARCHIVE_FAILED, NULL, "snafu", "betcha");
|
||||
|
||||
/* ARCHIVE_OK with iso9660 loaded, ARCHIVE_WARN otherwise */
|
||||
should(a, known_option_rv, "iso9660", "joliet", NULL);
|
||||
should(a, known_option_rv, "iso9660", "joliet", NULL);
|
||||
should(a, known_option_rv, NULL, "joliet", NULL);
|
||||
should(a, known_option_rv, NULL, "joliet", NULL);
|
||||
|
||||
archive_read_free(a);
|
||||
}
|
||||
|
||||
DEFINE_TEST(test_archive_read_set_format_option)
|
||||
{
|
||||
test(1);
|
||||
test(0);
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
/*-
|
||||
* Copyright (c) 2011 Tim Kientzle
|
||||
* 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 "test.h"
|
||||
|
||||
#define should(__a, __code, __m, __o, __v) \
|
||||
assertEqualInt(__code, archive_read_set_option(__a, __m, __o, __v))
|
||||
|
||||
static void
|
||||
test(int pristine)
|
||||
{
|
||||
struct archive* a = archive_read_new();
|
||||
int known_option_rv = pristine ? ARCHIVE_FAILED : ARCHIVE_OK;
|
||||
|
||||
if (!pristine) {
|
||||
archive_read_support_filter_all(a);
|
||||
archive_read_support_format_all(a);
|
||||
}
|
||||
|
||||
/* NULL and "" denote `no option', so they're ok no matter
|
||||
* what, if any, formats are registered */
|
||||
should(a, ARCHIVE_OK, NULL, NULL, NULL);
|
||||
should(a, ARCHIVE_OK, "", "", "");
|
||||
|
||||
/* unknown modules and options */
|
||||
should(a, ARCHIVE_FAILED, "fubar", "snafu", NULL);
|
||||
should(a, ARCHIVE_FAILED, "fubar", "snafu", "betcha");
|
||||
|
||||
/* unknown modules and options */
|
||||
should(a, ARCHIVE_FAILED, NULL, "snafu", NULL);
|
||||
should(a, ARCHIVE_FAILED, NULL, "snafu", "betcha");
|
||||
|
||||
/* ARCHIVE_OK with iso9660 loaded, ARCHIVE_WARN otherwise */
|
||||
should(a, known_option_rv, "iso9660", "joliet", NULL);
|
||||
should(a, known_option_rv, "iso9660", "joliet", NULL);
|
||||
should(a, known_option_rv, NULL, "joliet", NULL);
|
||||
should(a, known_option_rv, NULL, "joliet", NULL);
|
||||
|
||||
archive_read_free(a);
|
||||
}
|
||||
|
||||
DEFINE_TEST(test_archive_read_set_option)
|
||||
{
|
||||
test(1);
|
||||
test(0);
|
||||
}
|
||||
@@ -25,11 +25,121 @@
|
||||
|
||||
#include "test.h"
|
||||
|
||||
#define should(__a, __code, __opts) \
|
||||
#define should_read_set_filter_option(__a, __code, __m, __o, __v) \
|
||||
assertEqualInt(__code, archive_read_set_filter_option(__a, __m, __o, __v))
|
||||
|
||||
static void
|
||||
read_set_filter_option_test(int pristine)
|
||||
{
|
||||
struct archive* a = archive_read_new();
|
||||
|
||||
if (!pristine)
|
||||
archive_read_support_filter_all(a);
|
||||
|
||||
should_read_set_filter_option(a, ARCHIVE_OK, NULL, NULL, NULL);
|
||||
should_read_set_filter_option(a, ARCHIVE_OK, "", "", "");
|
||||
|
||||
should_read_set_filter_option(a, ARCHIVE_FAILED, NULL, "fubar", NULL);
|
||||
should_read_set_filter_option(a, ARCHIVE_FAILED, NULL, "fubar", "snafu");
|
||||
should_read_set_filter_option(a, ARCHIVE_FAILED, "fubar", "snafu", NULL);
|
||||
should_read_set_filter_option(a, ARCHIVE_FAILED, "fubar", "snafu", "betcha");
|
||||
|
||||
archive_read_free(a);
|
||||
}
|
||||
|
||||
DEFINE_TEST(test_archive_read_set_filter_option)
|
||||
{
|
||||
read_set_filter_option_test(1);
|
||||
read_set_filter_option_test(0);
|
||||
}
|
||||
|
||||
#define should_read_set_format_option(__a, __code, __m, __o, __v) \
|
||||
assertEqualInt(__code, archive_read_set_format_option(__a, __m, __o, __v))
|
||||
|
||||
static void
|
||||
read_set_format_option_test(int pristine)
|
||||
{
|
||||
struct archive* a = archive_read_new();
|
||||
int known_option_rv = pristine ? ARCHIVE_FAILED : ARCHIVE_OK;
|
||||
|
||||
if (!pristine)
|
||||
archive_read_support_format_all(a);
|
||||
|
||||
/* NULL and "" denote `no option', so they're ok no matter
|
||||
* what, if any, formats are registered */
|
||||
should_read_set_format_option(a, ARCHIVE_OK, NULL, NULL, NULL);
|
||||
should_read_set_format_option(a, ARCHIVE_OK, "", "", "");
|
||||
|
||||
/* unknown modules and options */
|
||||
should_read_set_format_option(a, ARCHIVE_FAILED, "fubar", "snafu", NULL);
|
||||
should_read_set_format_option(a, ARCHIVE_FAILED, "fubar", "snafu", "betcha");
|
||||
|
||||
/* unknown modules and options */
|
||||
should_read_set_format_option(a, ARCHIVE_FAILED, NULL, "snafu", NULL);
|
||||
should_read_set_format_option(a, ARCHIVE_FAILED, NULL, "snafu", "betcha");
|
||||
|
||||
/* ARCHIVE_OK with iso9660 loaded, ARCHIVE_WARN otherwise */
|
||||
should_read_set_format_option(a, known_option_rv, "iso9660", "joliet", NULL);
|
||||
should_read_set_format_option(a, known_option_rv, "iso9660", "joliet", NULL);
|
||||
should_read_set_format_option(a, known_option_rv, NULL, "joliet", NULL);
|
||||
should_read_set_format_option(a, known_option_rv, NULL, "joliet", NULL);
|
||||
|
||||
archive_read_free(a);
|
||||
}
|
||||
|
||||
DEFINE_TEST(test_archive_read_set_format_option)
|
||||
{
|
||||
read_set_format_option_test(1);
|
||||
read_set_format_option_test(0);
|
||||
}
|
||||
|
||||
#define should_read_set_option(__a, __code, __m, __o, __v) \
|
||||
assertEqualInt(__code, archive_read_set_option(__a, __m, __o, __v))
|
||||
|
||||
static void
|
||||
read_set_option_test(int pristine)
|
||||
{
|
||||
struct archive* a = archive_read_new();
|
||||
int known_option_rv = pristine ? ARCHIVE_FAILED : ARCHIVE_OK;
|
||||
|
||||
if (!pristine) {
|
||||
archive_read_support_filter_all(a);
|
||||
archive_read_support_format_all(a);
|
||||
}
|
||||
|
||||
/* NULL and "" denote `no option', so they're ok no matter
|
||||
* what, if any, formats are registered */
|
||||
should_read_set_option(a, ARCHIVE_OK, NULL, NULL, NULL);
|
||||
should_read_set_option(a, ARCHIVE_OK, "", "", "");
|
||||
|
||||
/* unknown modules and options */
|
||||
should_read_set_option(a, ARCHIVE_FAILED, "fubar", "snafu", NULL);
|
||||
should_read_set_option(a, ARCHIVE_FAILED, "fubar", "snafu", "betcha");
|
||||
|
||||
/* unknown modules and options */
|
||||
should_read_set_option(a, ARCHIVE_FAILED, NULL, "snafu", NULL);
|
||||
should_read_set_option(a, ARCHIVE_FAILED, NULL, "snafu", "betcha");
|
||||
|
||||
/* ARCHIVE_OK with iso9660 loaded, ARCHIVE_WARN otherwise */
|
||||
should_read_set_option(a, known_option_rv, "iso9660", "joliet", NULL);
|
||||
should_read_set_option(a, known_option_rv, "iso9660", "joliet", NULL);
|
||||
should_read_set_option(a, known_option_rv, NULL, "joliet", NULL);
|
||||
should_read_set_option(a, known_option_rv, NULL, "joliet", NULL);
|
||||
|
||||
archive_read_free(a);
|
||||
}
|
||||
|
||||
DEFINE_TEST(test_archive_read_set_option)
|
||||
{
|
||||
read_set_option_test(1);
|
||||
read_set_option_test(0);
|
||||
}
|
||||
|
||||
#define should_read_set_options(__a, __code, __opts) \
|
||||
assertEqualInt(__code, archive_read_set_options(__a, __opts))
|
||||
|
||||
static void
|
||||
test(int pristine)
|
||||
read_set_options_test(int pristine)
|
||||
{
|
||||
struct archive* a = archive_read_new();
|
||||
int halfempty_options_rv = pristine ? ARCHIVE_FAILED : ARCHIVE_OK;
|
||||
@@ -42,62 +152,62 @@ test(int pristine)
|
||||
|
||||
/* NULL and "" denote `no option', so they're ok no matter
|
||||
* what, if any, formats are registered */
|
||||
should(a, ARCHIVE_OK, NULL);
|
||||
should(a, ARCHIVE_OK, "");
|
||||
should_read_set_options(a, ARCHIVE_OK, NULL);
|
||||
should_read_set_options(a, ARCHIVE_OK, "");
|
||||
|
||||
/* unknown modules and options */
|
||||
should(a, ARCHIVE_FAILED, "fubar:snafu");
|
||||
should_read_set_options(a, ARCHIVE_FAILED, "fubar:snafu");
|
||||
assertEqualString("Unknown module name: `fubar'",
|
||||
archive_error_string(a));
|
||||
should(a, ARCHIVE_FAILED, "fubar:snafu=betcha");
|
||||
should_read_set_options(a, ARCHIVE_FAILED, "fubar:snafu=betcha");
|
||||
assertEqualString("Unknown module name: `fubar'",
|
||||
archive_error_string(a));
|
||||
|
||||
/* unknown modules and options */
|
||||
should(a, ARCHIVE_FAILED, "snafu");
|
||||
should_read_set_options(a, ARCHIVE_FAILED, "snafu");
|
||||
assertEqualString("Undefined option: `snafu'",
|
||||
archive_error_string(a));
|
||||
should(a, ARCHIVE_FAILED, "snafu=betcha");
|
||||
should_read_set_options(a, ARCHIVE_FAILED, "snafu=betcha");
|
||||
assertEqualString("Undefined option: `snafu'",
|
||||
archive_error_string(a));
|
||||
|
||||
/* ARCHIVE_OK with iso9660 loaded, ARCHIVE_FAILED otherwise */
|
||||
should(a, known_option_rv, "iso9660:joliet");
|
||||
should_read_set_options(a, known_option_rv, "iso9660:joliet");
|
||||
if (pristine) {
|
||||
assertEqualString("Unknown module name: `iso9660'",
|
||||
archive_error_string(a));
|
||||
}
|
||||
should(a, known_option_rv, "iso9660:joliet");
|
||||
should_read_set_options(a, known_option_rv, "iso9660:joliet");
|
||||
if (pristine) {
|
||||
assertEqualString("Unknown module name: `iso9660'",
|
||||
archive_error_string(a));
|
||||
}
|
||||
should(a, known_option_rv, "joliet");
|
||||
should_read_set_options(a, known_option_rv, "joliet");
|
||||
if (pristine) {
|
||||
assertEqualString("Undefined option: `joliet'",
|
||||
archive_error_string(a));
|
||||
}
|
||||
should(a, known_option_rv, "!joliet");
|
||||
should_read_set_options(a, known_option_rv, "!joliet");
|
||||
if (pristine) {
|
||||
assertEqualString("Undefined option: `joliet'",
|
||||
archive_error_string(a));
|
||||
}
|
||||
|
||||
should(a, ARCHIVE_OK, ",");
|
||||
should(a, ARCHIVE_OK, ",,");
|
||||
should_read_set_options(a, ARCHIVE_OK, ",");
|
||||
should_read_set_options(a, ARCHIVE_OK, ",,");
|
||||
|
||||
should(a, halfempty_options_rv, ",joliet");
|
||||
should_read_set_options(a, halfempty_options_rv, ",joliet");
|
||||
if (pristine) {
|
||||
assertEqualString("Undefined option: `joliet'",
|
||||
archive_error_string(a));
|
||||
}
|
||||
should(a, halfempty_options_rv, "joliet,");
|
||||
should_read_set_options(a, halfempty_options_rv, "joliet,");
|
||||
if (pristine) {
|
||||
assertEqualString("Undefined option: `joliet'",
|
||||
archive_error_string(a));
|
||||
}
|
||||
|
||||
should(a, ARCHIVE_FAILED, "joliet,snafu");
|
||||
should_read_set_options(a, ARCHIVE_FAILED, "joliet,snafu");
|
||||
if (pristine) {
|
||||
assertEqualString("Undefined option: `joliet'",
|
||||
archive_error_string(a));
|
||||
@@ -106,7 +216,7 @@ test(int pristine)
|
||||
archive_error_string(a));
|
||||
}
|
||||
|
||||
should(a, ARCHIVE_FAILED, "iso9660:snafu");
|
||||
should_read_set_options(a, ARCHIVE_FAILED, "iso9660:snafu");
|
||||
if (pristine) {
|
||||
assertEqualString("Unknown module name: `iso9660'",
|
||||
archive_error_string(a));
|
||||
@@ -120,6 +230,6 @@ test(int pristine)
|
||||
|
||||
DEFINE_TEST(test_archive_read_set_options)
|
||||
{
|
||||
test(1);
|
||||
test(0);
|
||||
read_set_options_test(1);
|
||||
read_set_options_test(0);
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
/*-
|
||||
* Copyright (c) 2011 Tim Kientzle
|
||||
* 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 "test.h"
|
||||
|
||||
#define should(__a, __code, __m, __o, __v) \
|
||||
assertEqualInt(__code, archive_write_set_filter_option(__a, __m, __o, __v))
|
||||
|
||||
static void
|
||||
test(int pristine)
|
||||
{
|
||||
struct archive* a = archive_write_new();
|
||||
|
||||
if (!pristine)
|
||||
archive_write_add_filter_gzip(a);
|
||||
|
||||
should(a, ARCHIVE_OK, NULL, NULL, NULL);
|
||||
should(a, ARCHIVE_OK, "", "", "");
|
||||
|
||||
should(a, ARCHIVE_FAILED, NULL, "fubar", NULL);
|
||||
should(a, ARCHIVE_FAILED, NULL, "fubar", "snafu");
|
||||
should(a, ARCHIVE_FAILED, "fubar", "snafu", NULL);
|
||||
should(a, ARCHIVE_FAILED, "fubar", "snafu", "betcha");
|
||||
|
||||
archive_write_free(a);
|
||||
}
|
||||
|
||||
DEFINE_TEST(test_archive_write_set_filter_option)
|
||||
{
|
||||
test(1);
|
||||
test(0);
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
/*-
|
||||
* Copyright (c) 2011 Tim Kientzle
|
||||
* 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 "test.h"
|
||||
|
||||
#define should(__a, __code, __m, __o, __v) \
|
||||
assertEqualInt(__code, archive_write_set_format_option(__a, __m, __o, __v))
|
||||
|
||||
static void
|
||||
test(int pristine)
|
||||
{
|
||||
struct archive* a = archive_write_new();
|
||||
int known_option_rv = pristine ? ARCHIVE_FAILED : ARCHIVE_OK;
|
||||
|
||||
if (!pristine)
|
||||
archive_write_set_format_iso9660(a);
|
||||
|
||||
/* NULL and "" denote `no option', so they're ok no matter
|
||||
* what, if any, formats are registered */
|
||||
should(a, ARCHIVE_OK, NULL, NULL, NULL);
|
||||
should(a, ARCHIVE_OK, "", "", "");
|
||||
|
||||
/* unknown modules and options */
|
||||
should(a, ARCHIVE_FAILED, "fubar", "snafu", NULL);
|
||||
should(a, ARCHIVE_FAILED, "fubar", "snafu", "betcha");
|
||||
|
||||
/* unknown modules and options */
|
||||
should(a, ARCHIVE_FAILED, NULL, "snafu", NULL);
|
||||
should(a, ARCHIVE_FAILED, NULL, "snafu", "betcha");
|
||||
|
||||
/* ARCHIVE_OK with iso9660 loaded, ARCHIVE_WARN otherwise */
|
||||
should(a, known_option_rv, "iso9660", "joliet", NULL);
|
||||
should(a, known_option_rv, "iso9660", "joliet", NULL);
|
||||
should(a, known_option_rv, NULL, "joliet", NULL);
|
||||
should(a, known_option_rv, NULL, "joliet", NULL);
|
||||
|
||||
archive_write_free(a);
|
||||
}
|
||||
|
||||
DEFINE_TEST(test_archive_write_set_format_option)
|
||||
{
|
||||
test(1);
|
||||
test(0);
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
/*-
|
||||
* Copyright (c) 2011 Tim Kientzle
|
||||
* 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 "test.h"
|
||||
|
||||
#define should(__a, __code, __m, __o, __v) \
|
||||
assertEqualInt(__code, archive_write_set_option(__a, __m, __o, __v))
|
||||
|
||||
static void
|
||||
test(int pristine)
|
||||
{
|
||||
struct archive* a = archive_write_new();
|
||||
int known_option_rv = pristine ? ARCHIVE_FAILED : ARCHIVE_OK;
|
||||
|
||||
if (!pristine) {
|
||||
archive_write_add_filter_gzip(a);
|
||||
archive_write_set_format_iso9660(a);
|
||||
}
|
||||
|
||||
/* NULL and "" denote `no option', so they're ok no matter
|
||||
* what, if any, formats are registered */
|
||||
should(a, ARCHIVE_OK, NULL, NULL, NULL);
|
||||
should(a, ARCHIVE_OK, "", "", "");
|
||||
|
||||
/* unknown modules and options */
|
||||
should(a, ARCHIVE_FAILED, "fubar", "snafu", NULL);
|
||||
should(a, ARCHIVE_FAILED, "fubar", "snafu", "betcha");
|
||||
|
||||
/* unknown modules and options */
|
||||
should(a, ARCHIVE_FAILED, NULL, "snafu", NULL);
|
||||
should(a, ARCHIVE_FAILED, NULL, "snafu", "betcha");
|
||||
|
||||
/* ARCHIVE_OK with iso9660 loaded, ARCHIVE_WARN otherwise */
|
||||
should(a, known_option_rv, "iso9660", "joliet", NULL);
|
||||
should(a, known_option_rv, "iso9660", "joliet", NULL);
|
||||
should(a, known_option_rv, NULL, "joliet", NULL);
|
||||
should(a, known_option_rv, NULL, "joliet", NULL);
|
||||
|
||||
archive_write_free(a);
|
||||
}
|
||||
|
||||
DEFINE_TEST(test_archive_write_set_option)
|
||||
{
|
||||
test(1);
|
||||
test(0);
|
||||
}
|
||||
@@ -25,11 +25,121 @@
|
||||
|
||||
#include "test.h"
|
||||
|
||||
#define should(__a, __code, __opts) \
|
||||
#define should_write_set_filter_option(__a, __code, __m, __o, __v) \
|
||||
assertEqualInt(__code, archive_write_set_filter_option(__a, __m, __o, __v))
|
||||
|
||||
static void
|
||||
write_set_filter_option_test(int pristine)
|
||||
{
|
||||
struct archive* a = archive_write_new();
|
||||
|
||||
if (!pristine)
|
||||
archive_write_add_filter_gzip(a);
|
||||
|
||||
should_write_set_filter_option(a, ARCHIVE_OK, NULL, NULL, NULL);
|
||||
should_write_set_filter_option(a, ARCHIVE_OK, "", "", "");
|
||||
|
||||
should_write_set_filter_option(a, ARCHIVE_FAILED, NULL, "fubar", NULL);
|
||||
should_write_set_filter_option(a, ARCHIVE_FAILED, NULL, "fubar", "snafu");
|
||||
should_write_set_filter_option(a, ARCHIVE_FAILED, "fubar", "snafu", NULL);
|
||||
should_write_set_filter_option(a, ARCHIVE_FAILED, "fubar", "snafu", "betcha");
|
||||
|
||||
archive_write_free(a);
|
||||
}
|
||||
|
||||
DEFINE_TEST(test_archive_write_set_filter_option)
|
||||
{
|
||||
write_set_filter_option_test(1);
|
||||
write_set_filter_option_test(0);
|
||||
}
|
||||
|
||||
#define should_write_set_format_option(__a, __code, __m, __o, __v) \
|
||||
assertEqualInt(__code, archive_write_set_format_option(__a, __m, __o, __v))
|
||||
|
||||
static void
|
||||
write_set_format_option_test(int pristine)
|
||||
{
|
||||
struct archive* a = archive_write_new();
|
||||
int known_option_rv = pristine ? ARCHIVE_FAILED : ARCHIVE_OK;
|
||||
|
||||
if (!pristine)
|
||||
archive_write_set_format_iso9660(a);
|
||||
|
||||
/* NULL and "" denote `no option', so they're ok no matter
|
||||
* what, if any, formats are registered */
|
||||
should_write_set_format_option(a, ARCHIVE_OK, NULL, NULL, NULL);
|
||||
should_write_set_format_option(a, ARCHIVE_OK, "", "", "");
|
||||
|
||||
/* unknown modules and options */
|
||||
should_write_set_format_option(a, ARCHIVE_FAILED, "fubar", "snafu", NULL);
|
||||
should_write_set_format_option(a, ARCHIVE_FAILED, "fubar", "snafu", "betcha");
|
||||
|
||||
/* unknown modules and options */
|
||||
should_write_set_format_option(a, ARCHIVE_FAILED, NULL, "snafu", NULL);
|
||||
should_write_set_format_option(a, ARCHIVE_FAILED, NULL, "snafu", "betcha");
|
||||
|
||||
/* ARCHIVE_OK with iso9660 loaded, ARCHIVE_WARN otherwise */
|
||||
should_write_set_format_option(a, known_option_rv, "iso9660", "joliet", NULL);
|
||||
should_write_set_format_option(a, known_option_rv, "iso9660", "joliet", NULL);
|
||||
should_write_set_format_option(a, known_option_rv, NULL, "joliet", NULL);
|
||||
should_write_set_format_option(a, known_option_rv, NULL, "joliet", NULL);
|
||||
|
||||
archive_write_free(a);
|
||||
}
|
||||
|
||||
DEFINE_TEST(test_archive_write_set_format_option)
|
||||
{
|
||||
write_set_format_option_test(1);
|
||||
write_set_format_option_test(0);
|
||||
}
|
||||
|
||||
#define should_write_set_option(__a, __code, __m, __o, __v) \
|
||||
assertEqualInt(__code, archive_write_set_option(__a, __m, __o, __v))
|
||||
|
||||
static void
|
||||
write_set_option_test(int pristine)
|
||||
{
|
||||
struct archive* a = archive_write_new();
|
||||
int known_option_rv = pristine ? ARCHIVE_FAILED : ARCHIVE_OK;
|
||||
|
||||
if (!pristine) {
|
||||
archive_write_add_filter_gzip(a);
|
||||
archive_write_set_format_iso9660(a);
|
||||
}
|
||||
|
||||
/* NULL and "" denote `no option', so they're ok no matter
|
||||
* what, if any, formats are registered */
|
||||
should_write_set_option(a, ARCHIVE_OK, NULL, NULL, NULL);
|
||||
should_write_set_option(a, ARCHIVE_OK, "", "", "");
|
||||
|
||||
/* unknown modules and options */
|
||||
should_write_set_option(a, ARCHIVE_FAILED, "fubar", "snafu", NULL);
|
||||
should_write_set_option(a, ARCHIVE_FAILED, "fubar", "snafu", "betcha");
|
||||
|
||||
/* unknown modules and options */
|
||||
should_write_set_option(a, ARCHIVE_FAILED, NULL, "snafu", NULL);
|
||||
should_write_set_option(a, ARCHIVE_FAILED, NULL, "snafu", "betcha");
|
||||
|
||||
/* ARCHIVE_OK with iso9660 loaded, ARCHIVE_WARN otherwise */
|
||||
should_write_set_option(a, known_option_rv, "iso9660", "joliet", NULL);
|
||||
should_write_set_option(a, known_option_rv, "iso9660", "joliet", NULL);
|
||||
should_write_set_option(a, known_option_rv, NULL, "joliet", NULL);
|
||||
should_write_set_option(a, known_option_rv, NULL, "joliet", NULL);
|
||||
|
||||
archive_write_free(a);
|
||||
}
|
||||
|
||||
DEFINE_TEST(test_archive_write_set_option)
|
||||
{
|
||||
write_set_option_test(1);
|
||||
write_set_option_test(0);
|
||||
}
|
||||
|
||||
#define should_write_set_options(__a, __code, __opts) \
|
||||
assertEqualInt(__code, archive_write_set_options(__a, __opts))
|
||||
|
||||
static void
|
||||
test(int pristine)
|
||||
write_set_options_test(int pristine)
|
||||
{
|
||||
struct archive* a = archive_write_new();
|
||||
int halfempty_options_rv = pristine ? ARCHIVE_FAILED : ARCHIVE_OK;
|
||||
@@ -42,62 +152,62 @@ test(int pristine)
|
||||
|
||||
/* NULL and "" denote `no option', so they're ok no matter
|
||||
* what, if any, formats are registered */
|
||||
should(a, ARCHIVE_OK, NULL);
|
||||
should(a, ARCHIVE_OK, "");
|
||||
should_write_set_options(a, ARCHIVE_OK, NULL);
|
||||
should_write_set_options(a, ARCHIVE_OK, "");
|
||||
|
||||
/* unknown modules and options */
|
||||
should(a, ARCHIVE_FAILED, "fubar:snafu");
|
||||
should_write_set_options(a, ARCHIVE_FAILED, "fubar:snafu");
|
||||
assertEqualString("Unknown module name: `fubar'",
|
||||
archive_error_string(a));
|
||||
should(a, ARCHIVE_FAILED, "fubar:snafu=betcha");
|
||||
should_write_set_options(a, ARCHIVE_FAILED, "fubar:snafu=betcha");
|
||||
assertEqualString("Unknown module name: `fubar'",
|
||||
archive_error_string(a));
|
||||
|
||||
/* unknown modules and options */
|
||||
should(a, ARCHIVE_FAILED, "snafu");
|
||||
should_write_set_options(a, ARCHIVE_FAILED, "snafu");
|
||||
assertEqualString("Undefined option: `snafu'",
|
||||
archive_error_string(a));
|
||||
should(a, ARCHIVE_FAILED, "snafu=betcha");
|
||||
should_write_set_options(a, ARCHIVE_FAILED, "snafu=betcha");
|
||||
assertEqualString("Undefined option: `snafu'",
|
||||
archive_error_string(a));
|
||||
|
||||
/* ARCHIVE_OK with iso9660 loaded, ARCHIVE_FAILED otherwise */
|
||||
should(a, known_option_rv, "iso9660:joliet");
|
||||
should_write_set_options(a, known_option_rv, "iso9660:joliet");
|
||||
if (pristine) {
|
||||
assertEqualString("Unknown module name: `iso9660'",
|
||||
archive_error_string(a));
|
||||
}
|
||||
should(a, known_option_rv, "iso9660:joliet");
|
||||
should_write_set_options(a, known_option_rv, "iso9660:joliet");
|
||||
if (pristine) {
|
||||
assertEqualString("Unknown module name: `iso9660'",
|
||||
archive_error_string(a));
|
||||
}
|
||||
should(a, known_option_rv, "joliet");
|
||||
should_write_set_options(a, known_option_rv, "joliet");
|
||||
if (pristine) {
|
||||
assertEqualString("Undefined option: `joliet'",
|
||||
archive_error_string(a));
|
||||
}
|
||||
should(a, known_option_rv, "!joliet");
|
||||
should_write_set_options(a, known_option_rv, "!joliet");
|
||||
if (pristine) {
|
||||
assertEqualString("Undefined option: `joliet'",
|
||||
archive_error_string(a));
|
||||
}
|
||||
|
||||
should(a, ARCHIVE_OK, ",");
|
||||
should(a, ARCHIVE_OK, ",,");
|
||||
should_write_set_options(a, ARCHIVE_OK, ",");
|
||||
should_write_set_options(a, ARCHIVE_OK, ",,");
|
||||
|
||||
should(a, halfempty_options_rv, ",joliet");
|
||||
should_write_set_options(a, halfempty_options_rv, ",joliet");
|
||||
if (pristine) {
|
||||
assertEqualString("Undefined option: `joliet'",
|
||||
archive_error_string(a));
|
||||
}
|
||||
should(a, halfempty_options_rv, "joliet,");
|
||||
should_write_set_options(a, halfempty_options_rv, "joliet,");
|
||||
if (pristine) {
|
||||
assertEqualString("Undefined option: `joliet'",
|
||||
archive_error_string(a));
|
||||
}
|
||||
|
||||
should(a, ARCHIVE_FAILED, "joliet,snafu");
|
||||
should_write_set_options(a, ARCHIVE_FAILED, "joliet,snafu");
|
||||
if (pristine) {
|
||||
assertEqualString("Undefined option: `joliet'",
|
||||
archive_error_string(a));
|
||||
@@ -106,7 +216,7 @@ test(int pristine)
|
||||
archive_error_string(a));
|
||||
}
|
||||
|
||||
should(a, ARCHIVE_FAILED, "iso9660:snafu");
|
||||
should_write_set_options(a, ARCHIVE_FAILED, "iso9660:snafu");
|
||||
if (pristine) {
|
||||
assertEqualString("Unknown module name: `iso9660'",
|
||||
archive_error_string(a));
|
||||
@@ -120,6 +230,6 @@ test(int pristine)
|
||||
|
||||
DEFINE_TEST(test_archive_write_set_options)
|
||||
{
|
||||
test(1);
|
||||
test(0);
|
||||
write_set_options_test(1);
|
||||
write_set_options_test(0);
|
||||
}
|
||||
@@ -31,7 +31,7 @@
|
||||
*
|
||||
* This test simply reads each archive image into memory, pokes
|
||||
* random values into it and runs it through libarchive. It tries
|
||||
* to damage about 1% of each file and repeats the exercise 100 times
|
||||
* to damage about 1% of each file and repeats the exercise 1000 times
|
||||
* with each file.
|
||||
*
|
||||
* Unlike most other tests, this test does not verify libarchive's
|
||||
|
||||
+3
-3
@@ -2,7 +2,7 @@
|
||||
* Copyright (c) 2003-2007 Tim Kientzle
|
||||
* All rights reserved.
|
||||
*
|
||||
* Based on libarchive/test/test_read_format_isorr_bz2.c with
|
||||
* Based on libarchive/test/test_read_format_isorr_compress.c with
|
||||
* bugs introduced by Andreas Henriksson <andreas@fatal.se> for
|
||||
* testing ISO9660 image with Joliet extension.
|
||||
*
|
||||
@@ -30,7 +30,7 @@
|
||||
|
||||
/*
|
||||
Execute the following to rebuild the data for this program:
|
||||
tail -n +35 test_read_format_isojoliet_bz2.c | /bin/sh
|
||||
tail -n +35 test_read_format_isojoliet_compress.c | /bin/sh
|
||||
|
||||
rm -rf /tmp/iso
|
||||
mkdir /tmp/iso
|
||||
@@ -51,7 +51,7 @@ uuencode $F $F > $F.uu
|
||||
exit 1
|
||||
*/
|
||||
|
||||
DEFINE_TEST(test_read_format_isojoliet_bz2)
|
||||
DEFINE_TEST(test_read_format_isojoliet_compress)
|
||||
{
|
||||
const char *refname = "test_read_format_iso_joliet.iso.Z";
|
||||
struct archive_entry *ae;
|
||||
+3
-3
@@ -29,7 +29,7 @@ PLEASE use old cdrtools; mkisofs version is 2.01.
|
||||
This version mkisofs made wrong "SL" System Use Entry of RRIP.
|
||||
|
||||
Execute the following command to rebuild the data for this program:
|
||||
tail -n +34 test_read_format_isorr_bz2.c | /bin/sh
|
||||
tail -n +34 test_read_format_isorr_compress.c | /bin/sh
|
||||
|
||||
rm -rf /tmp/iso
|
||||
mkdir /tmp/iso
|
||||
@@ -51,7 +51,7 @@ uuencode $F $F > $F.uu
|
||||
exit 1
|
||||
*/
|
||||
|
||||
DEFINE_TEST(test_read_format_isorr_bz2)
|
||||
DEFINE_TEST(test_read_format_isorr_compress)
|
||||
{
|
||||
const char *refname = "test_read_format_iso_rockridge.iso.Z";
|
||||
struct archive_entry *ae;
|
||||
@@ -68,7 +68,7 @@ DEFINE_TEST(test_read_format_isorr_bz2)
|
||||
assertEqualInt(ARCHIVE_OK,
|
||||
archive_read_open_filename(a, refname, 10240));
|
||||
|
||||
/* Retrieve each of the 8 files on the ISO image and
|
||||
/* Retrieve each of the 10 entries on the ISO image and
|
||||
* verify that each one is what we expect. */
|
||||
for (i = 0; i < 10; ++i) {
|
||||
assertEqualInt(0, archive_read_next_header(a, &ae));
|
||||
+3
-3
@@ -29,7 +29,7 @@ PLEASE use latest cdrtools at least mkisofs version is 2.01.01a63 or later.
|
||||
Old version mkisofs made wrong "SL" System Use Entry of RRIP.
|
||||
|
||||
Execute the following command to rebuild the data for this program:
|
||||
tail -n +34 test_read_format_isorr_new_bz2.c | /bin/sh
|
||||
tail -n +34 test_read_format_isorr_new_compress.c | /bin/sh
|
||||
|
||||
rm -rf /tmp/iso
|
||||
mkdir /tmp/iso
|
||||
@@ -51,7 +51,7 @@ uuencode $F $F > $F.uu
|
||||
exit 1
|
||||
*/
|
||||
|
||||
DEFINE_TEST(test_read_format_isorr_new_bz2)
|
||||
DEFINE_TEST(test_read_format_isorr_new_compress)
|
||||
{
|
||||
const char *refname = "test_read_format_iso_rockridge_new.iso.Z";
|
||||
struct archive_entry *ae;
|
||||
@@ -68,7 +68,7 @@ DEFINE_TEST(test_read_format_isorr_new_bz2)
|
||||
assertEqualInt(ARCHIVE_OK,
|
||||
archive_read_open_filename(a, refname, 10240));
|
||||
|
||||
/* Retrieve each of the 8 files on the ISO image and
|
||||
/* Retrieve each of the 10 entries on the ISO image and
|
||||
* verify that each one is what we expect. */
|
||||
for (i = 0; i < 10; ++i) {
|
||||
assertEqualInt(0, archive_read_next_header(a, &ae));
|
||||
+2
-2
@@ -26,7 +26,7 @@
|
||||
|
||||
/*
|
||||
Execute the following command to rebuild the data for this program:
|
||||
tail -n +32 test_read_format_isozisofs_bz2.c | /bin/sh
|
||||
tail -n +32 test_read_format_isozisofs_compress.c | /bin/sh
|
||||
|
||||
rm -rf /tmp/iso /tmp/ziso
|
||||
mkdir /tmp/iso
|
||||
@@ -50,7 +50,7 @@ exit 1
|
||||
|
||||
*/
|
||||
|
||||
DEFINE_TEST(test_read_format_isozisofs_bz2)
|
||||
DEFINE_TEST(test_read_format_isozisofs_compress)
|
||||
{
|
||||
const char *refname = "test_read_format_iso_zisofs.iso.Z";
|
||||
struct archive_entry *ae;
|
||||
+1
-1
@@ -320,7 +320,7 @@ static void verify_lzma_contents(const char *buff, size_t used)
|
||||
}
|
||||
|
||||
#endif /* HAVE_LZMA_H */
|
||||
DEFINE_TEST(test_write_format_zip_compression_lzmaxz)
|
||||
DEFINE_TEST(test_write_format_zip_compression_lzma_xz)
|
||||
{
|
||||
#ifndef HAVE_LZMA_H
|
||||
skipping("lzma is not fully supported on this platform");
|
||||
Reference in new issue
Block a user