diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2005-05-17 15:51:35 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:16:51 -0500 |
commit | 1751007e645d206f48d2efa4470fd99fbbecf2b8 (patch) | |
tree | 480830deecc4a36e453be7e24dbe0766bcd69f67 | |
parent | 9d56a6d8f86a2285231d1707635ce8a5bb996b1a (diff) | |
download | samba-1751007e645d206f48d2efa4470fd99fbbecf2b8.tar.gz samba-1751007e645d206f48d2efa4470fd99fbbecf2b8.tar.bz2 samba-1751007e645d206f48d2efa4470fd99fbbecf2b8.zip |
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 7d36e27e228ce83a5ce159eb424c4b5194c0e2fb)
-rwxr-xr-x | source4/build/pidl/tests/ndr_align.pl | 54 | ||||
-rwxr-xr-x | source4/build/pidl/tests/ndr_alloc.pl | 128 | ||||
-rwxr-xr-x | source4/build/pidl/tests/ndr_refptr.pl | 2 | ||||
-rwxr-xr-x | source4/build/pidl/tests/ndr_simple.pl | 3 | ||||
-rw-r--r-- | source4/build/pidl/typelist.pm | 6 | ||||
-rwxr-xr-x | source4/script/tests/test_pidl.sh | 1 |
6 files changed, 188 insertions, 6 deletions
diff --git a/source4/build/pidl/tests/ndr_align.pl b/source4/build/pidl/tests/ndr_align.pl index 5947c2998f..c428dd32bd 100755 --- a/source4/build/pidl/tests/ndr_align.pl +++ b/source4/build/pidl/tests/ndr_align.pl @@ -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; +'); diff --git a/source4/build/pidl/tests/ndr_alloc.pl b/source4/build/pidl/tests/ndr_alloc.pl new file mode 100755 index 0000000000..86f3ec153c --- /dev/null +++ b/source4/build/pidl/tests/ndr_alloc.pl @@ -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; +' +); diff --git a/source4/build/pidl/tests/ndr_refptr.pl b/source4/build/pidl/tests/ndr_refptr.pl index ba8d543f0b..72698a78bd 100755 --- a/source4/build/pidl/tests/ndr_refptr.pl +++ b/source4/build/pidl/tests/ndr_refptr.pl @@ -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); diff --git a/source4/build/pidl/tests/ndr_simple.pl b/source4/build/pidl/tests/ndr_simple.pl index c3b55ac98c..29b4784e52 100755 --- a/source4/build/pidl/tests/ndr_simple.pl +++ b/source4/build/pidl/tests/ndr_simple.pl @@ -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); diff --git a/source4/build/pidl/typelist.pm b/source4/build/pidl/typelist.pm index 9045e86bfd..8559878a69 100644 --- a/source4/build/pidl/typelist.pm +++ b/source4/build/pidl/typelist.pm @@ -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"; } diff --git a/source4/script/tests/test_pidl.sh b/source4/script/tests/test_pidl.sh index 81d443a307..8c57f10ffe 100755 --- a/source4/script/tests/test_pidl.sh +++ b/source4/script/tests/test_pidl.sh @@ -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 |