summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorPhilip Prindeville2017-09-05 11:19:26 +0200
committerKarel Zak2017-09-05 11:26:39 +0200
commit00476268870b01938800af9a5ca776695df13f5d (patch)
treeb9fabc95e52e620c5ff2ac0892947c785e8ad4d8 /tests
parenttests: update sfdisk wipe test (diff)
downloadkernel-qcow2-util-linux-00476268870b01938800af9a5ca776695df13f5d.tar.gz
kernel-qcow2-util-linux-00476268870b01938800af9a5ca776695df13f5d.tar.xz
kernel-qcow2-util-linux-00476268870b01938800af9a5ca776695df13f5d.zip
libuuid: add support for hash-based UUIDs
Adding V3 and V5 UUIDs per RFC-4122. [kzak@redhat.com: - fix symbols file] Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com> Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/commands.sh2
-rw-r--r--tests/expected/sha1/sha17
-rw-r--r--tests/expected/uuid/namespace7
-rw-r--r--tests/helpers/Makemodule.am7
-rw-r--r--tests/helpers/test_sha1.c29
-rw-r--r--tests/helpers/test_uuid_namespace.c37
-rw-r--r--tests/ts/sha1/data7
-rwxr-xr-xtests/ts/sha1/sha131
-rwxr-xr-xtests/ts/uuid/namespace29
9 files changed, 156 insertions, 0 deletions
diff --git a/tests/commands.sh b/tests/commands.sh
index efa0278c1..655344102 100644
--- a/tests/commands.sh
+++ b/tests/commands.sh
@@ -26,6 +26,7 @@ TS_HELPER_PYLIBMOUNT_UPDATE="$top_srcdir/libmount/python/test_mount_tab_update.p
TS_HELPER_LOGGER="$top_builddir/test_logger"
TS_HELPER_LOGINDEFS="$top_builddir/test_logindefs"
TS_HELPER_MD5="$top_builddir/test_md5"
+TS_HELPER_SHA1="$top_builddir/test_sha1"
TS_HELPER_MKFS_MINIX="$top_builddir/test_mkfs_minix"
TS_HELPER_MORE=${TS_HELPER_MORE-"$top_builddir/test_more"}
TS_HELPER_PARTITIONS="$top_builddir/sample-partitions"
@@ -36,6 +37,7 @@ TS_HELPER_STRUTILS="$top_builddir/test_strutils"
TS_HELPER_SYSINFO="$top_builddir/test_sysinfo"
TS_HELPER_TIOCSTI="$top_builddir/test_tiocsti"
TS_HELPER_UUID_PARSER="$top_builddir/test_uuid_parser"
+TS_HELPER_UUID_NAMESPACE="$top_builddir/test_uuid_namespace"
# paths to commands
TS_CMD_ADDPART=${TS_CMD_ADDPART:-"$top_builddir/addpart"}
diff --git a/tests/expected/sha1/sha1 b/tests/expected/sha1/sha1
new file mode 100644
index 000000000..35c72861c
--- /dev/null
+++ b/tests/expected/sha1/sha1
@@ -0,0 +1,7 @@
+da39a3ee5e6b4b0d3255bfef95601890afd80709
+a9993e364706816aba3e25717850c26c9cd0d89d
+da3175a32e6c1aacfd3d3f35770188ae0ab6d078
+7496226c17d4d0a770cea72eebb659c16753b956
+db50ea8b1b20567cd4d8a7fa14de8d37ce9b722c
+90e072e1df8de879ca307610d5ced675af55a4ac
+2eda696c8df17722d80518bebb33742e311a4ac1
diff --git a/tests/expected/uuid/namespace b/tests/expected/uuid/namespace
new file mode 100644
index 000000000..78609759e
--- /dev/null
+++ b/tests/expected/uuid/namespace
@@ -0,0 +1,7 @@
+uuid_get_template dns returns 6ba7b810-9dad-11d1-80b4-00c04fd430c8
+uuid_get_template url returns 6ba7b811-9dad-11d1-80b4-00c04fd430c8
+uuid_get_template oid returns 6ba7b812-9dad-11d1-80b4-00c04fd430c8
+uuid_get_template x500 returns 6ba7b814-9dad-11d1-80b4-00c04fd430c8
+uuid_get_template NULL returns NULL
+uuid_get_template returns NULL
+uuid_get_template unknown returns NULL
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);
+}
+
diff --git a/tests/ts/sha1/data b/tests/ts/sha1/data
new file mode 100644
index 000000000..1eed05a0b
--- /dev/null
+++ b/tests/ts/sha1/data
@@ -0,0 +1,7 @@
+
+abc
+qazxswedc
+1qazxsw23edc
+a a a a a a a a a a
+KUWIOJDNWQKLFDHQUWEDAYCNAUIWSYDUQUICBSKLBCLUWIGDF
+EASC6545642432132SDECSESCEACSJKDWIOUDOIWIDOQPWUDQWIOSNXCSASCA
diff --git a/tests/ts/sha1/sha1 b/tests/ts/sha1/sha1
new file mode 100755
index 000000000..055d690a1
--- /dev/null
+++ b/tests/ts/sha1/sha1
@@ -0,0 +1,31 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2009 Karel Zak <kzak@redhat.com>
+#
+# This file is part of util-linux.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+TS_TOPDIR="${0%/*}/../.."
+
+. $TS_TOPDIR/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_HELPER_SHA1"
+
+cat $TS_SELF/data | while read data
+do
+ echo -n $data | $TS_HELPER_SHA1 >> $TS_OUTPUT
+done
+
+ts_finalize
+
diff --git a/tests/ts/uuid/namespace b/tests/ts/uuid/namespace
new file mode 100755
index 000000000..bec2c9d69
--- /dev/null
+++ b/tests/ts/uuid/namespace
@@ -0,0 +1,29 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2009 Karel Zak <kzak@redhat.com>
+#
+# This file is part of util-linux.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+TS_TOPDIR="${0%/*}/../.."
+
+. $TS_TOPDIR/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_HELPER_UUID_NAMESPACE"
+
+$TS_HELPER_UUID_NAMESPACE > $TS_OUTPUT
+
+ts_finalize
+
+