ctdb-scripts: Support storing statd-callout state in cluster filesystem
[samba4-gss.git] / source4 / torture / ndr / ndr.h
blob82ccc69e94dca77f3eb13be38430916ee1d18aaa
1 /*
2 Unix SMB/CIFS implementation.
3 SMB torture tester
4 Copyright (C) Jelmer Vernooij 2007
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #ifndef __TORTURE_NDR_H__
21 #define __TORTURE_NDR_H__
23 #include "torture/torture.h"
24 #include "librpc/ndr/libndr.h"
25 #include "libcli/security/security.h"
27 _PUBLIC_ struct torture_test *_torture_suite_add_ndr_pullpush_test(
28 struct torture_suite *suite,
29 const char *name,
30 ndr_pull_flags_fn_t pull_fn,
31 ndr_push_flags_fn_t push_fn,
32 ndr_print_fn_t print_fn,
33 ndr_print_function_t print_function,
34 const char *db_name,
35 DATA_BLOB db,
36 size_t struct_size,
37 ndr_flags_type ndr_flags,
38 libndr_flags flags,
39 const char *check_fn_name,
40 bool (*check_fn) (struct torture_context *, void *data));
42 _PUBLIC_ struct torture_test *_torture_suite_add_ndr_pull_inout_test(
43 struct torture_suite *suite,
44 const char *name,
45 ndr_pull_flags_fn_t pull_fn,
46 ndr_print_function_t print_fn,
47 const char *db_in_name,
48 DATA_BLOB db_in,
49 const char *db_out_name,
50 DATA_BLOB db_out,
51 size_t struct_size,
52 libndr_flags flags,
53 const char *check_fn_name,
54 bool (*check_fn) (struct torture_context *ctx, void *data));
56 _PUBLIC_ struct torture_test *_torture_suite_add_ndr_pull_invalid_data_test(
57 struct torture_suite *suite,
58 const char *name,
59 ndr_pull_flags_fn_t pull_fn,
60 const char *db_name,
61 DATA_BLOB db,
62 size_t struct_size,
63 ndr_flags_type ndr_flags,
64 libndr_flags flags,
65 enum ndr_err_code ndr_err);
67 #define torture_suite_add_ndr_pull_test(suite,name,data,check_fn) \
68 do { \
69 bool (*check_fn_typed) (struct torture_context *, struct name *) = \
70 check_fn; \
71 bool (*check_fn_anon) (struct torture_context *, void *) = \
72 (bool (*) (struct torture_context *, void *)) check_fn_typed; \
73 _torture_suite_add_ndr_pullpush_test(suite, #name, \
74 (ndr_pull_flags_fn_t)ndr_pull_ ## name, \
75 NULL, \
76 (ndr_print_fn_t)ndr_print_ ## name, \
77 NULL, \
78 #data, \
79 data_blob_const(data, sizeof(data)), \
80 sizeof(struct name), \
81 NDR_SCALARS|NDR_BUFFERS, 0, \
82 #check_fn, \
83 check_fn_anon); \
84 } while(0)
86 #define torture_suite_add_ndr_pull_invalid_data_test(suite,name,data,ndr_err) \
87 _torture_suite_add_ndr_pull_invalid_data_test( \
88 suite, \
89 #name, \
90 (ndr_pull_flags_fn_t)ndr_pull_ ## name, \
91 #data, \
92 data_blob_const(data, sizeof(data)), \
93 sizeof(struct name), \
94 NDR_SCALARS|NDR_BUFFERS, 0, \
95 ndr_err);
97 #define torture_suite_add_ndr_pull_fn_test(suite,name,data,flags,check_fn) \
98 do { \
99 bool (*check_fn_typed) (struct torture_context *, struct name *) = \
100 check_fn; \
101 bool (*check_fn_anon) (struct torture_context *, void *) = \
102 (bool (*) (struct torture_context *, void *)) check_fn_typed; \
103 _torture_suite_add_ndr_pullpush_test(suite, #name "_" #flags, \
104 (ndr_pull_flags_fn_t)ndr_pull_ ## name, \
105 NULL, \
106 NULL, \
107 (ndr_print_function_t)ndr_print_ ## name, \
108 #data, \
109 data_blob_const(data, sizeof(data)), \
110 sizeof(struct name), \
111 flags, 0, \
112 #check_fn, \
113 check_fn_anon); \
114 } while(0)
116 #define torture_suite_add_ndr_pull_fn_test_flags(suite,name,data,flags,flags2,check_fn) \
117 do { \
118 bool (*check_fn_typed) (struct torture_context *, struct name *) = \
119 check_fn; \
120 bool (*check_fn_anon) (struct torture_context *, void *) = \
121 (bool (*) (struct torture_context *, void *)) check_fn_typed; \
122 _torture_suite_add_ndr_pullpush_test(suite, #name "_" #flags "_" #flags2, \
123 (ndr_pull_flags_fn_t)ndr_pull_ ## name, \
124 NULL, \
125 NULL, \
126 (ndr_print_function_t)ndr_print_ ## name, \
127 #data, \
128 data_blob_const(data, sizeof(data)), \
129 sizeof(struct name), \
130 flags, flags2, \
131 #check_fn, \
132 check_fn_anon); \
133 } while(0)
135 #define torture_suite_add_ndr_pull_validate_test(suite,name,data,check_fn) \
136 do { \
137 bool (*check_fn_typed) (struct torture_context *, struct name *) = \
138 check_fn; \
139 bool (*check_fn_anon) (struct torture_context *, void *) = \
140 (bool (*) (struct torture_context *, void *)) check_fn_typed; \
141 _torture_suite_add_ndr_pullpush_test(suite, #name "_VALIDATE", \
142 (ndr_pull_flags_fn_t)ndr_pull_ ## name, \
143 (ndr_push_flags_fn_t)ndr_push_ ## name, \
144 (ndr_print_fn_t)ndr_print_ ## name, \
145 NULL, \
146 #data, \
147 data_blob_const(data, sizeof(data)), \
148 sizeof(struct name), \
149 NDR_SCALARS|NDR_BUFFERS, 0, \
150 #check_fn, \
151 check_fn_anon); \
152 } while(0)
154 #define torture_suite_add_ndr_pull_validate_test_blob(suite,name,data_blob,check_fn) \
155 do { \
156 bool (*check_fn_typed) (struct torture_context *, struct name *) = \
157 check_fn; \
158 bool (*check_fn_anon) (struct torture_context *, void *) = \
159 (bool (*) (struct torture_context *, void *)) check_fn_typed; \
160 _torture_suite_add_ndr_pullpush_test(suite, #name "_VALIDATE", \
161 (ndr_pull_flags_fn_t)ndr_pull_ ## name, \
162 (ndr_push_flags_fn_t)ndr_push_ ## name, \
163 (ndr_print_fn_t)ndr_print_ ## name, \
164 NULL, \
165 #data_blob, \
166 data_blob, \
167 sizeof(struct name), \
168 NDR_SCALARS|NDR_BUFFERS, 0, \
169 #check_fn, \
170 check_fn_anon); \
171 } while(0)
173 #define torture_suite_add_ndr_pull_validate_test_b64(suite,name,tname,b64,check_fn) \
174 do { \
175 bool (*check_fn_typed) (struct torture_context *, struct name *) = \
176 check_fn; \
177 bool (*check_fn_anon) (struct torture_context *, void *) = \
178 (bool (*) (struct torture_context *, void *)) check_fn_typed; \
179 _torture_suite_add_ndr_pullpush_test(suite, #name "_" tname, \
180 (ndr_pull_flags_fn_t)ndr_pull_ ## name, \
181 (ndr_push_flags_fn_t)ndr_push_ ## name, \
182 (ndr_print_fn_t)ndr_print_ ## name, \
183 NULL, \
184 #b64, \
185 base64_decode_data_blob_talloc(suite, b64), \
186 sizeof(struct name), \
187 NDR_SCALARS|NDR_BUFFERS, 0, \
188 #check_fn, \
189 check_fn_anon); \
190 } while(0)
192 #define torture_suite_add_ndr_pullpush_fn_test_flags(suite,name,data,flags,flags2,check_fn) \
193 do { \
194 bool (*check_fn_typed) (struct torture_context *, struct name *) = \
195 check_fn; \
196 bool (*check_fn_anon) (struct torture_context *, void *) = \
197 (bool (*) (struct torture_context *, void *)) check_fn_typed; \
198 _torture_suite_add_ndr_pullpush_test(suite, #name, \
199 (ndr_pull_flags_fn_t)ndr_pull_ ## name, \
200 (ndr_push_flags_fn_t)ndr_push_ ## name, \
201 NULL, \
202 (ndr_print_function_t)ndr_print_ ## name, \
203 #data, \
204 data_blob_const(data, sizeof(data)), \
205 sizeof(struct name), \
206 flags, flags2, \
207 #check_fn, \
208 check_fn_anon); \
209 } while(0)
211 #define torture_suite_add_ndr_pull_io_test(suite,name,data_in,data_out,check_fn_out) \
212 do { \
213 bool (*check_fn_typed) (struct torture_context *, struct name *) = \
214 check_fn_out; \
215 bool (*check_fn_anon) (struct torture_context *, void *) = \
216 (bool (*) (struct torture_context *, void *)) check_fn_typed; \
217 _torture_suite_add_ndr_pull_inout_test(suite, #name "_INOUT", \
218 (ndr_pull_flags_fn_t)ndr_pull_ ## name, \
219 (ndr_print_function_t)ndr_print_ ## name, \
220 #data_in, \
221 data_blob_const(data_in, sizeof(data_in)), \
222 #data_out, \
223 data_blob_const(data_out, sizeof(data_out)), \
224 sizeof(struct name), \
225 0, \
226 #check_fn_out, \
227 check_fn_anon); \
228 } while(0)
230 #define torture_suite_add_ndr_pull_io_test_flags(suite,name,data_in,data_out,flags,check_fn_out) \
231 do { \
232 bool (*check_fn_typed) (struct torture_context *, struct name *) = \
233 check_fn_out; \
234 bool (*check_fn_anon) (struct torture_context *, void *) = \
235 (bool (*) (struct torture_context *, void *)) check_fn_typed; \
236 _torture_suite_add_ndr_pull_inout_test(suite, #name "_INOUT_" #flags, \
237 (ndr_pull_flags_fn_t)ndr_pull_ ## name, \
238 (ndr_print_function_t)ndr_print_ ## name, \
239 #data_in, \
240 data_blob_const(data_in, sizeof(data_in)), \
241 #data_out, \
242 data_blob_const(data_out, sizeof(data_out)), \
243 sizeof(struct name), \
244 flags, \
245 #check_fn_out, \
246 check_fn_anon); \
247 } while(0)
249 #endif /* __TORTURE_NDR_H__ */