From 0ac96a041b68f90745a743b244acaa19b98c9ab1 Mon Sep 17 00:00:00 2001 From: Antti Kantee Date: Thu, 30 Apr 2015 15:34:06 +0000 Subject: [PATCH] add a simple -lcrypto test --- tests/crypto/Makefile | 11 +++++++++++ tests/crypto/md5.c | 27 +++++++++++++++++++++++++++ tests/runtests.sh | 3 ++- 3 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 tests/crypto/Makefile create mode 100644 tests/crypto/md5.c diff --git a/tests/crypto/Makefile b/tests/crypto/Makefile new file mode 100644 index 0000000..af851c8 --- /dev/null +++ b/tests/crypto/Makefile @@ -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 index 0000000..ac7d34c --- /dev/null +++ b/tests/crypto/md5.c @@ -0,0 +1,27 @@ +#include + +#include + +#include + +#include + +#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)); +} diff --git a/tests/runtests.sh b/tests/runtests.sh index cfbb074..b107451 100755 --- a/tests/runtests.sh +++ b/tests/runtests.sh @@ -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 ===' -- 2.39.5