adler32: make test program more useful and add fate test
authorMans Rullgard <mans@mansr.com>
Wed, 29 Jun 2011 18:33:10 +0000 (19:33 +0100)
committerMans Rullgard <mans@mansr.com>
Thu, 30 Jun 2011 08:47:32 +0000 (09:47 +0100)
Signed-off-by: Mans Rullgard <mans@mansr.com>
libavutil/adler32.c
tests/fate2.mak

index 4f20010..ee1f70e 100644 (file)
@@ -52,22 +52,30 @@ unsigned long av_adler32_update(unsigned long adler, const uint8_t *buf, unsigne
 }
 
 #ifdef TEST
+#include <string.h>
 #include "log.h"
 #include "timer.h"
 #define LEN 7001
 volatile int checksum;
-int main(void){
+int main(int argc, char **argv)
+{
     int i;
     char data[LEN];
     av_log_set_level(AV_LOG_DEBUG);
     for(i=0; i<LEN; i++)
         data[i]= ((i*i)>>3) + 123*i;
-    for(i=0; i<1000; i++){
-        START_TIMER
-        checksum= av_adler32_update(1, data, LEN);
-        STOP_TIMER("adler")
+
+    if (argc > 1 && !strcmp(argv[1], "-t")) {
+        for (i = 0; i < 1000; i++) {
+            START_TIMER;
+            checksum = av_adler32_update(1, data, LEN);
+            STOP_TIMER("adler");
+        }
+    } else {
+        checksum = av_adler32_update(1, data, LEN);
     }
-    av_log(NULL, AV_LOG_DEBUG, "%X == 50E6E508\n", checksum);
-    return 0;
+
+    av_log(NULL, AV_LOG_DEBUG, "%X (expected 50E6E508)\n", checksum);
+    return checksum == 0x50e6e508? 0 : 1;
 }
 #endif
index f8bae65..d247ded 100644 (file)
@@ -217,6 +217,11 @@ FATE_TESTS += fate-sha
 fate-sha: libavutil/sha-test$(EXESUF)
 fate-sha: CMD = run libavutil/sha-test
 
+FATE_TESTS += fate-adler32
+fate-adler32: libavutil/adler32-test$(EXESUF)
+fate-adler32: CMD = run libavutil/adler32-test
+fate-adler32: REF = /dev/null
+
 FATE_TESTS += fate-musepack7
 fate-musepack7: CMD = pcm -i $(SAMPLES)/musepack/inside-mp7.mpc
 fate-musepack7: CMP = oneoff