2 Unix SMB/CIFS implementation.
3 test suite for winreg ndr operations
5 Copyright (C) Jelmer Vernooij 2007
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 #include "torture/ndr/ndr.h"
24 #include "torture/ndr/proto.h"
25 #include "util/dlinklist.h"
27 struct ndr_pull_test_data
{
30 ndr_pull_flags_fn_t pull_fn
;
34 static bool wrap_ndr_pull_test(struct torture_context
*tctx
,
35 struct torture_tcase
*tcase
,
36 struct torture_test
*test
)
38 bool (*check_fn
) (struct torture_context
*ctx
, void *data
) = test
->fn
;
39 const struct ndr_pull_test_data
*data
= test
->data
;
40 void *ds
= talloc_zero_size(tctx
, data
->struct_size
);
41 struct ndr_pull
*ndr
= ndr_pull_init_blob(&(data
->data
), tctx
);
43 ndr
->flags
|= LIBNDR_FLAG_REF_ALLOC
;
45 torture_assert_ntstatus_ok(tctx
, data
->pull_fn(ndr
, data
->ndr_flags
, ds
),
48 return check_fn(tctx
, ds
);
51 _PUBLIC_
struct torture_test
*_torture_suite_add_ndr_pull_test(
52 struct torture_suite
*suite
,
53 const char *name
, ndr_pull_flags_fn_t pull_fn
,
57 bool (*check_fn
) (struct torture_context
*ctx
, void *data
))
59 struct torture_test
*test
;
60 struct torture_tcase
*tcase
;
61 struct ndr_pull_test_data
*data
;
63 tcase
= torture_suite_add_tcase(suite
, name
);
65 test
= talloc(tcase
, struct torture_test
);
67 test
->name
= talloc_strdup(test
, name
);
68 test
->description
= NULL
;
69 test
->run
= wrap_ndr_pull_test
;
70 data
= talloc(test
, struct ndr_pull_test_data
);
72 data
->ndr_flags
= ndr_flags
;
73 data
->struct_size
= struct_size
;
74 data
->pull_fn
= pull_fn
;
77 test
->dangerous
= false;
79 DLIST_ADD_END(tcase
->tests
, test
, struct torture_test
*);
84 NTSTATUS
torture_ndr_init(void)
86 struct torture_suite
*suite
= torture_suite_create(talloc_autofree_context(), "NDR");
88 torture_suite_add_suite(suite
, ndr_winreg_suite(suite
));
89 torture_suite_add_suite(suite
, ndr_atsvc_suite(suite
));
90 torture_suite_add_suite(suite
, ndr_lsa_suite(suite
));
92 torture_register_suite(suite
);