]> xenbits.xensource.com Git - people/liuw/rumprun.git/commitdiff
add a simple -lcrypto test
authorAntti Kantee <pooka@iki.fi>
Thu, 30 Apr 2015 15:34:06 +0000 (15:34 +0000)
committerAntti Kantee <pooka@iki.fi>
Thu, 30 Apr 2015 15:34:06 +0000 (15:34 +0000)
tests/crypto/Makefile [new file with mode: 0644]
tests/crypto/md5.c [new file with mode: 0644]
tests/runtests.sh

diff --git a/tests/crypto/Makefile b/tests/crypto/Makefile
new file mode 100644 (file)
index 0000000..af851c8
--- /dev/null
@@ -0,0 +1,11 @@
+include ../Makefile.inc
+
+ALL=md5
+
+all: $(ALL)
+
+md5: md5.c
+       ${CC} ${CFLAGS} -o $@ $< -lcrypto ${LDFLAGS}
+
+clean:
+       rm -f md5
diff --git a/tests/crypto/md5.c b/tests/crypto/md5.c
new file mode 100644 (file)
index 0000000..ac7d34c
--- /dev/null
@@ -0,0 +1,27 @@
+#include <sys/types.h>
+
+#include <string.h>
+
+#include <openssl/md5.h>
+
+#include <rumprun/tester.h>
+
+#define TESTSTRING "sum test string this is"
+
+static unsigned char expected[MD5_DIGEST_LENGTH] = {
+       0x20, 0x62, 0xda, 0xe2, 0xa3, 0xb4, 0x1d, 0xc7,
+       0x0c, 0x23, 0x3f, 0x25, 0xd8, 0xff, 0x5b, 0x6e,
+};
+
+int
+rumprun_test(int argc, char *argv[])
+{
+       unsigned char md5sum[MD5_DIGEST_LENGTH];
+       MD5_CTX md5ctx;
+
+       MD5_Init(&md5ctx);
+       MD5_Update(&md5ctx, TESTSTRING, sizeof(TESTSTRING)-1);
+       MD5_Final(md5sum, &md5ctx);
+
+       return memcmp(expected, md5sum, sizeof(expected));
+}
index cfbb0744820598731c81bc2a998994864f0e2797..b1074513100da9cb3e09e4e5bfe7aec1a40b6461 100755 (executable)
@@ -26,7 +26,8 @@
 #
 
 # TODO: use a more scalable way of specifying tests
-TESTS='hello/hello basic/ctor_test basic/pthread_test basic/tls_test'
+TESTS='hello/hello basic/ctor_test basic/pthread_test basic/tls_test
+       crypto/md5'
 
 STARTMAGIC='=== FOE RUMPRUN 12345 TES-TER 54321 ==='
 ENDMAGIC='=== RUMPRUN 12345 TES-TER 54321 EOF ==='