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.
24 BOOL test_check_string_terminator(TALLOC_CTX *mem_ctx)
30 blob = strhex_to_data_blob("0000");
32 ndr = ndr_pull_init_blob(&blob, mem_ctx);
34 if (NT_STATUS_IS_ERR(ndr_check_string_terminator(ndr, 1, 2))) {
35 DEBUG(0, ("simple check_string_terminator test failed\n"));
39 if (ndr->offset != 0) {
40 DEBUG(0, ("check_string_terminator did not reset offset\n"));
44 if (NT_STATUS_IS_OK(ndr_check_string_terminator(ndr, 1, 3))) {
45 DEBUG(0, ("check_string_terminator checked beyond string boundaries\n"));
49 if (ndr->offset != 0) {
50 DEBUG(0, ("check_string_terminator did not reset offset\n"));
56 blob = strhex_to_data_blob("11220000");
57 ndr = ndr_pull_init_blob(&blob, mem_ctx);
59 if (NT_STATUS_IS_ERR(ndr_check_string_terminator(ndr, 4, 1))) {
60 DEBUG(0, ("check_string_terminator failed to recognize terminator\n"));
64 if (NT_STATUS_IS_ERR(ndr_check_string_terminator(ndr, 3, 1))) {
65 DEBUG(0, ("check_string_terminator failed to recognize terminator\n"));
69 if (NT_STATUS_IS_OK(ndr_check_string_terminator(ndr, 2, 1))) {
70 DEBUG(0, ("check_string_terminator erroneously reported terminator\n"));
74 if (ndr->offset != 0) {
75 DEBUG(0, ("check_string_terminator did not reset offset\n"));
84 BOOL torture_rpc_ndr(void)
90 mem_ctx = talloc_init("torture_rpc_mgmt");
92 ret &= test_check_string_terminator(mem_ctx);