aboutsummaryrefslogtreecommitdiffstats
path: root/libarchive/test
diff options
context:
space:
mode:
Diffstat (limited to 'libarchive/test')
-rw-r--r--libarchive/test/test_archive_write_add_filter_by_name.c4
-rw-r--r--libarchive/test/test_archive_write_set_format_filter_by_ext.c2
-rw-r--r--libarchive/test/test_read_format_raw.c4
-rw-r--r--libarchive/test/test_read_format_zip.c8
-rw-r--r--libarchive/test/test_read_format_zip_traditional_encryption_data.c4
-rw-r--r--libarchive/test/test_write_filter_zstd.c66
6 files changed, 73 insertions, 15 deletions
diff --git a/libarchive/test/test_archive_write_add_filter_by_name.c b/libarchive/test/test_archive_write_add_filter_by_name.c
index d962af92311b..ba8c1d0472f6 100644
--- a/libarchive/test/test_archive_write_add_filter_by_name.c
+++ b/libarchive/test/test_archive_write_add_filter_by_name.c
@@ -48,7 +48,7 @@ test_filter_by_name(const char *filter_name, int filter_code,
r = archive_write_add_filter_by_name(a, filter_name);
if (r == ARCHIVE_WARN) {
if (!can_filter_prog()) {
- skipping("%s filter not suported on this platform",
+ skipping("%s filter not supported on this platform",
filter_name);
assertEqualInt(ARCHIVE_OK, archive_write_free(a));
free(buff);
@@ -59,7 +59,7 @@ test_filter_by_name(const char *filter_name, int filter_code,
"lzma compression not supported on this platform") == 0 ||
strcmp(archive_error_string(a),
"xz compression not supported on this platform") == 0)) {
- skipping("%s filter not suported on this platform", filter_name);
+ skipping("%s filter not supported on this platform", filter_name);
assertEqualInt(ARCHIVE_OK, archive_write_free(a));
free(buff);
return;
diff --git a/libarchive/test/test_archive_write_set_format_filter_by_ext.c b/libarchive/test/test_archive_write_set_format_filter_by_ext.c
index c073505f7c97..4fe18e18c2d1 100644
--- a/libarchive/test/test_archive_write_set_format_filter_by_ext.c
+++ b/libarchive/test/test_archive_write_set_format_filter_by_ext.c
@@ -61,7 +61,7 @@ test_format_filter_by_ext(const char *output_file,
strcmp(archive_error_string(a),
"xz compression not supported on this platform") == 0)) {
const char *filter_name = archive_filter_name(a, 0);
- skipping("%s filter not suported on this platform", filter_name);
+ skipping("%s filter not supported on this platform", filter_name);
assertEqualInt(ARCHIVE_OK, archive_write_free(a));
free(buff);
return;
diff --git a/libarchive/test/test_read_format_raw.c b/libarchive/test/test_read_format_raw.c
index 0dac8bfbab4a..3961723b48a1 100644
--- a/libarchive/test/test_read_format_raw.c
+++ b/libarchive/test/test_read_format_raw.c
@@ -36,7 +36,9 @@ DEFINE_TEST(test_read_format_raw)
const char *reffile1 = "test_read_format_raw.data";
const char *reffile2 = "test_read_format_raw.data.Z";
const char *reffile3 = "test_read_format_raw.bufr";
+#ifdef HAVE_ZLIB_H
const char *reffile4 = "test_read_format_raw.data.gz";
+#endif
/* First, try pulling data out of an uninterpretable file. */
extract_reference_file(reffile1);
@@ -119,6 +121,7 @@ DEFINE_TEST(test_read_format_raw)
assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
assertEqualInt(ARCHIVE_OK, archive_read_free(a));
+#ifdef HAVE_ZLIB_H
/* Fourth, try with gzip which has metadata. */
extract_reference_file(reffile4);
assert((a = archive_read_new()) != NULL);
@@ -144,4 +147,5 @@ DEFINE_TEST(test_read_format_raw)
assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
assertEqualInt(ARCHIVE_OK, archive_read_free(a));
+#endif
}
diff --git a/libarchive/test/test_read_format_zip.c b/libarchive/test/test_read_format_zip.c
index b6e957a96cec..9afbfb6c5866 100644
--- a/libarchive/test/test_read_format_zip.c
+++ b/libarchive/test/test_read_format_zip.c
@@ -139,7 +139,7 @@ verify_basic(struct archive *a, int seek_checks)
} else {
assertEqualInt(ARCHIVE_FAILED, archive_read_data(a, buff, 19));
assertEqualString(archive_error_string(a),
- "Unsupported ZIP compression method (deflation)");
+ "Unsupported ZIP compression method (8: deflation)");
assert(archive_errno(a) != 0);
}
@@ -162,7 +162,7 @@ verify_basic(struct archive *a, int seek_checks)
} else {
assertEqualInt(ARCHIVE_FAILED, archive_read_data(a, buff, 19));
assertEqualString(archive_error_string(a),
- "Unsupported ZIP compression method (deflation)");
+ "Unsupported ZIP compression method (8: deflation)");
assert(archive_errno(a) != 0);
}
assertEqualInt(ARCHIVE_EOF, archive_read_next_header(a, &ae));
@@ -231,7 +231,7 @@ verify_info_zip_ux(struct archive *a, int seek_checks)
} else {
assertEqualInt(ARCHIVE_FAILED, archive_read_data(a, buff, 19));
assertEqualString(archive_error_string(a),
- "Unsupported ZIP compression method (deflation)");
+ "Unsupported ZIP compression method (8: deflation)");
assert(archive_errno(a) != 0);
}
assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
@@ -302,7 +302,7 @@ verify_extract_length_at_end(struct archive *a, int seek_checks)
} else {
assertEqualIntA(a, ARCHIVE_FAILED, archive_read_extract(a, ae, 0));
assertEqualString(archive_error_string(a),
- "Unsupported ZIP compression method (deflation)");
+ "Unsupported ZIP compression method (8: deflation)");
assert(archive_errno(a) != 0);
}
diff --git a/libarchive/test/test_read_format_zip_traditional_encryption_data.c b/libarchive/test/test_read_format_zip_traditional_encryption_data.c
index 305261567ec8..20e55bbc6948 100644
--- a/libarchive/test/test_read_format_zip_traditional_encryption_data.c
+++ b/libarchive/test/test_read_format_zip_traditional_encryption_data.c
@@ -130,7 +130,7 @@ DEFINE_TEST(test_read_format_zip_traditional_encryption_data)
assertEqualInt(ARCHIVE_FAILED,
archive_read_data(a, buff, sizeof(buff)));
assertEqualString(archive_error_string(a),
- "Unsupported ZIP compression method (deflation)");
+ "Unsupported ZIP compression method (8: deflation)");
assert(archive_errno(a) != 0);
}
@@ -148,7 +148,7 @@ DEFINE_TEST(test_read_format_zip_traditional_encryption_data)
assertEqualInt(ARCHIVE_FAILED,
archive_read_data(a, buff, sizeof(buff)));
assertEqualString(archive_error_string(a),
- "Unsupported ZIP compression method (deflation)");
+ "Unsupported ZIP compression method (8: deflation)");
assert(archive_errno(a) != 0);
}
diff --git a/libarchive/test/test_write_filter_zstd.c b/libarchive/test/test_write_filter_zstd.c
index da3c806671a4..ba1b6bfe716b 100644
--- a/libarchive/test/test_write_filter_zstd.c
+++ b/libarchive/test/test_write_filter_zstd.c
@@ -34,7 +34,7 @@ DEFINE_TEST(test_write_filter_zstd)
char *buff, *data;
size_t buffsize, datasize;
char path[16];
- size_t used1, used2;
+ size_t used1, used2, used3;
int i, r;
buffsize = 2000000;
@@ -125,7 +125,7 @@ DEFINE_TEST(test_write_filter_zstd)
assertEqualIntA(a, ARCHIVE_OK,
archive_write_set_filter_option(a, NULL, "compression-level", "9"));
assertEqualIntA(a, ARCHIVE_OK,
- archive_write_set_filter_option(a, NULL, "compression-level", "6"));
+ archive_write_set_filter_option(a, NULL, "compression-level", "7"));
assertEqualIntA(a, ARCHIVE_OK, archive_write_open_memory(a, buff, buffsize, &used2));
for (i = 0; i < 100; i++) {
sprintf(path, "file%03d", i);
@@ -140,10 +140,6 @@ DEFINE_TEST(test_write_filter_zstd)
assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a));
assertEqualInt(ARCHIVE_OK, archive_write_free(a));
- failure("compression-level=6 wrote %d bytes, default wrote %d bytes",
- (int)used2, (int)used1);
- assert(used2 < used1);
-
assert((a = archive_read_new()) != NULL);
assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
r = archive_read_support_filter_zstd(a);
@@ -168,6 +164,64 @@ DEFINE_TEST(test_write_filter_zstd)
assertEqualInt(ARCHIVE_OK, archive_read_free(a));
/*
+ * One more time at level 1
+ */
+ assert((a = archive_write_new()) != NULL);
+ assertEqualIntA(a, ARCHIVE_OK, archive_write_set_format_ustar(a));
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_write_set_bytes_per_block(a, 10));
+ assertEqualIntA(a, ARCHIVE_OK, archive_write_add_filter_zstd(a));
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_write_set_filter_option(a, NULL, "compression-level", "1"));
+ assertEqualIntA(a, ARCHIVE_OK, archive_write_open_memory(a, buff, buffsize, &used3));
+ assert((ae = archive_entry_new()) != NULL);
+ archive_entry_set_filetype(ae, AE_IFREG);
+ archive_entry_set_size(ae, datasize);
+ for (i = 0; i < 100; i++) {
+ sprintf(path, "file%03d", i);
+ archive_entry_copy_pathname(ae, path);
+ assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae));
+ assertA(datasize == (size_t)archive_write_data(a, data, datasize));
+ }
+ archive_entry_free(ae);
+ assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a));
+ assertEqualInt(ARCHIVE_OK, archive_write_free(a));
+
+ assert((a = archive_read_new()) != NULL);
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+ r = archive_read_support_filter_zstd(a);
+ if (r == ARCHIVE_WARN) {
+ skipping("zstd reading not fully supported on this platform");
+ } else {
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_support_filter_all(a));
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_open_memory(a, buff, used3));
+ for (i = 0; i < 100; i++) {
+ sprintf(path, "file%03d", i);
+ failure("Trying to read %s", path);
+ if (!assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_next_header(a, &ae)))
+ break;
+ assertEqualString(path, archive_entry_pathname(ae));
+ assertEqualInt((int)datasize, archive_entry_size(ae));
+ }
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+ }
+ assertEqualInt(ARCHIVE_OK, archive_read_free(a));
+
+ /*
+ * Check output sizes for various compression levels, expectation
+ * is that archive size for level=7 < default < level=1
+ */
+ failure("compression-level=7 wrote %d bytes, default wrote %d bytes",
+ (int)used2, (int)used1);
+ assert(used2 < used1);
+ failure("compression-level=1 wrote %d bytes, default wrote %d bytes",
+ (int)used3, (int)used1);
+ assert(used1 < used3);
+
+ /*
* Test various premature shutdown scenarios to make sure we
* don't crash or leak memory.
*/