Browse Source

Add an md5crypt test

Eric Andersen 22 years ago
parent
commit
75e3848d49
3 changed files with 33 additions and 2 deletions
  1. 1 0
      test/crypt/.cvsignore
  2. 13 2
      test/crypt/Makefile
  3. 19 0
      test/crypt/md5c-test.c

+ 1 - 0
test/crypt/.cvsignore

@@ -2,3 +2,4 @@ crypt
 crypt.out
 crypt_glibc
 crypt_glibc.out
+md5c-test

+ 13 - 2
test/crypt/Makefile

@@ -21,7 +21,7 @@
 TESTDIR=../
 include $(TESTDIR)/Rules.mak
 
-TARGETS=diff
+TARGETS=diff md5c-test
 EXTRA_LIBS=-lcrypt
 
 all: $(TARGETS)
@@ -56,7 +56,18 @@ diff: crypt_glibc crypt
 	-diff -u crypt_glibc.out crypt.out
 	-@ echo " "
 
+md5c-test: md5c-test.c Makefile $(TESTDIR)/Config $(TESTDIR)/Rules.mak $(CC)
+	-@ echo "-------"
+	-@ echo " "
+	-@ echo "Compiling vs uClibc: "
+	-@ echo " "
+	$(CC) $(CFLAGS) -c $< -o $@.o
+	$(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
+	$(STRIPTOOL) -x -R .note -R .comment $@
+	-./$@
+	-@ echo " "
+
 clean:
-	rm -f *.[oa] *~ core crypt_glibc crypt crypt_glibc.out crypt.out
+	rm -f *.[oa] *~ core crypt_glibc crypt crypt_glibc.out crypt.out md5c-test
 
 

+ 19 - 0
test/crypt/md5c-test.c

@@ -0,0 +1,19 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <crypt.h>
+
+int
+main (int argc, char *argv[])
+{
+  const char salt[] = "$1$saltstring";
+  char *cp;
+
+  cp = crypt ("Hello world!", salt);
+  if (strcmp ("$1$saltstri$YMyguxXMBpd2TEZ.vS/3q1", cp)) { 
+      fprintf(stderr, "Failed md5 crypt test!\n");
+      return EXIT_FAILURE;
+  }
+  fprintf(stderr, "Passed md5 crypt test!\n");
+  return EXIT_SUCCESS;
+}