2 Unix SMB/CIFS implementation.
3 test suite for basic ndr functions
5 Copyright (C) Jelmer Vernooij 2005
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/torture.h"
24 #include "librpc/ndr/libndr.h"
26 static bool test_check_string_terminator(struct torture_context *tctx)
30 TALLOC_CTX *mem_ctx = tctx;
33 blob = strhex_to_data_blob("0000");
35 ndr = ndr_pull_init_blob(&blob, mem_ctx);
37 torture_assert_ntstatus_ok(tctx, ndr_check_string_terminator(ndr, 1, 2),
38 "simple check_string_terminator test failed");
40 torture_assert(tctx, ndr->offset == 0,
41 "check_string_terminator did not reset offset");
43 if (NT_STATUS_IS_OK(ndr_check_string_terminator(ndr, 1, 3))) {
44 torture_fail(tctx, "check_string_terminator checked beyond string boundaries");
47 torture_assert(tctx, ndr->offset == 0,
48 "check_string_terminator did not reset offset");
52 blob = strhex_to_data_blob("11220000");
53 ndr = ndr_pull_init_blob(&blob, mem_ctx);
55 torture_assert_ntstatus_ok(tctx,
56 ndr_check_string_terminator(ndr, 4, 1),
57 "check_string_terminator failed to recognize terminator");
59 torture_assert_ntstatus_ok(tctx,
60 ndr_check_string_terminator(ndr, 3, 1),
61 "check_string_terminator failed to recognize terminator");
63 if (NT_STATUS_IS_OK(ndr_check_string_terminator(ndr, 2, 1))) {
65 "check_string_terminator erroneously reported terminator");
68 torture_assert(tctx, ndr->offset == 0,
69 "check_string_terminator did not reset offset");
73 struct torture_suite *torture_local_ndr(TALLOC_CTX *mem_ctx)
75 struct torture_suite *suite = torture_suite_create(mem_ctx, "NDR");
77 torture_suite_add_simple_test(suite, "string terminator",
78 test_check_string_terminator);