summaryrefslogtreecommitdiff
path: root/source4/pidl/tests
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2005-08-21 23:17:35 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:34:17 -0500
commitefc03df292aa84edb592c22191dbf86cdf8c32d0 (patch)
tree8a72f715ced0922effaa6dc48000bb1b48b82678 /source4/pidl/tests
parent6e388c27d86d77f2c7f9414fbb152c246ca53022 (diff)
downloadsamba-efc03df292aa84edb592c22191dbf86cdf8c32d0.tar.gz
samba-efc03df292aa84edb592c22191dbf86cdf8c32d0.tar.bz2
samba-efc03df292aa84edb592c22191dbf86cdf8c32d0.zip
r9459: Move pidl up one level (to prevent too much nesting)
(This used to be commit e48202275e60c18e464457d200daeb953386e221)
Diffstat (limited to 'source4/pidl/tests')
-rwxr-xr-xsource4/pidl/tests/ndr_align.pl144
-rwxr-xr-xsource4/pidl/tests/ndr_alloc.pl125
-rwxr-xr-xsource4/pidl/tests/ndr_array.pl45
-rwxr-xr-xsource4/pidl/tests/ndr_refptr.pl516
-rwxr-xr-xsource4/pidl/tests/ndr_simple.pl40
-rwxr-xr-xsource4/pidl/tests/ndr_string.pl57
6 files changed, 927 insertions, 0 deletions
diff --git a/source4/pidl/tests/ndr_align.pl b/source4/pidl/tests/ndr_align.pl
new file mode 100755
index 0000000000..da994224eb
--- /dev/null
+++ b/source4/pidl/tests/ndr_align.pl
@@ -0,0 +1,144 @@
+#!/usr/bin/perl
+# NDR alignment tests
+# (C) 2005 Jelmer Vernooij. Published under the GNU GPL
+use strict;
+
+use Parse::Pidl::Test;
+
+my %settings = Parse::Pidl::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'];
+
+Parse::Pidl::Test::test_idl('align-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, 0x00, 0xef, 0xbe };
+ DATA_BLOB expected_blob = { expected, 4 };
+ DATA_BLOB result_blob;
+ 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;
+');
+
+Parse::Pidl::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;
+');
+
+
+Parse::Pidl::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;
+');
+
+Parse::Pidl::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;
+');
+
+Parse::Pidl::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/pidl/tests/ndr_alloc.pl b/source4/pidl/tests/ndr_alloc.pl
new file mode 100755
index 0000000000..4f6eddbfb9
--- /dev/null
+++ b/source4/pidl/tests/ndr_alloc.pl
@@ -0,0 +1,125 @@
+#!/usr/bin/perl
+# NDR allocation tests
+# (C) 2005 Jelmer Vernooij. Published under the GNU GPL
+use strict;
+
+use Parse::Pidl::Test;
+
+my %settings = Parse::Pidl::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
+
+Parse::Pidl::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
+Parse::Pidl::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
+Parse::Pidl::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
+Parse::Pidl::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
+Parse::Pidl::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/pidl/tests/ndr_array.pl b/source4/pidl/tests/ndr_array.pl
new file mode 100755
index 0000000000..d486308339
--- /dev/null
+++ b/source4/pidl/tests/ndr_array.pl
@@ -0,0 +1,45 @@
+#!/usr/bin/perl
+# Array testing
+# (C) 2005 Jelmer Vernooij <jelmer@samba.org>
+# Published under the GNU General Public License
+use strict;
+
+use Parse::Pidl::Test;
+
+my %settings = Parse::Pidl::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'];
+
+Parse::Pidl::Test::test_idl(
+ # Name
+ 'Fixed-Array',
+
+ # Settings
+ \%settings,
+
+ # IDL
+ '[public] void Test([in] uint8 x[10]);',
+
+ # C Test
+ '
+ uint8_t data[] = {1,2,3,4,5,6,7,8,9,10};
+ int i;
+ DATA_BLOB b;
+ struct ndr_pull *ndr;
+ struct Test r;
+
+ b.data = data;
+ b.length = 10;
+ ndr = ndr_pull_init_blob(&b, mem_ctx);
+
+ if (NT_STATUS_IS_ERR(ndr_pull_Test(ndr, NDR_IN, &r)))
+ return 1;
+
+ if (ndr->offset != 10)
+ return 2;
+
+ for (i = 0; i < 10; i++) {
+ if (r.in.x[i] != i+1) return 3;
+ }
+');
diff --git a/source4/pidl/tests/ndr_refptr.pl b/source4/pidl/tests/ndr_refptr.pl
new file mode 100755
index 0000000000..8344661ad3
--- /dev/null
+++ b/source4/pidl/tests/ndr_refptr.pl
@@ -0,0 +1,516 @@
+#!/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 Parse::Pidl::Test;
+
+my %settings = Parse::Pidl::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'];
+
+Parse::Pidl::Test::test_idl("noptr-push", \%settings,
+' typedef struct {
+ uint16 x;
+ } xstruct;
+
+ [public] uint16 echo_TestRef([in] xstruct foo);
+',
+'
+ struct ndr_push *ndr = ndr_push_init();
+ uint16_t v = 13;
+ struct echo_TestRef r;
+ r.in.foo.x = v;
+
+ if (NT_STATUS_IS_ERR(ndr_push_echo_TestRef(ndr, NDR_IN, &r))) {
+ fprintf(stderr, "push failed\n");
+ return 1;
+ }
+
+ if (ndr->offset != 2) {
+ fprintf(stderr, "Offset(%d) != 2\n", ndr->offset);
+ return 2;
+ }
+
+ if (ndr->data[0] != 13 || ndr->data[1] != 0) {
+ fprintf(stderr, "Data incorrect\n");
+ return 3;
+ }
+');
+
+Parse::Pidl::Test::test_idl("ptr-embedded-push", \%settings,
+' typedef struct {
+ uint16 *x;
+ } xstruct;
+
+ [public] uint16 echo_TestRef([in] xstruct foo);
+',
+'
+ uint16_t v = 13;
+ struct ndr_push *ndr = ndr_push_init();
+ struct echo_TestRef r;
+ r.in.foo.x = &v;
+
+ if (NT_STATUS_IS_ERR(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
+ return 1;
+
+ if (ndr->offset != 6)
+ return 2;
+
+ if (ndr->data[0] == 0 && ndr->data[1] == 0 &&
+ ndr->data[2] == 0 && ndr->data[3] == 0)
+ return 3;
+
+ if (ndr->data[4] != 13 || ndr->data[5] != 0)
+ return 4;
+');
+
+Parse::Pidl::Test::test_idl("ptr-embedded-push-null", \%settings,
+' typedef struct {
+ uint16 *x;
+ } xstruct;
+
+ [public] uint16 echo_TestRef([in] xstruct foo);
+',
+'
+ struct ndr_push *ndr = ndr_push_init();
+ struct echo_TestRef r;
+ r.in.foo.x = NULL;
+
+ if (NT_STATUS_IS_ERR(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
+ return 1;
+
+ if (ndr->offset != 4)
+ return 2;
+
+ if (ndr->data[0] != 0 || ndr->data[1] != 0 ||
+ ndr->data[2] != 0 || ndr->data[3] != 0)
+ return 3;
+');
+
+Parse::Pidl::Test::test_idl("refptr-embedded-push", \%settings,
+'
+ typedef struct {
+ [ref] uint16 *x;
+ } xstruct;
+
+ [public] uint16 echo_TestRef([in] xstruct foo);
+',
+'
+ uint16_t v = 13;
+ struct ndr_push *ndr = ndr_push_init();
+ struct echo_TestRef r;
+ r.in.foo.x = &v;
+
+ if (NT_STATUS_IS_ERR(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
+ return 1;
+
+ if (ndr->offset != 6)
+ return 2;
+
+ if (ndr->data[0] == 0 && ndr->data[1] == 0 &&
+ ndr->data[2] == 0 && ndr->data[3] == 0)
+ return 3;
+
+ if (ndr->data[4] != 13 || ndr->data[5] != 0)
+ return 4;
+');
+
+Parse::Pidl::Test::test_idl("refptr-embedded-push-null", \%settings,
+'
+ typedef struct {
+ [ref] uint16 *x;
+ } xstruct;
+
+ [public] uint16 echo_TestRef([in] xstruct foo);
+',
+'
+ struct ndr_push *ndr = ndr_push_init();
+ struct echo_TestRef r;
+ r.in.foo.x = NULL;
+
+ if (NT_STATUS_IS_OK(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
+ return 1;
+ /* Windows gives [client runtime error 0x6f4] */
+');
+
+Parse::Pidl::Test::test_idl("ptr-top-push", \%settings,
+'
+ typedef struct {
+ uint16 x;
+ } xstruct;
+
+ [public] uint16 echo_TestRef([in] xstruct *foo);
+',
+'
+ struct ndr_push *ndr = ndr_push_init();
+ struct echo_TestRef r;
+ struct xstruct s;
+ s.x = 13;
+ r.in.foo = &s;
+
+ if (NT_STATUS_IS_ERR(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
+ return 1;
+
+ if (ndr->offset != 2)
+ return 2;
+
+ if (ndr->data[0] != 13 || ndr->data[1] != 0)
+ return 3;
+');
+
+Parse::Pidl::Test::test_idl("ptr-top-push-null", \%settings,
+'
+ typedef struct {
+ uint16 x;
+ } xstruct;
+
+ [public] uint16 echo_TestRef([in] xstruct *foo);
+',
+'
+ struct ndr_push *ndr = ndr_push_init();
+ struct echo_TestRef r;
+ r.in.foo = NULL;
+
+ if (NT_STATUS_IS_OK(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
+ return 1;
+
+ /* Windows gives [client runtime error 0x6f4] */
+');
+
+
+Parse::Pidl::Test::test_idl("refptr-top-push", \%settings,
+'
+ typedef struct {
+ uint16 x;
+ } xstruct;
+
+ [public] uint16 echo_TestRef([in,ref] xstruct *foo);
+',
+'
+ struct ndr_push *ndr = ndr_push_init();
+ struct echo_TestRef r;
+ struct xstruct s;
+ s.x = 13;
+ r.in.foo = &s;
+
+ if (NT_STATUS_IS_ERR(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
+ return 1;
+
+ if (ndr->offset != 2)
+ return 2;
+
+ if (ndr->data[0] != 13 || ndr->data[1] != 0)
+ return 3;
+');
+
+Parse::Pidl::Test::test_idl("refptr-top-push-null", \%settings,
+'
+ typedef struct {
+ uint16 x;
+ } xstruct;
+
+ [public] uint16 echo_TestRef([in,ref] xstruct *foo);
+',
+'
+ struct ndr_push *ndr = ndr_push_init();
+ struct echo_TestRef r;
+ r.in.foo = NULL;
+
+ if (NT_STATUS_IS_OK(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
+ return 1;
+
+ /* Windows gives [client runtime error 0x6f4] */
+');
+
+
+Parse::Pidl::Test::test_idl("uniqueptr-top-push", \%settings,
+' typedef struct {
+ uint16 x;
+ } xstruct;
+
+ [public] uint16 echo_TestRef([in,unique] xstruct *foo);
+',
+'
+ struct ndr_push *ndr = ndr_push_init();
+ struct echo_TestRef r;
+ struct xstruct s;
+ s.x = 13;
+ r.in.foo = &s;
+
+ if (NT_STATUS_IS_ERR(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
+ return 1;
+
+ if (ndr->offset != 6)
+ return 2;
+
+ if (ndr->data[0] == 0 && ndr->data[1] == 0 &&
+ ndr->data[2] == 0 && ndr->data[3] == 0)
+ return 3;
+
+ if (ndr->data[4] != 13 || ndr->data[5] != 0)
+ return 4;
+');
+
+Parse::Pidl::Test::test_idl("uniqueptr-top-push-null", \%settings,
+' typedef struct {
+ uint16 x;
+ } xstruct;
+
+ [public] uint16 echo_TestRef([in,unique] xstruct *foo);
+',
+'
+ struct ndr_push *ndr = ndr_push_init();
+ struct echo_TestRef r;
+ r.in.foo = NULL;
+
+ if (NT_STATUS_IS_ERR(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
+ return 1;
+
+ if (ndr->offset != 4)
+ return 2;
+
+ if (ndr->data[0] != 0 || ndr->data[1] != 0 ||
+ ndr->data[2] != 0 || ndr->data[3] != 0)
+ return 3;
+');
+
+
+Parse::Pidl::Test::test_idl("ptr-top-out-pull", \%settings,
+'
+ typedef struct {
+ uint16 x;
+ } xstruct;
+
+ [public] void echo_TestRef([out] xstruct *foo);
+',
+'
+ uint8_t data[] = { 0x0D, 0x00 };
+ DATA_BLOB b = { data, 2 };
+ struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL);
+ struct xstruct s;
+ struct echo_TestRef r;
+
+ r.out.foo = &s;
+
+ if (NT_STATUS_IS_ERR(ndr_pull_echo_TestRef(ndr, NDR_OUT, &r)))
+ return 1;
+
+ if (!r.out.foo)
+ return 2;
+
+ if (r.out.foo->x != 13)
+ return 3;
+');
+
+Parse::Pidl::Test::test_idl("ptr-top-out-pull-null", \%settings,
+'
+ typedef struct {
+ uint16 x;
+ } xstruct;
+
+ [public] void echo_TestRef([out] xstruct *foo);
+',
+'
+ uint8_t data[] = { 0x0D, 0x00 };
+ DATA_BLOB b = { data, 2 };
+ struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL);
+ struct echo_TestRef r;
+
+ r.out.foo = NULL;
+
+ if (NT_STATUS_IS_OK(ndr_pull_echo_TestRef(ndr, NDR_OUT, &r)))
+ return 1;
+
+ /* Windows gives [client runtime error 0x6f4] */
+');
+
+
+Parse::Pidl::Test::test_idl("refptr-top-out-pull", \%settings,
+'
+ typedef struct {
+ uint16 x;
+ } xstruct;
+
+ [public] void echo_TestRef([out,ref] xstruct *foo);
+',
+'
+ uint8_t data[] = { 0x0D, 0x00 };
+ DATA_BLOB b = { data, 2 };
+ struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL);
+ struct xstruct s;
+ struct echo_TestRef r;
+
+ r.out.foo = &s;
+
+ if (NT_STATUS_IS_ERR(ndr_pull_echo_TestRef(ndr, NDR_OUT, &r)))
+ return 1;
+
+ if (!r.out.foo)
+ return 2;
+
+ if (r.out.foo->x != 13)
+ return 3;
+');
+
+Parse::Pidl::Test::test_idl("refptr-top-out-pull-null", \%settings,
+'
+ typedef struct {
+ uint16 x;
+ } xstruct;
+
+ [public] void echo_TestRef([out,ref] xstruct *foo);
+',
+'
+ uint8_t data[] = { 0x0D, 0x00 };
+ DATA_BLOB b = { data, 2 };
+ struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL);
+ struct echo_TestRef r;
+
+ r.out.foo = NULL;
+
+ if (NT_STATUS_IS_OK(ndr_pull_echo_TestRef(ndr, NDR_OUT, &r)))
+ return 1;
+
+ /* Windows gives [client runtime error 0x6f4] */
+');
+
+
+Parse::Pidl::Test::test_idl("ptr-top-push-double", \%settings,
+'
+ [public] void echo_TestRef([in] uint16 **foo);
+',
+' struct ndr_push *ndr = ndr_push_init();
+ struct echo_TestRef r;
+ uint16_t v = 13;
+ uint16_t *pv = &v;
+ r.in.foo = &pv;
+
+ if (NT_STATUS_IS_ERR(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
+ return 1;
+
+ if (ndr->offset != 6)
+ return 2;
+
+ if (ndr->data[0] == 0 && ndr->data[1] == 0 &&
+ ndr->data[2] == 0 && ndr->data[3] == 0)
+ return 3;
+
+ if (ndr->data[4] != 0x0D || ndr->data[5] != 0x00)
+ return 4;
+');
+
+Parse::Pidl::Test::test_idl("ptr-top-push-double-sndnull", \%settings,
+'
+ [public] void echo_TestRef([in] uint16 **foo);
+',
+' struct ndr_push *ndr = ndr_push_init();
+ struct echo_TestRef r;
+ uint16_t *pv = NULL;
+ r.in.foo = &pv;
+
+ if (NT_STATUS_IS_ERR(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
+ return 1;
+
+ if (ndr->offset != 4)
+ return 2;
+
+ if (ndr->data[0] != 0 || ndr->data[1] != 0 ||
+ ndr->data[2] != 0 || ndr->data[3] != 0)
+ return 3;
+');
+
+Parse::Pidl::Test::test_idl("ptr-top-push-double-fstnull", \%settings,
+'
+ [public] void echo_TestRef([in] uint16 **foo);
+',
+' struct ndr_push *ndr = ndr_push_init();
+ struct echo_TestRef r;
+ r.in.foo = NULL;
+
+ if (NT_STATUS_IS_OK(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
+ return 1;
+
+ /* Windows gives [client runtime error 0x6f4] */
+
+');
+
+
+Parse::Pidl::Test::test_idl("refptr-top-push-double", \%settings,
+'
+ [public] void echo_TestRef([in,ref] uint16 **foo);
+',
+' struct ndr_push *ndr = ndr_push_init();
+ struct echo_TestRef r;
+ uint16_t v = 13;
+ uint16_t *pv = &v;
+ r.in.foo = &pv;
+
+ if (NT_STATUS_IS_ERR(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
+ return 1;
+
+ if (ndr->offset != 6)
+ return 2;
+
+ if (ndr->data[0] == 0 && ndr->data[1] == 0 &&
+ ndr->data[2] == 0 && ndr->data[3] == 0)
+ return 3;
+
+ if (ndr->data[4] != 0x0D || ndr->data[5] != 0x00)
+ return 4;
+');
+
+Parse::Pidl::Test::test_idl("refptr-top-push-double-sndnull", \%settings,
+'
+ [public] void echo_TestRef([in,ref] uint16 **foo);
+',
+' struct ndr_push *ndr = ndr_push_init();
+ struct echo_TestRef r;
+ uint16_t *pv = NULL;
+ r.in.foo = &pv;
+
+ if (NT_STATUS_IS_ERR(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
+ return 1;
+
+ if (ndr->offset != 4)
+ return 2;
+
+ if (ndr->data[0] != 0 || ndr->data[1] != 0 ||
+ ndr->data[2] != 0 || ndr->data[3] != 0)
+ return 3;
+');
+
+Parse::Pidl::Test::test_idl("refptr-top-push-double-fstnull", \%settings,
+'
+ [public] void echo_TestRef([in,ref] uint16 **foo);
+',
+' struct ndr_push *ndr = ndr_push_init();
+ struct echo_TestRef r;
+ r.in.foo = NULL;
+
+ if (NT_STATUS_IS_OK(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
+ return 1;
+
+ /* Windows gives [client runtime error 0x6f4] */
+
+');
+
+Parse::Pidl::Test::test_idl("ignore-ptr", \%settings,
+'
+ [public] void echo_TestRef([in,ignore] uint16 *foo, [in] uint16 *bar);
+',
+' struct ndr_push *ndr = ndr_push_init();
+ struct echo_TestRef r;
+ uint16_t v = 10;
+ r.in.foo = &v;
+ r.in.bar = &v;
+
+ if (NT_STATUS_IS_OK(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
+ return 1;
+
+ if (ndr->offset != 4)
+ return 2;
+');
diff --git a/source4/pidl/tests/ndr_simple.pl b/source4/pidl/tests/ndr_simple.pl
new file mode 100755
index 0000000000..7d48c9f4d7
--- /dev/null
+++ b/source4/pidl/tests/ndr_simple.pl
@@ -0,0 +1,40 @@
+#!/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 Parse::Pidl::Test;
+
+my %settings = Parse::Pidl::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'];
+
+Parse::Pidl::Test::test_idl(
+ # Name
+ 'UInt8',
+
+ # Settings
+ \%settings,
+
+ # IDL
+ 'void Test();',
+
+ # C Test
+ '
+ uint8_t data[] = { 0x02 };
+ uint8_t result;
+ DATA_BLOB b;
+ struct ndr_pull *ndr;
+
+ b.data = data;
+ b.length = 1;
+ ndr = ndr_pull_init_blob(&b, mem_ctx);
+
+ if (NT_STATUS_IS_ERR(ndr_pull_uint8(ndr, NDR_SCALARS, &result)))
+ return 1;
+
+ if (result != 0x02)
+ return 2;
+');
diff --git a/source4/pidl/tests/ndr_string.pl b/source4/pidl/tests/ndr_string.pl
new file mode 100755
index 0000000000..ad8db912d7
--- /dev/null
+++ b/source4/pidl/tests/ndr_string.pl
@@ -0,0 +1,57 @@
+#!/usr/bin/perl
+# String tests for pidl
+# (C) 2005 Jelmer Vernooij <jelmer@samba.org>
+# Published under the GNU General Public License
+use strict;
+
+use Parse::Pidl::Test;
+
+my %settings = Parse::Pidl::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'];
+
+Parse::Pidl::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;
+');
+
+Parse::Pidl::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;
+');