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"
25 BOOL test_check_string_terminator(TALLOC_CTX *mem_ctx)
31 blob = strhex_to_data_blob("0000");
33 ndr = ndr_pull_init_blob(&blob, mem_ctx);
35 if (NT_STATUS_IS_ERR(ndr_check_string_terminator(ndr, 1, 2))) {
36 DEBUG(0, ("simple check_string_terminator test failed\n"));
40 if (ndr->offset != 0) {
41 DEBUG(0, ("check_string_terminator did not reset offset\n"));
45 if (NT_STATUS_IS_OK(ndr_check_string_terminator(ndr, 1, 3))) {
46 DEBUG(0, ("check_string_terminator checked beyond string boundaries\n"));
50 if (ndr->offset != 0) {
51 DEBUG(0, ("check_string_terminator did not reset offset\n"));
57 blob = strhex_to_data_blob("11220000");
58 ndr = ndr_pull_init_blob(&blob, mem_ctx);
60 if (NT_STATUS_IS_ERR(ndr_check_string_terminator(ndr, 4, 1))) {
61 DEBUG(0, ("check_string_terminator failed to recognize terminator\n"));
65 if (NT_STATUS_IS_ERR(ndr_check_string_terminator(ndr, 3, 1))) {
66 DEBUG(0, ("check_string_terminator failed to recognize terminator\n"));
70 if (NT_STATUS_IS_OK(ndr_check_string_terminator(ndr, 2, 1))) {
71 DEBUG(0, ("check_string_terminator erroneously reported terminator\n"));
75 if (ndr->offset != 0) {
76 DEBUG(0, ("check_string_terminator did not reset offset\n"));
85 BOOL torture_local_ndr(void)
91 mem_ctx = talloc_init("torture_local_ndr");
93 ret &= test_check_string_terminator(mem_ctx);