[FFmpeg-cvslog] adler32: make test program more useful and add fate test
Mans Rullgard
git at videolan.org
Fri Jul 1 05:45:51 CEST 2011
ffmpeg | branch: master | Mans Rullgard <mans at mansr.com> | Wed Jun 29 19:33:10 2011 +0100| [f6252b48455dc8aa5413a480bc208ea4ac0c9136] | committer: Mans Rullgard
adler32: make test program more useful and add fate test
Signed-off-by: Mans Rullgard <mans at mansr.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f6252b48455dc8aa5413a480bc208ea4ac0c9136
---
libavutil/adler32.c | 22 +++++++++++++++-------
tests/fate2.mak | 5 +++++
2 files changed, 20 insertions(+), 7 deletions(-)
diff --git a/libavutil/adler32.c b/libavutil/adler32.c
index 4f20010..ee1f70e 100644
--- a/libavutil/adler32.c
+++ b/libavutil/adler32.c
@@ -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
diff --git a/tests/fate2.mak b/tests/fate2.mak
index f8bae65..d247ded 100644
--- a/tests/fate2.mak
+++ b/tests/fate2.mak
@@ -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
More information about the ffmpeg-cvslog
mailing list