]> mj.ucw.cz Git - libucw.git/blobdiff - lib/lizard-test.c
Merged obj2buck.h and buck2obj.h to object.h, the number of includes
[libucw.git] / lib / lizard-test.c
index 62da4dad2b1e69bffd2e0028ab6bc7889c9a7905..ba78e022cadd28ac52d404c31e45a921dab0f302 100644 (file)
@@ -14,10 +14,10 @@ Usage: lizard-test <options> input-file [output-file]\n\
 \n\
 Options:\n"
 CF_USAGE
-"-c\t\tCompress (default)\n\
+"-c\t\tCompress\n\
 -d\t\tDecompress\n\
--t\t\tCompress, decompress, and compare (in memory only)\n\
--x, -xx\t\tLet the test crash by shrinking the output buffer\n\
+-t\t\tCompress, decompress, and compare (in memory only, default)\n\
+-x\t\tLet the test crash by shrinking the output buffer\n\
 ";
 
 static void NONRET
@@ -31,7 +31,7 @@ int
 main(int argc, char **argv)
 {
   int opt;
-  uns action = 'c';
+  uns action = 't';
   uns crash = 0;
   log_init(argv[0]);
   while ((opt = cf_getopt(argc, argv, options, CF_NO_LONG_OPTS, NULL)) >= 0)
@@ -100,13 +100,11 @@ main(int argc, char **argv)
       smaller_li = li - PAGE_SIZE;
     else
       smaller_li = 0;
-    struct lizard_buffer *buf = lizard_alloc(crash==1 ? smaller_li : li);
-    int lv = lizard_decompress_safe(mo, buf, crash==2 ? smaller_li : li);
-    printf("-> %d ", lv);
-    fflush(stdout);
-    if (lv < 0)
-      printf("err:%m ");
-    else if (lv != li || memcmp(mi, buf->ptr, li))
+    struct lizard_buffer *buf = lizard_alloc();
+    byte *ptr = lizard_decompress_safe(mo, buf, crash ? smaller_li : li);
+    if (!ptr)
+      printf("err: %m");
+    else if (memcmp(mi, ptr, li))
       printf("WRONG");
     else
       printf("OK");