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),
49 return check_fn(tctx, ds);
54 _PUBLIC_ struct torture_test *_torture_suite_add_ndr_pull_test(
55 struct torture_suite *suite,
56 const char *name, ndr_pull_flags_fn_t pull_fn,
60 bool (*check_fn) (struct torture_context *ctx, void *data))
62 struct torture_test *test;
63 struct torture_tcase *tcase;
64 struct ndr_pull_test_data *data;
66 tcase = torture_suite_add_tcase(suite, name);
68 test = talloc(tcase, struct torture_test);
70 test->name = talloc_strdup(test, name);
71 test->description = NULL;
72 test->run = wrap_ndr_pull_test;
73 data = talloc(test, struct ndr_pull_test_data);
75 data->ndr_flags = ndr_flags;
76 data->struct_size = struct_size;
77 data->pull_fn = pull_fn;
80 test->dangerous = false;
82 DLIST_ADD_END(tcase->tests, test, struct torture_test *);
87 NTSTATUS torture_ndr_init(void)
89 struct torture_suite *suite = torture_suite_create(talloc_autofree_context(), "NDR");
91 torture_suite_add_suite(suite, ndr_winreg_suite(suite));
92 torture_suite_add_suite(suite, ndr_atsvc_suite(suite));
93 torture_suite_add_suite(suite, ndr_lsa_suite(suite));
94 torture_suite_add_suite(suite, ndr_epmap_suite(suite));
95 torture_suite_add_suite(suite, ndr_dfs_suite(suite));
97 torture_register_suite(suite);