]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
tests: add uuid parser check
authorSami Kerola <kerolasa@iki.fi>
Sun, 18 Oct 2015 17:39:21 +0000 (18:39 +0100)
committerSami Kerola <kerolasa@iki.fi>
Sun, 18 Oct 2015 17:39:21 +0000 (18:39 +0100)
The check is based on code by Theodore Ts'o to test libuuid, from which
unstable output is commented out.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
libuuid/src/Makemodule.am
libuuid/src/test_uuid.c
tests/commands.sh
tests/expected/uuid/uuid_parser [new file with mode: 0644]
tests/ts/uuid/uuid_parser [new file with mode: 0755]

index 061aff21d641d8d7ca19c65f4dc7a847acc2060d..180ac01c0f91f9293b662b066816f228c414ab28 100644 (file)
@@ -1,8 +1,8 @@
 
-check_PROGRAMS += test_uuid
-test_uuid_SOURCES = libuuid/src/test_uuid.c
-test_uuid_LDADD = libuuid.la $(SOCKET_LIBS)
-test_uuid_CFLAGS = -I$(ul_libuuid_incdir)
+check_PROGRAMS += test_uuid_parser
+test_uuid_parser_SOURCES = libuuid/src/test_uuid.c
+test_uuid_parser_LDADD = libuuid.la $(SOCKET_LIBS)
+test_uuid_parser_CFLAGS = -I$(ul_libuuid_incdir)
 
 # includes
 uuidincdir = $(includedir)/uuid
index e03138f7d182e71848179b17b9a93d729c8b3a21..e8f0703173be5ebeb2c3726a422d76c0d1fe508b 100644 (file)
@@ -69,13 +69,15 @@ static int test_uuid(const char * uuid, int isValid)
 int
 main(int argc ATTR((unused)) , char **argv ATTR((unused)))
 {
+       int failed = 0;
+/* Code commented out will print random uuid's that are unsuitable output
+ * for test suite.
        uuid_t          buf, tst;
        char            str[100];
        struct timeval  tv;
        time_t          time_reg;
        unsigned char   *cp;
        int i;
-       int failed = 0;
        int type, variant;
 
        uuid_generate(buf);
@@ -160,6 +162,7 @@ main(int argc ATTR((unused)) , char **argv ATTR((unused)))
                printf("UUID copy and compare failed!\n");
                failed++;
        }
+*/
        failed += test_uuid("84949cc5-4701-4a84-895b-354c584a981b", 1);
        failed += test_uuid("84949CC5-4701-4A84-895B-354C584A981B", 1);
        failed += test_uuid("84949cc5-4701-4a84-895b-354c584a981bc", 0);
@@ -171,6 +174,9 @@ main(int argc ATTR((unused)) , char **argv ATTR((unused)))
        failed += test_uuid("84949cc5-4701-4a84-895b0354c584a981b", 0);
        failed += test_uuid("g4949cc5-4701-4a84-895b-354c584a981b", 0);
        failed += test_uuid("84949cc5-4701-4a84-895b-354c584a981g", 0);
+       failed += test_uuid("00000000-0000-0000-0000-000000000000", 1);
+       failed += test_uuid("01234567-89ab-cdef-0134-567890abcedf", 1);
+       failed += test_uuid("ffffffff-ffff-ffff-ffff-ffffffffffff", 1);
 
        if (failed) {
                printf("%d failures.\n", failed);
index 737918f4b17474b61d325cc119da5a32ce003384..84bf661874069d561f928d80338bcfae2709acde 100644 (file)
@@ -30,6 +30,7 @@ TS_HELPER_SCRIPT="$top_builddir/test_script"
 TS_HELPER_SIGRECEIVE="$top_builddir/test_sigreceive"
 TS_HELPER_STRUTILS="$top_builddir/test_strutils"
 TS_HELPER_SYSINFO="$top_builddir/test_sysinfo"
+TS_HELPER_UUID_PARSER="$top_builddir/test_uuid_parser"
 
 # paths to commands
 TS_CMD_ADDPART=${TS_CMD_ADDPART:-"$top_builddir/addpart"}
diff --git a/tests/expected/uuid/uuid_parser b/tests/expected/uuid/uuid_parser
new file mode 100644 (file)
index 0000000..a9eb672
--- /dev/null
@@ -0,0 +1,15 @@
+84949cc5-4701-4a84-895b-354c584a981b is valid, OK
+84949CC5-4701-4A84-895B-354C584A981B is valid, OK
+84949cc5-4701-4a84-895b-354c584a981bc is invalid, OK
+84949cc5-4701-4a84-895b-354c584a981 is invalid, OK
+84949cc5x4701-4a84-895b-354c584a981b is invalid, OK
+84949cc504701-4a84-895b-354c584a981b is invalid, OK
+84949cc5-470104a84-895b-354c584a981b is invalid, OK
+84949cc5-4701-4a840895b-354c584a981b is invalid, OK
+84949cc5-4701-4a84-895b0354c584a981b is invalid, OK
+g4949cc5-4701-4a84-895b-354c584a981b is invalid, OK
+84949cc5-4701-4a84-895b-354c584a981g is invalid, OK
+00000000-0000-0000-0000-000000000000 is valid, OK
+01234567-89ab-cdef-0134-567890abcedf is valid, OK
+ffffffff-ffff-ffff-ffff-ffffffffffff is valid, OK
+return value: 0
diff --git a/tests/ts/uuid/uuid_parser b/tests/ts/uuid/uuid_parser
new file mode 100755 (executable)
index 0000000..d80d269
--- /dev/null
@@ -0,0 +1,26 @@
+#!/bin/bash
+
+# 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_DESC="uuid_parser"
+
+. $TS_TOPDIR/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_HELPER_UUID_PARSER"
+
+$TS_HELPER_UUID_PARSER > $TS_OUTPUT 2>&1
+echo "return value: $?" >> $TS_OUTPUT
+
+ts_finalize