Skip to content

Commit

Permalink
Use error strings for consistency check tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
dillof committed Aug 2, 2024
1 parent d87121a commit cf05449
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 37 deletions.
68 changes: 34 additions & 34 deletions regress/open_incons.test
Original file line number Diff line number Diff line change
Expand Up @@ -44,53 +44,53 @@ file incons-local-magic-bad.zzip incons-local-magic-bad.zip
file incons-local-size-larger.zzip incons-local-size-larger.zip
file incons-stored-size.zzip incons-stored-size.zip
file incons-streamed.zzip incons-streamed.zip
arguments -c incons-archive-comment-longer.zzip incons-archive-comment-shorter.zzip incons-cdoffset.zzip incons-central-compression-method.zzip incons-central-compsize-larger-toolarge.zzip incons-central-compsize-larger.zzip incons-central-compsize-smaller.zzip incons-central-crc.zzip incons-central-date.zzip incons-central-file-comment-longer.zzip incons-central-file-comment-shorter.zzip incons-central-magic-bad.zzip incons-central-magic-bad2.zzip incons-central-size-larger.zzip incons-data.zzip incons-ef-central-size-wrong.zzip incons-ef-local-dupe-utf8comment.zzip incons-ef-local-dupe-utf8name.zzip incons-ef-local-dupe-zip64-v1.zzip incons-ef-local-dupe-zip64-v2.zzip incons-ef-local-id-size.zzip incons-ef-local-id.zzip incons-ef-local-size.zzip incons-eocd64.zzip incons-eocd-magic-bad.zzip incons-file-count-high.zzip incons-file-count-low.zzip incons-file-count-overflow.zzip incons-gap-before-cd.zzip incons-gap-before-eocd.zzip incons-gap-before-local.zzip incons-local-compression-method.zzip incons-local-compsize-larger.zzip incons-local-compsize-smaller.zzip incons-local-crc.zzip incons-local-filename-long.zzip incons-local-filename-missing.zzip incons-local-filename-nil-byte.zzip incons-local-filename-short.zzip incons-local-filename.zzip incons-local-magic-bad.zzip incons-local-size-larger.zzip incons-stored-size.zzip incons-streamed.zzip
arguments -s -c incons-archive-comment-longer.zzip incons-archive-comment-shorter.zzip incons-cdoffset.zzip incons-central-compression-method.zzip incons-central-compsize-larger-toolarge.zzip incons-central-compsize-larger.zzip incons-central-compsize-smaller.zzip incons-central-crc.zzip incons-central-date.zzip incons-central-file-comment-longer.zzip incons-central-file-comment-shorter.zzip incons-central-magic-bad.zzip incons-central-magic-bad2.zzip incons-central-size-larger.zzip incons-data.zzip incons-ef-central-size-wrong.zzip incons-ef-local-dupe-utf8comment.zzip incons-ef-local-dupe-utf8name.zzip incons-ef-local-dupe-zip64-v1.zzip incons-ef-local-dupe-zip64-v2.zzip incons-ef-local-id-size.zzip incons-ef-local-id.zzip incons-ef-local-size.zzip incons-eocd64.zzip incons-eocd-magic-bad.zzip incons-file-count-high.zzip incons-file-count-low.zzip incons-file-count-overflow.zzip incons-gap-before-cd.zzip incons-gap-before-eocd.zzip incons-gap-before-local.zzip incons-local-compression-method.zzip incons-local-compsize-larger.zzip incons-local-compsize-smaller.zzip incons-local-crc.zzip incons-local-filename-long.zzip incons-local-filename-missing.zzip incons-local-filename-nil-byte.zzip incons-local-filename-short.zzip incons-local-filename.zzip incons-local-magic-bad.zzip incons-local-size-larger.zzip incons-stored-size.zzip incons-streamed.zzip
return 1
# tryopen does not test checksums, so this is fine.
# different extra fields local vs. central is fine
stdout
opening 'incons-archive-comment-longer.zzip' returned error 21/2
opening 'incons-archive-comment-shorter.zzip' returned error 21/2
opening 'incons-cdoffset.zzip' returned error 21/1
opening 'incons-central-compression-method.zzip' returned error 21/6
opening 'incons-central-compsize-larger-toolarge.zzip' returned error 35
opening 'incons-central-compsize-larger.zzip' returned error 21/6
opening 'incons-central-compsize-smaller.zzip' returned error 21/6
opening 'incons-central-crc.zzip' returned error 21/6
opening 'incons-central-date.zzip' returned error 21/6
opening 'incons-central-file-comment-longer.zzip' returned error 21/12
opening 'incons-central-file-comment-shorter.zzip' returned error 21/260
opening 'incons-central-magic-bad.zzip' returned error 35
opening 'incons-central-magic-bad2.zzip' returned error 35
opening 'incons-central-size-larger.zzip' returned error 21/6
opening 'incons-archive-comment-longer.zzip' returned error Zip archive inconsistent: archive comment length incorrect
opening 'incons-archive-comment-shorter.zzip' returned error Zip archive inconsistent: archive comment length incorrect
opening 'incons-cdoffset.zzip' returned error Zip archive inconsistent: central directory overlaps EOCD, or there is space between them
opening 'incons-central-compression-method.zzip' returned error Zip archive inconsistent: entry 0: local and central headers do not match
opening 'incons-central-compsize-larger-toolarge.zzip' returned error Possibly truncated or corrupted zip archive
opening 'incons-central-compsize-larger.zzip' returned error Zip archive inconsistent: entry 0: local and central headers do not match
opening 'incons-central-compsize-smaller.zzip' returned error Zip archive inconsistent: entry 0: local and central headers do not match
opening 'incons-central-crc.zzip' returned error Zip archive inconsistent: entry 0: local and central headers do not match
opening 'incons-central-date.zzip' returned error Zip archive inconsistent: entry 0: local and central headers do not match
opening 'incons-central-file-comment-longer.zzip' returned error Zip archive inconsistent: entry 0: variable size fields overflow header
opening 'incons-central-file-comment-shorter.zzip' returned error Zip archive inconsistent: entry 1: central header invalid
opening 'incons-central-magic-bad.zzip' returned error Possibly truncated or corrupted zip archive
opening 'incons-central-magic-bad2.zzip' returned error Possibly truncated or corrupted zip archive
opening 'incons-central-size-larger.zzip' returned error Zip archive inconsistent: entry 0: local and central headers do not match
opening 'incons-data.zzip' succeeded, 1 entries
opening 'incons-ef-central-size-wrong.zzip' returned error 21/16
opening 'incons-ef-central-size-wrong.zzip' returned error Zip archive inconsistent: entry 0: invalid WinZip AES extra field
opening 'incons-ef-local-dupe-utf8comment.zzip' succeeded, 1 entries
opening 'incons-ef-local-dupe-utf8name.zzip' returned error 21/6
opening 'incons-ef-local-dupe-zip64-v1.zzip' returned error 21/6
opening 'incons-ef-local-dupe-utf8name.zzip' returned error Zip archive inconsistent: entry 0: local and central headers do not match
opening 'incons-ef-local-dupe-zip64-v1.zzip' returned error Zip archive inconsistent: entry 0: local and central headers do not match
opening 'incons-ef-local-dupe-zip64-v2.zzip' succeeded, 1 entries
opening 'incons-ef-local-id-size.zzip' returned error 21/16
opening 'incons-ef-local-id-size.zzip' returned error Zip archive inconsistent: entry 0: invalid WinZip AES extra field
opening 'incons-ef-local-id.zzip' succeeded, 1 entries
opening 'incons-ef-local-size.zzip' returned error 21/16
opening 'incons-ef-local-size.zzip' returned error Zip archive inconsistent: entry 0: invalid WinZip AES extra field
opening 'incons-eocd64.zzip' succeeded, 1 entries
opening 'incons-eocd-magic-bad.zzip' returned error 35
opening 'incons-file-count-high.zzip' returned error 21/5
opening 'incons-file-count-low.zzip' returned error 21/5
opening 'incons-file-count-overflow.zzip' returned error 21/11
opening 'incons-eocd-magic-bad.zzip' returned error Possibly truncated or corrupted zip archive
opening 'incons-file-count-high.zzip' returned error Zip archive inconsistent: central directory count of entries is incorrect
opening 'incons-file-count-low.zzip' returned error Zip archive inconsistent: central directory count of entries is incorrect
opening 'incons-file-count-overflow.zzip' returned error Zip archive inconsistent: invalid value in central directory
opening 'incons-gap-before-cd.zzip' succeeded, 1 entries
opening 'incons-gap-before-eocd.zzip' succeeded, 1 entries
opening 'incons-gap-before-local.zzip' succeeded, 2 entries
opening 'incons-local-compression-method.zzip' returned error 21/6
opening 'incons-local-compsize-larger.zzip' returned error 21/6
opening 'incons-local-compsize-smaller.zzip' returned error 21/6
opening 'incons-local-crc.zzip' returned error 21/6
opening 'incons-local-filename-long.zzip' returned error 17
opening 'incons-local-filename-missing.zzip' returned error 21/6
opening 'incons-local-compression-method.zzip' returned error Zip archive inconsistent: entry 0: local and central headers do not match
opening 'incons-local-compsize-larger.zzip' returned error Zip archive inconsistent: entry 0: local and central headers do not match
opening 'incons-local-compsize-smaller.zzip' returned error Zip archive inconsistent: entry 0: local and central headers do not match
opening 'incons-local-crc.zzip' returned error Zip archive inconsistent: entry 0: local and central headers do not match
opening 'incons-local-filename-long.zzip' returned error Premature end of file
opening 'incons-local-filename-missing.zzip' returned error Zip archive inconsistent: entry 0: local and central headers do not match
opening 'incons-local-filename-nil-byte.zzip' succeeded, 1 entries
opening 'incons-local-filename-short.zzip' returned error 21/16
opening 'incons-local-filename.zzip' returned error 21/6
opening 'incons-local-magic-bad.zzip' returned error 19
opening 'incons-local-size-larger.zzip' returned error 21/6
opening 'incons-local-filename-short.zzip' returned error Zip archive inconsistent: entry 0: invalid WinZip AES extra field
opening 'incons-local-filename.zzip' returned error Zip archive inconsistent: entry 0: local and central headers do not match
opening 'incons-local-magic-bad.zzip' returned error Not a zip archive
opening 'incons-local-size-larger.zzip' returned error Zip archive inconsistent: entry 0: local and central headers do not match
opening 'incons-stored-size.zzip' succeeded, 1 entries
opening 'incons-streamed.zzip' succeeded, 1 entries
end-of-inline-data
Expand Down
17 changes: 14 additions & 3 deletions regress/tryopen.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"\t-c\tcheck consistency\n" \
"\t-e\texclusively open archive\n" \
"\t-n\tcreate new file\n" \
"\t-s\tprint error string\n" \
"\t-t\ttruncate file to size 0\n"


Expand All @@ -57,10 +58,11 @@ main(int argc, char *argv[]) {
zip_int64_t count;
int error_count;
zip_error_t error;
int error_strings = 0;

flags = 0;

while ((c = getopt(argc, argv, "cent")) != -1) {
while ((c = getopt(argc, argv, "censt")) != -1) {
switch (c) {
case 'c':
flags |= ZIP_CHECKCONS;
Expand All @@ -71,6 +73,9 @@ main(int argc, char *argv[]) {
case 'n':
flags |= ZIP_CREATE;
break;
case 's':
error_strings = 1;
break;
case 't':
flags |= ZIP_TRUNCATE;
break;
Expand All @@ -94,15 +99,21 @@ main(int argc, char *argv[]) {
}

zip_error_init_with_code(&error, ze);
printf("opening '%s' returned error %d", fname, ze);
switch (zip_error_system_type(&error)) {
printf("opening '%s' returned error ", fname);
if (error_strings) {
printf("%s", zip_error_strerror(&error));
}
else {
printf("%d", ze);
switch (zip_error_system_type(&error)) {
case ZIP_ET_SYS:
case ZIP_ET_LIBZIP:
printf("/%d", zip_error_code_system(&error));
break;

default:
break;
}
}
printf("\n");
error_count++;
Expand Down

0 comments on commit cf05449

Please sign in to comment.