blob: c474af74e25289a9dfbf19457079cff7133e0073 [file] [log] [blame]
Theodore Ts'o19c78dc1997-04-29 16:17:09 +00001/*
2 * tst_uuid.c --- test program from the UUID library
3 *
4 * Copyright (C) 1996, 1997 Theodore Ts'o.
5 *
6 * %Begin-Header%
7 * This file may be redistributed under the terms of the GNU Public
8 * License.
9 * %End-Header%
10 */
11
Theodore Ts'o1e3472c1997-04-29 14:53:37 +000012#include <stdio.h>
13#include <linux/ext2_fs.h>
14
15#include "uuid.h"
16
17int
Theodore Ts'o818180c1998-06-27 05:11:14 +000018main(int argc, char **argv)
Theodore Ts'o1e3472c1997-04-29 14:53:37 +000019{
20 uuid_t buf, tst;
21 char str[100];
22 unsigned char *cp;
23 int i;
24 int failed = 0;
25
26 uuid_generate(buf);
27 uuid_unparse(buf, str);
28 printf("UUID string = %s\n", str);
29 printf("UUID: ");
30 for (i=0, cp = (unsigned char *) &buf; i < 16; i++) {
31 printf("%02x", *cp++);
32 }
33 printf("\n");
34 uuid_parse(str, tst);
35 if (uuid_compare(buf, tst))
36 printf("UUID parse and compare succeeded.\n");
37 else {
38 printf("UUID parse and compare failed!\n");
39 failed++;
40 }
41 uuid_clear(tst);
42 if (uuid_is_null(tst))
43 printf("UUID clear and is null succeeded.\n");
44 else {
45 printf("UUID clear and is null failed!\n");
46 failed++;
47 }
48 uuid_copy(buf, tst);
49 if (uuid_compare(buf, tst))
50 printf("UUID copy and compare succeeded.\n");
51 else {
52 printf("UUID copy and compare failed!\n");
53 failed++;
54 }
55 if (failed) {
56 printf("%d failures.\n", failed);
57 exit(1);
58 }
59 return 0;
60}
61
62
63