summaryrefslogtreecommitdiff
path: root/source4/pidl/tests/ndr_align.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_align.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_align.pl')
-rwxr-xr-xsource4/pidl/tests/ndr_align.pl144
1 files changed, 144 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;
+');