test_assert_equal_int(__FILE__, __LINE__, (v1), #v1, (v2), #v2, (a))
#define assertEqualStringA(a,v1,v2) \
test_assert_equal_string(__FILE__, __LINE__, (v1), #v1, (v2), #v2, (a))
+
+/*
+ * A compression is not supported
+ * Use this define after archive_read_next_header() is called
+ */
+#define UnsupportedCompress(r, a) \
+ (r != ARCHIVE_OK && \
+ (strcmp(archive_error_string(a), \
+ "Unrecognized archive format") == 0 && \
+ archive_compression(a) == ARCHIVE_COMPRESSION_NONE))
+
/* Read entries, match up names with list above. */
for (i = 0; i < 6; ++i) {
r = archive_read_next_header(a, &ae);
- if (r != ARCHIVE_OK) {
- if (strcmp(archive_error_string(a),
- "Unrecognized archive format") == 0) {
- skipping("Skipping BZIP2 compression check: "
- "This version of libarchive was compiled "
- "without bzip2 support");
- goto finish;
- }
+ if (UnsupportedCompress(r, a)) {
+ skipping("Skipping BZIP2 compression check: "
+ "This version of libarchive was compiled "
+ "without bzip2 support");
+ goto finish;
}
failure("Could not read file %d (%s) from %s", i, n[i], name);
assertEqualIntA(a, ARCHIVE_OK, r);
/* Read entries, match up names with list above. */
for (i = 0; i < 6; ++i) {
r = archive_read_next_header(a, &ae);
- if (r != ARCHIVE_OK) {
- if (strcmp(archive_error_string(a),
- "Unrecognized archive format") == 0) {
- skipping("Skipping GZIP compression check: "
- "This version of libarchive was compiled "
- "without gzip support");
- goto finish;
- }
+ if (UnsupportedCompress(r, a)) {
+ skipping("Skipping GZIP compression check: "
+ "This version of libarchive was compiled "
+ "without gzip support");
+ goto finish;
}
failure("Could not read file %d (%s) from %s", i, n[i], name);
assertEqualIntA(a, ARCHIVE_OK, r);
/* Read entries, match up names with list above. */
for (i = 0; i < 6; ++i) {
r = archive_read_next_header(a, &ae);
- if (r != ARCHIVE_OK) {
- if (strcmp(archive_error_string(a),
- "Unrecognized archive format") == 0) {
- skipping("Skipping XZ compression check: "
- "This version of libarchive was compiled "
- "without xz support");
- goto finish;
- }
+ if (UnsupportedCompress(r, a)) {
+ skipping("Skipping XZ compression check: "
+ "This version of libarchive was compiled "
+ "without xz support");
+ goto finish;
}
failure("Could not read file %d (%s) from %s", i, n[i], name);
assertEqualIntA(a, ARCHIVE_OK, r);
assert(0 == archive_read_support_format_all(a));
assert(0 == archive_read_open_memory(a, rawimage, size));
r = archive_read_next_header(a, &ae);
- if (r != ARCHIVE_OK) {
- if (strcmp(archive_error_string(a),
- "Unrecognized archive format") == 0) {
- skipping("Skipping GZIP/BZIP2 compression check: "
- "This version of libarchive was compiled "
- "without gzip/bzip2 support");
- assert(0 == archive_read_close(a));
- assert(0 == archive_read_finish(a));
- continue;
- }
- } else {
+ if (UnsupportedCompress(r, a)) {
+ skipping("Skipping GZIP/BZIP2 compression check: "
+ "This version of libarchive was compiled "
+ "without gzip/bzip2 support");
+ assert(0 == archive_read_close(a));
+ assert(0 == archive_read_finish(a));
+ continue;
+ }
+ assert(0 == r);
+ if (r == ARCHIVE_OK) {
char buff[20];
r = archive_read_data(a, buff, 19);
- if (r < ARCHIVE_OK) {
- if (strcmp(archive_error_string(a),
- "libarchive compiled without deflate support (no libz)") == 0) {
- skipping("Skipping ZIP compression check: %s",
- archive_error_string(a));
- assert(0 == archive_read_close(a));
- assert(0 == archive_read_finish(a));
- continue;
- }
+ if (r < ARCHIVE_OK && strcmp(archive_error_string(a),
+ "libarchive compiled without deflate support (no libz)") == 0) {
+ skipping("Skipping ZIP compression check: %s",
+ archive_error_string(a));
+ assert(0 == archive_read_close(a));
+ assert(0 == archive_read_finish(a));
+ continue;
}
}
assert(0 == archive_read_close(a));
assertEqualIntA(a, ARCHIVE_OK,
archive_read_open_memory(a, archive, sizeof(archive)));
r = archive_read_next_header(a, &ae);
- if (r != ARCHIVE_OK) {
- if (strcmp(archive_error_string(a),
- "Unrecognized archive format") == 0) {
- skipping("Skipping BZ2 compression check: "
- "This version of libarchive was compiled "
- "without bz2 support");
- goto finish;
- }
+ if (UnsupportedCompress(r, a)) {
+ skipping("Skipping BZ2 compression check: "
+ "This version of libarchive was compiled "
+ "without bz2 support");
+ goto finish;
}
assertEqualIntA(a, ARCHIVE_OK, r);
assert(archive_compression(a) == ARCHIVE_COMPRESSION_BZIP2);
assert(0 == archive_read_support_format_all(a));
assert(0 == archive_read_open_memory(a, archive, sizeof(archive)));
r = archive_read_next_header(a, &ae);
- if (r != ARCHIVE_OK) {
- /* TODO: when cpio really broken */
- if (strcmp(archive_error_string(a),
- "Unrecognized archive format") == 0) {
- skipping("Skipping GZIP compression check: "
- "This version of libarchive was compiled "
- "without gzip support");
- goto finish;
- }
+ if (UnsupportedCompress(r, a)) {
+ skipping("Skipping GZIP compression check: "
+ "This version of libarchive was compiled "
+ "without gzip support");
+ goto finish;
}
assert(0 == r);
assert(archive_compression(a) == ARCHIVE_COMPRESSION_GZIP);
assert(0 == archive_read_support_format_all(a));
assert(0 == archive_read_open_memory(a, archive, sizeof(archive)));
r = archive_read_next_header(a, &ae);
- if (r != ARCHIVE_OK) {
- /* TODO: when cpio really broken */
- if (strcmp(archive_error_string(a),
- "Unrecognized archive format") == 0) {
- skipping("Skipping XZ compression check: "
- "This version of libarchive was compiled "
- "without xz support");
- goto finish;
- }
+ if (UnsupportedCompress(r, a)) {
+ skipping("Skipping XZ compression check: "
+ "This version of libarchive was compiled "
+ "without xz support");
+ goto finish;
}
assert(0 == r);
assert(archive_compression(a) == ARCHIVE_COMPRESSION_XZ);
assert(0 == archive_read_support_format_all(a));
assert(0 == archive_read_open_memory(a, archive, sizeof(archive)));
r = archive_read_next_header(a, &ae);
- if (r != ARCHIVE_OK) {
- if (strcmp(archive_error_string(a),
- "Unrecognized archive format") == 0) {
- skipping("Skipping GZIP compression check: "
- "This version of libarchive was compiled "
- "without gzip support");
- goto finish;
- }
+ if (UnsupportedCompress(r, a)) {
+ skipping("Skipping GZIP compression check: "
+ "This version of libarchive was compiled "
+ "without gzip support");
+ goto finish;
}
assert(0 == r);
assert(archive_compression(a) == ARCHIVE_COMPRESSION_GZIP);
assert(0 == archive_read_support_format_all(a));
assert(0 == archive_read_open_memory(a, archive, sizeof(archive)));
r = archive_read_next_header(a, &ae);
- if (r != ARCHIVE_OK) {
- if (strcmp(archive_error_string(a),
- "Unrecognized archive format") == 0) {
- skipping("Skipping GZIP compression check: "
- "This version of libarchive was compiled "
- "without gzip support");
- goto finish;
- }
+ if (UnsupportedCompress(r, a)) {
+ skipping("Skipping GZIP compression check: "
+ "This version of libarchive was compiled "
+ "without gzip support");
+ goto finish;
}
assert(0 == r);
assert(archive_compression(a) == ARCHIVE_COMPRESSION_GZIP);
assertEqualIntA(a, ARCHIVE_OK,
archive_read_open_memory(a, archive, sizeof(archive)));
r = archive_read_next_header(a, &ae);
- if (r != ARCHIVE_OK) {
- if (strcmp(archive_error_string(a),
- "Unrecognized archive format") == 0) {
- skipping("Skipping GZIP compression check: "
- "This version of libarchive was compiled "
- "without gzip support");
- goto finish;
- }
+ if (UnsupportedCompress(r, a)) {
+ skipping("Skipping GZIP compression check: "
+ "This version of libarchive was compiled "
+ "without gzip support");
+ goto finish;
}
assertEqualIntA(a, ARCHIVE_OK, r);
assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_GZIP);
assert(0 == archive_read_support_format_all(a));
assert(0 == archive_read_open_memory(a, archive, sizeof(archive)));
r = archive_read_next_header(a, &ae);
- if (r != ARCHIVE_OK) {
- if (strcmp(archive_error_string(a),
- "Unrecognized archive format") == 0) {
- skipping("Skipping BZIP2 compression check: "
- "This version of libarchive was compiled "
- "without bzip2 support");
- goto finish;
- }
+ if (UnsupportedCompress(r, a)) {
+ skipping("Skipping BZIP2 compression check: "
+ "This version of libarchive was compiled "
+ "without bzip2 support");
+ goto finish;
}
assert(0 == r);
assert(archive_compression(a) == ARCHIVE_COMPRESSION_BZIP2);
assert(0 == archive_read_support_format_all(a));
assert(0 == archive_read_open_memory(a, archive, sizeof(archive)));
r = archive_read_next_header(a, &ae);
- if (r != ARCHIVE_OK) {
- if (strcmp(archive_error_string(a),
- "Unrecognized archive format") == 0) {
- skipping("Skipping BZIP2 compression check: "
- "This version of libarchive was compiled "
- "without bzip2 support");
- goto finish;
- }
+ if (UnsupportedCompress(r, a)) {
+ skipping("Skipping BZIP2 compression check: "
+ "This version of libarchive was compiled "
+ "without bzip2 support");
+ goto finish;
}
assert(0 == r);
assert(archive_compression(a) == ARCHIVE_COMPRESSION_BZIP2);
assert(0 == archive_read_support_format_all(a));
assert(0 == archive_read_open_memory(a, archive, sizeof(archive)));
r = archive_read_next_header(a, &ae);
- if (r != ARCHIVE_OK) {
- if (strcmp(archive_error_string(a),
- "Unrecognized archive format") == 0) {
- skipping("Skipping GZIP compression check: "
- "This version of libarchive was compiled "
- "without gzip support");
- goto finish;
- }
+ if (UnsupportedCompress(r, a)) {
+ skipping("Skipping GZIP compression check: "
+ "This version of libarchive was compiled "
+ "without gzip support");
+ goto finish;
}
assert(0 == r);
assert(archive_compression(a) == ARCHIVE_COMPRESSION_GZIP);
assert(0 == archive_read_support_format_all(a));
assert(0 == archive_read_open_memory(a, archive, sizeof(archive)));
r = archive_read_next_header(a, &ae);
- if (r != ARCHIVE_OK) {
- if (strcmp(archive_error_string(a),
- "Unrecognized archive format") == 0) {
- skipping("Skipping XZ compression check: "
- "This version of libarchive was compiled "
- "without xz support",
- archive_error_string(a));
- goto finish;
- }
+ if (UnsupportedCompress(r, a)) {
+ skipping("Skipping XZ compression check: "
+ "This version of libarchive was compiled "
+ "without xz support");
+ goto finish;
}
assert(0 == r);
assert(archive_compression(a) == ARCHIVE_COMPRESSION_XZ);
assertA(0 == archive_read_open_memory(a, buff, used));
r = archive_read_next_header(a, &ae);
- if (r != ARCHIVE_OK) {
- if (strcmp(archive_error_string(a),
- "Unrecognized archive format") == 0) {
- skipping("This version of libarchive was compiled "
- "without gzip support");
- assert(0 == archive_read_finish(a));
- /*
- * Try using an external "gunzip","gzip -d" program
- */
- if ((extprog = external_gzip_program(1)) == NULL) {
- skipping("There is no gzip uncompression "
- "program in this platform");
- return;
- }
- assert((a = archive_read_new()) != NULL);
- assertEqualIntA(a, ARCHIVE_OK,
- archive_read_support_compression_none(a));
- assertEqualIntA(a, ARCHIVE_OK,
- archive_read_support_compression_program(a, extprog));
- assertA(0 == archive_read_support_format_all(a));
- assertA(0 == archive_read_open_memory(a, buff, used));
- r = archive_read_next_header(a, &ae);
+ if (UnsupportedCompress(r, a)) {
+ skipping("This version of libarchive was compiled "
+ "without gzip support");
+ assert(0 == archive_read_finish(a));
+ /*
+ * Try using an external "gunzip","gzip -d" program
+ */
+ if ((extprog = external_gzip_program(1)) == NULL) {
+ skipping("There is no gzip uncompression "
+ "program in this platform");
+ return;
}
+ assert((a = archive_read_new()) != NULL);
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_support_compression_none(a));
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_support_compression_program(a, extprog));
+ assertA(0 == archive_read_support_format_all(a));
+ assertA(0 == archive_read_open_memory(a, buff, used));
+ r = archive_read_next_header(a, &ae);
}
assertA(0 == r);