diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2005-05-17 17:32:25 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:16:52 -0500 |
commit | 6e3b2448eb6cc48a95eeec24f397d3243f9473bf (patch) | |
tree | fb15898b9a8b47e951db048a47cfe60169c4532e /source4/build/pidl/tests | |
parent | 1751007e645d206f48d2efa4470fd99fbbecf2b8 (diff) | |
download | samba-6e3b2448eb6cc48a95eeec24f397d3243f9473bf.tar.gz samba-6e3b2448eb6cc48a95eeec24f397d3243f9473bf.tar.bz2 samba-6e3b2448eb6cc48a95eeec24f397d3243f9473bf.zip |
r6862: Add some more tests
Accept new command-line options --keep, --outputdir and --idl-compiler.
We're currently at 34 IDL tests (...and counting)
(This used to be commit 7004f9515b75bce5b46e444f1865d377fdae0afa)
Diffstat (limited to 'source4/build/pidl/tests')
-rwxr-xr-x | source4/build/pidl/tests/ndr_align.pl | 65 | ||||
-rwxr-xr-x | source4/build/pidl/tests/ndr_alloc.pl | 9 | ||||
-rwxr-xr-x | source4/build/pidl/tests/ndr_refptr.pl | 9 | ||||
-rwxr-xr-x | source4/build/pidl/tests/ndr_simple.pl | 9 | ||||
-rw-r--r-- | source4/build/pidl/tests/ndr_string.pl | 59 |
5 files changed, 131 insertions, 20 deletions
diff --git a/source4/build/pidl/tests/ndr_align.pl b/source4/build/pidl/tests/ndr_align.pl index c428dd32bd..03b09e8758 100755 --- a/source4/build/pidl/tests/ndr_align.pl +++ b/source4/build/pidl/tests/ndr_align.pl @@ -7,11 +7,11 @@ 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'], -); +my %settings = Test::GetSettings(@ARGV); + +$settings{'IDL-Arguments'} = ['--quiet', '--parse', '--parser=ndr_test.c', '--header=ndr_test.h']; +$settings{'IncludeFiles'} = ['ndr_test.h']; +$settings{'ExtraFiles'} = ['ndr_test.c']; Test::test_idl('align-uint8-uint16', \%settings, ' @@ -89,3 +89,58 @@ Test::test_idl('align-uint8-hyper', \%settings, if (!data_blob_equal(&result_blob, &expected_blob)) return 2; '); + +Test::test_idl('noalignflag-uint8-uint16', \%settings, +' + typedef [public] struct { + uint8 x; + uint16 y; + } bla; +', +' + struct ndr_push *ndr = ndr_push_init(); + struct bla r; + uint8_t expected[] = { 0x0D, 0xef, 0xbe }; + DATA_BLOB expected_blob = { expected, 3 }; + DATA_BLOB result_blob; + ndr->flags |= LIBNDR_FLAG_NOALIGN; + + r.x = 13; + r.y = 0xbeef; + + 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-blob-align2', \%settings, +' + typedef [public] struct { + uint8 x; + [flag(LIBNDR_FLAG_ALIGN2)] DATA_BLOB data; + } bla; +', +' + struct ndr_push *ndr = ndr_push_init(); + struct bla r; + uint8_t data[] = { 0x01, 0x02 }; + uint8_t expected[] = { 0x0D, 0x00, 0x01, 0x02 }; + DATA_BLOB expected_blob = { expected, 4 }; + DATA_BLOB result_blob; + + r.x = 13; + r.data.data = data; + r.data.length = 2; + + 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 index 86f3ec153c..7918f312d4 100755 --- a/source4/build/pidl/tests/ndr_alloc.pl +++ b/source4/build/pidl/tests/ndr_alloc.pl @@ -7,11 +7,10 @@ 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'], -); +my %settings = Test::GetSettings(@ARGV); +$settings{'IDL-Arguments'} = ['--quiet', '--parse', '--parser=ndr_test.c', '--header=ndr_test.h']; +$settings{'IncludeFiles'} = ['ndr_test.h']; +$settings{'ExtraFiles'} = ['ndr_test.c']; # Check that an outgoing scalar pointer is allocated correctly diff --git a/source4/build/pidl/tests/ndr_refptr.pl b/source4/build/pidl/tests/ndr_refptr.pl index 72698a78bd..59ebd295f6 100755 --- a/source4/build/pidl/tests/ndr_refptr.pl +++ b/source4/build/pidl/tests/ndr_refptr.pl @@ -9,11 +9,10 @@ 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'], -); +my %settings = Test::GetSettings(@ARGV); +$settings{'IDL-Arguments'} = ['--quiet', '--parse', '--parser=ndr_test.c', '--header=ndr_test.h']; +$settings{'IncludeFiles'} = ['ndr_test.h']; +$settings{'ExtraFiles'} = ['ndr_test.c']; Test::test_idl("noptr-push", \%settings, ' typedef struct { diff --git a/source4/build/pidl/tests/ndr_simple.pl b/source4/build/pidl/tests/ndr_simple.pl index 29b4784e52..7049dfa68d 100755 --- a/source4/build/pidl/tests/ndr_simple.pl +++ b/source4/build/pidl/tests/ndr_simple.pl @@ -8,11 +8,10 @@ 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'], -); +my %settings = Test::GetSettings(@ARGV); +$settings{'IDL-Arguments'} = ['--quiet', '--parse', '--parser=ndr_test.c', '--header=ndr_test.h']; +$settings{'IncludeFiles'} = ['ndr_test.h']; +$settings{'ExtraFiles'} = ['ndr_test.c']; Test::test_idl( # Name diff --git a/source4/build/pidl/tests/ndr_string.pl b/source4/build/pidl/tests/ndr_string.pl new file mode 100644 index 0000000000..9ea4ca42b6 --- /dev/null +++ b/source4/build/pidl/tests/ndr_string.pl @@ -0,0 +1,59 @@ +#!/usr/bin/perl +# String tests for pidl +# (C) 2005 Jelmer Vernooij <jelmer@samba.org> +# Published under the GNU General Public License +use strict; + +use FindBin qw($RealBin); +use lib "$RealBin/.."; +use test; + +my %settings = Test::GetSettings(@ARGV); + +$settings{'IDL-Arguments'} = ['--quiet', '--parse', '--parser=ndr_test.c', '--header=ndr_test.h']; +$settings{'IncludeFiles'} = ['ndr_test.h']; +$settings{'ExtraFiles'} = ['ndr_test.c']; + +Test::test_idl("string-pull-empty", \%settings, +' [public] void TestString([in,flag(STR_ASCII|LIBNDR_FLAG_STR_SIZE4)] string data);', +' + uint8_t data[] = { 0x00, 0x00, 0x00, 0x00 }; + DATA_BLOB b = { data, 4 }; + struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL); + struct TestString r; + r.in.data = NULL; + + if (NT_STATUS_IS_ERR(ndr_pull_TestString(ndr, NDR_IN, &r))) + return 1; + + if (r.in.data == NULL) + return 2; + + if (r.in.data[0] != 0) + return 3; +'); + +Test::test_idl("string-ascii-pull", \%settings, +' + [public] void TestString([in,flag(STR_ASCII|LIBNDR_FLAG_STR_SIZE4)] string data); +', +' + uint8_t data[] = { 0x03, 0x00, 0x00, 0x00, + \'f\', \'o\', \'o\', 0 }; + DATA_BLOB b = { data, 8 }; + struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL); + struct TestString r; + r.in.data = NULL; + + if (NT_STATUS_IS_ERR(ndr_pull_TestString(ndr, NDR_IN, &r))) + return 1; + + if (r.in.data == NULL) + return 2; + + if (strncmp(r.in.data, "foo", 3) != 0) + return 3; + + if (r.in.data[4] != 0) + return 4; +'); |