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 2019, Joyent, Inc.
14 */
15
16 /*
17 * Check that we properly handle enums.
18 */
19
20 #include "check-common.h"
21
22 static check_symbol_t check_syms[] = {
23 { "ff6", "enum ff6" },
24 { "ff10", "ff10_t" },
25 { NULL }
26 };
27
28 static check_descent_t check_descent_ff6[] = {
29 { "enum ff6", CTF_K_ENUM },
30 { NULL }
31 };
32
33 static check_descent_t check_descent_ff10[] = {
84 { "CRONO", 0x1000 },
85 { "LUCCA", 0x2000 },
86 { "MARLE", 0x3000 },
87 { "FROG", 0x4000 },
88 { "ROBO", 0x5000 },
89 { "AYLA", 0x6000 },
90 { "MAGUS", 0x7000 },
91 { "SCHALA", 0x8000 },
92 { "LAVOS", 0x9000 },
93 { "BALTHAZAR", 0xa000 },
94 { NULL }
95 };
96
97 static check_enum_test_t enums[] = {
98 { "enum ff6", check_enum_ff6 },
99 { "enum ff10", check_enum_ff10 },
100 { "enum chrono", check_enum_chrono },
101 { NULL }
102 };
103
104 int
105 main(int argc, char *argv[])
106 {
107 int i, ret = 0;
108
109 if (argc < 2) {
110 errx(EXIT_FAILURE, "missing test files");
111 }
112
113 for (i = 1; i < argc; i++) {
114 ctf_file_t *fp;
115 uint_t d;
116
117 if ((fp = ctf_open(argv[i], &ret)) == NULL) {
118 warnx("failed to open %s: %s", argv[i],
119 ctf_errmsg(ret));
120 ret = EXIT_FAILURE;
121 continue;
122 }
123 if (!ctftest_check_symbols(fp, check_syms))
124 ret = EXIT_FAILURE;
125 for (d = 0; descents[d].cdt_sym != NULL; d++) {
126 if (!ctftest_check_descent(descents[d].cdt_sym, fp,
127 descents[d].cdt_tests, B_FALSE)) {
128 ret = EXIT_FAILURE;
129 }
130 }
131
132 for (d = 0; enums[d].cet_type != NULL; d++) {
133 if (!ctftest_check_enum(enums[d].cet_type, fp,
134 enums[d].cet_tests)) {
135 ret = EXIT_FAILURE;
136 }
137 }
138 ctf_close(fp);
139 }
140
141 return (ret);
142
143 }
|
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 2020 Joyent, Inc.
14 */
15
16 /*
17 * Check that we properly handle enums.
18 */
19
20 #include "check-common.h"
21
22 static check_symbol_t check_syms[] = {
23 { "ff6", "enum ff6" },
24 { "ff10", "ff10_t" },
25 { NULL }
26 };
27
28 static check_descent_t check_descent_ff6[] = {
29 { "enum ff6", CTF_K_ENUM },
30 { NULL }
31 };
32
33 static check_descent_t check_descent_ff10[] = {
84 { "CRONO", 0x1000 },
85 { "LUCCA", 0x2000 },
86 { "MARLE", 0x3000 },
87 { "FROG", 0x4000 },
88 { "ROBO", 0x5000 },
89 { "AYLA", 0x6000 },
90 { "MAGUS", 0x7000 },
91 { "SCHALA", 0x8000 },
92 { "LAVOS", 0x9000 },
93 { "BALTHAZAR", 0xa000 },
94 { NULL }
95 };
96
97 static check_enum_test_t enums[] = {
98 { "enum ff6", check_enum_ff6 },
99 { "enum ff10", check_enum_ff10 },
100 { "enum chrono", check_enum_chrono },
101 { NULL }
102 };
103
104 static check_size_test_t size_enums[] = {
105 { "enum char_enum", 1 },
106 { "enum short_enum", 2 },
107 { "enum int_enum", 4 },
108 { "enum ll_enum", 8 },
109 { NULL }
110 };
111
112 int
113 main(int argc, char *argv[])
114 {
115 int i, ret = 0;
116
117 if (argc < 2) {
118 errx(EXIT_FAILURE, "missing test files");
119 }
120
121 for (i = 1; i < argc; i++) {
122 ctf_file_t *fp;
123 uint_t d;
124
125 if ((fp = ctf_open(argv[i], &ret)) == NULL) {
126 warnx("failed to open %s: %s", argv[i],
127 ctf_errmsg(ret));
128 ret = EXIT_FAILURE;
129 continue;
130 }
131 if (!ctftest_check_symbols(fp, check_syms))
132 ret = EXIT_FAILURE;
133 for (d = 0; descents[d].cdt_sym != NULL; d++) {
134 if (!ctftest_check_descent(descents[d].cdt_sym, fp,
135 descents[d].cdt_tests, B_FALSE)) {
136 ret = EXIT_FAILURE;
137 }
138 }
139
140 for (d = 0; enums[d].cet_type != NULL; d++) {
141 if (!ctftest_check_enum(enums[d].cet_type, fp,
142 enums[d].cet_tests)) {
143 ret = EXIT_FAILURE;
144 }
145 }
146
147 for (d = 0; size_enums[d].cst_name != NULL; d++) {
148 if (!ctftest_check_size(size_enums[d].cst_name,
149 fp, size_enums[d].cst_size)) {
150 ret = EXIT_FAILURE;
151 }
152 }
153
154 ctf_close(fp);
155 }
156
157 return (ret);
158
159 }
|