summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/helpers/.gitignore1
-rw-r--r--tests/helpers/Makefile.am5
-rw-r--r--tests/helpers/test_md5.c30
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;
+}