1
0
mirror of https://github.com/facebook/zstd.git synced 2025-07-30 22:23:13 +03:00

improved logging

This commit is contained in:
inikep
2016-09-20 15:18:00 +02:00
parent c038c30048
commit 554b3b935c
4 changed files with 74 additions and 49 deletions

View File

@ -45,12 +45,12 @@
} \
}
z_const char hello[] = "hello, hello!";
z_const char hello[] = "hello, hello! I said hello, hello!";
/* "hello world" would be more standard, but the repeated "hello"
* stresses the compression code better, sorry...
*/
const char dictionary[] = "hello";
const char dictionary[] = "hello, hello!";
uLong dictId; /* Adler32 value of the dictionary */
void test_deflate OF((Byte *compr, uLong comprLen));
@ -156,7 +156,7 @@ void test_gzio(fname, uncompr, uncomprLen)
fprintf(stderr, "gzputs err: %s\n", gzerror(file, &err));
exit(1);
}
if (gzprintf(file, ", %s!", "hello") != 8) {
if (gzprintf(file, ", %s! I said hello, hello!", "hello") != 8+21) {
fprintf(stderr, "gzprintf err: %s\n", gzerror(file, &err));
exit(1);
}
@ -182,7 +182,7 @@ void test_gzio(fname, uncompr, uncomprLen)
}
pos = gzseek(file, -8L, SEEK_CUR);
if (pos != 6 || gztell(file) != pos) {
if (pos != 6+21 || gztell(file) != pos) {
fprintf(stderr, "gzseek error, pos=%ld, gztell=%ld\n",
(long)pos, (long)gztell(file));
exit(1);
@ -203,7 +203,7 @@ void test_gzio(fname, uncompr, uncomprLen)
fprintf(stderr, "gzgets err after gzseek: %s\n", gzerror(file, &err));
exit(1);
}
if (strcmp((char*)uncompr, hello + 6)) {
if (strcmp((char*)uncompr, hello + 6+21)) {
fprintf(stderr, "bad gzgets after gzseek\n");
exit(1);
} else {

View File

@ -76,18 +76,19 @@ local int partcompress(FILE *in, z_streamp def)
int ret, flush;
unsigned char raw[RAWLEN];
flush = Z_NO_FLUSH;
flush = Z_SYNC_FLUSH;
do {
def->avail_in = fread(raw, 1, RAWLEN, in);
printf("def->avail_in=%d\n", def->avail_in);
printf("partcompress def->avail_in=%d\n", def->avail_in);
if (ferror(in))
return Z_ERRNO;
def->next_in = raw;
if (feof(in))
flush = Z_FINISH;
ret = deflate(def, flush);
printf("partcompress def->avail_out=%d\n", def->avail_out);
assert(ret != Z_STREAM_ERROR);
} while (def->avail_out != 0 && flush == Z_NO_FLUSH);
} while (def->avail_out != 0 && flush == Z_SYNC_FLUSH);
return ret;
}
@ -104,7 +105,7 @@ local int recompress(z_streamp inf, z_streamp def)
do {
/* decompress */
inf->avail_out = RAWLEN;
printf("inf->avail_out=%d\n", inf->avail_out);
printf("recompress inf->avail_out=%d\n", inf->avail_out);
inf->next_out = raw;
ret = inflate(inf, Z_NO_FLUSH);
@ -120,6 +121,7 @@ local int recompress(z_streamp inf, z_streamp def)
flush = Z_FINISH;
ret = deflate(def, flush);
assert(ret != Z_STREAM_ERROR);
printf("recompress def->avail_out=%d ret=%d\n", def->avail_out, ret);
} while (ret != Z_STREAM_END && def->avail_out != 0);
return ret;
}
@ -167,7 +169,7 @@ int main(int argc, char **argv)
if (ret == Z_ERRNO)
quit("error reading input");
printf("partcompress def.avail_out=%d\n", def.avail_out);
printf("partcompress def.total_out=%d ret=%d\n", (int)def.total_out, ret);
/* if it all fit, then size was undersubscribed -- done! */
if (ret == Z_STREAM_END && def.avail_out >= EXCESS) {
/* write block to stdout */