Theodore Ts'o | 19c78dc | 1997-04-29 16:17:09 +0000 | [diff] [blame^] | 1 | /* |
| 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'o | 1e3472c | 1997-04-29 14:53:37 +0000 | [diff] [blame] | 12 | #include <stdio.h> |
| 13 | #include <linux/ext2_fs.h> |
| 14 | |
| 15 | #include "uuid.h" |
| 16 | |
| 17 | int |
| 18 | main(int argc, char *argv) |
| 19 | { |
| 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 | |