diff options
author | Karel Zak | 2008-12-06 01:43:55 +0100 |
---|---|---|
committer | Karel Zak | 2008-12-06 01:43:55 +0100 |
commit | 788a14403d032682c172c8021550db2e2a81c1a4 (patch) | |
tree | 36a034a02d8074c8068576b5950e54315e9a7f6b /tests/helpers | |
parent | tests: add swabN() regression test (diff) | |
download | kernel-qcow2-util-linux-788a14403d032682c172c8021550db2e2a81c1a4.tar.gz kernel-qcow2-util-linux-788a14403d032682c172c8021550db2e2a81c1a4.tar.xz kernel-qcow2-util-linux-788a14403d032682c172c8021550db2e2a81c1a4.zip |
tests: add MD5 regression test
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'tests/helpers')
-rw-r--r-- | tests/helpers/.gitignore | 1 | ||||
-rw-r--r-- | tests/helpers/Makefile.am | 5 | ||||
-rw-r--r-- | tests/helpers/test_md5.c | 30 |
3 files changed, 35 insertions, 1 deletions
diff --git a/tests/helpers/.gitignore b/tests/helpers/.gitignore index a2ca1fc06..62a829908 100644 --- a/tests/helpers/.gitignore +++ b/tests/helpers/.gitignore @@ -1,3 +1,4 @@ test_pathnames test_sysinfo test_byteswap +test_md5 diff --git a/tests/helpers/Makefile.am b/tests/helpers/Makefile.am index 127923295..26007d476 100644 --- a/tests/helpers/Makefile.am +++ b/tests/helpers/Makefile.am @@ -1,4 +1,7 @@ include $(top_srcdir)/config/include-Makefile.am -noinst_PROGRAMS = test_sysinfo test_pathnames test_byteswap +noinst_PROGRAMS = test_sysinfo test_pathnames test_byteswap \ + test_md5 + +test_md5_SOURCES = test_md5.c $(top_srcdir)/lib/md5.c diff --git a/tests/helpers/test_md5.c b/tests/helpers/test_md5.c new file mode 100644 index 000000000..b99882b53 --- /dev/null +++ b/tests/helpers/test_md5.c @@ -0,0 +1,30 @@ + +#include <stdio.h> +#include <unistd.h> + +#include "md5.h" + +int +main(int argc, char *argv[]) +{ + int i, ret; + struct MD5Context ctx; + unsigned char digest[16]; + unsigned char buf[BUFSIZ]; + + MD5Init( &ctx ); + + while(!feof(stdin) && !ferror(stdin)) { + ret = fread(buf, 1, sizeof(buf), stdin); + if (ret) + MD5Update( &ctx, buf, ret ); + } + + fclose(stdin); + MD5Final( digest, &ctx ); + + for (i = 0; i < 16; i++) + printf( "%02x", digest[i] ); + printf(" -\n"); + return 0; +} |