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 #ifndef _CHECK_COMMON_H
17 #define _CHECK_COMMON_H
18
19 /*
20 * Common definitions for the CTF tests
21 */
22
23 #include <stdlib.h>
24 #include <unistd.h>
25 #include <libctf.h>
26 #include <err.h>
27 #include <strings.h>
28 #include <sys/param.h>
29
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33
70 const char *cm_name;
71 const char *cm_type;
72 ulong_t cm_offset;
73 } check_member_t;
74
75 typedef struct check_member_test {
76 const char *cmt_type;
77 int cmt_kind;
78 size_t cmt_size;
79 const check_member_t *cmt_members;
80 } check_member_test_t;
81
82 typedef struct check_function_test {
83 const char *cft_name;
84 const char *cft_rtype;
85 uint_t cft_nargs;
86 uint_t cft_flags;
87 const char **cft_args;
88 } check_function_test_t;
89
90 /*
91 * Looks up each type and verifies that it matches the expected type.
92 */
93 extern boolean_t ctftest_check_numbers(ctf_file_t *, const check_number_t *);
94
95 /*
96 * Looks at each symbol specified and verifies that it matches the expected
97 * type.
98 */
99 extern boolean_t ctftest_check_symbols(ctf_file_t *, const check_symbol_t *);
100
101 /*
102 * Given a symbol name which refers to a type, walks all the references of that
103 * type and checks against it with each subsequent entry.
104 */
105 extern boolean_t ctftest_check_descent(const char *, ctf_file_t *,
106 const check_descent_t *, boolean_t);
107
108 /*
109 * Checks that all of the listed members of an enum are present and have the
113 const check_enum_t *);
114
115 /*
116 * Checks that all of the members of a structure or union are present and have
117 * the right types and byte offsets. This can be used for either structures or
118 * unions.
119 */
120 extern boolean_t ctftest_check_members(const char *, ctf_file_t *, int, size_t,
121 const check_member_t *);
122
123 /*
124 * Check that the named function or function pointer has the correct return
125 * type, arguments, and function flags.
126 */
127 extern boolean_t ctftest_check_function(const char *, ctf_file_t *,
128 const char *, uint_t, uint_t, const char **);
129 extern boolean_t ctftest_check_fptr(const char *, ctf_file_t *,
130 const char *, uint_t, uint_t, const char **);
131
132 /*
133 * Determine whether or not we have a duplicate type or not based on its name.
134 */
135 extern boolean_t ctftest_duplicates(ctf_file_t *);
136
137 #ifdef __cplusplus
138 }
139 #endif
140
141 #endif /* _CHECK_COMMON_H */
|
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 #ifndef _CHECK_COMMON_H
17 #define _CHECK_COMMON_H
18
19 /*
20 * Common definitions for the CTF tests
21 */
22
23 #include <stdlib.h>
24 #include <unistd.h>
25 #include <libctf.h>
26 #include <err.h>
27 #include <strings.h>
28 #include <sys/param.h>
29
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33
70 const char *cm_name;
71 const char *cm_type;
72 ulong_t cm_offset;
73 } check_member_t;
74
75 typedef struct check_member_test {
76 const char *cmt_type;
77 int cmt_kind;
78 size_t cmt_size;
79 const check_member_t *cmt_members;
80 } check_member_test_t;
81
82 typedef struct check_function_test {
83 const char *cft_name;
84 const char *cft_rtype;
85 uint_t cft_nargs;
86 uint_t cft_flags;
87 const char **cft_args;
88 } check_function_test_t;
89
90 typedef struct check_size_test {
91 const char *cst_name;
92 size_t cst_size;
93 } check_size_test_t;
94
95 /*
96 * Looks up each type and verifies that it matches the expected type.
97 */
98 extern boolean_t ctftest_check_numbers(ctf_file_t *, const check_number_t *);
99
100 /*
101 * Looks at each symbol specified and verifies that it matches the expected
102 * type.
103 */
104 extern boolean_t ctftest_check_symbols(ctf_file_t *, const check_symbol_t *);
105
106 /*
107 * Given a symbol name which refers to a type, walks all the references of that
108 * type and checks against it with each subsequent entry.
109 */
110 extern boolean_t ctftest_check_descent(const char *, ctf_file_t *,
111 const check_descent_t *, boolean_t);
112
113 /*
114 * Checks that all of the listed members of an enum are present and have the
118 const check_enum_t *);
119
120 /*
121 * Checks that all of the members of a structure or union are present and have
122 * the right types and byte offsets. This can be used for either structures or
123 * unions.
124 */
125 extern boolean_t ctftest_check_members(const char *, ctf_file_t *, int, size_t,
126 const check_member_t *);
127
128 /*
129 * Check that the named function or function pointer has the correct return
130 * type, arguments, and function flags.
131 */
132 extern boolean_t ctftest_check_function(const char *, ctf_file_t *,
133 const char *, uint_t, uint_t, const char **);
134 extern boolean_t ctftest_check_fptr(const char *, ctf_file_t *,
135 const char *, uint_t, uint_t, const char **);
136
137 /*
138 * Check size of types.
139 */
140 extern boolean_t ctftest_check_size(const char *, ctf_file_t *, size_t);
141
142 /*
143 * Determine whether or not we have a duplicate type or not based on its name.
144 */
145 extern boolean_t ctftest_duplicates(ctf_file_t *);
146
147 #ifdef __cplusplus
148 }
149 #endif
150
151 #endif /* _CHECK_COMMON_H */
|