2 * tst_uuid.c --- test program from the UUID library
4 * Copyright (C) 1996, 1997, 1998 Theodore Ts'o.
7 * This file may be redistributed under the terms of the GNU Public
13 #include <linux/ext2_fs.h>
18 main(int argc, char **argv)
30 uuid_unparse(buf, str);
31 printf("UUID generate = %s\n", str);
33 for (i=0, cp = (unsigned char *) &buf; i < 16; i++) {
34 printf("%02x", *cp++);
37 type = uuid_type(buf); variant = uuid_variant(buf);
38 printf("UUID type = %d, UUID variant = %d\n", type, variant);
39 if (variant != UUID_VARIANT_DCE) {
40 printf("Incorrect UUID Variant; was expecting DCE!\n");
45 uuid_generate_random(buf);
46 uuid_unparse(buf, str);
47 printf("UUID random string = %s\n", str);
49 for (i=0, cp = (unsigned char *) &buf; i < 16; i++) {
50 printf("%02x", *cp++);
53 type = uuid_type(buf); variant = uuid_variant(buf);
54 printf("UUID type = %d, UUID variant = %d\n", type, variant);
55 if (variant != UUID_VARIANT_DCE) {
56 printf("Incorrect UUID Variant; was expecting DCE!\n");
60 printf("Incorrect UUID type; was expecting "
61 "4 (random type)!\n");
66 uuid_generate_time(buf);
67 uuid_unparse(buf, str);
68 printf("UUID string = %s\n", str);
69 printf("UUID time: ");
70 for (i=0, cp = (unsigned char *) &buf; i < 16; i++) {
71 printf("%02x", *cp++);
74 type = uuid_type(buf); variant = uuid_variant(buf);
75 printf("UUID type = %d, UUID variant = %d\n", type, variant);
76 if (variant != UUID_VARIANT_DCE) {
77 printf("Incorrect UUID Variant; was expecting DCE!\n");
81 printf("Incorrect UUID type; was expecting "
82 "1 (time-based type)!\\n");
87 time_reg = uuid_time(buf, &tv);
88 printf("UUID time is: (%ld, %ld): %s\n", tv.tv_sec, tv.tv_usec,
91 if (!uuid_compare(buf, tst))
92 printf("UUID parse and compare succeeded.\n");
94 printf("UUID parse and compare failed!\n");
98 if (uuid_is_null(tst))
99 printf("UUID clear and is null succeeded.\n");
101 printf("UUID clear and is null failed!\n");
105 if (!uuid_compare(buf, tst))
106 printf("UUID copy and compare succeeded.\n");
108 printf("UUID copy and compare failed!\n");
112 printf("%d failures.\n", failed);