xref: /illumos-gate/usr/src/test/util-tests/tests/ctf/check-merge-dedup.c (revision 5328fc53d11d7151861fa272e4fb0248b8f0e145)
1 /*
2  * This file and its contents are supplied under the terms of the
3  * Common Development and Distribution License ("CDDL"), version 1.0.
4  * You may only use this file in accordance with the terms of version
5  * 1.0 of the CDDL.
6  *
7  * A full copy of the text of the CDDL should have accompanied this
8  * source.  A copy of the CDDL is also available via the Internet at
9  * http://www.illumos.org/license/CDDL.
10  */
11 
12 /*
13  * Copyright (c) 2019, Joyent, Inc.
14  */
15 
16 /*
17  * This tests that we don't end up with several copies of the same type.
18  */
19 
20 #include "check-common.h"
21 
22 static check_symbol_t check_syms[] = {
23 	{ "int", "a" },
24 	{ "short", "b" },
25 	{ "const char *", "c" },
26 	{ "float", "d" },
27 	{ "double" "e" },
28 	{ "int", "f" },
29 	{ "short", "g" },
30 	{ "const char *", "h" },
31 	{ "float", "i" },
32 	{ "double" "j" },
33 	{ "int", "k" },
34 	{ "short", "l" },
35 	{ "const char *", "m" },
36 	{ "float", "n" },
37 	{ "double" "o" },
38 	{ "int", "p" },
39 	{ "short", "q" },
40 	{ "const char *", "r" },
41 	{ "float", "s" },
42 	{ "double" "t" },
43 	{ "struct dup" "dupmain" },
44 	{ "struct dup" "dup1" },
45 	{ "struct dup" "dup2" },
46 	{ "struct dup" "dup3" },
47 	{ NULL }
48 };
49 
50 
51 int
52 main(int argc, char *argv[])
53 {
54 	int i, ret = 0;
55 
56 	if (argc < 2) {
57 		errx(EXIT_FAILURE, "missing test files");
58 	}
59 
60 	for (i = 1; i < argc; i++) {
61 		ctf_file_t *fp;
62 
63 		if ((fp = ctf_open(argv[i], &ret)) == NULL) {
64 			warnx("failed to open %s: %s", argv[i],
65 			    ctf_errmsg(ret));
66 			ret = EXIT_FAILURE;
67 			continue;
68 		}
69 
70 		if (!ctftest_check_symbols(fp, check_syms)) {
71 			ret = EXIT_FAILURE;
72 		}
73 
74 		if (!ctftest_duplicates(fp)) {
75 			ret = EXIT_FAILURE;
76 		}
77 
78 		ctf_close(fp);
79 	}
80 
81 	return (ret);
82 }
83