2 Unix SMB/CIFS implementation.
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
,
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
,
37 ndr_flags_type ndr_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
,
45 ndr_pull_flags_fn_t pull_fn
,
46 ndr_print_function_t print_fn
,
47 const char *db_in_name
,
49 const char *db_out_name
,
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
,
59 ndr_pull_flags_fn_t pull_fn
,
63 ndr_flags_type ndr_flags
,
65 enum ndr_err_code ndr_err
);
67 #define torture_suite_add_ndr_pull_test(suite,name,data,check_fn) \
69 bool (*check_fn_typed) (struct torture_context *, struct name *) = \
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, \
76 (ndr_print_fn_t)ndr_print_ ## name, \
79 data_blob_const(data, sizeof(data)), \
80 sizeof(struct name), \
81 NDR_SCALARS|NDR_BUFFERS, 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( \
90 (ndr_pull_flags_fn_t)ndr_pull_ ## name, \
92 data_blob_const(data, sizeof(data)), \
93 sizeof(struct name), \
94 NDR_SCALARS|NDR_BUFFERS, 0, \
97 #define torture_suite_add_ndr_pull_fn_test(suite,name,data,flags,check_fn) \
99 bool (*check_fn_typed) (struct torture_context *, struct name *) = \
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, \
107 (ndr_print_function_t)ndr_print_ ## name, \
109 data_blob_const(data, sizeof(data)), \
110 sizeof(struct name), \
116 #define torture_suite_add_ndr_pull_fn_test_flags(suite,name,data,flags,flags2,check_fn) \
118 bool (*check_fn_typed) (struct torture_context *, struct name *) = \
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, \
126 (ndr_print_function_t)ndr_print_ ## name, \
128 data_blob_const(data, sizeof(data)), \
129 sizeof(struct name), \
135 #define torture_suite_add_ndr_pull_validate_test(suite,name,data,check_fn) \
137 bool (*check_fn_typed) (struct torture_context *, struct name *) = \
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, \
147 data_blob_const(data, sizeof(data)), \
148 sizeof(struct name), \
149 NDR_SCALARS|NDR_BUFFERS, 0, \
154 #define torture_suite_add_ndr_pull_validate_test_blob(suite,name,data_blob,check_fn) \
156 bool (*check_fn_typed) (struct torture_context *, struct name *) = \
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, \
167 sizeof(struct name), \
168 NDR_SCALARS|NDR_BUFFERS, 0, \
173 #define torture_suite_add_ndr_pull_validate_test_b64(suite,name,tname,b64,check_fn) \
175 bool (*check_fn_typed) (struct torture_context *, struct name *) = \
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, \
185 base64_decode_data_blob_talloc(suite, b64), \
186 sizeof(struct name), \
187 NDR_SCALARS|NDR_BUFFERS, 0, \
192 #define torture_suite_add_ndr_pullpush_fn_test_flags(suite,name,data,flags,flags2,check_fn) \
194 bool (*check_fn_typed) (struct torture_context *, struct name *) = \
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, \
202 (ndr_print_function_t)ndr_print_ ## name, \
204 data_blob_const(data, sizeof(data)), \
205 sizeof(struct name), \
211 #define torture_suite_add_ndr_pull_io_test(suite,name,data_in,data_out,check_fn_out) \
213 bool (*check_fn_typed) (struct torture_context *, struct name *) = \
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, \
221 data_blob_const(data_in, sizeof(data_in)), \
223 data_blob_const(data_out, sizeof(data_out)), \
224 sizeof(struct name), \
230 #define torture_suite_add_ndr_pull_io_test_flags(suite,name,data_in,data_out,flags,check_fn_out) \
232 bool (*check_fn_typed) (struct torture_context *, struct name *) = \
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, \
240 data_blob_const(data_in, sizeof(data_in)), \
242 data_blob_const(data_out, sizeof(data_out)), \
243 sizeof(struct name), \
249 #endif /* __TORTURE_NDR_H__ */