diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2008-09-18 20:29:05 +0200 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2008-09-18 20:29:05 +0200 |
commit | 729ffbae086309992d7433a296fca64f6800f8fa (patch) | |
tree | 6c133d2b91ab9313da11bf8bad15f497e1b5c61f /pidl/tests/ndr_align.pl | |
parent | 88ad1a936ccd2451d6dbf542a0a746ad71a3e968 (diff) | |
parent | fc7050e54c69919d754ca0adf3f2f741a501fec4 (diff) | |
download | samba-729ffbae086309992d7433a296fca64f6800f8fa.tar.gz samba-729ffbae086309992d7433a296fca64f6800f8fa.tar.bz2 samba-729ffbae086309992d7433a296fca64f6800f8fa.zip |
Merge branch 'master' of ssh://git.samba.org/data/git/samba into noejs
Conflicts:
source4/main.mk
Diffstat (limited to 'pidl/tests/ndr_align.pl')
-rwxr-xr-x | pidl/tests/ndr_align.pl | 143 |
1 files changed, 143 insertions, 0 deletions
diff --git a/pidl/tests/ndr_align.pl b/pidl/tests/ndr_align.pl new file mode 100755 index 0000000000..cc089eaa1f --- /dev/null +++ b/pidl/tests/ndr_align.pl @@ -0,0 +1,143 @@ +#!/usr/bin/perl +# NDR alignment tests +# (C) 2005 Jelmer Vernooij. Published under the GNU GPL +use strict; + +use Test::More tests => 5 * 8; +use FindBin qw($RealBin); +use lib "$RealBin"; +use Util qw(test_samba4_ndr); + +test_samba4_ndr('align-uint8-uint16', +' + typedef [public] struct { + uint8 x; + uint16 y; + } bla; +', +' + struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL); + 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 (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r))) + return 1; + + result_blob = ndr_push_blob(ndr); + + if (data_blob_cmp(&result_blob, &expected_blob) != 0) + return 2; +'); + +test_samba4_ndr('align-uint8-uint32', +' + typedef [public] struct { + uint8 x; + uint32 y; + } bla; +', +' + struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL); + 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 (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r))) + return 1; + + result_blob = ndr_push_blob(ndr); + + if (data_blob_cmp(&result_blob, &expected_blob) != 0) + return 2; +'); + + +test_samba4_ndr('align-uint8-hyper', +' + typedef [public] struct { + uint8 x; + hyper y; + } bla; +', +' + struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL); + 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 = 0xbeefbeefbeefbeefLLU; + + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r))) + return 1; + + result_blob = ndr_push_blob(ndr); + + if (data_blob_cmp(&result_blob, &expected_blob) != 0) + return 2; +'); + +test_samba4_ndr('noalignflag-uint8-uint16', +' + typedef [public] struct { + uint8 x; + uint16 y; + } bla; +', +' + struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL); + 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 (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r))) + return 1; + + result_blob = ndr_push_blob(ndr); + + if (data_blob_cmp(&result_blob, &expected_blob) != 0) + return 2; +'); + +test_samba4_ndr('align-blob-align2', +' + typedef [public] struct { + uint8 x; + [flag(LIBNDR_FLAG_ALIGN2)] DATA_BLOB data; + uint8 y; + } blie; +', +' + struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL); + struct blie r; + uint8_t data[] = { 0x01, 0x02 }; + uint8_t expected[] = { 0x0D, 0x00, 0x0E }; + DATA_BLOB expected_blob = { expected, 3 }; + DATA_BLOB result_blob; + + r.x = 13; + r.y = 14; + r.data.data = data; + r.data.length = 2; + + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_blie(ndr, NDR_SCALARS|NDR_BUFFERS, &r))) + return 1; + + result_blob = ndr_push_blob(ndr); + + if (data_blob_cmp(&result_blob, &expected_blob) != 0) + return 2; +'); |