summaryrefslogtreecommitdiff
path: root/source4/pidl/tests/ndr_alloc.pl
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/ndr_alloc.pl
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/ndr_alloc.pl')
-rwxr-xr-xsource4/pidl/tests/ndr_alloc.pl125
1 files changed, 125 insertions, 0 deletions
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;
+'
+);