summaryrefslogtreecommitdiffstats
path: root/tests/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'tests/helpers')
-rw-r--r--tests/helpers/Makemodule.am7
-rw-r--r--tests/helpers/test_sha1.c29
-rw-r--r--tests/helpers/test_uuid_namespace.c37
3 files changed, 73 insertions, 0 deletions
diff --git a/tests/helpers/Makemodule.am b/tests/helpers/Makemodule.am
index 3070a8bbc..2f2611b67 100644
--- a/tests/helpers/Makemodule.am
+++ b/tests/helpers/Makemodule.am
@@ -5,6 +5,9 @@ test_byteswap_SOURCES = tests/helpers/test_byteswap.c
check_PROGRAMS += test_md5
test_md5_SOURCES = tests/helpers/test_md5.c lib/md5.c
+check_PROGRAMS += test_sha1
+test_sha1_SOURCES = tests/helpers/test_sha1.c lib/sha1.c
+
check_PROGRAMS += test_pathnames
test_pathnames_SOURCES = tests/helpers/test_pathnames.c
@@ -18,3 +21,7 @@ test_sigreceive_LDADD = $(LDADD) libcommon.la
check_PROGRAMS += test_tiocsti
test_tiocsti_SOURCES = tests/helpers/test_tiocsti.c
+check_PROGRAMS += test_uuid_namespace
+test_uuid_namespace_SOURCES = tests/helpers/test_uuid_namespace.c \
+ libuuid/src/predefined.c libuuid/src/unpack.c libuuid/src/unparse.c
+
diff --git a/tests/helpers/test_sha1.c b/tests/helpers/test_sha1.c
new file mode 100644
index 000000000..5a1972935
--- /dev/null
+++ b/tests/helpers/test_sha1.c
@@ -0,0 +1,29 @@
+
+#include <stdio.h>
+#include <unistd.h>
+
+#include "sha1.h"
+
+int main(void)
+{
+ int i, ret;
+ SHA1_CTX ctx;
+ unsigned char digest[SHA1LENGTH];
+ unsigned char buf[BUFSIZ];
+
+ SHA1Init( &ctx );
+
+ while(!feof(stdin) && !ferror(stdin)) {
+ ret = fread(buf, 1, sizeof(buf), stdin);
+ if (ret)
+ SHA1Update( &ctx, buf, ret );
+ }
+
+ fclose(stdin);
+ SHA1Final( digest, &ctx );
+
+ for (i = 0; i < SHA1LENGTH; i++)
+ printf( "%02x", digest[i] );
+ printf("\n");
+ return 0;
+}
diff --git a/tests/helpers/test_uuid_namespace.c b/tests/helpers/test_uuid_namespace.c
new file mode 100644
index 000000000..1bbf8754d
--- /dev/null
+++ b/tests/helpers/test_uuid_namespace.c
@@ -0,0 +1,37 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "../libuuid/src/uuid.h"
+
+static void get_template(const char *ns)
+{
+ const uuid_t *uuidptr;
+ char buf[37];
+
+ uuidptr = uuid_get_template(ns);
+ if (uuidptr == NULL)
+ strcpy(buf, "NULL");
+ else
+ uuid_unparse_lower(*uuidptr, buf);
+
+ printf("uuid_get_template %s returns %s\n", (ns ? ns : "NULL"), buf);
+}
+
+int main(void)
+{
+ get_template("dns");
+
+ get_template("url");
+
+ get_template("oid");
+
+ get_template("x500");
+
+ get_template(NULL);
+ get_template("");
+ get_template("unknown");
+
+ exit(0);
+}
+