d3a6492b64eae20ee1d6ef133c6fb874ee76e794
[obnox/samba/samba-obnox.git] / source4 / torture / ndr / ndr.h
1 /*
2    Unix SMB/CIFS implementation.
3    SMB torture tester
4    Copyright (C) Jelmer Vernooij 2007
5
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.
10
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.
15
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/>.
18 */
19
20 #ifndef __TORTURE_NDR_H__
21 #define __TORTURE_NDR_H__
22
23 #include "torture/torture.h"
24 #include "librpc/ndr/libndr.h"
25 #include "libcli/security/security.h"
26
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                                         DATA_BLOB db,
33                                         size_t struct_size,
34                                         int ndr_flags,
35                                         int flags,
36                                         bool (*check_fn) (struct torture_context *, void *data));
37
38 _PUBLIC_ struct torture_test *_torture_suite_add_ndr_pull_inout_test(
39                                         struct torture_suite *suite,
40                                         const char *name, ndr_pull_flags_fn_t pull_fn,
41                                         DATA_BLOB db_in,
42                                         DATA_BLOB db_out,
43                                         size_t struct_size,
44                                         bool (*check_fn) (struct torture_context *ctx, void *data));
45
46 #define torture_suite_add_ndr_pull_test(suite,name,data,check_fn) \
47                 _torture_suite_add_ndr_pullpush_test(suite, #name, \
48                          (ndr_pull_flags_fn_t)ndr_pull_ ## name, \
49                          NULL, \
50                          data_blob_const(data, sizeof(data)), \
51                          sizeof(struct name), \
52                          NDR_SCALARS|NDR_BUFFERS, 0, \
53                          (bool (*) (struct torture_context *, void *)) check_fn);
54
55 #define torture_suite_add_ndr_pull_fn_test(suite,name,data,flags,check_fn) \
56                 _torture_suite_add_ndr_pullpush_test(suite, #name "_" #flags, \
57                          (ndr_pull_flags_fn_t)ndr_pull_ ## name, \
58                          NULL, \
59                          data_blob_const(data, sizeof(data)), \
60                          sizeof(struct name), \
61                          flags, 0, \
62                          (bool (*) (struct torture_context *, void *)) check_fn);
63
64 #define torture_suite_add_ndr_pull_fn_test_flags(suite,name,data,flags,flags2,check_fn) \
65                 _torture_suite_add_ndr_pullpush_test(suite, #name "_" #flags "_" #flags2, \
66                          (ndr_pull_flags_fn_t)ndr_pull_ ## name, \
67                          NULL, \
68                          data_blob_const(data, sizeof(data)), \
69                          sizeof(struct name), \
70                          flags, flags2, \
71                          (bool (*) (struct torture_context *, void *)) check_fn);
72
73 #define torture_suite_add_ndr_pullpush_test(suite,name,data_blob,check_fn) \
74                 _torture_suite_add_ndr_pullpush_test(suite, #name, \
75                          (ndr_pull_flags_fn_t)ndr_pull_ ## name, \
76                          (ndr_push_flags_fn_t)ndr_push_ ## name, \
77                          data_blob, \
78                          sizeof(struct name), \
79                          NDR_SCALARS|NDR_BUFFERS, 0, \
80                          (bool (*) (struct torture_context *, void *)) check_fn);
81
82 #define torture_suite_add_ndr_pull_io_test(suite,name,data_in,data_out,check_fn_out) \
83                 _torture_suite_add_ndr_pull_inout_test(suite, #name "_INOUT", \
84                          (ndr_pull_flags_fn_t)ndr_pull_ ## name, \
85                          data_blob_const(data_in, sizeof(data_in)), \
86                          data_blob_const(data_out, sizeof(data_out)), \
87                          sizeof(struct name), \
88                          (bool (*) (struct torture_context *, void *)) check_fn_out);
89
90 #endif /* __TORTURE_NDR_H__ */