mirror of
https://github.com/samba-team/samba.git
synced 2025-08-26 01:49:31 +03:00
r6860: Add some allocation and alignment tests, remove uint64 from list of scalars
(it doesn't have any push/pull functions anymore either)
(This used to be commit 7d36e27e22
)
This commit is contained in:
committed by
Gerald (Jerry) Carter
parent
9d56a6d8f8
commit
1751007e64
@ -23,7 +23,7 @@ Test::test_idl('align-uint8-uint16', \%settings,
|
||||
'
|
||||
struct ndr_push *ndr = ndr_push_init();
|
||||
struct bla r;
|
||||
uint8_t expected[] = { 0x0D, 0x00, 0xbe, 0xef };
|
||||
uint8_t expected[] = { 0x0D, 0x00, 0xef, 0xbe };
|
||||
DATA_BLOB expected_blob = { expected, 4 };
|
||||
DATA_BLOB result_blob;
|
||||
r.x = 13;
|
||||
@ -37,3 +37,55 @@ Test::test_idl('align-uint8-uint16', \%settings,
|
||||
if (!data_blob_equal(&result_blob, &expected_blob))
|
||||
return 2;
|
||||
');
|
||||
|
||||
Test::test_idl('align-uint8-uint32', \%settings,
|
||||
'
|
||||
typedef [public] struct {
|
||||
uint8 x;
|
||||
uint32 y;
|
||||
} bla;
|
||||
',
|
||||
'
|
||||
struct ndr_push *ndr = ndr_push_init();
|
||||
struct bla r;
|
||||
uint8_t expected[] = { 0x0D, 0x00, 0x00, 0x00, 0xef, 0xbe, 0xef, 0xbe };
|
||||
DATA_BLOB expected_blob = { expected, 8 };
|
||||
DATA_BLOB result_blob;
|
||||
r.x = 13;
|
||||
r.y = 0xbeefbeef;
|
||||
|
||||
if (NT_STATUS_IS_ERR(ndr_push_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r)))
|
||||
return 1;
|
||||
|
||||
result_blob = ndr_push_blob(ndr);
|
||||
|
||||
if (!data_blob_equal(&result_blob, &expected_blob))
|
||||
return 2;
|
||||
');
|
||||
|
||||
|
||||
Test::test_idl('align-uint8-hyper', \%settings,
|
||||
'
|
||||
typedef [public] struct {
|
||||
uint8 x;
|
||||
hyper y;
|
||||
} bla;
|
||||
',
|
||||
'
|
||||
struct ndr_push *ndr = ndr_push_init();
|
||||
struct bla r;
|
||||
uint8_t expected[] = { 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xef, 0xbe, 0xef, 0xbe, 0xef, 0xbe, 0xef, 0xbe };
|
||||
DATA_BLOB expected_blob = { expected, 16 };
|
||||
DATA_BLOB result_blob;
|
||||
r.x = 13;
|
||||
r.y = 0xbeefbeefbeefbeef;
|
||||
|
||||
if (NT_STATUS_IS_ERR(ndr_push_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r)))
|
||||
return 1;
|
||||
|
||||
result_blob = ndr_push_blob(ndr);
|
||||
|
||||
if (!data_blob_equal(&result_blob, &expected_blob))
|
||||
return 2;
|
||||
');
|
||||
|
128
source4/build/pidl/tests/ndr_alloc.pl
Executable file
128
source4/build/pidl/tests/ndr_alloc.pl
Executable file
@ -0,0 +1,128 @@
|
||||
#!/usr/bin/perl
|
||||
# NDR allocation tests
|
||||
# (C) 2005 Jelmer Vernooij. Published under the GNU GPL
|
||||
use strict;
|
||||
|
||||
use FindBin qw($RealBin);
|
||||
use lib "$RealBin/..";
|
||||
use test;
|
||||
|
||||
my %settings = (
|
||||
'IDL-Arguments' => ['--quiet', '--parse', '--parser=ndr_test.c', '--header=ndr_test.h'],
|
||||
'IncludeFiles' => ['ndr_test.h'],
|
||||
'ExtraFiles' => ['ndr_test.c'],
|
||||
);
|
||||
|
||||
# Check that an outgoing scalar pointer is allocated correctly
|
||||
|
||||
Test::test_idl("alloc-scalar", \%settings,
|
||||
'
|
||||
typedef struct {
|
||||
uint8 *x;
|
||||
} bla;
|
||||
|
||||
[public] void TestAlloc([in] bla foo);
|
||||
','
|
||||
uint8_t data[] = { 0xde, 0xad, 0xbe, 0xef, 0x03 };
|
||||
DATA_BLOB b = { data, 5 };
|
||||
struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL);
|
||||
struct TestAlloc r;
|
||||
|
||||
if (NT_STATUS_IS_ERR(ndr_pull_TestAlloc(ndr, NDR_IN, &r)))
|
||||
return 1;
|
||||
|
||||
if (r.in.foo.x == NULL)
|
||||
return 2;
|
||||
|
||||
if (*r.in.foo.x != 0x03)
|
||||
return 3;
|
||||
'
|
||||
);
|
||||
|
||||
# Check that an outgoing buffer pointer is allocated correctly
|
||||
Test::test_idl("alloc-buffer", \%settings,
|
||||
'
|
||||
typedef struct {
|
||||
uint8 data;
|
||||
} blie;
|
||||
|
||||
typedef struct {
|
||||
blie *x;
|
||||
} bla;
|
||||
|
||||
[public] void TestAlloc([in] bla foo);
|
||||
','
|
||||
uint8_t data[] = { 0xde, 0xad, 0xbe, 0xef, 0x03 };
|
||||
DATA_BLOB b = { data, 5 };
|
||||
struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL);
|
||||
struct TestAlloc r;
|
||||
|
||||
if (NT_STATUS_IS_ERR(ndr_pull_TestAlloc(ndr, NDR_IN, &r)))
|
||||
return 1;
|
||||
|
||||
if (r.in.foo.x == NULL)
|
||||
return 2;
|
||||
|
||||
if (r.in.foo.x->data != 0x03)
|
||||
return 3;
|
||||
'
|
||||
);
|
||||
|
||||
# Check that ref pointers aren't allocated by default
|
||||
Test::test_idl("ref-noalloc-null", \%settings,
|
||||
'
|
||||
[public] void TestAlloc([in,ref] uint8 *t);
|
||||
','
|
||||
uint8_t data[] = { 0x03 };
|
||||
DATA_BLOB b = { data, 1 };
|
||||
struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL);
|
||||
struct TestAlloc r;
|
||||
r.in.t = NULL;
|
||||
|
||||
if (NT_STATUS_IS_OK(ndr_pull_TestAlloc(ndr, NDR_IN, &r)))
|
||||
return 1;
|
||||
'
|
||||
);
|
||||
|
||||
# Check that ref pointers aren't allocated by default
|
||||
Test::test_idl("ref-noalloc", \%settings,
|
||||
'
|
||||
[public] void TestAlloc([in,ref] uint8 *t);
|
||||
','
|
||||
uint8_t data[] = { 0x03 };
|
||||
DATA_BLOB b = { data, 1 };
|
||||
struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL);
|
||||
struct TestAlloc r;
|
||||
uint8_t x;
|
||||
r.in.t = &x;
|
||||
|
||||
if (NT_STATUS_IS_ERR(ndr_pull_TestAlloc(ndr, NDR_IN, &r)))
|
||||
return 1;
|
||||
|
||||
if (*r.in.t != 0x03)
|
||||
return 2;
|
||||
'
|
||||
);
|
||||
|
||||
# Check that an outgoing ref pointer is allocated correctly
|
||||
Test::test_idl("ref-alloc", \%settings,
|
||||
'
|
||||
[public] void TestAlloc([in,ref] uint8 *t);
|
||||
','
|
||||
uint8_t data[] = { 0x03 };
|
||||
DATA_BLOB b = { data, 1 };
|
||||
struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL);
|
||||
struct TestAlloc r;
|
||||
ndr->flags |= LIBNDR_FLAG_REF_ALLOC;
|
||||
r.in.t = NULL;
|
||||
|
||||
if (NT_STATUS_IS_ERR(ndr_pull_TestAlloc(ndr, NDR_IN, &r)))
|
||||
return 1;
|
||||
|
||||
if (r.in.t == NULL)
|
||||
return 2;
|
||||
|
||||
if (*r.in.t != 0x03)
|
||||
return 3;
|
||||
'
|
||||
);
|
@ -1,6 +1,8 @@
|
||||
#!/usr/bin/perl
|
||||
# Simple tests for pidl's handling of ref pointers, based
|
||||
# on tridge's ref_notes.txt
|
||||
# (C) 2005 Jelmer Vernooij <jelmer@samba.org>.
|
||||
# Published under the GNU General Public License.
|
||||
use strict;
|
||||
|
||||
use FindBin qw($RealBin);
|
||||
|
@ -1,4 +1,7 @@
|
||||
#!/usr/bin/perl
|
||||
# Some simple tests for pidl
|
||||
# (C) 2005 Jelmer Vernooij <jelmer@samba.org>
|
||||
# Published under the GNU General Public License
|
||||
use strict;
|
||||
|
||||
use FindBin qw($RealBin);
|
||||
|
@ -54,10 +54,6 @@ my $scalars = {
|
||||
C_TYPE => "int64_t",
|
||||
NDR_ALIGN => 8
|
||||
},
|
||||
"uint64" => {
|
||||
C_TYPE => "uint64_t",
|
||||
NDR_ALIGN => 8
|
||||
},
|
||||
"hyper" => {
|
||||
C_TYPE => "uint64_t",
|
||||
NDR_ALIGN => 8
|
||||
@ -217,7 +213,7 @@ sub bitmap_type_fn($)
|
||||
} elsif (util::has_property($bitmap, "bitmap16bit")) {
|
||||
return "uint16";
|
||||
} elsif (util::has_property($bitmap, "bitmap64bit")) {
|
||||
return "uint64";
|
||||
return "hyper";
|
||||
}
|
||||
return "uint32";
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/sh
|
||||
./build/pidl/tests/ndr_simple.pl
|
||||
./build/pidl/tests/ndr_align.pl
|
||||
./build/pidl/tests/ndr_alloc.pl
|
||||
./build/pidl/tests/ndr_refptr.pl
|
||||
|
Reference in New Issue
Block a user