From 60d1b5df04f415473671a28c5862927398cb6913 Mon Sep 17 00:00:00 2001
From: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
Date: Wed, 23 Mar 2011 11:35:00 +0100
Subject: [PATCH] Contributed by Daniel Kahn Gillmor: * testsuite/Makefile.in
 (TS_NETTLE_SOURCES): Added meta-hash-test.c, meta-cipher-test.c, and
 meta-armor-test.c.

* testsuite/meta-hash-test.c: New file.
* testsuite/meta-cipher-test.c: New file.
* testsuite/meta-armor-test.c: New file.

Rev: nettle/testsuite/.test-rules.make:1.10
Rev: nettle/testsuite/Makefile.in:1.13
Rev: nettle/testsuite/meta-armor-test.c:1.1
Rev: nettle/testsuite/meta-cipher-test.c:1.1
Rev: nettle/testsuite/meta-hash-test.c:1.1
---
 testsuite/.test-rules.make   |  9 ++++++++
 testsuite/Makefile.in        |  1 +
 testsuite/meta-armor-test.c  | 27 ++++++++++++++++++++++
 testsuite/meta-cipher-test.c | 43 ++++++++++++++++++++++++++++++++++++
 testsuite/meta-hash-test.c   | 33 +++++++++++++++++++++++++++
 5 files changed, 113 insertions(+)
 create mode 100644 testsuite/meta-armor-test.c
 create mode 100644 testsuite/meta-cipher-test.c
 create mode 100644 testsuite/meta-hash-test.c

diff --git a/testsuite/.test-rules.make b/testsuite/.test-rules.make
index 1233307b..fc234729 100644
--- a/testsuite/.test-rules.make
+++ b/testsuite/.test-rules.make
@@ -82,6 +82,15 @@ gcm-test$(EXEEXT): gcm-test.$(OBJEXT)
 hmac-test$(EXEEXT): hmac-test.$(OBJEXT)
 	$(LINK) hmac-test.$(OBJEXT) $(TEST_OBJS) -o hmac-test$(EXEEXT)
 
+meta-hash-test$(EXEEXT): meta-hash-test.$(OBJEXT)
+	$(LINK) meta-hash-test.$(OBJEXT) $(TEST_OBJS) -o meta-hash-test$(EXEEXT)
+
+meta-cipher-test$(EXEEXT): meta-cipher-test.$(OBJEXT)
+	$(LINK) meta-cipher-test.$(OBJEXT) $(TEST_OBJS) -o meta-cipher-test$(EXEEXT)
+
+meta-armor-test$(EXEEXT): meta-armor-test.$(OBJEXT)
+	$(LINK) meta-armor-test.$(OBJEXT) $(TEST_OBJS) -o meta-armor-test$(EXEEXT)
+
 buffer-test$(EXEEXT): buffer-test.$(OBJEXT)
 	$(LINK) buffer-test.$(OBJEXT) $(TEST_OBJS) -o buffer-test$(EXEEXT)
 
diff --git a/testsuite/Makefile.in b/testsuite/Makefile.in
index 6eef3dc3..8a263cb3 100644
--- a/testsuite/Makefile.in
+++ b/testsuite/Makefile.in
@@ -22,6 +22,7 @@ TS_NETTLE_SOURCES = aes-test.c arcfour-test.c arctwo-test.c \
 		    serpent-test.c twofish-test.c \
 		    knuth-lfib-test.c \
 		    cbc-test.c ctr-test.c gcm-test.c hmac-test.c \
+		    meta-hash-test.c meta-cipher-test.c meta-armor-test.c \
 		    buffer-test.c yarrow-test.c
 
 TS_HOGWEED_SOURCES = sexp-test.c sexp-format-test.c \
diff --git a/testsuite/meta-armor-test.c b/testsuite/meta-armor-test.c
new file mode 100644
index 00000000..a99064b9
--- /dev/null
+++ b/testsuite/meta-armor-test.c
@@ -0,0 +1,27 @@
+#include "testutils.h"
+#include "nettle-meta.h"
+
+const char* armors[] = {
+  "base16",
+  "base64"
+};
+
+int
+test_main(void)
+{
+  int i,j;
+  int count = sizeof(armors)/sizeof(*armors);
+  for (i = 0; i < count; i++) {
+    for (j = 0; NULL != nettle_armors[j]; j++) {
+      if (0 == strcmp(armors[i], nettle_armors[j]->name))
+        break;
+    }
+    ASSERT(NULL != nettle_armors[j]); /* make sure we found a matching armor */
+  }
+  j = 0;
+  while (NULL != nettle_armors[j])
+    j++;
+  ASSERT(j == count); /* we are not missing testing any armors */
+  SUCCESS();
+}
+  
diff --git a/testsuite/meta-cipher-test.c b/testsuite/meta-cipher-test.c
new file mode 100644
index 00000000..1bb74d86
--- /dev/null
+++ b/testsuite/meta-cipher-test.c
@@ -0,0 +1,43 @@
+#include "testutils.h"
+#include "nettle-meta.h"
+
+const char* ciphers[] = {
+  "aes128",
+  "aes192",
+  "aes256",
+  "arctwo40",
+  "arctwo64",
+  "arctwo128",
+  "arctwo_gutmann128",
+  "arcfour128",
+  "camellia128",
+  "camellia192",
+  "camellia256",
+  "cast128",
+  "serpent128",
+  "serpent192",
+  "serpent256",
+  "twofish128",
+  "twofish192",
+  "twofish256"
+};
+
+int
+test_main(void)
+{
+  int i,j;
+  int count = sizeof(ciphers)/sizeof(*ciphers);
+  for (i = 0; i < count; i++) {
+    for (j = 0; NULL != nettle_ciphers[j]; j++) {
+      if (0 == strcmp(ciphers[i], nettle_ciphers[j]->name))
+        break;
+    }
+    ASSERT(NULL != nettle_ciphers[j]); /* make sure we found a matching cipher */
+  }
+  j = 0;
+  while (NULL != nettle_ciphers[j])
+    j++;
+  ASSERT(j == count); /* we are not missing testing any ciphers */
+  SUCCESS();
+}
+  
diff --git a/testsuite/meta-hash-test.c b/testsuite/meta-hash-test.c
new file mode 100644
index 00000000..d7f251cf
--- /dev/null
+++ b/testsuite/meta-hash-test.c
@@ -0,0 +1,33 @@
+#include "testutils.h"
+#include "nettle-meta.h"
+
+const char* hashes[] = {
+  "md2",
+  "md4",
+  "md5",
+  "sha1",
+  "sha224",
+  "sha256",
+  "sha384",
+  "sha512"
+};
+
+int
+test_main(void)
+{
+  int i,j;
+  int count = sizeof(hashes)/sizeof(*hashes);
+  for (i = 0; i < count; i++) {
+    for (j = 0; NULL != nettle_hashes[j]; j++) {
+      if (0 == strcmp(hashes[i], nettle_hashes[j]->name))
+        break;
+    }
+    ASSERT(NULL != nettle_hashes[j]); /* make sure we found a matching hash */
+  }
+  j = 0;
+  while (NULL != nettle_hashes[j])
+    j++;
+  ASSERT(j == count); /* we are not missing testing any hashes */
+  SUCCESS();
+}
+  
-- 
GitLab