2 Unix SMB/CIFS implementation.
3 test suite for basic tdr functions
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/torture.h"
24 #include "lib/tdr/tdr.h"
26 static bool test_push_uint8(struct torture_context
*tctx
)
29 struct tdr_push
*tdr
= talloc_zero(tctx
, struct tdr_push
);
31 torture_assert_ntstatus_ok(tctx
, tdr_push_uint8(tdr
, &v
), "push failed");
32 torture_assert_int_equal(tctx
, tdr
->data
.length
, 1, "length incorrect");
33 torture_assert_int_equal(tctx
, tdr
->data
.data
[0], 4, "data incorrect");
37 static bool test_pull_uint8(struct torture_context
*tctx
)
46 torture_assert_ntstatus_ok(tctx
, tdr_pull_uint8(&tdr
, tctx
, &l
),
48 torture_assert_int_equal(tctx
, 1, tdr
.offset
,
53 static bool test_push_uint16(struct torture_context
*tctx
)
56 struct tdr_push
*tdr
= talloc_zero(tctx
, struct tdr_push
);
58 torture_assert_ntstatus_ok(tctx
, tdr_push_uint16(tdr
, &v
), "push failed");
59 torture_assert_int_equal(tctx
, tdr
->data
.length
, 2, "length incorrect");
60 torture_assert_int_equal(tctx
, tdr
->data
.data
[0], 0x32, "data incorrect");
61 torture_assert_int_equal(tctx
, tdr
->data
.data
[1], 0x0F, "data incorrect");
65 static bool test_pull_uint16(struct torture_context
*tctx
)
70 tdr
.data
.data
= (uint8_t *)&d
;
74 torture_assert_ntstatus_ok(tctx
, tdr_pull_uint16(&tdr
, tctx
, &l
),
76 torture_assert_int_equal(tctx
, 2, tdr
.offset
,
78 torture_assert_int_equal(tctx
, 782, l
, "right int read");
82 struct torture_suite
*torture_local_tdr(TALLOC_CTX
*mem_ctx
)
84 struct torture_suite
*suite
= torture_suite_create(mem_ctx
, "TDR");
86 torture_suite_add_simple_test(suite
, "pull_uint8", test_pull_uint8
);
87 torture_suite_add_simple_test(suite
, "push_uint8", test_push_uint8
);
89 torture_suite_add_simple_test(suite
, "pull_uint16", test_pull_uint16
);
90 torture_suite_add_simple_test(suite
, "push_uint16", test_push_uint16
);