summaryrefslogtreecommitdiff
path: root/source4/lib/tdr/testsuite.c
diff options
context:
space:
mode:
Diffstat (limited to 'source4/lib/tdr/testsuite.c')
-rw-r--r--source4/lib/tdr/testsuite.c86
1 files changed, 43 insertions, 43 deletions
diff --git a/source4/lib/tdr/testsuite.c b/source4/lib/tdr/testsuite.c
index 20afca25a5..44c5810f90 100644
--- a/source4/lib/tdr/testsuite.c
+++ b/source4/lib/tdr/testsuite.c
@@ -21,11 +21,12 @@
#include "includes.h"
#include "torture/torture.h"
#include "lib/tdr/tdr.h"
+#include "param/param.h"
static bool test_push_uint8(struct torture_context *tctx)
{
uint8_t v = 4;
- struct tdr_push *tdr = talloc_zero(tctx, struct tdr_push);
+ struct tdr_push *tdr = tdr_push_init(tctx, lp_iconv_convenience(tctx->lp_ctx));
torture_assert_ntstatus_ok(tctx, tdr_push_uint8(tdr, &v), "push failed");
torture_assert_int_equal(tctx, tdr->data.length, 1, "length incorrect");
@@ -37,14 +38,14 @@ static bool test_pull_uint8(struct torture_context *tctx)
{
uint8_t d = 2;
uint8_t l;
- struct tdr_pull tdr;
- tdr.data.data = &d;
- tdr.data.length = 1;
- tdr.offset = 0;
- tdr.flags = 0;
- torture_assert_ntstatus_ok(tctx, tdr_pull_uint8(&tdr, tctx, &l),
+ struct tdr_pull *tdr = tdr_pull_init(tctx, lp_iconv_convenience(tctx->lp_ctx));
+ tdr->data.data = &d;
+ tdr->data.length = 1;
+ tdr->offset = 0;
+ tdr->flags = 0;
+ torture_assert_ntstatus_ok(tctx, tdr_pull_uint8(tdr, tctx, &l),
"pull failed");
- torture_assert_int_equal(tctx, 1, tdr.offset,
+ torture_assert_int_equal(tctx, 1, tdr->offset,
"offset invalid");
return true;
}
@@ -52,7 +53,7 @@ static bool test_pull_uint8(struct torture_context *tctx)
static bool test_push_uint16(struct torture_context *tctx)
{
uint16_t v = 0xF32;
- struct tdr_push *tdr = talloc_zero(tctx, struct tdr_push);
+ struct tdr_push *tdr = tdr_push_init(tctx, lp_iconv_convenience(tctx->lp_ctx));
torture_assert_ntstatus_ok(tctx, tdr_push_uint16(tdr, &v), "push failed");
torture_assert_int_equal(tctx, tdr->data.length, 2, "length incorrect");
@@ -65,15 +66,14 @@ static bool test_pull_uint16(struct torture_context *tctx)
{
uint8_t d[2] = { 782 & 0xFF, (782 & 0xFF00) / 0x100 };
uint16_t l;
- struct tdr_pull tdr;
- tdr.data.data = d;
- tdr.data.length = 2;
- tdr.offset = 0;
- tdr.flags = 0;
- torture_assert_ntstatus_ok(tctx, tdr_pull_uint16(&tdr, tctx, &l),
+ struct tdr_pull *tdr = tdr_pull_init(tctx, lp_iconv_convenience(tctx->lp_ctx));
+ tdr->data.data = d;
+ tdr->data.length = 2;
+ tdr->offset = 0;
+ tdr->flags = 0;
+ torture_assert_ntstatus_ok(tctx, tdr_pull_uint16(tdr, tctx, &l),
"pull failed");
- torture_assert_int_equal(tctx, 2, tdr.offset,
- "offset invalid");
+ torture_assert_int_equal(tctx, 2, tdr->offset, "offset invalid");
torture_assert_int_equal(tctx, 782, l, "right int read");
return true;
}
@@ -81,7 +81,7 @@ static bool test_pull_uint16(struct torture_context *tctx)
static bool test_push_uint32(struct torture_context *tctx)
{
uint32_t v = 0x100F32;
- struct tdr_push *tdr = talloc_zero(tctx, struct tdr_push);
+ struct tdr_push *tdr = tdr_push_init(tctx, lp_iconv_convenience(tctx->lp_ctx));
torture_assert_ntstatus_ok(tctx, tdr_push_uint32(tdr, &v), "push failed");
torture_assert_int_equal(tctx, tdr->data.length, 4, "length incorrect");
@@ -96,35 +96,35 @@ static bool test_pull_uint32(struct torture_context *tctx)
{
uint8_t d[4] = { 782 & 0xFF, (782 & 0xFF00) / 0x100, 0, 0 };
uint32_t l;
- struct tdr_pull tdr;
- tdr.data.data = d;
- tdr.data.length = 4;
- tdr.offset = 0;
- tdr.flags = 0;
- torture_assert_ntstatus_ok(tctx, tdr_pull_uint32(&tdr, tctx, &l),
+ struct tdr_pull *tdr = tdr_pull_init(tctx, lp_iconv_convenience(tctx->lp_ctx));
+ tdr->data.data = d;
+ tdr->data.length = 4;
+ tdr->offset = 0;
+ tdr->flags = 0;
+ torture_assert_ntstatus_ok(tctx, tdr_pull_uint32(tdr, tctx, &l),
"pull failed");
- torture_assert_int_equal(tctx, 4, tdr.offset, "offset invalid");
+ torture_assert_int_equal(tctx, 4, tdr->offset, "offset invalid");
torture_assert_int_equal(tctx, 782, l, "right int read");
return true;
}
static bool test_pull_charset(struct torture_context *tctx)
{
- struct tdr_pull tdr;
+ struct tdr_pull *tdr = tdr_pull_init(tctx, lp_iconv_convenience(tctx->lp_ctx));
const char *l = NULL;
- tdr.data.data = (uint8_t *)talloc_strdup(tctx, "bla");
- tdr.data.length = 4;
- tdr.offset = 0;
- tdr.flags = 0;
- torture_assert_ntstatus_ok(tctx, tdr_pull_charset(&tdr, tctx, &l, -1, 1, CH_DOS),
+ tdr->data.data = (uint8_t *)talloc_strdup(tctx, "bla");
+ tdr->data.length = 4;
+ tdr->offset = 0;
+ tdr->flags = 0;
+ torture_assert_ntstatus_ok(tctx, tdr_pull_charset(tdr, tctx, &l, -1, 1, CH_DOS),
"pull failed");
- torture_assert_int_equal(tctx, 4, tdr.offset, "offset invalid");
+ torture_assert_int_equal(tctx, 4, tdr->offset, "offset invalid");
torture_assert_str_equal(tctx, "bla", l, "right int read");
- tdr.offset = 0;
- torture_assert_ntstatus_ok(tctx, tdr_pull_charset(&tdr, tctx, &l, 2, 1, CH_UNIX),
+ tdr->offset = 0;
+ torture_assert_ntstatus_ok(tctx, tdr_pull_charset(tdr, tctx, &l, 2, 1, CH_UNIX),
"pull failed");
- torture_assert_int_equal(tctx, 2, tdr.offset, "offset invalid");
+ torture_assert_int_equal(tctx, 2, tdr->offset, "offset invalid");
torture_assert_str_equal(tctx, "bl", l, "right int read");
return true;
@@ -132,15 +132,15 @@ static bool test_pull_charset(struct torture_context *tctx)
static bool test_pull_charset_empty(struct torture_context *tctx)
{
- struct tdr_pull tdr;
+ struct tdr_pull *tdr = tdr_pull_init(tctx, lp_iconv_convenience(tctx->lp_ctx));
const char *l = NULL;
- tdr.data.data = (uint8_t *)talloc_strdup(tctx, "bla");
- tdr.data.length = 4;
- tdr.offset = 0;
- tdr.flags = 0;
- torture_assert_ntstatus_ok(tctx, tdr_pull_charset(&tdr, tctx, &l, 0, 1, CH_DOS),
+ tdr->data.data = (uint8_t *)talloc_strdup(tctx, "bla");
+ tdr->data.length = 4;
+ tdr->offset = 0;
+ tdr->flags = 0;
+ torture_assert_ntstatus_ok(tctx, tdr_pull_charset(tdr, tctx, &l, 0, 1, CH_DOS),
"pull failed");
- torture_assert_int_equal(tctx, 0, tdr.offset, "offset invalid");
+ torture_assert_int_equal(tctx, 0, tdr->offset, "offset invalid");
torture_assert_str_equal(tctx, "", l, "right string read");
return true;
@@ -151,7 +151,7 @@ static bool test_pull_charset_empty(struct torture_context *tctx)
static bool test_push_charset(struct torture_context *tctx)
{
const char *l = "bloe";
- struct tdr_push *tdr = talloc_zero(tctx, struct tdr_push);
+ struct tdr_push *tdr = tdr_push_init(tctx, lp_iconv_convenience(tctx->lp_ctx));
torture_assert_ntstatus_ok(tctx, tdr_push_charset(tdr, &l, 4, 1, CH_UTF8),
"push failed");
torture_assert_int_equal(tctx, 4, tdr->data.length, "offset invalid");