From efc03df292aa84edb592c22191dbf86cdf8c32d0 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 21 Aug 2005 23:17:35 +0000 Subject: r9459: Move pidl up one level (to prevent too much nesting) (This used to be commit e48202275e60c18e464457d200daeb953386e221) --- source4/pidl/tests/ndr_align.pl | 144 +++++++++++ source4/pidl/tests/ndr_alloc.pl | 125 ++++++++++ source4/pidl/tests/ndr_array.pl | 45 ++++ source4/pidl/tests/ndr_refptr.pl | 516 +++++++++++++++++++++++++++++++++++++++ source4/pidl/tests/ndr_simple.pl | 40 +++ source4/pidl/tests/ndr_string.pl | 57 +++++ 6 files changed, 927 insertions(+) create mode 100755 source4/pidl/tests/ndr_align.pl create mode 100755 source4/pidl/tests/ndr_alloc.pl create mode 100755 source4/pidl/tests/ndr_array.pl create mode 100755 source4/pidl/tests/ndr_refptr.pl create mode 100755 source4/pidl/tests/ndr_simple.pl create mode 100755 source4/pidl/tests/ndr_string.pl (limited to 'source4/pidl/tests') 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 +# 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 . +# 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 +# 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 +# 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; +'); -- cgit From ebfbb2a7abe33e47af48d69164c37f4c24b7f8ed Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 24 Dec 2005 22:11:44 +0000 Subject: r12463: Rename 'Samba' namespace to 'Samba4' (This used to be commit f25358270d44a5642adbb85ecaa50b2e5730d7f0) --- source4/pidl/tests/ndr_simple.pl | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/ndr_simple.pl b/source4/pidl/tests/ndr_simple.pl index 7d48c9f4d7..2c2c910a56 100755 --- a/source4/pidl/tests/ndr_simple.pl +++ b/source4/pidl/tests/ndr_simple.pl @@ -5,12 +5,18 @@ use strict; use Parse::Pidl::Test; +use Parse::Pidl::IDL; +use Parse::Pidl::NDR; +use Parse::Pidl::Samba::NDR; 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']; +my $pidl = Parse::Pidl::IDL::parse_string('void Test();'); +my $pndr = Parse::Pidl::NDR::Parse($pidl); + Parse::Pidl::Test::test_idl( # Name 'UInt8', @@ -18,8 +24,6 @@ Parse::Pidl::Test::test_idl( # Settings \%settings, - # IDL - 'void Test();', # C Test ' -- cgit From 68ef82aac72c351f6e166b92bbb4573e8bcdbc86 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 24 Dec 2005 23:32:50 +0000 Subject: r12464: Add simple IDL parsing tests for pidl using the standard perl testing framework (Test::Simple, distributed with perl itself). Run these tests from 'make test' (This used to be commit 975d8816db6697dab828941b69a740e3a0a2c272) --- source4/pidl/tests/ndr_align.pl | 8 +---- source4/pidl/tests/ndr_alloc.pl | 16 ++-------- source4/pidl/tests/ndr_array.pl | 7 +---- source4/pidl/tests/ndr_refptr.pl | 7 +---- source4/pidl/tests/ndr_simple.pl | 68 +++++++++++++++++++++------------------- source4/pidl/tests/ndr_string.pl | 8 +---- source4/pidl/tests/parse_idl.pl | 57 +++++++++++++++++++++++++++++++++ 7 files changed, 100 insertions(+), 71 deletions(-) create mode 100755 source4/pidl/tests/parse_idl.pl (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/ndr_align.pl b/source4/pidl/tests/ndr_align.pl index da994224eb..073ce5ce2f 100755 --- a/source4/pidl/tests/ndr_align.pl +++ b/source4/pidl/tests/ndr_align.pl @@ -3,13 +3,7 @@ # (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']; +use Test::Simple tests => 1; Parse::Pidl::Test::test_idl('align-uint8-uint16', \%settings, ' diff --git a/source4/pidl/tests/ndr_alloc.pl b/source4/pidl/tests/ndr_alloc.pl index 4f6eddbfb9..4786d96971 100755 --- a/source4/pidl/tests/ndr_alloc.pl +++ b/source4/pidl/tests/ndr_alloc.pl @@ -3,12 +3,7 @@ # (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']; +use Test::Simple tests => 1; # Check that an outgoing scalar pointer is allocated correctly @@ -39,14 +34,9 @@ Parse::Pidl::Test::test_idl("alloc-scalar", \%settings, # Check that an outgoing buffer pointer is allocated correctly Parse::Pidl::Test::test_idl("alloc-buffer", \%settings, ' - typedef struct { - uint8 data; - } blie; + typedef struct { uint8 data; } blie; + typedef struct { blie *x; } bla; - typedef struct { - blie *x; - } bla; - [public] void TestAlloc([in] bla foo); ',' uint8_t data[] = { 0xde, 0xad, 0xbe, 0xef, 0x03 }; diff --git a/source4/pidl/tests/ndr_array.pl b/source4/pidl/tests/ndr_array.pl index d486308339..ad313949c5 100755 --- a/source4/pidl/tests/ndr_array.pl +++ b/source4/pidl/tests/ndr_array.pl @@ -4,12 +4,7 @@ # 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']; +use Test::Simple tests => 1; Parse::Pidl::Test::test_idl( # Name diff --git a/source4/pidl/tests/ndr_refptr.pl b/source4/pidl/tests/ndr_refptr.pl index 8344661ad3..46d74f9b1e 100755 --- a/source4/pidl/tests/ndr_refptr.pl +++ b/source4/pidl/tests/ndr_refptr.pl @@ -5,12 +5,7 @@ # 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']; +use Test::Simple tests => 1; Parse::Pidl::Test::test_idl("noptr-push", \%settings, ' typedef struct { diff --git a/source4/pidl/tests/ndr_simple.pl b/source4/pidl/tests/ndr_simple.pl index 2c2c910a56..96e213ede9 100755 --- a/source4/pidl/tests/ndr_simple.pl +++ b/source4/pidl/tests/ndr_simple.pl @@ -4,41 +4,45 @@ # Published under the GNU General Public License use strict; -use Parse::Pidl::Test; +use Test::Simple tests => 4; +use FindBin qw($RealBin); +use lib "$RealBin/../lib"; use Parse::Pidl::IDL; use Parse::Pidl::NDR; -use Parse::Pidl::Samba::NDR; +use Parse::Pidl::Samba4::NDR::Parser; -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']; - -my $pidl = Parse::Pidl::IDL::parse_string('void Test();'); +my $pidl = Parse::Pidl::IDL::parse_string( +"interface test { void Test(); }; ", ""); +ok (defined($pidl)); my $pndr = Parse::Pidl::NDR::Parse($pidl); +ok(defined($pndr)); +my ($header,$parser) = Parse::Pidl::Samba4::NDR::Parser($pndr); +ok(defined($header)); +ok(defined($parser)); -Parse::Pidl::Test::test_idl( - # Name - 'UInt8', - - # Settings - \%settings, - - - # 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; -'); +#Parse::Pidl::Test::test_idl( +# # Name +# 'UInt8', +# +# # Settings +# \%settings, +# +# +# # 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 index ad8db912d7..6ece73fb4d 100755 --- a/source4/pidl/tests/ndr_string.pl +++ b/source4/pidl/tests/ndr_string.pl @@ -4,13 +4,7 @@ # 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']; +use Test::Simple tests => 1; Parse::Pidl::Test::test_idl("string-pull-empty", \%settings, ' [public] void TestString([in,flag(STR_ASCII|LIBNDR_FLAG_STR_SIZE4)] string data);', diff --git a/source4/pidl/tests/parse_idl.pl b/source4/pidl/tests/parse_idl.pl new file mode 100755 index 0000000000..d4b680d055 --- /dev/null +++ b/source4/pidl/tests/parse_idl.pl @@ -0,0 +1,57 @@ +#!/usr/bin/perl +# Some simple tests for pidls parsing routines +# (C) 2005 Jelmer Vernooij +# Published under the GNU General Public License +use strict; + +use Test::Simple tests => 26; +use FindBin qw($RealBin); +use lib "$RealBin/../lib"; +use Parse::Pidl::IDL; +use Parse::Pidl::NDR; + +sub testok($$) +{ + my ($name, $data) = @_; + + my $pidl = Parse::Pidl::IDL::parse_string($data, "<$name>"); + + ok (defined($pidl), $name); + return $pidl +} + +sub testfail($$) +{ + my ($name, $data) = @_; + + my $pidl = Parse::Pidl::IDL::parse_string($data, "<$name>"); + + ok ((not defined $pidl), $name); +} + +testok "test1", "interface test { void Test(); }; "; +testok "voidtest", "interface test { int Testx(void); }; "; +testfail "voidtest", "interface test { Test(); }; "; +testok "argtest", "interface test { int Test(int a, long b, uint32 c); }; "; +testok "array1", "interface test { int Test(int a[]); };"; +testok "array2", "interface test { int Test(int a[2]); };"; +testok "array3", "interface test { int Test(int a[b]); };"; +testfail "array4", "interface test { int Test(int[] a); };"; +testok "ptr1", "interface test { int Test(int *a); };"; +testok "ptr2", "interface test { int Test(int **a); };"; +testok "ptr3", "interface test { int Test(int ***a); };"; +testfail "empty1", "interface test { };"; +testfail "empty2", ""; +testok "attr1", "[uuid(\"myuuid\"),attr] interface test { int Test(int ***a); };"; +testok "attr2", "interface test { [public] int Test(); };"; +testok "multfn", "interface test { int test1(); int test2(); };"; +testok "multif", "interface test { int test1(); }; interface test2 { int test2(); };"; +testok "tdstruct1", "interface test { typedef struct { } foo; };"; +testok "tdstruct2", "interface test { typedef struct { int a; } foo; };"; +testok "tdstruct3", "interface test { typedef struct { int a; int b; } foo; };"; +testfail "tdstruct4", "interface test { typedef struct { int a, int b; } foo; };"; +testok "tdunion1", "interface test { typedef union { } a; };"; +testok "tdunion2", "interface test { typedef union { int a; } a; };"; +testok "typedef1", "interface test { typedef int a; };"; +testfail "typedef2", "interface test { typedef x; };"; +testok "tdenum1", "interface test { typedef enum { A=1, B=2, C} a; };"; -- cgit From 620d375320e143abcf6775a392f9bde3146f2baa Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 25 Dec 2005 01:33:35 +0000 Subject: r12465: Merge Parse::Pidl::Samba4::NDR::Header into Parse::Pidl::Samba4::NDR::Parser. Small optimization to avoid including NDR headers multiple times (This used to be commit 6967b9884970b6f1d7617196ab024d401628a13c) --- source4/pidl/tests/ndr_simple.pl | 70 ++++++++++++++++++++++++---------------- 1 file changed, 43 insertions(+), 27 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/ndr_simple.pl b/source4/pidl/tests/ndr_simple.pl index 96e213ede9..5bdd02b763 100755 --- a/source4/pidl/tests/ndr_simple.pl +++ b/source4/pidl/tests/ndr_simple.pl @@ -4,45 +4,61 @@ # Published under the GNU General Public License use strict; -use Test::Simple tests => 4; +use Test::Simple tests => 6; use FindBin qw($RealBin); use lib "$RealBin/../lib"; use Parse::Pidl::IDL; use Parse::Pidl::NDR; use Parse::Pidl::Samba4::NDR::Parser; +use Parse::Pidl::Samba4::Header; my $pidl = Parse::Pidl::IDL::parse_string( "interface test { void Test(); }; ", ""); ok (defined($pidl)); my $pndr = Parse::Pidl::NDR::Parse($pidl); ok(defined($pndr)); -my ($header,$parser) = Parse::Pidl::Samba4::NDR::Parser($pndr); +my $header = Parse::Pidl::Samba4::Header::Parse($pidl); ok(defined($header)); +my ($ndrheader,$parser) = Parse::Pidl::Samba4::NDR::Parser::Parse($pndr, "foo"); ok(defined($parser)); +ok(defined($ndrheader)); +my $outfile = "test"; -#Parse::Pidl::Test::test_idl( -# # Name -# 'UInt8', -# -# # Settings -# \%settings, -# -# -# # 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; -#'); +#my $cflags = $ENV{CFLAGS}; +my $cflags = "-Iinclude -I."; + +open CC, "|cc -x c -o $outfile $cflags -"; +#open CC, ">foo"; +print CC "#include \"includes.h\""; +print CC $header; +print CC $ndrheader; +print CC $parser; +print CC + ' +int main(int argc, const char **argv) +{ + uint8_t data[] = { 0x02 }; + uint8_t result; + DATA_BLOB b; + struct ndr_pull *ndr; + TALLOC_CTX *mem_ctx = talloc_init(NULL); + + 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; + + talloc_free(mem_ctx); + + return 0; +} +'; +close CC; + +ok(-f $outfile); -- cgit From 7717f180ca2f908e1b3258355520719991215050 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 25 Dec 2005 03:04:13 +0000 Subject: r12470: Add helper module for pidl tests Convert other pidl tests to use Test::More and run them from 'make test' (This used to be commit 3a57d29a62112ab654e290ccc985fba7f67664c5) --- source4/pidl/tests/Util.pm | 94 ++++++++++++++++++++++++++++++++++++++++ source4/pidl/tests/ndr_align.pl | 16 ++++--- source4/pidl/tests/ndr_alloc.pl | 16 ++++--- source4/pidl/tests/ndr_array.pl | 14 +++--- source4/pidl/tests/ndr_refptr.pl | 81 ++++++++++++++++++---------------- source4/pidl/tests/ndr_simple.pl | 47 +++----------------- source4/pidl/tests/ndr_string.pl | 10 +++-- source4/pidl/tests/parse_idl.pl | 2 +- 8 files changed, 177 insertions(+), 103 deletions(-) create mode 100644 source4/pidl/tests/Util.pm (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/Util.pm b/source4/pidl/tests/Util.pm new file mode 100644 index 0000000000..52fde11bf5 --- /dev/null +++ b/source4/pidl/tests/Util.pm @@ -0,0 +1,94 @@ +# Some simple utility functions for pidl tests +# Copyright (C) 2005 Jelmer Vernooij +# Published under the GNU General Public License + +package Util; + +require Exporter; +@ISA = qw(Exporter); +@EXPORT_OK = qw(test_samba4_ndr); + +use strict; + +use Test::More; +use Parse::Pidl::IDL; +use Parse::Pidl::NDR; +use Parse::Pidl::Samba4::NDR::Parser; +use Parse::Pidl::Samba4::Header; + +my $sanecc = 0; + +# Generate a Samba4 parser for an IDL fragment and run it with a specified +# piece of code to check whether the parser works as expected +sub test_samba4_ndr($$$) +{ + my ($name,$idl,$c) = @_; + my $pidl = Parse::Pidl::IDL::parse_string("interface echo { $idl }; ", "<$name>"); + + ok (defined($pidl), "($name) parse idl"); + my $header = Parse::Pidl::Samba4::Header::Parse($pidl); + ok(defined($header), "($name) generate generic header"); + my $pndr = Parse::Pidl::NDR::Parse($pidl); + ok(defined($pndr), "($name) generate NDR tree"); + my ($ndrheader,$ndrparser) = Parse::Pidl::Samba4::NDR::Parser::Parse($pndr, "foo"); + ok(defined($ndrparser), "($name) generate NDR parser"); + ok(defined($ndrheader), "($name) generate NDR header"); + +SKIP: { + + my $insamba = -f "include/includes.h"; + my $link = $insamba && 0; # FIXME + + skip "no samba environment available, skipping compilation", 3 + if not $insamba; + + skip "no sane C compiler, skipping compilation", 3 + if not $sanecc; + + my $outfile = "test-$name"; + + #my $cflags = $ENV{CFLAGS}; + my $cflags = "-Iinclude -I."; + + if ($insamba and $link) { + open CC, "|cc -x c -o $outfile $cflags -"; + } elsif ($insamba) { + open CC, "|cc -x c -c -o $outfile $cflags -"; + } + print CC "#include \"includes.h\"\n"; + print CC $header; + print CC $ndrheader; + print CC $ndrparser; + print CC "int main(int argc, const char **argv) +{ + TALLOC_CTX *mem_ctx = talloc_init(NULL); + + $c + + talloc_free(mem_ctx); + + return 0; }\n"; + close CC; + + ok(-f $outfile, "($name) compile"); + + unless ($link) { + skip "no shared libraries of Samba available yet, can't run test", 2; + unlink($outfile); + } + + ok(system($outfile), "($name) run"); + + ok(unlink($outfile), "($name) remove"); + + } +} + +my $outfile = "test"; # FIXME: Somewhat more unique name + +# Test whether CC is sane. The real 'fix' here would be using the +# Samba build system, but unfortunately, we have no way of hooking into that +# yet so we're running CC directly for now +$sanecc = 1 if system('echo "main() {}"'." | cc -I. -x c -c - -o $outfile") == 0; + +1; diff --git a/source4/pidl/tests/ndr_align.pl b/source4/pidl/tests/ndr_align.pl index 073ce5ce2f..7ca180cf20 100755 --- a/source4/pidl/tests/ndr_align.pl +++ b/source4/pidl/tests/ndr_align.pl @@ -3,9 +3,13 @@ # (C) 2005 Jelmer Vernooij. Published under the GNU GPL use strict; -use Test::Simple tests => 1; +use Test::More tests => 5 * 8; +use FindBin qw($RealBin); +use lib "$RealBin/../lib"; +use lib "$RealBin"; +use Util qw(test_samba4_ndr); -Parse::Pidl::Test::test_idl('align-uint8-uint16', \%settings, +test_samba4_ndr('align-uint8-uint16', ' typedef [public] struct { uint8 x; @@ -30,7 +34,7 @@ Parse::Pidl::Test::test_idl('align-uint8-uint16', \%settings, return 2; '); -Parse::Pidl::Test::test_idl('align-uint8-uint32', \%settings, +test_samba4_ndr('align-uint8-uint32', ' typedef [public] struct { uint8 x; @@ -56,7 +60,7 @@ Parse::Pidl::Test::test_idl('align-uint8-uint32', \%settings, '); -Parse::Pidl::Test::test_idl('align-uint8-hyper', \%settings, +test_samba4_ndr('align-uint8-hyper', ' typedef [public] struct { uint8 x; @@ -82,7 +86,7 @@ Parse::Pidl::Test::test_idl('align-uint8-hyper', \%settings, return 2; '); -Parse::Pidl::Test::test_idl('noalignflag-uint8-uint16', \%settings, +test_samba4_ndr('noalignflag-uint8-uint16', ' typedef [public] struct { uint8 x; @@ -109,7 +113,7 @@ Parse::Pidl::Test::test_idl('noalignflag-uint8-uint16', \%settings, return 2; '); -Parse::Pidl::Test::test_idl('align-blob-align2', \%settings, +test_samba4_ndr('align-blob-align2', ' typedef [public] struct { uint8 x; diff --git a/source4/pidl/tests/ndr_alloc.pl b/source4/pidl/tests/ndr_alloc.pl index 4786d96971..039826e4ea 100755 --- a/source4/pidl/tests/ndr_alloc.pl +++ b/source4/pidl/tests/ndr_alloc.pl @@ -3,11 +3,15 @@ # (C) 2005 Jelmer Vernooij. Published under the GNU GPL use strict; -use Test::Simple tests => 1; +use Test::More tests => 5 * 8; +use FindBin qw($RealBin); +use lib "$RealBin/../lib"; +use lib "$RealBin"; +use Util qw(test_samba4_ndr); # Check that an outgoing scalar pointer is allocated correctly -Parse::Pidl::Test::test_idl("alloc-scalar", \%settings, +test_samba4_ndr("alloc-scalar", ' typedef struct { uint8 *x; @@ -32,7 +36,7 @@ Parse::Pidl::Test::test_idl("alloc-scalar", \%settings, ); # Check that an outgoing buffer pointer is allocated correctly -Parse::Pidl::Test::test_idl("alloc-buffer", \%settings, +test_samba4_ndr("alloc-buffer", ' typedef struct { uint8 data; } blie; typedef struct { blie *x; } bla; @@ -56,7 +60,7 @@ Parse::Pidl::Test::test_idl("alloc-buffer", \%settings, ); # Check that ref pointers aren't allocated by default -Parse::Pidl::Test::test_idl("ref-noalloc-null", \%settings, +test_samba4_ndr("ref-noalloc-null", ' [public] void TestAlloc([in,ref] uint8 *t); ',' @@ -72,7 +76,7 @@ Parse::Pidl::Test::test_idl("ref-noalloc-null", \%settings, ); # Check that ref pointers aren't allocated by default -Parse::Pidl::Test::test_idl("ref-noalloc", \%settings, +test_samba4_ndr("ref-noalloc", ' [public] void TestAlloc([in,ref] uint8 *t); ',' @@ -92,7 +96,7 @@ Parse::Pidl::Test::test_idl("ref-noalloc", \%settings, ); # Check that an outgoing ref pointer is allocated correctly -Parse::Pidl::Test::test_idl("ref-alloc", \%settings, +test_samba4_ndr("ref-alloc", ' [public] void TestAlloc([in,ref] uint8 *t); ',' diff --git a/source4/pidl/tests/ndr_array.pl b/source4/pidl/tests/ndr_array.pl index ad313949c5..b28070536e 100755 --- a/source4/pidl/tests/ndr_array.pl +++ b/source4/pidl/tests/ndr_array.pl @@ -4,19 +4,17 @@ # Published under the GNU General Public License use strict; -use Test::Simple tests => 1; +use Test::More tests => 8; +use FindBin qw($RealBin); +use lib "$RealBin/../lib"; +use lib "$RealBin"; +use Util qw(test_samba4_ndr); -Parse::Pidl::Test::test_idl( - # Name +test_samba4_ndr( '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; diff --git a/source4/pidl/tests/ndr_refptr.pl b/source4/pidl/tests/ndr_refptr.pl index 46d74f9b1e..0fd573d51e 100755 --- a/source4/pidl/tests/ndr_refptr.pl +++ b/source4/pidl/tests/ndr_refptr.pl @@ -5,9 +5,13 @@ # Published under the GNU General Public License. use strict; -use Test::Simple tests => 1; +use Test::More tests => 21 * 8; +use FindBin qw($RealBin); +use lib "$RealBin/../lib"; +use lib "$RealBin"; +use Util qw(test_samba4_ndr); -Parse::Pidl::Test::test_idl("noptr-push", \%settings, +test_samba4_ndr("noptr-push", ' typedef struct { uint16 x; } xstruct; @@ -36,7 +40,7 @@ Parse::Pidl::Test::test_idl("noptr-push", \%settings, } '); -Parse::Pidl::Test::test_idl("ptr-embedded-push", \%settings, +test_samba4_ndr("ptr-embedded-push", ' typedef struct { uint16 *x; } xstruct; @@ -63,7 +67,7 @@ Parse::Pidl::Test::test_idl("ptr-embedded-push", \%settings, return 4; '); -Parse::Pidl::Test::test_idl("ptr-embedded-push-null", \%settings, +test_samba4_ndr("ptr-embedded-push-null", ' typedef struct { uint16 *x; } xstruct; @@ -86,7 +90,7 @@ Parse::Pidl::Test::test_idl("ptr-embedded-push-null", \%settings, return 3; '); -Parse::Pidl::Test::test_idl("refptr-embedded-push", \%settings, +test_samba4_ndr("refptr-embedded-push", ' typedef struct { [ref] uint16 *x; @@ -114,7 +118,7 @@ Parse::Pidl::Test::test_idl("refptr-embedded-push", \%settings, return 4; '); -Parse::Pidl::Test::test_idl("refptr-embedded-push-null", \%settings, +test_samba4_ndr("refptr-embedded-push-null", ' typedef struct { [ref] uint16 *x; @@ -132,7 +136,7 @@ Parse::Pidl::Test::test_idl("refptr-embedded-push-null", \%settings, /* Windows gives [client runtime error 0x6f4] */ '); -Parse::Pidl::Test::test_idl("ptr-top-push", \%settings, +test_samba4_ndr("ptr-top-push", ' typedef struct { uint16 x; @@ -157,7 +161,7 @@ Parse::Pidl::Test::test_idl("ptr-top-push", \%settings, return 3; '); -Parse::Pidl::Test::test_idl("ptr-top-push-null", \%settings, +test_samba4_ndr("ptr-top-push-null", ' typedef struct { uint16 x; @@ -177,7 +181,7 @@ Parse::Pidl::Test::test_idl("ptr-top-push-null", \%settings, '); -Parse::Pidl::Test::test_idl("refptr-top-push", \%settings, +test_samba4_ndr("refptr-top-push", ' typedef struct { uint16 x; @@ -202,7 +206,7 @@ Parse::Pidl::Test::test_idl("refptr-top-push", \%settings, return 3; '); -Parse::Pidl::Test::test_idl("refptr-top-push-null", \%settings, +test_samba4_ndr("refptr-top-push-null", ' typedef struct { uint16 x; @@ -222,7 +226,7 @@ Parse::Pidl::Test::test_idl("refptr-top-push-null", \%settings, '); -Parse::Pidl::Test::test_idl("uniqueptr-top-push", \%settings, +test_samba4_ndr("uniqueptr-top-push", ' typedef struct { uint16 x; } xstruct; @@ -250,7 +254,7 @@ Parse::Pidl::Test::test_idl("uniqueptr-top-push", \%settings, return 4; '); -Parse::Pidl::Test::test_idl("uniqueptr-top-push-null", \%settings, +test_samba4_ndr("uniqueptr-top-push-null", ' typedef struct { uint16 x; } xstruct; @@ -274,7 +278,7 @@ Parse::Pidl::Test::test_idl("uniqueptr-top-push-null", \%settings, '); -Parse::Pidl::Test::test_idl("ptr-top-out-pull", \%settings, +test_samba4_ndr("ptr-top-out-pull", ' typedef struct { uint16 x; @@ -301,7 +305,7 @@ Parse::Pidl::Test::test_idl("ptr-top-out-pull", \%settings, return 3; '); -Parse::Pidl::Test::test_idl("ptr-top-out-pull-null", \%settings, +test_samba4_ndr("ptr-top-out-pull-null", ' typedef struct { uint16 x; @@ -324,7 +328,7 @@ Parse::Pidl::Test::test_idl("ptr-top-out-pull-null", \%settings, '); -Parse::Pidl::Test::test_idl("refptr-top-out-pull", \%settings, +test_samba4_ndr("refptr-top-out-pull", ' typedef struct { uint16 x; @@ -351,7 +355,7 @@ Parse::Pidl::Test::test_idl("refptr-top-out-pull", \%settings, return 3; '); -Parse::Pidl::Test::test_idl("refptr-top-out-pull-null", \%settings, +test_samba4_ndr("refptr-top-out-pull-null", ' typedef struct { uint16 x; @@ -374,7 +378,7 @@ Parse::Pidl::Test::test_idl("refptr-top-out-pull-null", \%settings, '); -Parse::Pidl::Test::test_idl("ptr-top-push-double", \%settings, +test_samba4_ndr("ptr-top-push-double", ' [public] void echo_TestRef([in] uint16 **foo); ', @@ -398,7 +402,7 @@ Parse::Pidl::Test::test_idl("ptr-top-push-double", \%settings, return 4; '); -Parse::Pidl::Test::test_idl("ptr-top-push-double-sndnull", \%settings, +test_samba4_ndr("ptr-top-push-double-sndnull", ' [public] void echo_TestRef([in] uint16 **foo); ', @@ -418,7 +422,7 @@ Parse::Pidl::Test::test_idl("ptr-top-push-double-sndnull", \%settings, return 3; '); -Parse::Pidl::Test::test_idl("ptr-top-push-double-fstnull", \%settings, +test_samba4_ndr("ptr-top-push-double-fstnull", ' [public] void echo_TestRef([in] uint16 **foo); ', @@ -434,7 +438,7 @@ Parse::Pidl::Test::test_idl("ptr-top-push-double-fstnull", \%settings, '); -Parse::Pidl::Test::test_idl("refptr-top-push-double", \%settings, +test_samba4_ndr("refptr-top-push-double", ' [public] void echo_TestRef([in,ref] uint16 **foo); ', @@ -458,7 +462,7 @@ Parse::Pidl::Test::test_idl("refptr-top-push-double", \%settings, return 4; '); -Parse::Pidl::Test::test_idl("refptr-top-push-double-sndnull", \%settings, +test_samba4_ndr("refptr-top-push-double-sndnull", ' [public] void echo_TestRef([in,ref] uint16 **foo); ', @@ -478,7 +482,7 @@ Parse::Pidl::Test::test_idl("refptr-top-push-double-sndnull", \%settings, return 3; '); -Parse::Pidl::Test::test_idl("refptr-top-push-double-fstnull", \%settings, +test_samba4_ndr("refptr-top-push-double-fstnull", ' [public] void echo_TestRef([in,ref] uint16 **foo); ', @@ -493,19 +497,20 @@ Parse::Pidl::Test::test_idl("refptr-top-push-double-fstnull", \%settings, '); -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; -'); +#FIXME: Not supported yet +#test_samba4_ndr("ignore-ptr", +#' +# [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 index 5bdd02b763..9535ee1fae 100755 --- a/source4/pidl/tests/ndr_simple.pl +++ b/source4/pidl/tests/ndr_simple.pl @@ -4,45 +4,18 @@ # Published under the GNU General Public License use strict; -use Test::Simple tests => 6; +use Test::More tests => 8; use FindBin qw($RealBin); use lib "$RealBin/../lib"; -use Parse::Pidl::IDL; -use Parse::Pidl::NDR; -use Parse::Pidl::Samba4::NDR::Parser; -use Parse::Pidl::Samba4::Header; +use lib "$RealBin"; +use Util qw(test_samba4_ndr); -my $pidl = Parse::Pidl::IDL::parse_string( -"interface test { void Test(); }; ", ""); -ok (defined($pidl)); -my $pndr = Parse::Pidl::NDR::Parse($pidl); -ok(defined($pndr)); -my $header = Parse::Pidl::Samba4::Header::Parse($pidl); -ok(defined($header)); -my ($ndrheader,$parser) = Parse::Pidl::Samba4::NDR::Parser::Parse($pndr, "foo"); -ok(defined($parser)); -ok(defined($ndrheader)); - -my $outfile = "test"; - -#my $cflags = $ENV{CFLAGS}; -my $cflags = "-Iinclude -I."; - -open CC, "|cc -x c -o $outfile $cflags -"; -#open CC, ">foo"; -print CC "#include \"includes.h\""; -print CC $header; -print CC $ndrheader; -print CC $parser; -print CC - ' -int main(int argc, const char **argv) -{ +test_samba4_ndr("simple", "void Test(); ", +" uint8_t data[] = { 0x02 }; uint8_t result; DATA_BLOB b; struct ndr_pull *ndr; - TALLOC_CTX *mem_ctx = talloc_init(NULL); b.data = data; b.length = 1; @@ -53,12 +26,4 @@ int main(int argc, const char **argv) if (result != 0x02) return 2; - - talloc_free(mem_ctx); - - return 0; -} -'; -close CC; - -ok(-f $outfile); +"); diff --git a/source4/pidl/tests/ndr_string.pl b/source4/pidl/tests/ndr_string.pl index 6ece73fb4d..e8e37be8c1 100755 --- a/source4/pidl/tests/ndr_string.pl +++ b/source4/pidl/tests/ndr_string.pl @@ -4,9 +4,13 @@ # Published under the GNU General Public License use strict; -use Test::Simple tests => 1; +use Test::More tests => 2 * 8; +use FindBin qw($RealBin); +use lib "$RealBin/../lib"; +use lib "$RealBin"; +use Util qw(test_samba4_ndr); -Parse::Pidl::Test::test_idl("string-pull-empty", \%settings, +test_samba4_ndr("string-pull-empty", ' [public] void TestString([in,flag(STR_ASCII|LIBNDR_FLAG_STR_SIZE4)] string data);', ' uint8_t data[] = { 0x00, 0x00, 0x00, 0x00 }; @@ -25,7 +29,7 @@ Parse::Pidl::Test::test_idl("string-pull-empty", \%settings, return 3; '); -Parse::Pidl::Test::test_idl("string-ascii-pull", \%settings, +test_samba4_ndr("string-ascii-pull", ' [public] void TestString([in,flag(STR_ASCII|LIBNDR_FLAG_STR_SIZE4)] string data); ', diff --git a/source4/pidl/tests/parse_idl.pl b/source4/pidl/tests/parse_idl.pl index d4b680d055..7fdd2ddfac 100755 --- a/source4/pidl/tests/parse_idl.pl +++ b/source4/pidl/tests/parse_idl.pl @@ -4,7 +4,7 @@ # Published under the GNU General Public License use strict; -use Test::Simple tests => 26; +use Test::More tests => 26; use FindBin qw($RealBin); use lib "$RealBin/../lib"; use Parse::Pidl::IDL; -- cgit From 8e924678b205910a5147ceb948d4db86e3a9ae0c Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 25 Dec 2005 14:11:59 +0000 Subject: r12480: Extend testsuite (This used to be commit 1fa6c3568b9653f637da92e9a66695cd89825a2f) --- source4/pidl/tests/parse_idl.pl | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/parse_idl.pl b/source4/pidl/tests/parse_idl.pl index 7fdd2ddfac..2236c6d0b5 100755 --- a/source4/pidl/tests/parse_idl.pl +++ b/source4/pidl/tests/parse_idl.pl @@ -4,7 +4,7 @@ # Published under the GNU General Public License use strict; -use Test::More tests => 26; +use Test::More tests => 46; use FindBin qw($RealBin); use lib "$RealBin/../lib"; use Parse::Pidl::IDL; @@ -44,14 +44,37 @@ testfail "empty1", "interface test { };"; testfail "empty2", ""; testok "attr1", "[uuid(\"myuuid\"),attr] interface test { int Test(int ***a); };"; testok "attr2", "interface test { [public] int Test(); };"; +testok "attr3", "[attr1] [attr2] interface test { [public] int Test(); };"; testok "multfn", "interface test { int test1(); int test2(); };"; testok "multif", "interface test { int test1(); }; interface test2 { int test2(); };"; testok "tdstruct1", "interface test { typedef struct { } foo; };"; testok "tdstruct2", "interface test { typedef struct { int a; } foo; };"; testok "tdstruct3", "interface test { typedef struct { int a; int b; } foo; };"; testfail "tdstruct4", "interface test { typedef struct { int a, int b; } foo; };"; +testok "struct1", "interface test { struct x { }; };"; +testok "struct2", "interface test { struct x { int a; }; };"; +testok "struct3", "interface test { struct x { int a; int b; }; };"; +testfail "struct4", "interface test { struct x { int a, int b; }; };"; +testfail "struct5", "interface test { struct { int a; } x; };"; testok "tdunion1", "interface test { typedef union { } a; };"; testok "tdunion2", "interface test { typedef union { int a; } a; };"; +testok "union1", "interface test { union a { }; };"; +testok "union2", "interface test { union x { int a; }; };"; +testfail "union3", "interface test { union { int a; } x; };"; testok "typedef1", "interface test { typedef int a; };"; testfail "typedef2", "interface test { typedef x; };"; testok "tdenum1", "interface test { typedef enum { A=1, B=2, C} a; };"; +testok "enum1", "interface test { enum a { A=1, B=2, C}; };"; +testfail "enum2", "interface test { enum { A=1, B=2, C} a; };"; +testok "nested1", "interface test { struct x { struct { int a; } z; }; };"; +testok "nested2", "interface test { struct x { struct y { int a; } z; }; };"; +testok "bitmap1", "interface test { bitmap x { a=1 }; };"; +TODO: { + local $TODO = "qualifiers on defined types not supported yet"; + testok "unsigned", "interface test { struct x { unsigned short y; }; };"; + testok "signed", "interface test { struct x { signed short y; }; };"; + testok "structqual", "interface test { struct x { struct y z; }; };"; + testok "unionqual", "interface test { struct x { union y z; }; };"; + testok "enumqual", "interface test { struct x { enum y z; }; };"; + testok "bitmapqual", "interface test { struct x { bitmap y z; }; };" +}; -- cgit From d3ced46329fe5caa590d2f0b132763d7d1825ffd Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 25 Dec 2005 14:59:39 +0000 Subject: r12482: Add some more tests (This used to be commit 516b66e0f1c65688abb936b4432039bc431b872c) --- source4/pidl/tests/parse_idl.pl | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/parse_idl.pl b/source4/pidl/tests/parse_idl.pl index 2236c6d0b5..8114cd9992 100755 --- a/source4/pidl/tests/parse_idl.pl +++ b/source4/pidl/tests/parse_idl.pl @@ -4,7 +4,7 @@ # Published under the GNU General Public License use strict; -use Test::More tests => 46; +use Test::More tests => 51; use FindBin qw($RealBin); use lib "$RealBin/../lib"; use Parse::Pidl::IDL; @@ -29,6 +29,7 @@ sub testfail($$) ok ((not defined $pidl), $name); } +testfail "unknowntag", "bla test {};"; testok "test1", "interface test { void Test(); }; "; testok "voidtest", "interface test { int Testx(void); }; "; testfail "voidtest", "interface test { Test(); }; "; @@ -69,12 +70,13 @@ testfail "enum2", "interface test { enum { A=1, B=2, C} a; };"; testok "nested1", "interface test { struct x { struct { int a; } z; }; };"; testok "nested2", "interface test { struct x { struct y { int a; } z; }; };"; testok "bitmap1", "interface test { bitmap x { a=1 }; };"; -TODO: { - local $TODO = "qualifiers on defined types not supported yet"; - testok "unsigned", "interface test { struct x { unsigned short y; }; };"; - testok "signed", "interface test { struct x { signed short y; }; };"; - testok "structqual", "interface test { struct x { struct y z; }; };"; - testok "unionqual", "interface test { struct x { union y z; }; };"; - testok "enumqual", "interface test { struct x { enum y z; }; };"; - testok "bitmapqual", "interface test { struct x { bitmap y z; }; };" -}; +testok "unsigned", "interface test { struct x { unsigned short y; }; };"; +testok "signed", "interface test { struct x { signed short y; }; };"; +testok "declarg", "interface test { void test(struct { int x; } a); };"; +testok "structqual", "interface test { struct x { struct y z; }; };"; +testok "unionqual", "interface test { struct x { union y z; }; };"; +testok "enumqual", "interface test { struct x { enum y z; }; };"; +testok "bitmapqual", "interface test { struct x { bitmap y z; }; };"; +testok "emptystructdecl", "interface test { struct x; };"; +testok "emptyenumdecl", "interface test { enum x; };"; +testok "emptytdstructdecl", "interface test { typedef struct x y; };"; -- cgit From 43c3c7349d4d5029fc800d46c2c589f28daadb89 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 28 Dec 2005 09:31:43 +0000 Subject: r12539: fix the pidl tests metze (This used to be commit 4b90ad7a272b3cb976c2efc2c67b339519b1cd90) --- source4/pidl/tests/Util.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/Util.pm b/source4/pidl/tests/Util.pm index 52fde11bf5..c85ef72d0a 100644 --- a/source4/pidl/tests/Util.pm +++ b/source4/pidl/tests/Util.pm @@ -48,7 +48,7 @@ SKIP: { my $outfile = "test-$name"; #my $cflags = $ENV{CFLAGS}; - my $cflags = "-Iinclude -I."; + my $cflags = "-Iinclude -Ilib -I."; if ($insamba and $link) { open CC, "|cc -x c -o $outfile $cflags -"; -- cgit From d7963738959b4e9d4d1cc814aa93dbf341c56a64 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sun, 8 Jan 2006 20:20:18 +0000 Subject: r12776: use $ENV{TEST_DATA_PREFIX} for test files if available metze (This used to be commit 5552eaa37c228872736688bb65b4f678bdfeddf4) --- source4/pidl/tests/Util.pm | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/Util.pm b/source4/pidl/tests/Util.pm index c85ef72d0a..cd2ba2a37e 100644 --- a/source4/pidl/tests/Util.pm +++ b/source4/pidl/tests/Util.pm @@ -25,7 +25,7 @@ sub test_samba4_ndr($$$) my ($name,$idl,$c) = @_; my $pidl = Parse::Pidl::IDL::parse_string("interface echo { $idl }; ", "<$name>"); - ok (defined($pidl), "($name) parse idl"); + ok(defined($pidl), "($name) parse idl"); my $header = Parse::Pidl::Samba4::Header::Parse($pidl); ok(defined($header), "($name) generate generic header"); my $pndr = Parse::Pidl::NDR::Parse($pidl); @@ -45,7 +45,14 @@ SKIP: { skip "no sane C compiler, skipping compilation", 3 if not $sanecc; - my $outfile = "test-$name"; + my $test_data_prefix = $ENV{TEST_DATA_PREFIX}; + + my $outfile; + if (defined($test_data_prefix)) { + $outfile = "$test_data_prefix/test-$name"; + } else { + $outfile = "test-$name"; + } #my $cflags = $ENV{CFLAGS}; my $cflags = "-Iinclude -Ilib -I."; -- cgit From fb67b0d99a2744272767d88f48416154d7150443 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 18 Mar 2006 22:16:24 +0000 Subject: r14550: Fix tests (This used to be commit 765fd852e789371f6b6361acd7603f8056ac14a9) --- source4/pidl/tests/Util.pm | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/Util.pm b/source4/pidl/tests/Util.pm index cd2ba2a37e..37177cc730 100644 --- a/source4/pidl/tests/Util.pm +++ b/source4/pidl/tests/Util.pm @@ -15,6 +15,7 @@ use Parse::Pidl::IDL; use Parse::Pidl::NDR; use Parse::Pidl::Samba4::NDR::Parser; use Parse::Pidl::Samba4::Header; +use Parse::Pidl::Samba4 qw(is_intree); my $sanecc = 0; @@ -30,17 +31,16 @@ sub test_samba4_ndr($$$) ok(defined($header), "($name) generate generic header"); my $pndr = Parse::Pidl::NDR::Parse($pidl); ok(defined($pndr), "($name) generate NDR tree"); - my ($ndrheader,$ndrparser) = Parse::Pidl::Samba4::NDR::Parser::Parse($pndr, "foo"); + my ($ndrheader,$ndrparser) = Parse::Pidl::Samba4::NDR::Parser::Parse($pndr, undef, undef); ok(defined($ndrparser), "($name) generate NDR parser"); ok(defined($ndrheader), "($name) generate NDR header"); SKIP: { - my $insamba = -f "include/includes.h"; - my $link = $insamba && 0; # FIXME + my $link = is_intree() && 0; # FIXME skip "no samba environment available, skipping compilation", 3 - if not $insamba; + if not is_intree(); skip "no sane C compiler, skipping compilation", 3 if not $sanecc; @@ -57,9 +57,9 @@ SKIP: { #my $cflags = $ENV{CFLAGS}; my $cflags = "-Iinclude -Ilib -I."; - if ($insamba and $link) { + if (is_intree() and $link) { open CC, "|cc -x c -o $outfile $cflags -"; - } elsif ($insamba) { + } elsif (is_intree()) { open CC, "|cc -x c -c -o $outfile $cflags -"; } print CC "#include \"includes.h\"\n"; -- cgit From 311d6f47c85282925932b3a7326e66679be9451f Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 23 Mar 2006 21:47:16 +0000 Subject: r14686: Fix pidl testsuite to run whenever there is a shared libary built Samba present. Ignore tests that are known to fail for now. (This used to be commit a7279f13f0431a5036c931c5339542f98139c461) --- source4/pidl/tests/Util.pm | 41 ++++++++++------------------------- source4/pidl/tests/ndr_align.pl | 7 ++++++ source4/pidl/tests/ndr_refptr.pl | 47 +++++++++++++++++++++++++--------------- 3 files changed, 48 insertions(+), 47 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/Util.pm b/source4/pidl/tests/Util.pm index 37177cc730..3e0f214854 100644 --- a/source4/pidl/tests/Util.pm +++ b/source4/pidl/tests/Util.pm @@ -15,9 +15,6 @@ use Parse::Pidl::IDL; use Parse::Pidl::NDR; use Parse::Pidl::Samba4::NDR::Parser; use Parse::Pidl::Samba4::Header; -use Parse::Pidl::Samba4 qw(is_intree); - -my $sanecc = 0; # Generate a Samba4 parser for an IDL fragment and run it with a specified # piece of code to check whether the parser works as expected @@ -37,13 +34,8 @@ sub test_samba4_ndr($$$) SKIP: { - my $link = is_intree() && 0; # FIXME - skip "no samba environment available, skipping compilation", 3 - if not is_intree(); - - skip "no sane C compiler, skipping compilation", 3 - if not $sanecc; + if (system("pkg-config --exists dcerpc ndr") != 0); my $test_data_prefix = $ENV{TEST_DATA_PREFIX}; @@ -54,15 +46,15 @@ SKIP: { $outfile = "test-$name"; } - #my $cflags = $ENV{CFLAGS}; - my $cflags = "-Iinclude -Ilib -I."; + my $cflags = `pkg-config --libs --cflags dcerpc ndr`; - if (is_intree() and $link) { - open CC, "|cc -x c -o $outfile $cflags -"; - } elsif (is_intree()) { - open CC, "|cc -x c -c -o $outfile $cflags -"; - } - print CC "#include \"includes.h\"\n"; + open CC, "|cc -x c - -o $outfile $cflags"; + print CC "#define uint_t unsigned int\n"; + print CC "#define _GNU_SOURCE\n"; + print CC "#include \n"; + print CC "#include \n"; + print CC "#include \n"; + print CC "#include \n"; print CC $header; print CC $ndrheader; print CC $ndrparser; @@ -79,23 +71,14 @@ SKIP: { ok(-f $outfile, "($name) compile"); - unless ($link) { - skip "no shared libraries of Samba available yet, can't run test", 2; - unlink($outfile); - } + my $ret = system("./$outfile", ()) >> 8; + print "# return code: $ret\n" if ($ret != 0); - ok(system($outfile), "($name) run"); + ok($ret == 0, "($name) run"); ok(unlink($outfile), "($name) remove"); } } -my $outfile = "test"; # FIXME: Somewhat more unique name - -# Test whether CC is sane. The real 'fix' here would be using the -# Samba build system, but unfortunately, we have no way of hooking into that -# yet so we're running CC directly for now -$sanecc = 1 if system('echo "main() {}"'." | cc -I. -x c -c - -o $outfile") == 0; - 1; diff --git a/source4/pidl/tests/ndr_align.pl b/source4/pidl/tests/ndr_align.pl index 7ca180cf20..55a86861ca 100755 --- a/source4/pidl/tests/ndr_align.pl +++ b/source4/pidl/tests/ndr_align.pl @@ -113,6 +113,10 @@ test_samba4_ndr('noalignflag-uint8-uint16', return 2; '); +SKIP: { + +skip "align-blob-align2 is known to fail", 8; + test_samba4_ndr('align-blob-align2', ' typedef [public] struct { @@ -137,6 +141,9 @@ test_samba4_ndr('align-blob-align2', result_blob = ndr_push_blob(ndr); + printf("%02x%02x%02x%02x\n", result_blob.data[0], result_blob.data[1], result_blob.data[2], result_blob.data[3]); + if (!data_blob_equal(&result_blob, &expected_blob)) return 2; '); +} diff --git a/source4/pidl/tests/ndr_refptr.pl b/source4/pidl/tests/ndr_refptr.pl index 0fd573d51e..6940586f01 100755 --- a/source4/pidl/tests/ndr_refptr.pl +++ b/source4/pidl/tests/ndr_refptr.pl @@ -5,7 +5,7 @@ # Published under the GNU General Public License. use strict; -use Test::More tests => 21 * 8; +use Test::More tests => 22 * 8; use FindBin qw($RealBin); use lib "$RealBin/../lib"; use lib "$RealBin"; @@ -402,6 +402,9 @@ test_samba4_ndr("ptr-top-push-double", return 4; '); +SKIP: { + skip "ptr-top-push-double-sndnull is known to fail", 8; + test_samba4_ndr("ptr-top-push-double-sndnull", ' [public] void echo_TestRef([in] uint16 **foo); @@ -421,6 +424,7 @@ test_samba4_ndr("ptr-top-push-double-sndnull", ndr->data[2] != 0 || ndr->data[3] != 0) return 3; '); +} test_samba4_ndr("ptr-top-push-double-fstnull", ' @@ -462,6 +466,10 @@ test_samba4_ndr("refptr-top-push-double", return 4; '); +SKIP: { + + skip "refptr-top-push-double-sndnull is known to fail", 8; + test_samba4_ndr("refptr-top-push-double-sndnull", ' [public] void echo_TestRef([in,ref] uint16 **foo); @@ -481,6 +489,7 @@ test_samba4_ndr("refptr-top-push-double-sndnull", ndr->data[2] != 0 || ndr->data[3] != 0) return 3; '); +} test_samba4_ndr("refptr-top-push-double-fstnull", ' @@ -497,20 +506,22 @@ test_samba4_ndr("refptr-top-push-double-fstnull", '); -#FIXME: Not supported yet -#test_samba4_ndr("ignore-ptr", -#' -# [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; -#'); +SKIP: { + skip "ignore-ptrs are not supported yet", 8; +test_samba4_ndr("ignore-ptr", +' + [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; +'); +} -- cgit From b6cae24de839756db87a62213795856c0051b8b9 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 24 Mar 2006 01:03:02 +0000 Subject: r14687: Start working on support for represent_as() and transmit_as() as an alternative to subcontext() (This used to be commit 744402160d5f994f5440553bb726e95a13033a83) --- source4/pidl/tests/Util.pm | 7 ++++--- source4/pidl/tests/ndr_represent.pl | 40 +++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 source4/pidl/tests/ndr_represent.pl (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/Util.pm b/source4/pidl/tests/Util.pm index 3e0f214854..bb633f6e32 100644 --- a/source4/pidl/tests/Util.pm +++ b/source4/pidl/tests/Util.pm @@ -1,5 +1,5 @@ # Some simple utility functions for pidl tests -# Copyright (C) 2005 Jelmer Vernooij +# Copyright (C) 2005-2006 Jelmer Vernooij # Published under the GNU General Public License package Util; @@ -18,9 +18,9 @@ use Parse::Pidl::Samba4::Header; # Generate a Samba4 parser for an IDL fragment and run it with a specified # piece of code to check whether the parser works as expected -sub test_samba4_ndr($$$) +sub test_samba4_ndr { - my ($name,$idl,$c) = @_; + my ($name,$idl,$c,$extra) = @_; my $pidl = Parse::Pidl::IDL::parse_string("interface echo { $idl }; ", "<$name>"); ok(defined($pidl), "($name) parse idl"); @@ -58,6 +58,7 @@ SKIP: { print CC $header; print CC $ndrheader; print CC $ndrparser; + print CC $extra if ($extra); print CC "int main(int argc, const char **argv) { TALLOC_CTX *mem_ctx = talloc_init(NULL); diff --git a/source4/pidl/tests/ndr_represent.pl b/source4/pidl/tests/ndr_represent.pl new file mode 100644 index 0000000000..772df2b94e --- /dev/null +++ b/source4/pidl/tests/ndr_represent.pl @@ -0,0 +1,40 @@ +#!/usr/bin/perl +# NDR represent_as() / transmit_as() tests +# (C) 2006 Jelmer Vernooij. Published under the GNU GPL +use strict; + +use Test::More tests => 1 * 8; +use FindBin qw($RealBin); +use lib "$RealBin/../lib"; +use lib "$RealBin"; +use Util qw(test_samba4_ndr); + +SKIP: { + skip "represent_as() is not finished yet", 8; + +test_samba4_ndr('represent_as-simple', +' + void bla([in,represent_as(foo)] uint8 x); +', +' + uint8_t expected[] = { 0x0D }; + DATA_BLOB in_blob = { expected, 1 }; + struct ndr_pull *ndr = ndr_pull_init_blob(&in_blob, NULL); + struct bla r; + + if (NT_STATUS_IS_ERR(ndr_pull_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r))) + return 1; + + if (r != 13) + return 2; +', +' +NTSTATUS ndr_uint8_to_foo(uint8 from, foo *to) +{ + *to = from; + return NT_STATUS_OK; +} +' +); + +} -- cgit From 85e91438b119f91cc0eb7da0992fadd5d2e47332 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 24 Mar 2006 11:42:03 +0000 Subject: r14688: More work on represent_as(): output the right function calls, fix test. (This used to be commit 7bc72277b37f9d89f6a078e85c14d560fd33a3bb) --- source4/pidl/tests/Util.pm | 2 +- source4/pidl/tests/ndr_represent.pl | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/Util.pm b/source4/pidl/tests/Util.pm index bb633f6e32..fde92c2a77 100644 --- a/source4/pidl/tests/Util.pm +++ b/source4/pidl/tests/Util.pm @@ -57,8 +57,8 @@ SKIP: { print CC "#include \n"; print CC $header; print CC $ndrheader; - print CC $ndrparser; print CC $extra if ($extra); + print CC $ndrparser; print CC "int main(int argc, const char **argv) { TALLOC_CTX *mem_ctx = talloc_init(NULL); diff --git a/source4/pidl/tests/ndr_represent.pl b/source4/pidl/tests/ndr_represent.pl index 772df2b94e..e72fcf6a50 100644 --- a/source4/pidl/tests/ndr_represent.pl +++ b/source4/pidl/tests/ndr_represent.pl @@ -29,7 +29,16 @@ test_samba4_ndr('represent_as-simple', return 2; ', ' -NTSTATUS ndr_uint8_to_foo(uint8 from, foo *to) +#include +typedef int foo; + +NTSTATUS ndr_uint8_to_foo(uint8_t from, foo *to) +{ + *to = from; + return NT_STATUS_OK; +} + +NTSTATUS ndr_foo_to_uint8(foo from, uint8_t *to) { *to = from; return NT_STATUS_OK; -- cgit From 6ba19b57290d7a625e0939563160eec0c419a91a Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 24 Mar 2006 11:45:40 +0000 Subject: r14689: Fix test (This used to be commit b199f5345cc92ff8aeb59479c8c2a89ab1278d70) --- source4/pidl/tests/ndr_align.pl | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/ndr_align.pl b/source4/pidl/tests/ndr_align.pl index 55a86861ca..c05f6383ed 100755 --- a/source4/pidl/tests/ndr_align.pl +++ b/source4/pidl/tests/ndr_align.pl @@ -113,26 +113,24 @@ test_samba4_ndr('noalignflag-uint8-uint16', return 2; '); -SKIP: { - -skip "align-blob-align2 is known to fail", 8; - test_samba4_ndr('align-blob-align2', ' typedef [public] struct { uint8 x; [flag(LIBNDR_FLAG_ALIGN2)] DATA_BLOB data; + uint8 y; } 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 }; + 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; @@ -141,9 +139,6 @@ test_samba4_ndr('align-blob-align2', result_blob = ndr_push_blob(ndr); - printf("%02x%02x%02x%02x\n", result_blob.data[0], result_blob.data[1], result_blob.data[2], result_blob.data[3]); - if (!data_blob_equal(&result_blob, &expected_blob)) return 2; '); -} -- cgit From 5d9ea9170d2e0fd816285bd460de05f800ce26e8 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 24 Mar 2006 12:40:07 +0000 Subject: r14690: Support represent_as in headers, enable represent_as() test (which works now) (This used to be commit 31e847a0844a6871befc6091e813ae017cd6e4b4) --- source4/pidl/tests/ndr_represent.pl | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/ndr_represent.pl b/source4/pidl/tests/ndr_represent.pl index e72fcf6a50..3c6b8cf6ab 100644 --- a/source4/pidl/tests/ndr_represent.pl +++ b/source4/pidl/tests/ndr_represent.pl @@ -9,12 +9,9 @@ use lib "$RealBin/../lib"; use lib "$RealBin"; use Util qw(test_samba4_ndr); -SKIP: { - skip "represent_as() is not finished yet", 8; - test_samba4_ndr('represent_as-simple', ' - void bla([in,represent_as(foo)] uint8 x); + void bla([in,represent_as(uint32)] uint8 x); ', ' uint8_t expected[] = { 0x0D }; @@ -25,25 +22,22 @@ test_samba4_ndr('represent_as-simple', if (NT_STATUS_IS_ERR(ndr_pull_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r))) return 1; - if (r != 13) + if (r.in.x != 13) return 2; ', ' #include -typedef int foo; -NTSTATUS ndr_uint8_to_foo(uint8_t from, foo *to) +NTSTATUS ndr_uint8_to_uint32(uint8_t from, uint32_t *to) { *to = from; return NT_STATUS_OK; } -NTSTATUS ndr_foo_to_uint8(foo from, uint8_t *to) +NTSTATUS ndr_uint32_to_uint8(uint32_t from, uint8_t *to) { *to = from; return NT_STATUS_OK; } ' ); - -} -- cgit From a2d4079c81940b336b9b47cf23d24c66644a6076 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 25 Mar 2006 20:51:41 +0000 Subject: r14727: Update pidls' TODO, add test that demonstrates the desired behaviour (This used to be commit c2f510d38be6b4387120d7477ddd200b9bec13e5) --- source4/pidl/tests/ndr_tagtype.pl | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100755 source4/pidl/tests/ndr_tagtype.pl (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/ndr_tagtype.pl b/source4/pidl/tests/ndr_tagtype.pl new file mode 100755 index 0000000000..dcdbc22494 --- /dev/null +++ b/source4/pidl/tests/ndr_tagtype.pl @@ -0,0 +1,38 @@ +#!/usr/bin/perl +# Support for tagged types +# (C) 2005 Jelmer Vernooij. Published under the GNU GPL +use strict; + +use Test::More tests => 1 * 8; +use FindBin qw($RealBin); +use lib "$RealBin/../lib"; +use lib "$RealBin"; +use Util qw(test_samba4_ndr); + +SKIP: { + skip "Tagged types without typedef are not supported yet", 8; + +test_samba4_ndr('struct-notypedef', +' + struct bla { + uint8 x; + }; +', +' + struct ndr_push *ndr = ndr_push_init(); + struct bla r; + uint8_t expected[] = { 0x0D }; + DATA_BLOB expected_blob = { expected, 1 }; + DATA_BLOB result_blob; + r.x = 13; + + 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; +'); + +} -- cgit From 1b22141c874ff704ad4fe048d4464168495c36b6 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 2 Apr 2006 16:26:02 +0000 Subject: r14867: Include in external compiles (This used to be commit 03224dab111b931effd548586e630480fa1423b1) --- source4/pidl/tests/Util.pm | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/Util.pm b/source4/pidl/tests/Util.pm index fde92c2a77..ccac1a6d7e 100644 --- a/source4/pidl/tests/Util.pm +++ b/source4/pidl/tests/Util.pm @@ -54,6 +54,7 @@ SKIP: { print CC "#include \n"; print CC "#include \n"; print CC "#include \n"; + print CC "#include \n"; print CC "#include \n"; print CC $header; print CC $ndrheader; -- cgit From 291c5ed53c9957d1da981fa39477b046b94fe192 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 15 Sep 2006 17:34:46 +0000 Subject: r18559: [string] always applies to the last pointer (This used to be commit 86b4624226d6e72645221cadb8669b0f1aba0903) --- source4/pidl/tests/ndr_string.pl | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/ndr_string.pl b/source4/pidl/tests/ndr_string.pl index e8e37be8c1..00ccbb31bb 100755 --- a/source4/pidl/tests/ndr_string.pl +++ b/source4/pidl/tests/ndr_string.pl @@ -4,7 +4,7 @@ # Published under the GNU General Public License use strict; -use Test::More tests => 2 * 8; +use Test::More tests => 3 * 8; use FindBin qw($RealBin); use lib "$RealBin/../lib"; use lib "$RealBin"; @@ -53,3 +53,32 @@ test_samba4_ndr("string-ascii-pull", if (r.in.data[4] != 0) return 4; '); + +test_samba4_ndr("string-out", +' + [public] void TestString([out,string] uint8 **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; + char *str = NULL; + r.out.data = &str; + + if (NT_STATUS_IS_ERR(ndr_pull_TestString(ndr, NDR_IN, &r))) + return 1; + + if (r.out.data == NULL) + return 2; + + if (*r.out.data == NULL) + return 3; + + if (strncmp(r.out.data, "foo", 3) != 0) + return 3; + + if (r.in.data[4] != 0) + return 4; +'); -- cgit From e3ea863a3c4a021966847b62bf175fc83daa3fd0 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 16 Nov 2006 22:11:32 +0000 Subject: r19751: Add some tests for parsing the "include", "import" and "importlib" statements. (This used to be commit 3a850bda962da9ce58227ea6d74e974f7654d734) --- source4/pidl/tests/parse_idl.pl | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/parse_idl.pl b/source4/pidl/tests/parse_idl.pl index 8114cd9992..ebdb8ae58a 100755 --- a/source4/pidl/tests/parse_idl.pl +++ b/source4/pidl/tests/parse_idl.pl @@ -4,7 +4,7 @@ # Published under the GNU General Public License use strict; -use Test::More tests => 51; +use Test::More tests => 59; use FindBin qw($RealBin); use lib "$RealBin/../lib"; use Parse::Pidl::IDL; @@ -80,3 +80,11 @@ testok "bitmapqual", "interface test { struct x { bitmap y z; }; };"; testok "emptystructdecl", "interface test { struct x; };"; testok "emptyenumdecl", "interface test { enum x; };"; testok "emptytdstructdecl", "interface test { typedef struct x y; };"; +testok "import", "import \"foo.idl\";"; +testok "include", "include \"foo.h\";"; +testfail "import-noquotes", "import foo.idl;"; +testfail "include-noquotes", "include foo.idl;"; +testok "importlib", "importlib \"foo.idl\";"; +testfail "import-nosemicolon", "import \"foo.idl\""; +testok "import-multiple", "import \"foo.idl\", \"bar.idl\";"; +testok "include-multiple", "include \"foo.idl\", \"bar.idl\";"; -- cgit From 8d870db811ef4f120d7df3b3f50243b47d94da2f Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 23 Nov 2006 16:02:20 +0000 Subject: r19859: Reuse referrent ids when pushing full pointers (still need to avoid pushing the referred object twice) and add test for full pointers. (This used to be commit 1638c8d234dbc85298000685e49570f23dfd0bf8) --- source4/pidl/tests/Util.pm | 4 ++-- source4/pidl/tests/ndr_fullptr.pl | 41 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 2 deletions(-) create mode 100755 source4/pidl/tests/ndr_fullptr.pl (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/Util.pm b/source4/pidl/tests/Util.pm index ccac1a6d7e..e0d87b2dac 100644 --- a/source4/pidl/tests/Util.pm +++ b/source4/pidl/tests/Util.pm @@ -35,7 +35,7 @@ sub test_samba4_ndr SKIP: { skip "no samba environment available, skipping compilation", 3 - if (system("pkg-config --exists dcerpc ndr") != 0); + if (system("pkg-config --exists ndr") != 0); my $test_data_prefix = $ENV{TEST_DATA_PREFIX}; @@ -46,7 +46,7 @@ SKIP: { $outfile = "test-$name"; } - my $cflags = `pkg-config --libs --cflags dcerpc ndr`; + my $cflags = `pkg-config --libs --cflags ndr`; open CC, "|cc -x c - -o $outfile $cflags"; print CC "#define uint_t unsigned int\n"; diff --git a/source4/pidl/tests/ndr_fullptr.pl b/source4/pidl/tests/ndr_fullptr.pl new file mode 100755 index 0000000000..d9f2cd6b02 --- /dev/null +++ b/source4/pidl/tests/ndr_fullptr.pl @@ -0,0 +1,41 @@ +#!/usr/bin/perl +# Simple tests for unique pointers +# (C) 2006 Jelmer Vernooij . +# Published under the GNU General Public License. +use strict; + +use Test::More tests => 1 * 8; +use FindBin qw($RealBin); +use lib "$RealBin/../lib"; +use lib "$RealBin"; +use Util qw(test_samba4_ndr); + +test_samba4_ndr("fullptr-push-dup", +' + [public] uint16 echo_TestFull([in,ptr] uint32 *x, [in,ptr] uint32 *y); +', +' + struct ndr_push *ndr = ndr_push_init(); + uint32_t v = 13; + struct echo_TestRef r; + r.in.x = &v; + r.in.y = &v; + + if (NT_STATUS_IS_ERR(ndr_push_echo_TestRef(ndr, NDR_IN, &r))) { + fprintf(stderr, "push failed\n"); + return 1; + } + + if (ndr->offset != 12) { + fprintf(stderr, "Offset(%d) != 12\n", ndr->offset); + return 2; + } + + if (ndr->data[0] != ndr->data[8] || + ndr->data[1] != ndr->data[9] || + ndr->data[2] != ndr->data[10] || + ndr->data[3] != ndr->data[11]) { + fprintf(stderr, "Data incorrect\n"); + return 3; + } +'); -- cgit From a2a151a04621e3e2252e207b54526c75deb039d9 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 23 Nov 2006 18:26:55 +0000 Subject: r19866: Fix test compilation. (This used to be commit 2a3196db9dae9f15bbe2ffa36ce1204daf4e701c) --- source4/pidl/tests/ndr_fullptr.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/ndr_fullptr.pl b/source4/pidl/tests/ndr_fullptr.pl index d9f2cd6b02..569f0060a3 100755 --- a/source4/pidl/tests/ndr_fullptr.pl +++ b/source4/pidl/tests/ndr_fullptr.pl @@ -17,11 +17,11 @@ test_samba4_ndr("fullptr-push-dup", ' struct ndr_push *ndr = ndr_push_init(); uint32_t v = 13; - struct echo_TestRef r; + struct echo_TestFull r; r.in.x = &v; r.in.y = &v; - if (NT_STATUS_IS_ERR(ndr_push_echo_TestRef(ndr, NDR_IN, &r))) { + if (NT_STATUS_IS_ERR(ndr_push_echo_TestFull(ndr, NDR_IN, &r))) { fprintf(stderr, "push failed\n"); return 1; } -- cgit From 0bb6dacc169d34c55feb1938a36b9c8936cea844 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 23 Nov 2006 20:59:09 +0000 Subject: r19868: Fix more tests. (This used to be commit 01a4fb1b22d09f38636c211a93efc4099f4766b3) --- source4/pidl/tests/Util.pm | 1 + source4/pidl/tests/ndr_align.pl | 6 +++--- source4/pidl/tests/ndr_represent.pl | 2 +- source4/pidl/tests/ndr_string.pl | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/Util.pm b/source4/pidl/tests/Util.pm index e0d87b2dac..83651e6073 100644 --- a/source4/pidl/tests/Util.pm +++ b/source4/pidl/tests/Util.pm @@ -56,6 +56,7 @@ SKIP: { print CC "#include \n"; print CC "#include \n"; print CC "#include \n"; + print CC "#include \n"; print CC $header; print CC $ndrheader; print CC $extra if ($extra); diff --git a/source4/pidl/tests/ndr_align.pl b/source4/pidl/tests/ndr_align.pl index c05f6383ed..26f41377e7 100755 --- a/source4/pidl/tests/ndr_align.pl +++ b/source4/pidl/tests/ndr_align.pl @@ -119,11 +119,11 @@ test_samba4_ndr('align-blob-align2', uint8 x; [flag(LIBNDR_FLAG_ALIGN2)] DATA_BLOB data; uint8 y; - } bla; + } blie; ', ' struct ndr_push *ndr = ndr_push_init(); - struct bla r; + struct blie r; uint8_t data[] = { 0x01, 0x02 }; uint8_t expected[] = { 0x0D, 0x00, 0x0E }; DATA_BLOB expected_blob = { expected, 3 }; @@ -134,7 +134,7 @@ test_samba4_ndr('align-blob-align2', r.data.data = data; r.data.length = 2; - if (NT_STATUS_IS_ERR(ndr_push_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r))) + if (NT_STATUS_IS_ERR(ndr_push_blie(ndr, NDR_SCALARS|NDR_BUFFERS, &r))) return 1; result_blob = ndr_push_blob(ndr); diff --git a/source4/pidl/tests/ndr_represent.pl b/source4/pidl/tests/ndr_represent.pl index 3c6b8cf6ab..93764451cf 100644 --- a/source4/pidl/tests/ndr_represent.pl +++ b/source4/pidl/tests/ndr_represent.pl @@ -26,7 +26,7 @@ test_samba4_ndr('represent_as-simple', return 2; ', ' -#include +#include NTSTATUS ndr_uint8_to_uint32(uint8_t from, uint32_t *to) { diff --git a/source4/pidl/tests/ndr_string.pl b/source4/pidl/tests/ndr_string.pl index 00ccbb31bb..9a09261996 100755 --- a/source4/pidl/tests/ndr_string.pl +++ b/source4/pidl/tests/ndr_string.pl @@ -79,6 +79,6 @@ test_samba4_ndr("string-out", if (strncmp(r.out.data, "foo", 3) != 0) return 3; - if (r.in.data[4] != 0) + if (r.out.data[4] != 0) return 4; '); -- cgit From 253c1bec462de467a923f7a8951598f7abbe163e Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 21 Dec 2006 01:51:35 +0000 Subject: r20298: Fix pidl tests (missing symlink..). (This used to be commit ab3d57394630cefc1fefe859c8bd3d56f6e63695) --- source4/pidl/tests/Util.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/Util.pm b/source4/pidl/tests/Util.pm index 83651e6073..cbe6283852 100644 --- a/source4/pidl/tests/Util.pm +++ b/source4/pidl/tests/Util.pm @@ -46,9 +46,9 @@ SKIP: { $outfile = "test-$name"; } - my $cflags = `pkg-config --libs --cflags ndr`; + my $flags = `pkg-config --libs --cflags ndr samba-config`; - open CC, "|cc -x c - -o $outfile $cflags"; + open CC, "|cc -x c - -o $outfile $flags"; print CC "#define uint_t unsigned int\n"; print CC "#define _GNU_SOURCE\n"; print CC "#include \n"; -- cgit From c8a5f304c6de43b5f0d56dbff315ac193bb12f9b Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 21 Dec 2006 02:48:46 +0000 Subject: r20299: Disable two new tests that are apparently broken. (This used to be commit b3f64869fc4590850203a231ecf6810ae9f1d8cf) --- source4/pidl/tests/Util.pm | 4 ++-- source4/pidl/tests/ndr_fullptr.pl | 4 ++++ source4/pidl/tests/ndr_string.pl | 10 +++++++--- 3 files changed, 13 insertions(+), 5 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/Util.pm b/source4/pidl/tests/Util.pm index cbe6283852..d8ae30f3c3 100644 --- a/source4/pidl/tests/Util.pm +++ b/source4/pidl/tests/Util.pm @@ -43,7 +43,7 @@ SKIP: { if (defined($test_data_prefix)) { $outfile = "$test_data_prefix/test-$name"; } else { - $outfile = "test-$name"; + $outfile = "./test-$name"; } my $flags = `pkg-config --libs --cflags ndr samba-config`; @@ -74,7 +74,7 @@ SKIP: { ok(-f $outfile, "($name) compile"); - my $ret = system("./$outfile", ()) >> 8; + my $ret = system($outfile, ()) >> 8; print "# return code: $ret\n" if ($ret != 0); ok($ret == 0, "($name) run"); diff --git a/source4/pidl/tests/ndr_fullptr.pl b/source4/pidl/tests/ndr_fullptr.pl index 569f0060a3..dabbc6f5b6 100755 --- a/source4/pidl/tests/ndr_fullptr.pl +++ b/source4/pidl/tests/ndr_fullptr.pl @@ -10,6 +10,9 @@ use lib "$RealBin/../lib"; use lib "$RealBin"; use Util qw(test_samba4_ndr); +SKIP: { + skip "full pointers not supported yet", 8; + test_samba4_ndr("fullptr-push-dup", ' [public] uint16 echo_TestFull([in,ptr] uint32 *x, [in,ptr] uint32 *y); @@ -39,3 +42,4 @@ test_samba4_ndr("fullptr-push-dup", return 3; } '); +} diff --git a/source4/pidl/tests/ndr_string.pl b/source4/pidl/tests/ndr_string.pl index 9a09261996..dd6afde2b2 100755 --- a/source4/pidl/tests/ndr_string.pl +++ b/source4/pidl/tests/ndr_string.pl @@ -54,9 +54,12 @@ test_samba4_ndr("string-ascii-pull", return 4; '); +SKIP: { + skip "doesn't seem to work yet", 8; + test_samba4_ndr("string-out", ' - [public] void TestString([out,string] uint8 **data); + [public] void TestString([out,string,charset(UNIX)] uint8 **data); ', ' uint8_t data[] = { 0x03, 0x00, 0x00, 0x00, @@ -77,8 +80,9 @@ test_samba4_ndr("string-out", return 3; if (strncmp(r.out.data, "foo", 3) != 0) - return 3; + return 4; if (r.out.data[4] != 0) - return 4; + return 5; '); +} -- cgit From 362d4b14aecb32aac5c7c4f6beb3b9a979bf9d5a Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 5 Jan 2007 12:56:15 +0000 Subject: r20543: Merge some pidl bug fixes: * C expressions that just started with a constant were erroneously flagged as being a constant. * 1-length variable names in expressions were broken. (This used to be commit 44775a6ac456247fe7ab4da75498bb550c74c854) --- source4/pidl/tests/util.pl | 55 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100755 source4/pidl/tests/util.pl (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/util.pl b/source4/pidl/tests/util.pl new file mode 100755 index 0000000000..7c51b72196 --- /dev/null +++ b/source4/pidl/tests/util.pl @@ -0,0 +1,55 @@ +#!/usr/bin/perl +# (C) 2007 Jelmer Vernooij +# Published under the GNU General Public License +use strict; + +use Test::More tests => 25; +use FindBin qw($RealBin); +use lib "$RealBin/../lib"; +use Parse::Pidl::Util; + +# has_property() +is(undef, has_property({}, "foo")); +is(undef, has_property({PROPERTIES => {}}, "foo")); +is("data", has_property({PROPERTIES => {foo => "data"}}, "foo")); +is(undef, has_property({PROPERTIES => {foo => undef}}, "foo")); + +# is_constant() +ok(is_constant("2")); +ok(not is_constant("str")); +ok(not is_constant("2 * expr")); + +# make_str() +is("\"bla\"", make_str("bla")); +is("\"bla\"", make_str("\"bla\"")); +is("\"\"bla\"\"", make_str("\"\"bla\"\"")); +is("\"bla\"\"", make_str("bla\"")); +is("\"foo\"bar\"", make_str("foo\"bar")); + +# print_uuid() +is(undef, print_uuid("invalid")); +is("{0x12345778,0x1234,0xabcd,{0xef,0x00},{0x01,0x23,0x45,0x67,0x89,0xac}}", + print_uuid("12345778-1234-abcd-ef00-0123456789ac")); +is("{0x12345778,0x1234,0xabcd,{0xef,0x00},{0x01,0x23,0x45,0x67,0x89,0xac}}", + print_uuid("\"12345778-1234-abcd-ef00-0123456789ac\"")); + +# property_matches() +# missing property +ok(not property_matches({PROPERTIES => {}}, "x", "data")); +# data not matching +ok(not property_matches({PROPERTIES => {x => "bar"}}, "x", "data")); +# data matching exactly +ok(property_matches({PROPERTIES => {x => "data"}}, "x", "data")); +# regex matching +ok(property_matches({PROPERTIES => {x => "data"}}, "x", "^([dat]+)\$")); + +# ParseExpr() +is("", ParseExpr("", {})); +is("a", ParseExpr("a", {"b" => "2"})); +is("2", ParseExpr("a", {"a" => "2"})); +is("2*2", ParseExpr("a*a", {"a" => "2"})); +is("r->length+r->length", + ParseExpr("length+length", {"length" => "r->length"})); +is("2/2*(r->length)", + ParseExpr("constant/constant*(len)", {"constant" => "2", + "len" => "r->length"})); -- cgit From 306dc32687e68dbf388187ec927444fb4a139158 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 5 Jan 2007 14:25:21 +0000 Subject: r20545: Fix is_constant(). (This used to be commit ae9b0895e8b7fd98335ece82aae3e391b94d2ec9) --- source4/pidl/tests/util.pl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/util.pl b/source4/pidl/tests/util.pl index 7c51b72196..f32ab41e8d 100755 --- a/source4/pidl/tests/util.pl +++ b/source4/pidl/tests/util.pl @@ -3,7 +3,7 @@ # Published under the GNU General Public License use strict; -use Test::More tests => 25; +use Test::More tests => 29; use FindBin qw($RealBin); use lib "$RealBin/../lib"; use Parse::Pidl::Util; @@ -16,6 +16,10 @@ is(undef, has_property({PROPERTIES => {foo => undef}}, "foo")); # is_constant() ok(is_constant("2")); +ok(is_constant("256")); +ok(is_constant("0x400")); +ok(is_constant("0x4BC")); +ok(not is_constant("0x4BGC")); ok(not is_constant("str")); ok(not is_constant("2 * expr")); -- cgit From 2963c639871665ced7ee0b5afad3406e7496b233 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 5 Jan 2007 14:55:26 +0000 Subject: r20547: Add tests for expected errors/warnings. (This used to be commit 2d960d4d7b0bc39c3ec4c2face546adc2cb345ee) --- source4/pidl/tests/Util.pm | 41 +++++++++++++++++++++++++++++++++++++++- source4/pidl/tests/ndr_compat.pl | 27 ++++++++++++++++++++++++++ source4/pidl/tests/test_util.pl | 22 +++++++++++++++++++++ 3 files changed, 89 insertions(+), 1 deletion(-) create mode 100755 source4/pidl/tests/ndr_compat.pl create mode 100755 source4/pidl/tests/test_util.pl (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/Util.pm b/source4/pidl/tests/Util.pm index d8ae30f3c3..fdd3c421f6 100644 --- a/source4/pidl/tests/Util.pm +++ b/source4/pidl/tests/Util.pm @@ -6,10 +6,28 @@ package Util; require Exporter; @ISA = qw(Exporter); -@EXPORT_OK = qw(test_samba4_ndr); +@EXPORT = qw(test_samba4_ndr test_warnings test_errors); use strict; +use FindBin qw($RealBin); +use lib "$RealBin/../lib"; + +use Parse::Pidl; +my $warnings = ""; +sub Parse::Pidl::warning($$) +{ + my ($e, $l) = @_; + $warnings .= "$e->{FILE}:$e->{LINE}: $l\n"; +}; + +my $errors = ""; +sub Parse::Pidl::error($$) +{ + my ($e, $l) = @_; + $errors .= "$e->{FILE}:$e->{LINE}: $l\n"; +}; + use Test::More; use Parse::Pidl::IDL; use Parse::Pidl::NDR; @@ -84,4 +102,25 @@ SKIP: { } } +sub test_warnings($$) +{ + my ($exp, $code) = @_; + + $warnings = ""; + + $code->(); + + is($warnings, $exp); +} + + +sub test_errors($$) +{ + my ($exp, $code) = @_; + $errors = ""; + $code->(); + + is($errors, $exp); +} + 1; diff --git a/source4/pidl/tests/ndr_compat.pl b/source4/pidl/tests/ndr_compat.pl new file mode 100755 index 0000000000..735d929e27 --- /dev/null +++ b/source4/pidl/tests/ndr_compat.pl @@ -0,0 +1,27 @@ +#!/usr/bin/perl +# (C) 2007 Jelmer Vernooij +# Published under the GNU General Public License +use strict; + +use Test::More tests => 3; +use FindBin qw($RealBin); +use lib "$RealBin"; +use Util; +use Parse::Pidl; +use Parse::Pidl::IDL; + +sub parse_idl($) +{ + my $idl = shift; + my $pidl = Parse::Pidl::IDL::parse_string("interface echo { $idl }; ", "nofile"); + Parse::Pidl::NDR::Parse($pidl); +} + +test_warnings("", sub {parse_idl("void x();"); }); +test_warnings("nofile:0: top-level [out] pointer `x' is not a [ref] pointer\n", sub {parse_idl("void x([out,unique] int *x);"); }); + +test_warnings("nofile:0: pointer_default_top() is a pidl extension and should not be used\n", sub { + my $pidl = Parse::Pidl::IDL::parse_string("[pointer_default_top(unique)] interface echo { void x(); }; ", "nofile"); + Parse::Pidl::NDR::Parse($pidl); +}); + diff --git a/source4/pidl/tests/test_util.pl b/source4/pidl/tests/test_util.pl new file mode 100755 index 0000000000..e6133727af --- /dev/null +++ b/source4/pidl/tests/test_util.pl @@ -0,0 +1,22 @@ +#!/usr/bin/perl +# (C) 2007 Jelmer Vernooij +# Published under the GNU General Public License +use strict; + +use Test::More tests => 6; +use FindBin qw($RealBin); +use lib "$RealBin/../lib"; +use lib "$RealBin"; +use Util qw(test_warnings test_errors); +use Parse::Pidl qw(warning error); + +test_warnings("", sub {}); + +test_warnings("x:1: msg\n", sub { warning({FILE => "x", LINE => 1}, "msg"); }); +test_warnings("", sub {}); + +test_errors("", sub {}); + +test_errors("x:1: msg\n", sub { error({FILE => "x", LINE => 1}, "msg"); }); +test_errors("", sub {}); + -- cgit From f7ca27b9ca318657b38688bf063a63d96b1e8c3a Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 5 Jan 2007 15:03:21 +0000 Subject: r20548: Remove unnecessary "use lib", fix warnings. (This used to be commit 30d721569fdf33e4784eb1f7c650e75ed1b80527) --- source4/pidl/tests/Util.pm | 8 ++++---- source4/pidl/tests/ndr_align.pl | 1 - source4/pidl/tests/ndr_alloc.pl | 1 - source4/pidl/tests/ndr_array.pl | 1 - source4/pidl/tests/ndr_fullptr.pl | 1 - source4/pidl/tests/ndr_refptr.pl | 1 - source4/pidl/tests/ndr_represent.pl | 1 - source4/pidl/tests/ndr_simple.pl | 1 - source4/pidl/tests/ndr_string.pl | 1 - source4/pidl/tests/ndr_tagtype.pl | 1 - source4/pidl/tests/test_util.pl | 1 - 11 files changed, 4 insertions(+), 14 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/Util.pm b/source4/pidl/tests/Util.pm index fdd3c421f6..2f43abe1ed 100644 --- a/source4/pidl/tests/Util.pm +++ b/source4/pidl/tests/Util.pm @@ -15,15 +15,15 @@ use lib "$RealBin/../lib"; use Parse::Pidl; my $warnings = ""; -sub Parse::Pidl::warning($$) -{ +undef &Parse::Pidl::warning; +*Parse::Pidl::warning = sub { my ($e, $l) = @_; $warnings .= "$e->{FILE}:$e->{LINE}: $l\n"; }; my $errors = ""; -sub Parse::Pidl::error($$) -{ +undef &Parse::Pidl::error; +*Parse::Pidl::error = sub { my ($e, $l) = @_; $errors .= "$e->{FILE}:$e->{LINE}: $l\n"; }; diff --git a/source4/pidl/tests/ndr_align.pl b/source4/pidl/tests/ndr_align.pl index 26f41377e7..5117be95bd 100755 --- a/source4/pidl/tests/ndr_align.pl +++ b/source4/pidl/tests/ndr_align.pl @@ -5,7 +5,6 @@ use strict; use Test::More tests => 5 * 8; use FindBin qw($RealBin); -use lib "$RealBin/../lib"; use lib "$RealBin"; use Util qw(test_samba4_ndr); diff --git a/source4/pidl/tests/ndr_alloc.pl b/source4/pidl/tests/ndr_alloc.pl index 039826e4ea..61df1c3548 100755 --- a/source4/pidl/tests/ndr_alloc.pl +++ b/source4/pidl/tests/ndr_alloc.pl @@ -5,7 +5,6 @@ use strict; use Test::More tests => 5 * 8; use FindBin qw($RealBin); -use lib "$RealBin/../lib"; use lib "$RealBin"; use Util qw(test_samba4_ndr); diff --git a/source4/pidl/tests/ndr_array.pl b/source4/pidl/tests/ndr_array.pl index b28070536e..27f42cd391 100755 --- a/source4/pidl/tests/ndr_array.pl +++ b/source4/pidl/tests/ndr_array.pl @@ -6,7 +6,6 @@ use strict; use Test::More tests => 8; use FindBin qw($RealBin); -use lib "$RealBin/../lib"; use lib "$RealBin"; use Util qw(test_samba4_ndr); diff --git a/source4/pidl/tests/ndr_fullptr.pl b/source4/pidl/tests/ndr_fullptr.pl index dabbc6f5b6..482edcf030 100755 --- a/source4/pidl/tests/ndr_fullptr.pl +++ b/source4/pidl/tests/ndr_fullptr.pl @@ -6,7 +6,6 @@ use strict; use Test::More tests => 1 * 8; use FindBin qw($RealBin); -use lib "$RealBin/../lib"; use lib "$RealBin"; use Util qw(test_samba4_ndr); diff --git a/source4/pidl/tests/ndr_refptr.pl b/source4/pidl/tests/ndr_refptr.pl index 6940586f01..0bc5fd9416 100755 --- a/source4/pidl/tests/ndr_refptr.pl +++ b/source4/pidl/tests/ndr_refptr.pl @@ -7,7 +7,6 @@ use strict; use Test::More tests => 22 * 8; use FindBin qw($RealBin); -use lib "$RealBin/../lib"; use lib "$RealBin"; use Util qw(test_samba4_ndr); diff --git a/source4/pidl/tests/ndr_represent.pl b/source4/pidl/tests/ndr_represent.pl index 93764451cf..880ecba827 100644 --- a/source4/pidl/tests/ndr_represent.pl +++ b/source4/pidl/tests/ndr_represent.pl @@ -5,7 +5,6 @@ use strict; use Test::More tests => 1 * 8; use FindBin qw($RealBin); -use lib "$RealBin/../lib"; use lib "$RealBin"; use Util qw(test_samba4_ndr); diff --git a/source4/pidl/tests/ndr_simple.pl b/source4/pidl/tests/ndr_simple.pl index 9535ee1fae..02803ceea9 100755 --- a/source4/pidl/tests/ndr_simple.pl +++ b/source4/pidl/tests/ndr_simple.pl @@ -6,7 +6,6 @@ use strict; use Test::More tests => 8; use FindBin qw($RealBin); -use lib "$RealBin/../lib"; use lib "$RealBin"; use Util qw(test_samba4_ndr); diff --git a/source4/pidl/tests/ndr_string.pl b/source4/pidl/tests/ndr_string.pl index dd6afde2b2..23d94be640 100755 --- a/source4/pidl/tests/ndr_string.pl +++ b/source4/pidl/tests/ndr_string.pl @@ -6,7 +6,6 @@ use strict; use Test::More tests => 3 * 8; use FindBin qw($RealBin); -use lib "$RealBin/../lib"; use lib "$RealBin"; use Util qw(test_samba4_ndr); diff --git a/source4/pidl/tests/ndr_tagtype.pl b/source4/pidl/tests/ndr_tagtype.pl index dcdbc22494..662985a646 100755 --- a/source4/pidl/tests/ndr_tagtype.pl +++ b/source4/pidl/tests/ndr_tagtype.pl @@ -5,7 +5,6 @@ use strict; use Test::More tests => 1 * 8; use FindBin qw($RealBin); -use lib "$RealBin/../lib"; use lib "$RealBin"; use Util qw(test_samba4_ndr); diff --git a/source4/pidl/tests/test_util.pl b/source4/pidl/tests/test_util.pl index e6133727af..2d59f6283b 100755 --- a/source4/pidl/tests/test_util.pl +++ b/source4/pidl/tests/test_util.pl @@ -5,7 +5,6 @@ use strict; use Test::More tests => 6; use FindBin qw($RealBin); -use lib "$RealBin/../lib"; use lib "$RealBin"; use Util qw(test_warnings test_errors); use Parse::Pidl qw(warning error); -- cgit From e2b62f7d4168b5900dbaeadf4d4061abf6c1bd7c Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 5 Jan 2007 15:20:23 +0000 Subject: r20550: Use standard error mechanism in parser. Make sure errors are reported correctly. (This used to be commit 9f794c55a60b09536d6e0dbadfc172e1e74497ff) --- source4/pidl/tests/parse_idl.pl | 63 +++++++++++++++++++++++++---------------- 1 file changed, 39 insertions(+), 24 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/parse_idl.pl b/source4/pidl/tests/parse_idl.pl index ebdb8ae58a..859c2b4e46 100755 --- a/source4/pidl/tests/parse_idl.pl +++ b/source4/pidl/tests/parse_idl.pl @@ -4,9 +4,10 @@ # Published under the GNU General Public License use strict; -use Test::More tests => 59; +use Test::More tests => 59 * 2; use FindBin qw($RealBin); -use lib "$RealBin/../lib"; +use lib "$RealBin"; +use Util qw(test_errors); use Parse::Pidl::IDL; use Parse::Pidl::NDR; @@ -14,35 +15,40 @@ sub testok($$) { my ($name, $data) = @_; - my $pidl = Parse::Pidl::IDL::parse_string($data, "<$name>"); - - ok (defined($pidl), $name); - return $pidl + test_errors("", sub { + my $pidl = Parse::Pidl::IDL::parse_string($data, "<$name>"); + ok (defined($pidl), $name); + }); } -sub testfail($$) +sub testfail($$$) { - my ($name, $data) = @_; + my ($name, $data, $error) = @_; - my $pidl = Parse::Pidl::IDL::parse_string($data, "<$name>"); + test_errors($error, sub { + my $pidl = Parse::Pidl::IDL::parse_string($data, "<$name>"); - ok ((not defined $pidl), $name); + ok ((not defined $pidl), $name); + }); } -testfail "unknowntag", "bla test {};"; +testfail "unknowntag", "bla test {};", + ":0: Syntax error near 'bla'\n"; testok "test1", "interface test { void Test(); }; "; testok "voidtest", "interface test { int Testx(void); }; "; -testfail "voidtest", "interface test { Test(); }; "; +testfail "voidtest", "interface test { Test(); }; ", + ":0: Syntax error near '('\n"; testok "argtest", "interface test { int Test(int a, long b, uint32 c); }; "; testok "array1", "interface test { int Test(int a[]); };"; testok "array2", "interface test { int Test(int a[2]); };"; testok "array3", "interface test { int Test(int a[b]); };"; -testfail "array4", "interface test { int Test(int[] a); };"; +testfail "array4", "interface test { int Test(int[] a); };", + ":0: Syntax error near '['\n"; testok "ptr1", "interface test { int Test(int *a); };"; testok "ptr2", "interface test { int Test(int **a); };"; testok "ptr3", "interface test { int Test(int ***a); };"; -testfail "empty1", "interface test { };"; -testfail "empty2", ""; +testfail "empty1", "interface test { };", ":0: Syntax error near '}'\n"; +testfail "empty2", "", ""; testok "attr1", "[uuid(\"myuuid\"),attr] interface test { int Test(int ***a); };"; testok "attr2", "interface test { [public] int Test(); };"; testok "attr3", "[attr1] [attr2] interface test { [public] int Test(); };"; @@ -51,22 +57,28 @@ testok "multif", "interface test { int test1(); }; interface test2 { int test2() testok "tdstruct1", "interface test { typedef struct { } foo; };"; testok "tdstruct2", "interface test { typedef struct { int a; } foo; };"; testok "tdstruct3", "interface test { typedef struct { int a; int b; } foo; };"; -testfail "tdstruct4", "interface test { typedef struct { int a, int b; } foo; };"; +testfail "tdstruct4", "interface test { typedef struct { int a, int b; } foo; };", + ":0: Syntax error near ','\n"; testok "struct1", "interface test { struct x { }; };"; testok "struct2", "interface test { struct x { int a; }; };"; testok "struct3", "interface test { struct x { int a; int b; }; };"; -testfail "struct4", "interface test { struct x { int a, int b; }; };"; -testfail "struct5", "interface test { struct { int a; } x; };"; +testfail "struct4", "interface test { struct x { int a, int b; }; };", + ":0: Syntax error near ','\n"; +testfail "struct5", "interface test { struct { int a; } x; };", + ":0: Syntax error near 'x'\n"; testok "tdunion1", "interface test { typedef union { } a; };"; testok "tdunion2", "interface test { typedef union { int a; } a; };"; testok "union1", "interface test { union a { }; };"; testok "union2", "interface test { union x { int a; }; };"; -testfail "union3", "interface test { union { int a; } x; };"; +testfail "union3", "interface test { union { int a; } x; };", + ":0: Syntax error near 'x'\n"; testok "typedef1", "interface test { typedef int a; };"; -testfail "typedef2", "interface test { typedef x; };"; +testfail "typedef2", "interface test { typedef x; };", + ":0: Syntax error near ';'\n"; testok "tdenum1", "interface test { typedef enum { A=1, B=2, C} a; };"; testok "enum1", "interface test { enum a { A=1, B=2, C}; };"; -testfail "enum2", "interface test { enum { A=1, B=2, C} a; };"; +testfail "enum2", "interface test { enum { A=1, B=2, C} a; };", + ":0: Syntax error near 'a'\n"; testok "nested1", "interface test { struct x { struct { int a; } z; }; };"; testok "nested2", "interface test { struct x { struct y { int a; } z; }; };"; testok "bitmap1", "interface test { bitmap x { a=1 }; };"; @@ -82,9 +94,12 @@ testok "emptyenumdecl", "interface test { enum x; };"; testok "emptytdstructdecl", "interface test { typedef struct x y; };"; testok "import", "import \"foo.idl\";"; testok "include", "include \"foo.h\";"; -testfail "import-noquotes", "import foo.idl;"; -testfail "include-noquotes", "include foo.idl;"; +testfail "import-noquotes", "import foo.idl;", + ":0: Syntax error near 'foo'\n"; +testfail "include-noquotes", "include foo.idl;", + ":0: Syntax error near 'foo'\n"; testok "importlib", "importlib \"foo.idl\";"; -testfail "import-nosemicolon", "import \"foo.idl\""; +testfail "import-nosemicolon", "import \"foo.idl\"", + ":0: Syntax error near 'foo.idl'\n"; testok "import-multiple", "import \"foo.idl\", \"bar.idl\";"; testok "include-multiple", "include \"foo.idl\", \"bar.idl\";"; -- cgit From 42a5a1c550a39febe3ec5f3cc824ebeed29c7d34 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 5 Jan 2007 17:18:22 +0000 Subject: r20556: Add more tests to make sure nothing breaks when I replace the ParseExpr code. (This used to be commit 0ba52e459bb322a0aee59c6616d7696658934b38) --- source4/pidl/tests/util.pl | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/util.pl b/source4/pidl/tests/util.pl index f32ab41e8d..4287d78980 100755 --- a/source4/pidl/tests/util.pl +++ b/source4/pidl/tests/util.pl @@ -3,7 +3,7 @@ # Published under the GNU General Public License use strict; -use Test::More tests => 29; +use Test::More tests => 41; use FindBin qw($RealBin); use lib "$RealBin/../lib"; use Parse::Pidl::Util; @@ -57,3 +57,21 @@ is("r->length+r->length", is("2/2*(r->length)", ParseExpr("constant/constant*(len)", {"constant" => "2", "len" => "r->length"})); +is("2+2-r->length", + ParseExpr("constant+constant-len", {"constant" => "2", + "len" => "r->length"})); +is("*r->length", ParseExpr("*len", { "len" => "r->length"})); +is("**r->length", ParseExpr("**len", { "len" => "r->length"})); +is("r->length&2", ParseExpr("len&2", { "len" => "r->length"})); +is("&r->length", ParseExpr("&len", { "len" => "r->length"})); +is("strlen(\"data\")", ParseExpr("strlen(foo)", { "foo" => "\"data\""})); +is("strlen(\"data\", 4)", ParseExpr("strlen(foo, 4)", { "foo" => "\"data\""})); +is("foo / bar", ParseExpr("foo / bar", { "bla" => "\"data\""})); +is("r->length%2", ParseExpr("len%2", { "len" => "r->length"})); +is("r->length==2", ParseExpr("len==2", { "len" => "r->length"})); +is("r->length!=2", ParseExpr("len!=2", { "len" => "r->length"})); +is("pr->length", ParseExpr("pr->length", { "p" => "r"})); +TODO: { + todo_skip 1, "Broken at the moment"; + is("r->length", ParseExpr("p->length", { "p" => "r"})); +} -- cgit From 74239c2e944fdbe1ff137e91d80576b87c59d478 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 5 Jan 2007 20:18:33 +0000 Subject: r20563: Start using the new parser in ParseExpr(). It's now trivial to use this to check for NULL pointers when pointers are being dereferenced (#4218). There are exactly 500 tests for pidl now :-) (This used to be commit d3146f3bcd4541f890d6c1b072ff34853e9239d2) --- source4/pidl/tests/util.pl | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/util.pl b/source4/pidl/tests/util.pl index 4287d78980..4c002458ea 100755 --- a/source4/pidl/tests/util.pl +++ b/source4/pidl/tests/util.pl @@ -3,7 +3,7 @@ # Published under the GNU General Public License use strict; -use Test::More tests => 41; +use Test::More tests => 53; use FindBin qw($RealBin); use lib "$RealBin/../lib"; use Parse::Pidl::Util; @@ -48,30 +48,39 @@ ok(property_matches({PROPERTIES => {x => "data"}}, "x", "data")); ok(property_matches({PROPERTIES => {x => "data"}}, "x", "^([dat]+)\$")); # ParseExpr() -is("", ParseExpr("", {})); +#is("", ParseExpr("", {})); is("a", ParseExpr("a", {"b" => "2"})); is("2", ParseExpr("a", {"a" => "2"})); -is("2*2", ParseExpr("a*a", {"a" => "2"})); -is("r->length+r->length", +is("2 * 2", ParseExpr("a*a", {"a" => "2"})); +is("r->length + r->length", ParseExpr("length+length", {"length" => "r->length"})); -is("2/2*(r->length)", +is("2 / 2 * (r->length)", ParseExpr("constant/constant*(len)", {"constant" => "2", "len" => "r->length"})); -is("2+2-r->length", +is("2 + 2 - r->length", ParseExpr("constant+constant-len", {"constant" => "2", "len" => "r->length"})); is("*r->length", ParseExpr("*len", { "len" => "r->length"})); is("**r->length", ParseExpr("**len", { "len" => "r->length"})); -is("r->length&2", ParseExpr("len&2", { "len" => "r->length"})); +is("r->length & 2", ParseExpr("len&2", { "len" => "r->length"})); is("&r->length", ParseExpr("&len", { "len" => "r->length"})); +is("calc()", ParseExpr("calc()", { "foo" => "2"})); +is("calc(2 * 2)", ParseExpr("calc(foo * 2)", { "foo" => "2"})); is("strlen(\"data\")", ParseExpr("strlen(foo)", { "foo" => "\"data\""})); is("strlen(\"data\", 4)", ParseExpr("strlen(foo, 4)", { "foo" => "\"data\""})); is("foo / bar", ParseExpr("foo / bar", { "bla" => "\"data\""})); -is("r->length%2", ParseExpr("len%2", { "len" => "r->length"})); -is("r->length==2", ParseExpr("len==2", { "len" => "r->length"})); -is("r->length!=2", ParseExpr("len!=2", { "len" => "r->length"})); +is("r->length % 2", ParseExpr("len%2", { "len" => "r->length"})); +is("r->length == 2", ParseExpr("len==2", { "len" => "r->length"})); +is("r->length != 2", ParseExpr("len!=2", { "len" => "r->length"})); is("pr->length", ParseExpr("pr->length", { "p" => "r"})); -TODO: { - todo_skip 1, "Broken at the moment"; - is("r->length", ParseExpr("p->length", { "p" => "r"})); -} +is("r->length", ParseExpr("p->length", { "p" => "r"})); +is("_foo / bla32", ParseExpr("_foo / bla32", { "bla" => "\"data\""})); +is("foo.bar.blah", ParseExpr("foo.blah", { "foo" => "foo.bar"})); +is("\"bla\"", ParseExpr("\"bla\"", {})); +is("1 << 2", ParseExpr("1 << 2", {})); +is("1 >> 2", ParseExpr("1 >> 2", {})); +is("0x200", ParseExpr("0x200", {})); +is("2?3:0", ParseExpr("2?3:0", {})); +is("~0", ParseExpr("~0", {})); +is("b->a->a", ParseExpr("a->a->a", {"a" => "b"})); +is("b.a.a", ParseExpr("a.a.a", {"a" => "b"})); -- cgit From a7bc3801f94891880a90b2974dfbadc9e9f8c2ee Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 5 Jan 2007 20:52:12 +0000 Subject: r20567: Print proper errors with filename and line numbers in ParseExpr() (This used to be commit f5dc1b47ecf18068a47f8f68016463ef4a55dc03) --- source4/pidl/tests/util.pl | 68 ++++++++++++++++++++++++---------------------- 1 file changed, 36 insertions(+), 32 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/util.pl b/source4/pidl/tests/util.pl index 4c002458ea..1dde97b192 100755 --- a/source4/pidl/tests/util.pl +++ b/source4/pidl/tests/util.pl @@ -3,9 +3,10 @@ # Published under the GNU General Public License use strict; -use Test::More tests => 53; +use Test::More tests => 55; use FindBin qw($RealBin); -use lib "$RealBin/../lib"; +use lib "$RealBin"; +use Util; use Parse::Pidl::Util; # has_property() @@ -49,38 +50,41 @@ ok(property_matches({PROPERTIES => {x => "data"}}, "x", "^([dat]+)\$")); # ParseExpr() #is("", ParseExpr("", {})); -is("a", ParseExpr("a", {"b" => "2"})); -is("2", ParseExpr("a", {"a" => "2"})); -is("2 * 2", ParseExpr("a*a", {"a" => "2"})); +is("a", ParseExpr("a", {"b" => "2"}, undef)); +is("2", ParseExpr("a", {"a" => "2"}, undef)); +is("2 * 2", ParseExpr("a*a", {"a" => "2"}, undef)); is("r->length + r->length", - ParseExpr("length+length", {"length" => "r->length"})); + ParseExpr("length+length", {"length" => "r->length"}, undef)); is("2 / 2 * (r->length)", ParseExpr("constant/constant*(len)", {"constant" => "2", - "len" => "r->length"})); + "len" => "r->length"}, undef)); is("2 + 2 - r->length", ParseExpr("constant+constant-len", {"constant" => "2", - "len" => "r->length"})); -is("*r->length", ParseExpr("*len", { "len" => "r->length"})); -is("**r->length", ParseExpr("**len", { "len" => "r->length"})); -is("r->length & 2", ParseExpr("len&2", { "len" => "r->length"})); -is("&r->length", ParseExpr("&len", { "len" => "r->length"})); -is("calc()", ParseExpr("calc()", { "foo" => "2"})); -is("calc(2 * 2)", ParseExpr("calc(foo * 2)", { "foo" => "2"})); -is("strlen(\"data\")", ParseExpr("strlen(foo)", { "foo" => "\"data\""})); -is("strlen(\"data\", 4)", ParseExpr("strlen(foo, 4)", { "foo" => "\"data\""})); -is("foo / bar", ParseExpr("foo / bar", { "bla" => "\"data\""})); -is("r->length % 2", ParseExpr("len%2", { "len" => "r->length"})); -is("r->length == 2", ParseExpr("len==2", { "len" => "r->length"})); -is("r->length != 2", ParseExpr("len!=2", { "len" => "r->length"})); -is("pr->length", ParseExpr("pr->length", { "p" => "r"})); -is("r->length", ParseExpr("p->length", { "p" => "r"})); -is("_foo / bla32", ParseExpr("_foo / bla32", { "bla" => "\"data\""})); -is("foo.bar.blah", ParseExpr("foo.blah", { "foo" => "foo.bar"})); -is("\"bla\"", ParseExpr("\"bla\"", {})); -is("1 << 2", ParseExpr("1 << 2", {})); -is("1 >> 2", ParseExpr("1 >> 2", {})); -is("0x200", ParseExpr("0x200", {})); -is("2?3:0", ParseExpr("2?3:0", {})); -is("~0", ParseExpr("~0", {})); -is("b->a->a", ParseExpr("a->a->a", {"a" => "b"})); -is("b.a.a", ParseExpr("a.a.a", {"a" => "b"})); + "len" => "r->length"}, undef)); +is("*r->length", ParseExpr("*len", { "len" => "r->length"}, undef)); +is("**r->length", ParseExpr("**len", { "len" => "r->length"}, undef)); +is("r->length & 2", ParseExpr("len&2", { "len" => "r->length"}, undef)); +is("&r->length", ParseExpr("&len", { "len" => "r->length"}, undef)); +is("calc()", ParseExpr("calc()", { "foo" => "2"}, undef)); +is("calc(2 * 2)", ParseExpr("calc(foo * 2)", { "foo" => "2"}, undef)); +is("strlen(\"data\")", ParseExpr("strlen(foo)", { "foo" => "\"data\""}, undef)); +is("strlen(\"data\", 4)", ParseExpr("strlen(foo, 4)", { "foo" => "\"data\""}, undef)); +is("foo / bar", ParseExpr("foo / bar", { "bla" => "\"data\""}, undef)); +is("r->length % 2", ParseExpr("len%2", { "len" => "r->length"}, undef)); +is("r->length == 2", ParseExpr("len==2", { "len" => "r->length"}, undef)); +is("r->length != 2", ParseExpr("len!=2", { "len" => "r->length"}, undef)); +is("pr->length", ParseExpr("pr->length", { "p" => "r"}, undef)); +is("r->length", ParseExpr("p->length", { "p" => "r"}, undef)); +is("_foo / bla32", ParseExpr("_foo / bla32", { "bla" => "\"data\""}, undef)); +is("foo.bar.blah", ParseExpr("foo.blah", { "foo" => "foo.bar"}, undef)); +is("\"bla\"", ParseExpr("\"bla\"", {}, undef)); +is("1 << 2", ParseExpr("1 << 2", {}, undef)); +is("1 >> 2", ParseExpr("1 >> 2", {}, undef)); +is("0x200", ParseExpr("0x200", {}, undef)); +is("2?3:0", ParseExpr("2?3:0", {}, undef)); +is("~0", ParseExpr("~0", {}, undef)); +is("b->a->a", ParseExpr("a->a->a", {"a" => "b"}, undef)); +is("b.a.a", ParseExpr("a.a.a", {"a" => "b"}, undef)); + +test_errors("nofile:0: Parse error in `~' near `~'\n", sub { + is(undef, ParseExpr("~", {}, {FILE => "nofile", LINE => 0})); }); -- cgit From a95d58ae8f45089e74099f707450a73432792ed9 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 5 Jan 2007 21:26:28 +0000 Subject: r20571: fix '' case (This used to be commit 1618921a7e24213d39e042a4e2f9d5cb59997f50) --- source4/pidl/tests/util.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/util.pl b/source4/pidl/tests/util.pl index 1dde97b192..cea59af1b6 100755 --- a/source4/pidl/tests/util.pl +++ b/source4/pidl/tests/util.pl @@ -3,7 +3,7 @@ # Published under the GNU General Public License use strict; -use Test::More tests => 55; +use Test::More tests => 56; use FindBin qw($RealBin); use lib "$RealBin"; use Util; @@ -49,7 +49,7 @@ ok(property_matches({PROPERTIES => {x => "data"}}, "x", "data")); ok(property_matches({PROPERTIES => {x => "data"}}, "x", "^([dat]+)\$")); # ParseExpr() -#is("", ParseExpr("", {})); +is(undef, ParseExpr("", {}, undef)); is("a", ParseExpr("a", {"b" => "2"}, undef)); is("2", ParseExpr("a", {"a" => "2"}, undef)); is("2 * 2", ParseExpr("a*a", {"a" => "2"}, undef)); -- cgit From cfa230c480b0c55a23e23dcb39e1b170da576c95 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 9 Jan 2007 06:02:41 +0000 Subject: r20625: Fix couple of warnings. (This used to be commit 203076129b967ccc6258e807280dc1b75583a064) --- source4/pidl/tests/Util.pm | 12 ++++++++++-- source4/pidl/tests/util.pl | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/Util.pm b/source4/pidl/tests/Util.pm index 2f43abe1ed..cfa1422674 100644 --- a/source4/pidl/tests/Util.pm +++ b/source4/pidl/tests/Util.pm @@ -18,14 +18,22 @@ my $warnings = ""; undef &Parse::Pidl::warning; *Parse::Pidl::warning = sub { my ($e, $l) = @_; - $warnings .= "$e->{FILE}:$e->{LINE}: $l\n"; + if (defined($e)) { + $warnings .= "$e->{FILE}:$e->{LINE}: $l\n"; + } else { + $warnings .= "$l\n"; + } }; my $errors = ""; undef &Parse::Pidl::error; *Parse::Pidl::error = sub { my ($e, $l) = @_; - $errors .= "$e->{FILE}:$e->{LINE}: $l\n"; + if (defined($e)) { + $errors .= "$e->{FILE}:$e->{LINE}: $l\n"; + } else { + $errors .= "$l\n"; + } }; use Test::More; diff --git a/source4/pidl/tests/util.pl b/source4/pidl/tests/util.pl index cea59af1b6..19cb90c080 100755 --- a/source4/pidl/tests/util.pl +++ b/source4/pidl/tests/util.pl @@ -2,6 +2,7 @@ # (C) 2007 Jelmer Vernooij # Published under the GNU General Public License use strict; +use warnings; use Test::More tests => 56; use FindBin qw($RealBin); -- cgit From bf39b5e5929449b7ef8685b6c7737efd3a31843b Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 9 Jan 2007 15:50:36 +0000 Subject: r20631: Add some tests for the ndr parser. (This used to be commit ded25eca701b8e3e0e13e7ef64d5511d8953eb0d) --- source4/pidl/tests/ndr.pl | 154 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 154 insertions(+) create mode 100755 source4/pidl/tests/ndr.pl (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/ndr.pl b/source4/pidl/tests/ndr.pl new file mode 100755 index 0000000000..97199a4120 --- /dev/null +++ b/source4/pidl/tests/ndr.pl @@ -0,0 +1,154 @@ +#!/usr/bin/perl +# (C) 2007 Jelmer Vernooij +# Published under the GNU General Public License +use strict; +use warnings; + +use Test::More tests => 9; +use FindBin qw($RealBin); +use lib "$RealBin"; +use Util; +use Parse::Pidl::Util qw(MyDumper); +use Parse::Pidl::NDR qw(GetElementLevelTable ParseElement); + +# Case 1 + +my $e = { + 'FILE' => 'foo.idl', + 'NAME' => 'v', + 'PROPERTIES' => {}, + 'POINTERS' => 0, + 'TYPE' => 'uint8', + 'LINE' => 42 }; + +is_deeply(GetElementLevelTable($e), [ + { + 'IS_DEFERRED' => 0, + 'LEVEL_INDEX' => 0, + 'DATA_TYPE' => 'uint8', + 'CONVERT_FROM' => undef, + 'CONTAINS_DEFERRED' => 0, + 'TYPE' => 'DATA', + 'IS_SURROUNDING' => 0, + 'CONVERT_TO' => undef + } +]); + +my $ne = ParseElement($e); +is($ne->{ORIGINAL}, $e); +is($ne->{NAME}, "v"); +is($ne->{ALIGN}, 1); +is($ne->{TYPE}, "uint8"); +is_deeply($ne->{LEVELS}, [ + { + 'IS_DEFERRED' => 0, + 'LEVEL_INDEX' => 0, + 'DATA_TYPE' => 'uint8', + 'CONVERT_FROM' => undef, + 'CONTAINS_DEFERRED' => 0, + 'TYPE' => 'DATA', + 'IS_SURROUNDING' => 0, + 'CONVERT_TO' => undef + } +]); + +# Case 2 : pointers +# +$e = { + 'FILE' => 'foo.idl', + 'NAME' => 'v', + 'PROPERTIES' => {}, + 'POINTERS' => 1, + 'TYPE' => 'uint8', + 'LINE' => 42 }; + +is_deeply(GetElementLevelTable($e), [ + { + LEVEL_INDEX => 0, + IS_DEFERRED => 0, + TYPE => 'POINTER', + POINTER_TYPE => undef, + POINTER_INDEX => 0, + LEVEL => 'EMBEDDED' + }, + { + 'IS_DEFERRED' => 1, + 'LEVEL_INDEX' => 1, + 'DATA_TYPE' => 'uint8', + 'CONVERT_FROM' => undef, + 'CONTAINS_DEFERRED' => 0, + 'TYPE' => 'DATA', + 'IS_SURROUNDING' => 0, + 'CONVERT_TO' => undef + } +]); + +# Case 3 : double pointers +# +$e = { + 'FILE' => 'foo.idl', + 'NAME' => 'v', + 'PROPERTIES' => {}, + 'POINTERS' => 2, + 'TYPE' => 'uint8', + 'LINE' => 42 }; + +is_deeply(GetElementLevelTable($e), [ + { + LEVEL_INDEX => 0, + IS_DEFERRED => 0, + TYPE => 'POINTER', + POINTER_TYPE => undef, + POINTER_INDEX => 0, + LEVEL => 'EMBEDDED' + }, + { + LEVEL_INDEX => 1, + IS_DEFERRED => 1, + TYPE => 'POINTER', + POINTER_TYPE => undef, + POINTER_INDEX => 1, + LEVEL => 'EMBEDDED' + }, + { + 'IS_DEFERRED' => 1, + 'LEVEL_INDEX' => 2, + 'DATA_TYPE' => 'uint8', + 'CONVERT_FROM' => undef, + 'CONTAINS_DEFERRED' => 0, + 'TYPE' => 'DATA', + 'IS_SURROUNDING' => 0, + 'CONVERT_TO' => undef + } +]); + +# Case 2 : ref pointers +# +$e = { + 'FILE' => 'foo.idl', + 'NAME' => 'v', + 'PROPERTIES' => {"ref" => 1}, + 'POINTERS' => 1, + 'TYPE' => 'uint8', + 'LINE' => 42 }; + +is_deeply(GetElementLevelTable($e), [ + { + LEVEL_INDEX => 0, + IS_DEFERRED => 0, + TYPE => 'POINTER', + POINTER_TYPE => "ref", + POINTER_INDEX => 0, + LEVEL => 'EMBEDDED' + }, + { + 'IS_DEFERRED' => 1, + 'LEVEL_INDEX' => 1, + 'DATA_TYPE' => 'uint8', + 'CONVERT_FROM' => undef, + 'CONTAINS_DEFERRED' => 0, + 'TYPE' => 'DATA', + 'IS_SURROUNDING' => 0, + 'CONVERT_TO' => undef + } +]); -- cgit From a338d29bc1e7d902190cc5ddb370eebc2ea4929d Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 9 Jan 2007 15:54:36 +0000 Subject: r20633: Add another test, fix warnings. (This used to be commit 3ddc76772765db8009120ada820837737c49e409) --- source4/pidl/tests/ndr.pl | 51 ++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 44 insertions(+), 7 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/ndr.pl b/source4/pidl/tests/ndr.pl index 97199a4120..da22949c6d 100755 --- a/source4/pidl/tests/ndr.pl +++ b/source4/pidl/tests/ndr.pl @@ -4,7 +4,7 @@ use strict; use warnings; -use Test::More tests => 9; +use Test::More tests => 10; use FindBin qw($RealBin); use lib "$RealBin"; use Util; @@ -19,6 +19,7 @@ my $e = { 'PROPERTIES' => {}, 'POINTERS' => 0, 'TYPE' => 'uint8', + 'PARENT' => { TYPE => 'STRUCT' }, 'LINE' => 42 }; is_deeply(GetElementLevelTable($e), [ @@ -57,8 +58,9 @@ is_deeply($ne->{LEVELS}, [ $e = { 'FILE' => 'foo.idl', 'NAME' => 'v', - 'PROPERTIES' => {}, + 'PROPERTIES' => {"unique" => 1}, 'POINTERS' => 1, + 'PARENT' => { TYPE => 'STRUCT' }, 'TYPE' => 'uint8', 'LINE' => 42 }; @@ -67,7 +69,7 @@ is_deeply(GetElementLevelTable($e), [ LEVEL_INDEX => 0, IS_DEFERRED => 0, TYPE => 'POINTER', - POINTER_TYPE => undef, + POINTER_TYPE => "unique", POINTER_INDEX => 0, LEVEL => 'EMBEDDED' }, @@ -88,9 +90,10 @@ is_deeply(GetElementLevelTable($e), [ $e = { 'FILE' => 'foo.idl', 'NAME' => 'v', - 'PROPERTIES' => {}, + 'PROPERTIES' => {"unique" => 1}, 'POINTERS' => 2, 'TYPE' => 'uint8', + 'PARENT' => { TYPE => 'STRUCT' }, 'LINE' => 42 }; is_deeply(GetElementLevelTable($e), [ @@ -98,7 +101,7 @@ is_deeply(GetElementLevelTable($e), [ LEVEL_INDEX => 0, IS_DEFERRED => 0, TYPE => 'POINTER', - POINTER_TYPE => undef, + POINTER_TYPE => "unique", POINTER_INDEX => 0, LEVEL => 'EMBEDDED' }, @@ -106,7 +109,7 @@ is_deeply(GetElementLevelTable($e), [ LEVEL_INDEX => 1, IS_DEFERRED => 1, TYPE => 'POINTER', - POINTER_TYPE => undef, + POINTER_TYPE => "unique", POINTER_INDEX => 1, LEVEL => 'EMBEDDED' }, @@ -122,7 +125,7 @@ is_deeply(GetElementLevelTable($e), [ } ]); -# Case 2 : ref pointers +# Case 3 : ref pointers # $e = { 'FILE' => 'foo.idl', @@ -130,6 +133,7 @@ $e = { 'PROPERTIES' => {"ref" => 1}, 'POINTERS' => 1, 'TYPE' => 'uint8', + 'PARENT' => { TYPE => 'STRUCT' }, 'LINE' => 42 }; is_deeply(GetElementLevelTable($e), [ @@ -152,3 +156,36 @@ is_deeply(GetElementLevelTable($e), [ 'CONVERT_TO' => undef } ]); + + +# Case 4 : top-level ref pointers +# +$e = { + 'FILE' => 'foo.idl', + 'NAME' => 'v', + 'PROPERTIES' => {"ref" => 1}, + 'POINTERS' => 1, + 'TYPE' => 'uint8', + 'PARENT' => { TYPE => 'FUNCTION' }, + 'LINE' => 42 }; + +is_deeply(GetElementLevelTable($e), [ + { + LEVEL_INDEX => 0, + IS_DEFERRED => 0, + TYPE => 'POINTER', + POINTER_TYPE => "ref", + POINTER_INDEX => 0, + LEVEL => 'TOP' + }, + { + 'IS_DEFERRED' => 0, + 'LEVEL_INDEX' => 1, + 'DATA_TYPE' => 'uint8', + 'CONVERT_FROM' => undef, + 'CONTAINS_DEFERRED' => 0, + 'TYPE' => 'DATA', + 'IS_SURROUNDING' => 0, + 'CONVERT_TO' => undef + } +]); -- cgit From 95f7f4d001684d447ce8e0f880200cfac89f011a Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 9 Jan 2007 23:41:25 +0000 Subject: r20637: Don't check for NULL pointers when the pointer is guaranteed to not be NULL (if it is a ref pointer). (This used to be commit 419547df76c38fde1f54b06dc633832523ad3394) --- source4/pidl/tests/samba-ndr.pl | 135 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 135 insertions(+) create mode 100755 source4/pidl/tests/samba-ndr.pl (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/samba-ndr.pl b/source4/pidl/tests/samba-ndr.pl new file mode 100755 index 0000000000..487f203f41 --- /dev/null +++ b/source4/pidl/tests/samba-ndr.pl @@ -0,0 +1,135 @@ +#!/usr/bin/perl +# (C) 2007 Jelmer Vernooij +# Published under the GNU General Public License +use strict; +use warnings; + +use Test::More tests => 10; +use FindBin qw($RealBin); +use lib "$RealBin"; +use Util; +use Parse::Pidl::Util qw(MyDumper); +use Parse::Pidl::Samba4::NDR::Parser qw(check_null_pointer); + +my $output; +sub print_fn($) { my $x = shift; $output.=$x; } + +# Test case 1: Simple unique pointer dereference + +$output = ""; +my $fn = check_null_pointer({ + PARENT => { + ELEMENTS => [ + { + NAME => "bla", + LEVELS => [ + { TYPE => "POINTER", + POINTER_INDEX => 0, + POINTER_TYPE => "unique" }, + { TYPE => "DATA" } + ], + }, + ] + } +}, { bla => "r->in.bla" }, \&print_fn); + + +test_warnings("", sub { $fn->("r->in.bla"); }); + +is($output, "if (r->in.bla == NULL) return NT_STATUS_INVALID_PARAMETER_MIX;"); + +# Test case 2: Simple ref pointer dereference + +$output = ""; +$fn = check_null_pointer({ + PARENT => { + ELEMENTS => [ + { + NAME => "bla", + LEVELS => [ + { TYPE => "POINTER", + POINTER_INDEX => 0, + POINTER_TYPE => "ref" }, + { TYPE => "DATA" } + ], + }, + ] + } +}, { bla => "r->in.bla" }, \&print_fn); + +test_warnings("", sub { $fn->("r->in.bla"); }); + +is($output, ""); + +# Test case 3: Illegal dereference + +$output = ""; +$fn = check_null_pointer({ + FILE => "nofile", + LINE => 1, + PARENT => { + ELEMENTS => [ + { + NAME => "bla", + LEVELS => [ + { TYPE => "DATA" } + ], + }, + ] + } +}, { bla => "r->in.bla" }, \&print_fn); + +test_warnings("nofile:1: too much dereferences for `bla'\n", + sub { $fn->("r->in.bla"); }); + +is($output, ""); + +# Test case 4: Double pointer dereference + +$output = ""; +$fn = check_null_pointer({ + PARENT => { + ELEMENTS => [ + { + NAME => "bla", + LEVELS => [ + { TYPE => "POINTER", + POINTER_INDEX => 0, + POINTER_TYPE => "unique" }, + { TYPE => "POINTER", + POINTER_INDEX => 1, + POINTER_TYPE => "unique" }, + { TYPE => "DATA" } + ], + }, + ] + } +}, { bla => "r->in.bla" }, \&print_fn); + +test_warnings("", + sub { $fn->("*r->in.bla"); }); + +is($output, "if (*r->in.bla == NULL) return NT_STATUS_INVALID_PARAMETER_MIX;"); + +# Test case 5: Unknown variable + +$output = ""; +$fn = check_null_pointer({ + FILE => "nofile", + LINE => 2, + PARENT => { + ELEMENTS => [ + { + NAME => "bla", + LEVELS => [ + { TYPE => "DATA" } + ], + }, + ] + } +}, { }, \&print_fn); + +test_warnings("nofile:2: unknown dereferenced expression `r->in.bla'\n", + sub { $fn->("r->in.bla"); }); + +is($output, "if (r->in.bla == NULL) return NT_STATUS_INVALID_PARAMETER_MIX;"); -- cgit From 348b7bc380e4ce95cf053134e62c3f5ab6520e34 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 10 Jan 2007 00:37:30 +0000 Subject: r20638: Check for NULL pointers (where possible) in print functions. Fixes #4218, but without reintroducing coverity warnings. (This used to be commit a0e2e30d570f246d646f88d7f81ab08208b96131) --- source4/pidl/tests/samba-ndr.pl | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/samba-ndr.pl b/source4/pidl/tests/samba-ndr.pl index 487f203f41..a3e94bd8b5 100755 --- a/source4/pidl/tests/samba-ndr.pl +++ b/source4/pidl/tests/samba-ndr.pl @@ -31,12 +31,12 @@ my $fn = check_null_pointer({ }, ] } -}, { bla => "r->in.bla" }, \&print_fn); +}, { bla => "r->in.bla" }, \&print_fn, "return;"); test_warnings("", sub { $fn->("r->in.bla"); }); -is($output, "if (r->in.bla == NULL) return NT_STATUS_INVALID_PARAMETER_MIX;"); +is($output, "if (r->in.bla == NULL) return;"); # Test case 2: Simple ref pointer dereference @@ -55,7 +55,7 @@ $fn = check_null_pointer({ }, ] } -}, { bla => "r->in.bla" }, \&print_fn); +}, { bla => "r->in.bla" }, \&print_fn, undef); test_warnings("", sub { $fn->("r->in.bla"); }); @@ -77,7 +77,7 @@ $fn = check_null_pointer({ }, ] } -}, { bla => "r->in.bla" }, \&print_fn); +}, { bla => "r->in.bla" }, \&print_fn, undef); test_warnings("nofile:1: too much dereferences for `bla'\n", sub { $fn->("r->in.bla"); }); @@ -104,12 +104,12 @@ $fn = check_null_pointer({ }, ] } -}, { bla => "r->in.bla" }, \&print_fn); +}, { bla => "r->in.bla" }, \&print_fn, "return;"); test_warnings("", sub { $fn->("*r->in.bla"); }); -is($output, "if (*r->in.bla == NULL) return NT_STATUS_INVALID_PARAMETER_MIX;"); +is($output, "if (*r->in.bla == NULL) return;"); # Test case 5: Unknown variable @@ -127,9 +127,9 @@ $fn = check_null_pointer({ }, ] } -}, { }, \&print_fn); +}, { }, \&print_fn, "return;"); test_warnings("nofile:2: unknown dereferenced expression `r->in.bla'\n", sub { $fn->("r->in.bla"); }); -is($output, "if (r->in.bla == NULL) return NT_STATUS_INVALID_PARAMETER_MIX;"); +is($output, "if (r->in.bla == NULL) return;"); -- cgit From fe938ca91f6ead7371390ec01a232dde0565c42e Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 23 Jan 2007 10:08:08 +0000 Subject: r20967: Allow pidl tests to work with gcov (This used to be commit 9da63e362c9d590388c77d882f9dbf54b0aa78cc) --- source4/pidl/tests/Util.pm | 21 +++++++++++++++++++-- source4/pidl/tests/ndr_align.pl | 10 +++++----- source4/pidl/tests/ndr_refptr.pl | 36 ++++++++++++++++++------------------ source4/pidl/tests/ndr_tagtype.pl | 2 +- 4 files changed, 43 insertions(+), 26 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/Util.pm b/source4/pidl/tests/Util.pm index cfa1422674..a406b868e1 100644 --- a/source4/pidl/tests/Util.pm +++ b/source4/pidl/tests/Util.pm @@ -72,9 +72,27 @@ SKIP: { $outfile = "./test-$name"; } + my $cflags = $ENV{CFLAGS}; + unless (defined($cflags)) { + $cflags = ""; + } + + my $ldflags = $ENV{LDFLAGS}; + unless (defined($ldflags)) { + $ldflags = ""; + } + + my $cc = $ENV{CC}; + unless (defined($cc)) { + $cc = "cc"; + } + my $flags = `pkg-config --libs --cflags ndr samba-config`; - open CC, "|cc -x c - -o $outfile $flags"; + my $cmd = "$cc $cflags -x c - -o $outfile $flags $ldflags"; + $cmd =~ s/\n//g; + print "$cmd\n"; + open CC, "|$cmd"; print CC "#define uint_t unsigned int\n"; print CC "#define _GNU_SOURCE\n"; print CC "#include \n"; @@ -121,7 +139,6 @@ sub test_warnings($$) is($warnings, $exp); } - sub test_errors($$) { my ($exp, $code) = @_; diff --git a/source4/pidl/tests/ndr_align.pl b/source4/pidl/tests/ndr_align.pl index 5117be95bd..405b74597c 100755 --- a/source4/pidl/tests/ndr_align.pl +++ b/source4/pidl/tests/ndr_align.pl @@ -16,7 +16,7 @@ test_samba4_ndr('align-uint8-uint16', } bla; ', ' - struct ndr_push *ndr = ndr_push_init(); + struct ndr_push *ndr = ndr_push_init_ctx(NULL); struct bla r; uint8_t expected[] = { 0x0D, 0x00, 0xef, 0xbe }; DATA_BLOB expected_blob = { expected, 4 }; @@ -41,7 +41,7 @@ test_samba4_ndr('align-uint8-uint32', } bla; ', ' - struct ndr_push *ndr = ndr_push_init(); + struct ndr_push *ndr = ndr_push_init_ctx(NULL); struct bla r; uint8_t expected[] = { 0x0D, 0x00, 0x00, 0x00, 0xef, 0xbe, 0xef, 0xbe }; DATA_BLOB expected_blob = { expected, 8 }; @@ -67,7 +67,7 @@ test_samba4_ndr('align-uint8-hyper', } bla; ', ' - struct ndr_push *ndr = ndr_push_init(); + struct ndr_push *ndr = ndr_push_init_ctx(NULL); struct bla r; uint8_t expected[] = { 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xef, 0xbe, 0xef, 0xbe, 0xef, 0xbe, 0xef, 0xbe }; @@ -93,7 +93,7 @@ test_samba4_ndr('noalignflag-uint8-uint16', } bla; ', ' - struct ndr_push *ndr = ndr_push_init(); + struct ndr_push *ndr = ndr_push_init_ctx(NULL); struct bla r; uint8_t expected[] = { 0x0D, 0xef, 0xbe }; DATA_BLOB expected_blob = { expected, 3 }; @@ -121,7 +121,7 @@ test_samba4_ndr('align-blob-align2', } blie; ', ' - struct ndr_push *ndr = ndr_push_init(); + struct ndr_push *ndr = ndr_push_init_ctx(NULL); struct blie r; uint8_t data[] = { 0x01, 0x02 }; uint8_t expected[] = { 0x0D, 0x00, 0x0E }; diff --git a/source4/pidl/tests/ndr_refptr.pl b/source4/pidl/tests/ndr_refptr.pl index 0bc5fd9416..4a56e3ca38 100755 --- a/source4/pidl/tests/ndr_refptr.pl +++ b/source4/pidl/tests/ndr_refptr.pl @@ -18,7 +18,7 @@ test_samba4_ndr("noptr-push", [public] uint16 echo_TestRef([in] xstruct foo); ', ' - struct ndr_push *ndr = ndr_push_init(); + struct ndr_push *ndr = ndr_push_init_ctx(NULL); uint16_t v = 13; struct echo_TestRef r; r.in.foo.x = v; @@ -48,7 +48,7 @@ test_samba4_ndr("ptr-embedded-push", ', ' uint16_t v = 13; - struct ndr_push *ndr = ndr_push_init(); + struct ndr_push *ndr = ndr_push_init_ctx(NULL); struct echo_TestRef r; r.in.foo.x = &v; @@ -74,7 +74,7 @@ test_samba4_ndr("ptr-embedded-push-null", [public] uint16 echo_TestRef([in] xstruct foo); ', ' - struct ndr_push *ndr = ndr_push_init(); + struct ndr_push *ndr = ndr_push_init_ctx(NULL); struct echo_TestRef r; r.in.foo.x = NULL; @@ -99,7 +99,7 @@ test_samba4_ndr("refptr-embedded-push", ', ' uint16_t v = 13; - struct ndr_push *ndr = ndr_push_init(); + struct ndr_push *ndr = ndr_push_init_ctx(NULL); struct echo_TestRef r; r.in.foo.x = &v; @@ -126,7 +126,7 @@ test_samba4_ndr("refptr-embedded-push-null", [public] uint16 echo_TestRef([in] xstruct foo); ', ' - struct ndr_push *ndr = ndr_push_init(); + struct ndr_push *ndr = ndr_push_init_ctx(NULL); struct echo_TestRef r; r.in.foo.x = NULL; @@ -144,7 +144,7 @@ test_samba4_ndr("ptr-top-push", [public] uint16 echo_TestRef([in] xstruct *foo); ', ' - struct ndr_push *ndr = ndr_push_init(); + struct ndr_push *ndr = ndr_push_init_ctx(NULL); struct echo_TestRef r; struct xstruct s; s.x = 13; @@ -169,7 +169,7 @@ test_samba4_ndr("ptr-top-push-null", [public] uint16 echo_TestRef([in] xstruct *foo); ', ' - struct ndr_push *ndr = ndr_push_init(); + struct ndr_push *ndr = ndr_push_init_ctx(NULL); struct echo_TestRef r; r.in.foo = NULL; @@ -189,7 +189,7 @@ test_samba4_ndr("refptr-top-push", [public] uint16 echo_TestRef([in,ref] xstruct *foo); ', ' - struct ndr_push *ndr = ndr_push_init(); + struct ndr_push *ndr = ndr_push_init_ctx(NULL); struct echo_TestRef r; struct xstruct s; s.x = 13; @@ -214,7 +214,7 @@ test_samba4_ndr("refptr-top-push-null", [public] uint16 echo_TestRef([in,ref] xstruct *foo); ', ' - struct ndr_push *ndr = ndr_push_init(); + struct ndr_push *ndr = ndr_push_init_ctx(NULL); struct echo_TestRef r; r.in.foo = NULL; @@ -233,7 +233,7 @@ test_samba4_ndr("uniqueptr-top-push", [public] uint16 echo_TestRef([in,unique] xstruct *foo); ', ' - struct ndr_push *ndr = ndr_push_init(); + struct ndr_push *ndr = ndr_push_init_ctx(NULL); struct echo_TestRef r; struct xstruct s; s.x = 13; @@ -261,7 +261,7 @@ test_samba4_ndr("uniqueptr-top-push-null", [public] uint16 echo_TestRef([in,unique] xstruct *foo); ', ' - struct ndr_push *ndr = ndr_push_init(); + struct ndr_push *ndr = ndr_push_init_ctx(NULL); struct echo_TestRef r; r.in.foo = NULL; @@ -381,7 +381,7 @@ test_samba4_ndr("ptr-top-push-double", ' [public] void echo_TestRef([in] uint16 **foo); ', -' struct ndr_push *ndr = ndr_push_init(); +' struct ndr_push *ndr = ndr_push_init_ctx(NULL); struct echo_TestRef r; uint16_t v = 13; uint16_t *pv = &v; @@ -408,7 +408,7 @@ test_samba4_ndr("ptr-top-push-double-sndnull", ' [public] void echo_TestRef([in] uint16 **foo); ', -' struct ndr_push *ndr = ndr_push_init(); +' struct ndr_push *ndr = ndr_push_init_ctx(NULL); struct echo_TestRef r; uint16_t *pv = NULL; r.in.foo = &pv; @@ -429,7 +429,7 @@ test_samba4_ndr("ptr-top-push-double-fstnull", ' [public] void echo_TestRef([in] uint16 **foo); ', -' struct ndr_push *ndr = ndr_push_init(); +' struct ndr_push *ndr = ndr_push_init_ctx(NULL); struct echo_TestRef r; r.in.foo = NULL; @@ -445,7 +445,7 @@ test_samba4_ndr("refptr-top-push-double", ' [public] void echo_TestRef([in,ref] uint16 **foo); ', -' struct ndr_push *ndr = ndr_push_init(); +' struct ndr_push *ndr = ndr_push_init_ctx(NULL); struct echo_TestRef r; uint16_t v = 13; uint16_t *pv = &v; @@ -473,7 +473,7 @@ test_samba4_ndr("refptr-top-push-double-sndnull", ' [public] void echo_TestRef([in,ref] uint16 **foo); ', -' struct ndr_push *ndr = ndr_push_init(); +' struct ndr_push *ndr = ndr_push_init_ctx(NULL); struct echo_TestRef r; uint16_t *pv = NULL; r.in.foo = &pv; @@ -494,7 +494,7 @@ test_samba4_ndr("refptr-top-push-double-fstnull", ' [public] void echo_TestRef([in,ref] uint16 **foo); ', -' struct ndr_push *ndr = ndr_push_init(); +' struct ndr_push *ndr = ndr_push_init_ctx(NULL); struct echo_TestRef r; r.in.foo = NULL; @@ -511,7 +511,7 @@ test_samba4_ndr("ignore-ptr", ' [public] void echo_TestRef([in,ignore] uint16 *foo, [in] uint16 *bar); ', -' struct ndr_push *ndr = ndr_push_init(); +' struct ndr_push *ndr = ndr_push_init_ctx(NULL); struct echo_TestRef r; uint16_t v = 10; r.in.foo = &v; diff --git a/source4/pidl/tests/ndr_tagtype.pl b/source4/pidl/tests/ndr_tagtype.pl index 662985a646..a7f7d0490a 100755 --- a/source4/pidl/tests/ndr_tagtype.pl +++ b/source4/pidl/tests/ndr_tagtype.pl @@ -18,7 +18,7 @@ test_samba4_ndr('struct-notypedef', }; ', ' - struct ndr_push *ndr = ndr_push_init(); + struct ndr_push *ndr = ndr_push_init_ctx(NULL); struct bla r; uint8_t expected[] = { 0x0D }; DATA_BLOB expected_blob = { expected, 1 }; -- cgit From ecf2c1effb778a95fd863a5e87ec7e378d228b57 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 7 Feb 2007 19:03:19 +0000 Subject: r21222: Merge a couple of pidl fixes: * Pidl will now warn when trying to use pointers as integers in expressions. * "subcontext()" is now marked as deprecated. The alternatives, transmit_as() / represent_as() should be available soon. * More tests. * Remove some unused code in smbtorture. (This used to be commit 37c0da541e3962164d5af3e3c9560803a733f3b7) --- source4/pidl/tests/ndr_deprecations.pl | 28 ++++++++++++++++++++++++++ source4/pidl/tests/ndr_represent.pl | 36 +++++++++++++++++++++++++++++++++- source4/pidl/tests/util.pl | 23 +++++++++++++++++++++- 3 files changed, 85 insertions(+), 2 deletions(-) create mode 100755 source4/pidl/tests/ndr_deprecations.pl mode change 100644 => 100755 source4/pidl/tests/ndr_represent.pl (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/ndr_deprecations.pl b/source4/pidl/tests/ndr_deprecations.pl new file mode 100755 index 0000000000..89738e42f6 --- /dev/null +++ b/source4/pidl/tests/ndr_deprecations.pl @@ -0,0 +1,28 @@ +#!/usr/bin/perl +# (C) 2007 Jelmer Vernooij +# Published under the GNU General Public License +use strict; +use warnings; + +use Test::More tests => 1; +use FindBin qw($RealBin); +use lib "$RealBin"; +use Util; +use Parse::Pidl::Util qw(MyDumper); +use Parse::Pidl::NDR qw(ValidElement); + +# Case 1 + +my $e = { + 'FILE' => 'foo.idl', + 'NAME' => 'v', + 'PROPERTIES' => {"subcontext" => 1}, + 'POINTERS' => 0, + 'TYPE' => 'uint8', + 'PARENT' => { TYPE => 'STRUCT' }, + 'LINE' => 42 }; + +test_warnings("foo.idl:42: subcontext() is deprecated. Use represent_as() or transmit_as() instead\n", + sub { ValidElement($e); }); + + diff --git a/source4/pidl/tests/ndr_represent.pl b/source4/pidl/tests/ndr_represent.pl old mode 100644 new mode 100755 index 880ecba827..52cd06f817 --- a/source4/pidl/tests/ndr_represent.pl +++ b/source4/pidl/tests/ndr_represent.pl @@ -3,7 +3,7 @@ # (C) 2006 Jelmer Vernooij. Published under the GNU GPL use strict; -use Test::More tests => 1 * 8; +use Test::More tests => 2 * 8; use FindBin qw($RealBin); use lib "$RealBin"; use Util qw(test_samba4_ndr); @@ -40,3 +40,37 @@ NTSTATUS ndr_uint32_to_uint8(uint32_t from, uint8_t *to) } ' ); + +test_samba4_ndr('transmit_as-simple', +' + void bla([in,transmit_as(uint32)] uint8 x); +', +' + uint8_t expected[] = { 0x0D }; + DATA_BLOB in_blob = { expected, 1 }; + struct ndr_pull *ndr = ndr_pull_init_blob(&in_blob, NULL); + struct bla r; + + if (NT_STATUS_IS_ERR(ndr_pull_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r))) + return 1; + + if (r.in.x != 13) + return 2; +', +' +#include + +NTSTATUS ndr_uint8_to_uint32(uint8_t from, uint32_t *to) +{ + *to = from; + return NT_STATUS_OK; +} + +NTSTATUS ndr_uint32_to_uint8(uint32_t from, uint8_t *to) +{ + *to = from; + return NT_STATUS_OK; +} +' +); + diff --git a/source4/pidl/tests/util.pl b/source4/pidl/tests/util.pl index 19cb90c080..ba2f7b7b49 100755 --- a/source4/pidl/tests/util.pl +++ b/source4/pidl/tests/util.pl @@ -4,10 +4,11 @@ use strict; use warnings; -use Test::More tests => 56; +use Test::More tests => 70; use FindBin qw($RealBin); use lib "$RealBin"; use Util; +use Parse::Pidl qw(error); use Parse::Pidl::Util; # has_property() @@ -89,3 +90,23 @@ is("b.a.a", ParseExpr("a.a.a", {"a" => "b"}, undef)); test_errors("nofile:0: Parse error in `~' near `~'\n", sub { is(undef, ParseExpr("~", {}, {FILE => "nofile", LINE => 0})); }); + +test_errors("nofile:0: Got pointer, expected integer\n", sub { + is(undef, ParseExprExt("foo", {}, {FILE => "nofile", LINE => 0}, + undef, sub { my $x = shift; + error({FILE => "nofile", LINE => 0}, + "Got pointer, expected integer"); + return undef; }))}); + +is("b.a.a", ParseExpr("b.a.a", {"a" => "b"}, undef)); +is("((rr_type) == NBT_QTYPE_NETBIOS)", ParseExpr("((rr_type)==NBT_QTYPE_NETBIOS)", {}, undef)); +is("talloc_check_name", ParseExpr("talloc_check_name", {}, undef)); +is("talloc_check_name()", ParseExpr("talloc_check_name()", {}, undef)); +is("talloc_check_name(ndr)", ParseExpr("talloc_check_name(ndr)", {}, undef)); +is("talloc_check_name(ndr, 1)", ParseExpr("talloc_check_name(ndr,1)", {}, undef)); +is("talloc_check_name(ndr, \"struct ndr_push\")", ParseExpr("talloc_check_name(ndr,\"struct ndr_push\")", {}, undef)); +is("((rr_type) == NBT_QTYPE_NETBIOS) && talloc_check_name(ndr, \"struct ndr_push\")", ParseExpr("((rr_type)==NBT_QTYPE_NETBIOS)&&talloc_check_name(ndr,\"struct ndr_push\")", {}, undef)); +is("(rdata).data.length", ParseExpr("(rdata).data.length", {}, undef)); +is("((rdata).data.length == 2)", ParseExpr("((rdata).data.length==2)", {}, undef)); +is("((rdata).data.length == 2)?0:rr_type", ParseExpr("((rdata).data.length==2)?0:rr_type", {}, undef)); +is("((((rr_type) == NBT_QTYPE_NETBIOS) && talloc_check_name(ndr, \"struct ndr_push\") && ((rdata).data.length == 2))?0:rr_type)", ParseExpr("((((rr_type)==NBT_QTYPE_NETBIOS)&&talloc_check_name(ndr,\"struct ndr_push\")&&((rdata).data.length==2))?0:rr_type)", {}, undef)); -- cgit From 45db1030651e69896fdb9e78aa2e2495a7ce7ff5 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 8 Feb 2007 23:54:31 +0000 Subject: r21253: Merge some pidl fixes: * Add tests for wireshark dissector generator * Add tests for the header code * Some cleanups * Fix handling of elements without [in] or [out] (This used to be commit 1aecba7100685ed291ea13b0ae47fb0cf9e6a6c8) --- source4/pidl/tests/header.pl | 36 +++++++++++++++++++++ source4/pidl/tests/samba-ndr.pl | 23 +++++++++++-- source4/pidl/tests/wireshark-conf.pl | 62 ++++++++++++++++++++++++++++++++++++ 3 files changed, 119 insertions(+), 2 deletions(-) create mode 100755 source4/pidl/tests/header.pl create mode 100755 source4/pidl/tests/wireshark-conf.pl (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/header.pl b/source4/pidl/tests/header.pl new file mode 100755 index 0000000000..e7cd913916 --- /dev/null +++ b/source4/pidl/tests/header.pl @@ -0,0 +1,36 @@ +#!/usr/bin/perl +# (C) 2007 Jelmer Vernooij +# Published under the GNU General Public License +use strict; +use warnings; + +use Test::More tests => 9; +use FindBin qw($RealBin); +use lib "$RealBin"; +use Util; +use Parse::Pidl::Util qw(MyDumper); +use Parse::Pidl::Samba4::Header; +use Parse::Pidl::IDL qw(parse_string); + +sub parse_idl($) +{ + my $text = shift; + my $idl = Parse::Pidl::IDL::parse_string($text, "nofile"); + return Parse::Pidl::Samba4::Header::Parse($idl); +} + +is("/* header auto-generated by pidl */\n\n#include \n\n", parse_idl(""), "includes work"); +is("/* header auto-generated by pidl */\n\n#include \n\n", parse_idl("interface x {}"), "simple empty interface doesn't cause overhead"); +like(parse_idl("interface p { typedef struct { int y; } x; };"), + qr/.*#ifndef _HEADER_p\n#define _HEADER_p\n.+\n#endif \/\* _HEADER_p \*\/.*/ms, "ifdefs are created"); +like(parse_idl("interface p { typedef struct { int y; } x; };"), + qr/struct x.*{.*int32_t y;.*}.*;/sm, "interface member generated properly"); +like(parse_idl("interface x { void foo (void); };"), + qr/struct foo.*{\s+int _dummy_element;\s+};/sm, "void fn contains dummy element"); +like(parse_idl("interface x { void foo ([in] uint32 x); };"), + qr/struct foo.*{\s+struct\s+{\s+uint32_t x;\s+} in;\s+};/sm, "fn in arg works"); +like(parse_idl("interface x { void foo ([out] uint32 x); };"), + qr/struct foo.*{.*struct\s+{\s+uint32_t x;\s+} out;.*};/sm, "fn out arg works"); +like(parse_idl("interface x { void foo ([in,out] uint32 x); };"), + qr/struct foo.*{.*struct\s+{\s+uint32_t x;\s+} in;\s+struct\s+{\s+uint32_t x;\s+} out;.*};/sm, "fn in,out arg works"); +like(parse_idl("interface x { void foo (uint32 x); };"), qr/struct foo.*{.*struct\s+{\s+uint32_t x;\s+} in;\s+struct\s+{\s+uint32_t x;\s+} out;.*};/sm, "fn with no props implies in,out"); diff --git a/source4/pidl/tests/samba-ndr.pl b/source4/pidl/tests/samba-ndr.pl index a3e94bd8b5..a6d74beea9 100755 --- a/source4/pidl/tests/samba-ndr.pl +++ b/source4/pidl/tests/samba-ndr.pl @@ -4,12 +4,12 @@ use strict; use warnings; -use Test::More tests => 10; +use Test::More tests => 16; use FindBin qw($RealBin); use lib "$RealBin"; use Util; use Parse::Pidl::Util qw(MyDumper); -use Parse::Pidl::Samba4::NDR::Parser qw(check_null_pointer); +use Parse::Pidl::Samba4::NDR::Parser qw(check_null_pointer GenerateFunctionInEnv GenerateFunctionOutEnv); my $output; sub print_fn($) { my $x = shift; $output.=$x; } @@ -133,3 +133,22 @@ test_warnings("nofile:2: unknown dereferenced expression `r->in.bla'\n", sub { $fn->("r->in.bla"); }); is($output, "if (r->in.bla == NULL) return;"); + +# Make sure GenerateFunctionInEnv and GenerateFunctionOutEnv work +$fn = { ELEMENTS => [ { DIRECTION => ["in"], NAME => "foo" } ] }; +is_deeply({ "foo" => "r->in.foo" }, GenerateFunctionInEnv($fn)); + +$fn = { ELEMENTS => [ { DIRECTION => ["out"], NAME => "foo" } ] }; +is_deeply({ "foo" => "r->out.foo" }, GenerateFunctionOutEnv($fn)); + +$fn = { ELEMENTS => [ { DIRECTION => ["out", "in"], NAME => "foo" } ] }; +is_deeply({ "foo" => "r->in.foo" }, GenerateFunctionInEnv($fn)); + +$fn = { ELEMENTS => [ { DIRECTION => ["out", "in"], NAME => "foo" } ] }; +is_deeply({ "foo" => "r->out.foo" }, GenerateFunctionOutEnv($fn)); + +$fn = { ELEMENTS => [ { DIRECTION => ["in"], NAME => "foo" } ] }; +is_deeply({ "foo" => "r->in.foo" }, GenerateFunctionOutEnv($fn)); + +$fn = { ELEMENTS => [ { DIRECTION => ["out"], NAME => "foo" } ] }; +is_deeply({ }, GenerateFunctionInEnv($fn)); diff --git a/source4/pidl/tests/wireshark-conf.pl b/source4/pidl/tests/wireshark-conf.pl new file mode 100755 index 0000000000..8601a91ed9 --- /dev/null +++ b/source4/pidl/tests/wireshark-conf.pl @@ -0,0 +1,62 @@ +#!/usr/bin/perl +# (C) 2007 Jelmer Vernooij +# Published under the GNU General Public License +# test parsing wireshark conformance files +use strict; +use warnings; + +use Test::More tests => 20; +use FindBin qw($RealBin); +use lib "$RealBin"; +use Util; +use Parse::Pidl::Util qw(MyDumper); +use Parse::Pidl::Wireshark::Conformance qw(ReadConformanceFH); + +sub parse_conf($) +{ + my $str = shift; + open(TMP, "+>", undef) or die("unable to open temp file"); + print TMP $str; + seek(TMP, 0, 0); + my $data = {}; + ReadConformanceFH(*TMP, $data, "nofile") or return undef; + close(TMP); + return $data; +} + +ok(parse_conf("\n"), undef); +ok(parse_conf(" \n"), undef); +ok(parse_conf("CODE START\nCODE END\n")); +test_warnings("nofile:1: Expecting CODE END\n", sub { is(parse_conf("CODE START\n"), undef); }); +ok(parse_conf("#foobar\n"), undef); +test_warnings("nofile:1: Unknown command `foobar'\n", + sub { ok(parse_conf("foobar\n"), undef); }); + +test_warnings("nofile:1: incomplete HF_RENAME command\n", + sub { parse_conf("HF_RENAME\n"); }); + + +is_deeply(parse_conf("HF_RENAME foo bar\n")->{hf_renames}->{foo}, + { OLDNAME => "foo", NEWNAME => "bar", POS => {FILE => "nofile", LINE => 1}, USED => 0}); + +is_deeply(parse_conf("NOEMIT\n"), { "noemit_dissector" => 1 }); +is_deeply(parse_conf("NOEMIT foo\n"), { "noemit" => { "foo" => 1 } }); + +test_warnings("nofile:1: incomplete MANUAL command\n", + sub { parse_conf("MANUAL\n"); } ); + +is_deeply(parse_conf("MANUAL foo\n"), { manual => {foo => 1}}); + +test_warnings("nofile:1: incomplete FIELD_DESCRIPTION command\n", + sub { parse_conf("FIELD_DESCRIPTION foo\n"); }); + +is_deeply(parse_conf("FIELD_DESCRIPTION foo \"my description\"\n"), + { fielddescription => { foo => { DESCRIPTION => "\"my description\"", POS => { FILE => "nofile", LINE => 1}, USED => 0 }}}); + +is_deeply(parse_conf("FIELD_DESCRIPTION foo my description\n"), + { fielddescription => { foo => { DESCRIPTION => "my", POS => { FILE => "nofile", LINE => 1}, USED => 0 }}}); + +is_deeply(parse_conf("CODE START\ndata\nCODE END\n"), { override => "data\n" }); +is_deeply(parse_conf("CODE START\ndata\nmore data\nCODE END\n"), { override => "data\nmore data\n" }); +test_warnings("nofile:1: Unknown command `CODE'\n", + sub { parse_conf("CODE END\n"); } ); -- cgit From 9ca02af51059244a9b30cda8575b0e535e86f4b9 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 9 Feb 2007 00:18:06 +0000 Subject: r21254: Fix running the testsuite outside pidl/ (This used to be commit 84c15158b986ef9e82f46d6c01d5cbf04300cda5) --- source4/pidl/tests/header.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/header.pl b/source4/pidl/tests/header.pl index e7cd913916..9271c57c4c 100755 --- a/source4/pidl/tests/header.pl +++ b/source4/pidl/tests/header.pl @@ -19,8 +19,8 @@ sub parse_idl($) return Parse::Pidl::Samba4::Header::Parse($idl); } -is("/* header auto-generated by pidl */\n\n#include \n\n", parse_idl(""), "includes work"); -is("/* header auto-generated by pidl */\n\n#include \n\n", parse_idl("interface x {}"), "simple empty interface doesn't cause overhead"); +like(parse_idl(""), qr/\/\* header auto-generated by pidl \*\n\//sm, "includes work"); +like(parse_idl("interface x {}"), qr/\/\* header auto-generated by pidl \*\/\n/sm, "simple empty interface doesn't cause overhead"); like(parse_idl("interface p { typedef struct { int y; } x; };"), qr/.*#ifndef _HEADER_p\n#define _HEADER_p\n.+\n#endif \/\* _HEADER_p \*\/.*/ms, "ifdefs are created"); like(parse_idl("interface p { typedef struct { int y; } x; };"), -- cgit From b619e959c9c8d5a17e882d8b8316a97ec860245b Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 9 Feb 2007 09:44:11 +0000 Subject: r21260: Fix regex. (This used to be commit 025597a3593d9dede93180d284beda256caf9483) --- source4/pidl/tests/header.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/header.pl b/source4/pidl/tests/header.pl index 9271c57c4c..b7c0b285f3 100755 --- a/source4/pidl/tests/header.pl +++ b/source4/pidl/tests/header.pl @@ -19,7 +19,7 @@ sub parse_idl($) return Parse::Pidl::Samba4::Header::Parse($idl); } -like(parse_idl(""), qr/\/\* header auto-generated by pidl \*\n\//sm, "includes work"); +like(parse_idl(""), qr/\/\* header auto-generated by pidl \*\/\n/sm, "includes work"); like(parse_idl("interface x {}"), qr/\/\* header auto-generated by pidl \*\/\n/sm, "simple empty interface doesn't cause overhead"); like(parse_idl("interface p { typedef struct { int y; } x; };"), qr/.*#ifndef _HEADER_p\n#define _HEADER_p\n.+\n#endif \/\* _HEADER_p \*\/.*/ms, "ifdefs are created"); -- cgit From e50dc79226bcb722485019533033500b0e145a46 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 14 Feb 2007 12:44:50 +0000 Subject: r21332: Fix bug in pidl that prevented value(0) from working. Bug reported by metze. (This used to be commit 8212a3b8e0d3d59264f659c3f657b165ececefeb) --- source4/pidl/tests/samba-ndr.pl | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/samba-ndr.pl b/source4/pidl/tests/samba-ndr.pl index a6d74beea9..db261d4492 100755 --- a/source4/pidl/tests/samba-ndr.pl +++ b/source4/pidl/tests/samba-ndr.pl @@ -4,12 +4,12 @@ use strict; use warnings; -use Test::More tests => 16; +use Test::More tests => 20; use FindBin qw($RealBin); use lib "$RealBin"; use Util; use Parse::Pidl::Util qw(MyDumper); -use Parse::Pidl::Samba4::NDR::Parser qw(check_null_pointer GenerateFunctionInEnv GenerateFunctionOutEnv); +use Parse::Pidl::Samba4::NDR::Parser qw(check_null_pointer GenerateFunctionInEnv GenerateFunctionOutEnv GenerateStructEnv EnvSubstituteValue); my $output; sub print_fn($) { my $x = shift; $output.=$x; } @@ -152,3 +152,23 @@ is_deeply({ "foo" => "r->in.foo" }, GenerateFunctionOutEnv($fn)); $fn = { ELEMENTS => [ { DIRECTION => ["out"], NAME => "foo" } ] }; is_deeply({ }, GenerateFunctionInEnv($fn)); + +$fn = { ELEMENTS => [ { NAME => "foo" }, { NAME => "bar" } ] }; +is_deeply({ foo => "r->foo", bar => "r->bar", this => "r" }, GenerateStructEnv($fn)); + +$fn = { ELEMENTS => [ { NAME => "foo", PROPERTIES => { value => 3 }} ] }; + +my $env = GenerateStructEnv($fn); +EnvSubstituteValue($env, $fn); +is_deeply($env, { foo => 3, this => "r" }); + +$fn = { ELEMENTS => [ { NAME => "foo" }, { NAME => "bar" } ] }; +$env = GenerateStructEnv($fn); +EnvSubstituteValue($env, $fn); +is_deeply($env, { foo => 'r->foo', bar => 'r->bar', this => "r" }); + +$fn = { ELEMENTS => [ { NAME => "foo", PROPERTIES => { value => 0 }} ] }; + +$env = GenerateStructEnv($fn); +EnvSubstituteValue($env, $fn); +is_deeply($env, { foo => 0, this => "r" }); -- cgit From a7fa0d7063dd8abe5d9cdb3721fe0733983f5310 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 14 Feb 2007 14:23:59 +0000 Subject: r21338: Fix handling of top-level arrays for the Samba 3 client code. This doesn't fix the winreg code yet (as that's an array on top of a pointer), but at least it gets us closer. Also added a couple of tests for the Samba 3 client code. (This used to be commit 4a5b62ad622d7be08591e19bc2e89f665fff445a) --- source4/pidl/tests/samba3-cli.pl | 56 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100755 source4/pidl/tests/samba3-cli.pl (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/samba3-cli.pl b/source4/pidl/tests/samba3-cli.pl new file mode 100755 index 0000000000..1d1bae8550 --- /dev/null +++ b/source4/pidl/tests/samba3-cli.pl @@ -0,0 +1,56 @@ +#!/usr/bin/perl +# (C) 2007 Jelmer Vernooij +# Published under the GNU General Public License +use strict; +use warnings; + +use Test::More tests => 4; +use FindBin qw($RealBin); +use lib "$RealBin"; +use Util; +use Parse::Pidl::Util qw(MyDumper); +use Parse::Pidl::Samba3::ClientNDR qw(GenerateFunctionInEnv ParseFunction $res + $res_hdr); + +# Make sure GenerateFunctionInEnv and GenerateFunctionOutEnv work +my $fn = { ELEMENTS => [ { DIRECTION => ["in"], NAME => "foo" } ] }; +is_deeply({ "foo" => "r.in.foo" }, GenerateFunctionInEnv($fn)); + +$fn = { ELEMENTS => [ { DIRECTION => ["out", "in"], NAME => "foo" } ] }; +is_deeply({ "foo" => "r.in.foo" }, GenerateFunctionInEnv($fn)); + +$fn = { ELEMENTS => [ { DIRECTION => ["out"], NAME => "foo" } ] }; +is_deeply({ }, GenerateFunctionInEnv($fn)); + +$fn = { NAME => "bar", ELEMENTS => [ ] }; +ParseFunction("foo", $fn); +is($res, "NTSTATUS rpccli_bar(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx) +{ +\tstruct bar r; +\tNTSTATUS status; +\t +\t/* In parameters */ +\t +\tif (DEBUGLEVEL >= 10) +\t\tNDR_PRINT_IN_DEBUG(bar, &r); +\t +\tstatus = cli_do_rpc_ndr(cli, mem_ctx, PI_foo, DCERPC_BAR, &r, (ndr_pull_flags_fn_t)ndr_pull_bar, (ndr_push_flags_fn_t)ndr_push_bar); +\t +\tif (!NT_STATUS_IS_OK(status)) { +\t\treturn status; +\t} +\t +\tif (DEBUGLEVEL >= 10) +\t\tNDR_PRINT_OUT_DEBUG(bar, &r); +\t +\tif (NT_STATUS_IS_ERR(status)) { +\t\treturn status; +\t} +\t +\t/* Return variables */ +\t +\t/* Return result */ +\treturn NT_STATUS_OK; +} + +"); -- cgit From ec587914ed4df87b6aedab129fb59248b137f07b Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 17 Feb 2007 23:38:57 +0000 Subject: r21411: Add some simple tests for the wireshark NDR generator. (This used to be commit 361977448210dfd889abca19b520cd259b9d0855) --- source4/pidl/tests/wireshark-ndr.pl | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100755 source4/pidl/tests/wireshark-ndr.pl (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/wireshark-ndr.pl b/source4/pidl/tests/wireshark-ndr.pl new file mode 100755 index 0000000000..574060f8ea --- /dev/null +++ b/source4/pidl/tests/wireshark-ndr.pl @@ -0,0 +1,23 @@ +#!/usr/bin/perl +# (C) 2007 Jelmer Vernooij +# Published under the GNU General Public License +# test parsing wireshark conformance files +use strict; +use warnings; + +use Test::More tests => 3; +use FindBin qw($RealBin); +use lib "$RealBin"; +use Util; +use Parse::Pidl::Util qw(MyDumper); +use Parse::Pidl::Wireshark::NDR qw(field2name %res PrintIdl); + +is("Access Mask", field2name("access_mask")); +is("Accessmask", field2name("AccessMask")); + +$res{code} = ""; +PrintIdl("foo\nbar\n"); +is("/* IDL: foo */ +/* IDL: bar */ + +", $res{code}); -- cgit From ae76a5a92819bfd2d31bc5d23a540c6c71b47354 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 18 Feb 2007 12:54:03 +0000 Subject: r21427: Add tests for Needed*(), in preparation of refactoring. (This used to be commit a21e7b22ac99c66e2b23d0fa694a8a2ea6e7994e) --- source4/pidl/tests/samba-ndr.pl | 60 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 58 insertions(+), 2 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/samba-ndr.pl b/source4/pidl/tests/samba-ndr.pl index db261d4492..f64a8c4093 100755 --- a/source4/pidl/tests/samba-ndr.pl +++ b/source4/pidl/tests/samba-ndr.pl @@ -4,12 +4,14 @@ use strict; use warnings; -use Test::More tests => 20; +use Test::More tests => 29; use FindBin qw($RealBin); use lib "$RealBin"; use Util; use Parse::Pidl::Util qw(MyDumper); -use Parse::Pidl::Samba4::NDR::Parser qw(check_null_pointer GenerateFunctionInEnv GenerateFunctionOutEnv GenerateStructEnv EnvSubstituteValue); +use Parse::Pidl::Samba4::NDR::Parser qw(check_null_pointer + GenerateFunctionInEnv GenerateFunctionOutEnv GenerateStructEnv + EnvSubstituteValue NeededFunction NeededElement NeededTypedef); my $output; sub print_fn($) { my $x = shift; $output.=$x; } @@ -172,3 +174,57 @@ $fn = { ELEMENTS => [ { NAME => "foo", PROPERTIES => { value => 0 }} ] }; $env = GenerateStructEnv($fn); EnvSubstituteValue($env, $fn); is_deeply($env, { foo => 0, this => "r" }); + +my $needed = {}; +NeededElement({ TYPE => "foo" }, "pull", $needed); +is_deeply($needed, { pull_foo => 1 }); + +# old settings should be kept +$needed = { pull_foo => 0 }; +NeededElement({ TYPE => "foo" }, "pull", $needed); +is_deeply($needed, { pull_foo => 0 }); + +# print/pull/push are independent of each other +$needed = { pull_foo => 0 }; +NeededElement({ TYPE => "foo" }, "print", $needed); +is_deeply($needed, { pull_foo => 0, print_foo => 1 }); + +$needed = { }; +NeededFunction({ NAME => "foo", ELEMENTS => [ { TYPE => "bar" } ] }, $needed); +is_deeply($needed, { pull_foo => 1, print_foo => 1, push_foo => 1, + pull_bar => 1, print_bar => 1, push_bar => 1}); + +# push/pull/print are always set for functions +$needed = { pull_foo => 0 }; +NeededFunction({ NAME => "foo", ELEMENTS => [ { TYPE => "bar" } ] }, $needed); +is_deeply($needed, { pull_foo => 1, print_foo => 1, push_foo => 1, + pull_bar => 1, push_bar => 1, print_bar => 1}); + +# public structs are always needed +$needed = {}; +NeededTypedef({ NAME => "bla", DATA => { TYPE => "STRUCT", ELEMENTS => [] } }, + $needed); +is_deeply($needed, { }); + +$needed = {}; +NeededTypedef({ PROPERTIES => { public => 1 }, NAME => "bla", + DATA => { TYPE => "STRUCT", ELEMENTS => [] } }, + $needed); +is_deeply($needed, { pull_bla => 1, print_bla => 1, push_bla => 1 }); + +# make sure types for elements are set too +$needed = {}; +NeededTypedef({ PROPERTIES => { public => 1 }, NAME => "bla", + DATA => { TYPE => "STRUCT", + ELEMENTS => [ { TYPE => "bar" } ] } }, + $needed); +is_deeply($needed, { pull_bla => 1, print_bla => 1, push_bla => 1, + pull_bar => 1, print_bar => 1, push_bar => 1}); + +$needed = {}; +NeededTypedef({ PROPERTIES => { gensize => 1}, NAME => "bla", + DATA => { TYPE => "STRUCT", + ELEMENTS => [ { TYPE => "bar" } ] } }, + $needed); +is_deeply($needed, { ndr_size_bla => 1 }); + -- cgit From 2b43de2ed8025ef598c31d41f0fe710f8e3a3658 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 18 Feb 2007 13:44:01 +0000 Subject: r21428: Handle representation types in Needed(). (This used to be commit 34517c69e67d7eafa00e6fe0072bd04f074cdbde) --- source4/pidl/tests/ndr.pl | 28 +++++++++++++++++++++++++++- source4/pidl/tests/samba-ndr.pl | 34 ++++++++++++++++++++++++++-------- 2 files changed, 53 insertions(+), 9 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/ndr.pl b/source4/pidl/tests/ndr.pl index da22949c6d..baf06b1eae 100755 --- a/source4/pidl/tests/ndr.pl +++ b/source4/pidl/tests/ndr.pl @@ -4,7 +4,7 @@ use strict; use warnings; -use Test::More tests => 10; +use Test::More tests => 12; use FindBin qw($RealBin); use lib "$RealBin"; use Util; @@ -189,3 +189,29 @@ is_deeply(GetElementLevelTable($e), [ 'CONVERT_TO' => undef } ]); + +# representation_type +$e = { + 'FILE' => 'foo.idl', + 'NAME' => 'v', + 'PROPERTIES' => { represent_as => "bar" }, + 'POINTERS' => 0, + 'TYPE' => 'uint8', + 'PARENT' => { TYPE => 'STRUCT' }, + 'LINE' => 42 }; + +$ne = ParseElement($e); +is($ne->{REPRESENTATION_TYPE}, "bar"); + +# representation_type +$e = { + 'FILE' => 'foo.idl', + 'NAME' => 'v', + 'PROPERTIES' => { }, + 'POINTERS' => 0, + 'TYPE' => 'uint8', + 'PARENT' => { TYPE => 'STRUCT' }, + 'LINE' => 42 }; + +$ne = ParseElement($e); +is($ne->{REPRESENTATION_TYPE}, "uint8"); diff --git a/source4/pidl/tests/samba-ndr.pl b/source4/pidl/tests/samba-ndr.pl index f64a8c4093..1f859db788 100755 --- a/source4/pidl/tests/samba-ndr.pl +++ b/source4/pidl/tests/samba-ndr.pl @@ -4,7 +4,7 @@ use strict; use warnings; -use Test::More tests => 29; +use Test::More tests => 31; use FindBin qw($RealBin); use lib "$RealBin"; use Util; @@ -176,27 +176,27 @@ EnvSubstituteValue($env, $fn); is_deeply($env, { foo => 0, this => "r" }); my $needed = {}; -NeededElement({ TYPE => "foo" }, "pull", $needed); +NeededElement({ TYPE => "foo", REPRESENTATION_TYPE => "foo" }, "pull", $needed); is_deeply($needed, { pull_foo => 1 }); # old settings should be kept $needed = { pull_foo => 0 }; -NeededElement({ TYPE => "foo" }, "pull", $needed); +NeededElement({ TYPE => "foo", REPRESENTATION_TYPE => "foo" }, "pull", $needed); is_deeply($needed, { pull_foo => 0 }); # print/pull/push are independent of each other $needed = { pull_foo => 0 }; -NeededElement({ TYPE => "foo" }, "print", $needed); +NeededElement({ TYPE => "foo", REPRESENTATION_TYPE => "foo" }, "print", $needed); is_deeply($needed, { pull_foo => 0, print_foo => 1 }); $needed = { }; -NeededFunction({ NAME => "foo", ELEMENTS => [ { TYPE => "bar" } ] }, $needed); +NeededFunction({ NAME => "foo", ELEMENTS => [ { TYPE => "bar", REPRESENTATION_TYPE => "bar" } ] }, $needed); is_deeply($needed, { pull_foo => 1, print_foo => 1, push_foo => 1, pull_bar => 1, print_bar => 1, push_bar => 1}); # push/pull/print are always set for functions $needed = { pull_foo => 0 }; -NeededFunction({ NAME => "foo", ELEMENTS => [ { TYPE => "bar" } ] }, $needed); +NeededFunction({ NAME => "foo", ELEMENTS => [ { TYPE => "bar", REPRESENTATION_TYPE => "bar" } ] }, $needed); is_deeply($needed, { pull_foo => 1, print_foo => 1, push_foo => 1, pull_bar => 1, push_bar => 1, print_bar => 1}); @@ -216,7 +216,7 @@ is_deeply($needed, { pull_bla => 1, print_bla => 1, push_bla => 1 }); $needed = {}; NeededTypedef({ PROPERTIES => { public => 1 }, NAME => "bla", DATA => { TYPE => "STRUCT", - ELEMENTS => [ { TYPE => "bar" } ] } }, + ELEMENTS => [ { TYPE => "bar", REPRESENTATION_TYPE => "bar" } ] } }, $needed); is_deeply($needed, { pull_bla => 1, print_bla => 1, push_bla => 1, pull_bar => 1, print_bar => 1, push_bar => 1}); @@ -224,7 +224,25 @@ is_deeply($needed, { pull_bla => 1, print_bla => 1, push_bla => 1, $needed = {}; NeededTypedef({ PROPERTIES => { gensize => 1}, NAME => "bla", DATA => { TYPE => "STRUCT", - ELEMENTS => [ { TYPE => "bar" } ] } }, + ELEMENTS => [ { TYPE => "bar", REPRESENTATION_TYPE => "bar" } ] } }, $needed); is_deeply($needed, { ndr_size_bla => 1 }); +# make sure types for elements are set too +$needed = { pull_bla => 1 }; +NeededTypedef({ NAME => "bla", + DATA => { TYPE => "STRUCT", + ELEMENTS => [ { TYPE => "bar", REPRESENTATION_TYPE => "bar" } ] } }, + $needed); +is_deeply($needed, { pull_bla => 1, pull_bar => 1 }); + +$needed = {}; +NeededTypedef({ PROPERTIES => { public => 1}, + NAME => "bla", + DATA => { TYPE => "STRUCT", + ELEMENTS => [ { TYPE => "bar", REPRESENTATION_TYPE => "rep" } ] } }, + $needed); +is_deeply($needed, { pull_bla => 1, push_bla => 1, print_bla => 1, print_rep => 1, + pull_bar => 1, push_bar => 1, + ndr_bar_to_rep => 1, ndr_rep_to_bar => 1}); + -- cgit From 8cf122c2d2a0913fd9a7c55032c549598844111c Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 18 Feb 2007 16:21:28 +0000 Subject: r21430: Support tagged types without typedef. This means: struct foo { ... }; in IDL will now work. This is the first step towards nested types and using typedefs for partial types (such as "typedef int *bar;"), a requirement for complex uses of represent_as(). (This used to be commit a716aa70f0c90898e6fcf57d63a2cf4c40e7d4df) --- source4/pidl/tests/Util.pm | 1 - source4/pidl/tests/header.pl | 4 +++- source4/pidl/tests/ndr_deprecations.pl | 2 -- source4/pidl/tests/ndr_tagtype.pl | 12 +----------- source4/pidl/tests/parse_idl.pl | 6 +++++- source4/pidl/tests/samba-ndr.pl | 14 +++++++------- 6 files changed, 16 insertions(+), 23 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/Util.pm b/source4/pidl/tests/Util.pm index a406b868e1..a65cd89c55 100644 --- a/source4/pidl/tests/Util.pm +++ b/source4/pidl/tests/Util.pm @@ -91,7 +91,6 @@ SKIP: { my $cmd = "$cc $cflags -x c - -o $outfile $flags $ldflags"; $cmd =~ s/\n//g; - print "$cmd\n"; open CC, "|$cmd"; print CC "#define uint_t unsigned int\n"; print CC "#define _GNU_SOURCE\n"; diff --git a/source4/pidl/tests/header.pl b/source4/pidl/tests/header.pl index b7c0b285f3..3dae33ae6c 100755 --- a/source4/pidl/tests/header.pl +++ b/source4/pidl/tests/header.pl @@ -4,7 +4,7 @@ use strict; use warnings; -use Test::More tests => 9; +use Test::More tests => 10; use FindBin qw($RealBin); use lib "$RealBin"; use Util; @@ -34,3 +34,5 @@ like(parse_idl("interface x { void foo ([out] uint32 x); };"), like(parse_idl("interface x { void foo ([in,out] uint32 x); };"), qr/struct foo.*{.*struct\s+{\s+uint32_t x;\s+} in;\s+struct\s+{\s+uint32_t x;\s+} out;.*};/sm, "fn in,out arg works"); like(parse_idl("interface x { void foo (uint32 x); };"), qr/struct foo.*{.*struct\s+{\s+uint32_t x;\s+} in;\s+struct\s+{\s+uint32_t x;\s+} out;.*};/sm, "fn with no props implies in,out"); +like(parse_idl("interface p { struct x { int y; }; };"), + qr/struct x.*{.*int32_t y;.*}.*;/sm, "interface member generated properly"); diff --git a/source4/pidl/tests/ndr_deprecations.pl b/source4/pidl/tests/ndr_deprecations.pl index 89738e42f6..86828e5982 100755 --- a/source4/pidl/tests/ndr_deprecations.pl +++ b/source4/pidl/tests/ndr_deprecations.pl @@ -24,5 +24,3 @@ my $e = { test_warnings("foo.idl:42: subcontext() is deprecated. Use represent_as() or transmit_as() instead\n", sub { ValidElement($e); }); - - diff --git a/source4/pidl/tests/ndr_tagtype.pl b/source4/pidl/tests/ndr_tagtype.pl index a7f7d0490a..067fa096b4 100755 --- a/source4/pidl/tests/ndr_tagtype.pl +++ b/source4/pidl/tests/ndr_tagtype.pl @@ -8,15 +8,7 @@ use FindBin qw($RealBin); use lib "$RealBin"; use Util qw(test_samba4_ndr); -SKIP: { - skip "Tagged types without typedef are not supported yet", 8; - -test_samba4_ndr('struct-notypedef', -' - struct bla { - uint8 x; - }; -', +test_samba4_ndr('struct-notypedef', '[public] struct bla { uint8 x; }; ', ' struct ndr_push *ndr = ndr_push_init_ctx(NULL); struct bla r; @@ -33,5 +25,3 @@ test_samba4_ndr('struct-notypedef', if (!data_blob_equal(&result_blob, &expected_blob)) return 2; '); - -} diff --git a/source4/pidl/tests/parse_idl.pl b/source4/pidl/tests/parse_idl.pl index 859c2b4e46..265ac7a2bd 100755 --- a/source4/pidl/tests/parse_idl.pl +++ b/source4/pidl/tests/parse_idl.pl @@ -4,7 +4,7 @@ # Published under the GNU General Public License use strict; -use Test::More tests => 59 * 2; +use Test::More tests => 62 * 2; use FindBin qw($RealBin); use lib "$RealBin"; use Util qw(test_errors); @@ -83,8 +83,12 @@ testok "nested1", "interface test { struct x { struct { int a; } z; }; };"; testok "nested2", "interface test { struct x { struct y { int a; } z; }; };"; testok "bitmap1", "interface test { bitmap x { a=1 }; };"; testok "unsigned", "interface test { struct x { unsigned short y; }; };"; +testok "struct-property", "interface test { [public] struct x { short y; }; };"; testok "signed", "interface test { struct x { signed short y; }; };"; testok "declarg", "interface test { void test(struct { int x; } a); };"; +testok "structarg", "interface test { void test(struct a b); };"; +testfail "structargmissing", "interface test { void test(struct a); };", + ":0: Syntax error near ')'\n"; testok "structqual", "interface test { struct x { struct y z; }; };"; testok "unionqual", "interface test { struct x { union y z; }; };"; testok "enumqual", "interface test { struct x { enum y z; }; };"; diff --git a/source4/pidl/tests/samba-ndr.pl b/source4/pidl/tests/samba-ndr.pl index 1f859db788..50b0bd269f 100755 --- a/source4/pidl/tests/samba-ndr.pl +++ b/source4/pidl/tests/samba-ndr.pl @@ -11,7 +11,7 @@ use Util; use Parse::Pidl::Util qw(MyDumper); use Parse::Pidl::Samba4::NDR::Parser qw(check_null_pointer GenerateFunctionInEnv GenerateFunctionOutEnv GenerateStructEnv - EnvSubstituteValue NeededFunction NeededElement NeededTypedef); + EnvSubstituteValue NeededFunction NeededElement NeededType); my $output; sub print_fn($) { my $x = shift; $output.=$x; } @@ -202,19 +202,19 @@ is_deeply($needed, { pull_foo => 1, print_foo => 1, push_foo => 1, # public structs are always needed $needed = {}; -NeededTypedef({ NAME => "bla", DATA => { TYPE => "STRUCT", ELEMENTS => [] } }, +NeededType({ NAME => "bla", DATA => { TYPE => "STRUCT", ELEMENTS => [] } }, $needed); is_deeply($needed, { }); $needed = {}; -NeededTypedef({ PROPERTIES => { public => 1 }, NAME => "bla", +NeededType({ PROPERTIES => { public => 1 }, NAME => "bla", DATA => { TYPE => "STRUCT", ELEMENTS => [] } }, $needed); is_deeply($needed, { pull_bla => 1, print_bla => 1, push_bla => 1 }); # make sure types for elements are set too $needed = {}; -NeededTypedef({ PROPERTIES => { public => 1 }, NAME => "bla", +NeededType({ PROPERTIES => { public => 1 }, NAME => "bla", DATA => { TYPE => "STRUCT", ELEMENTS => [ { TYPE => "bar", REPRESENTATION_TYPE => "bar" } ] } }, $needed); @@ -222,7 +222,7 @@ is_deeply($needed, { pull_bla => 1, print_bla => 1, push_bla => 1, pull_bar => 1, print_bar => 1, push_bar => 1}); $needed = {}; -NeededTypedef({ PROPERTIES => { gensize => 1}, NAME => "bla", +NeededType({ PROPERTIES => { gensize => 1}, NAME => "bla", DATA => { TYPE => "STRUCT", ELEMENTS => [ { TYPE => "bar", REPRESENTATION_TYPE => "bar" } ] } }, $needed); @@ -230,14 +230,14 @@ is_deeply($needed, { ndr_size_bla => 1 }); # make sure types for elements are set too $needed = { pull_bla => 1 }; -NeededTypedef({ NAME => "bla", +NeededType({ NAME => "bla", DATA => { TYPE => "STRUCT", ELEMENTS => [ { TYPE => "bar", REPRESENTATION_TYPE => "bar" } ] } }, $needed); is_deeply($needed, { pull_bla => 1, pull_bar => 1 }); $needed = {}; -NeededTypedef({ PROPERTIES => { public => 1}, +NeededType({ PROPERTIES => { public => 1}, NAME => "bla", DATA => { TYPE => "STRUCT", ELEMENTS => [ { TYPE => "bar", REPRESENTATION_TYPE => "rep" } ] } }, -- cgit From f9885687878560c21c569a850cb7023b062b4e33 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 18 Feb 2007 16:46:59 +0000 Subject: r21431: More tests, work on support in wireshark for tagged types. (This used to be commit a91e624af22aae5b460ccf94d2540b8780f90070) --- source4/pidl/tests/dump.pl | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100755 source4/pidl/tests/dump.pl (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/dump.pl b/source4/pidl/tests/dump.pl new file mode 100755 index 0000000000..d1a56f0973 --- /dev/null +++ b/source4/pidl/tests/dump.pl @@ -0,0 +1,15 @@ +#!/usr/bin/perl +# (C) 2007 Jelmer Vernooij +# Published under the GNU General Public License +use strict; +use warnings; + +use Test::More tests => 1; +use FindBin qw($RealBin); +use lib "$RealBin"; +use Util; +use Parse::Pidl::Dump qw(DumpStruct); + +is (DumpStruct({ NAME => "foo", ELEMENTS => []}), + "struct foo {\n}"); + -- cgit From 0515f728e64dde0c197aee6180dce79ad281d5f8 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 18 Feb 2007 18:44:56 +0000 Subject: r21433: Get rid of the COM support code - it's not used and unmaintained. We can always bring it back if we need to. This code was getting in the way while refactoring. Add some tests for TDR. Get rid of typedef in lib/registry/tdr_regf.idl and fix the TDR code to be able to deal with it. (This used to be commit 1ad0f99a439f0d52a735b391bf9900d50171aca5) --- source4/pidl/tests/tdr.pl | 48 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100755 source4/pidl/tests/tdr.pl (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/tdr.pl b/source4/pidl/tests/tdr.pl new file mode 100755 index 0000000000..35e54f53fc --- /dev/null +++ b/source4/pidl/tests/tdr.pl @@ -0,0 +1,48 @@ +#!/usr/bin/perl +# (C) 2007 Jelmer Vernooij +# Published under the GNU General Public License +use strict; +use warnings; + +use Test::More tests => 6; +use FindBin qw($RealBin); +use lib "$RealBin"; +use Util; +use Parse::Pidl::Samba4::TDR qw($ret $ret_hdr ParserType); + +ParserType({TYPE => "STRUCT", NAME => "foo", PROPERTIES => {public => 1}}, "pull"); +is($ret, "NTSTATUS tdr_pull_foo (struct tdr_pull *tdr, TALLOC_CTX *mem_ctx, struct foo *v) +{ + return NT_STATUS_OK; +} + +"); +is($ret_hdr, "NTSTATUS tdr_pull_foo (struct tdr_pull *tdr, TALLOC_CTX *mem_ctx, struct foo *v);\n"); + +$ret = ""; $ret_hdr = ""; + +ParserType({TYPE => "UNION", NAME => "bar", PROPERTIES => {public => 1}}, "pull"); +is($ret, "NTSTATUS tdr_pull_bar(struct tdr_pull *tdr, TALLOC_CTX *mem_ctx, int level, union bar *v) +{ + switch (level) { + } + return NT_STATUS_OK; + +} + +"); +is($ret_hdr, "NTSTATUS tdr_pull_bar(struct tdr_pull *tdr, TALLOC_CTX *mem_ctx, int level, union bar *v);\n"); + +$ret = ""; $ret_hdr = ""; + +ParserType({TYPE => "UNION", NAME => "bar", PROPERTIES => {}}, "pull"); +is($ret, "static NTSTATUS tdr_pull_bar(struct tdr_pull *tdr, TALLOC_CTX *mem_ctx, int level, union bar *v) +{ + switch (level) { + } + return NT_STATUS_OK; + +} + +"); +is($ret_hdr, ""); -- cgit From 127ccc27d45f4da84a6687562f50d733a011adfe Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 18 Feb 2007 23:48:16 +0000 Subject: r21437: Cherrypick typelib tests. (This used to be commit 9ba814d033412150d383d3687f02775d4efc618e) --- source4/pidl/tests/typelist.pl | 59 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100755 source4/pidl/tests/typelist.pl (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/typelist.pl b/source4/pidl/tests/typelist.pl new file mode 100755 index 0000000000..5c1a7ddd21 --- /dev/null +++ b/source4/pidl/tests/typelist.pl @@ -0,0 +1,59 @@ +#!/usr/bin/perl +# (C) 2007 Jelmer Vernooij +# Published under the GNU General Public License +use strict; +use warnings; + +use Test::More tests => 33; +use FindBin qw($RealBin); +use lib "$RealBin"; +use Util; +use Parse::Pidl::Typelist qw(hasType getType mapTypeName expandAlias + mapScalarType addType typeIs is_scalar scalar_is_reference + enum_type_fn bitmap_type_fn mapType); + +is("foo", expandAlias("foo")); +is("uint32", expandAlias("DWORD")); +is("int32", expandAlias("int")); +is("", expandAlias("")); +is("int32", expandAlias("int32")); + +is("uint32_t", mapScalarType("uint32")); +is("void", mapScalarType("void")); +is("uint64_t", mapScalarType("hyper")); + +my $x = { TYPE => "ENUM", NAME => "foo" }; +addType($x); +is($x, getType("foo")); +is(undef, getType("bloebla")); + +is(0, typeIs("someUnknownType", "ENUM")); + +is(1, hasType("foo")); +is(0, hasType("nonexistant")); + +is(1, is_scalar("uint32")); +is(0, is_scalar("nonexistant")); + +is(1, scalar_is_reference("string")); +is(0, scalar_is_reference("uint32")); + +is("uint8", enum_type_fn({TYPE => "ENUM", PARENT=>{PROPERTIES => {enum8bit => 1}}})); +is("uint32", enum_type_fn({TYPE => "ENUM", PARENT=>{PROPERTIES => {v1_enum => 1}}})); +is("uint16", enum_type_fn({TYPE => "ENUM", PARENT=>{PROPERTIES => {}}})); + +is("uint8", bitmap_type_fn({TYPE => "BITMAP", PROPERTIES => {bitmap8bit => 1}})); +is("uint16", bitmap_type_fn({TYPE => "BITMAP", PROPERTIES => {bitmap16bit => 1}})); +is("hyper", bitmap_type_fn({TYPE => "BITMAP", PROPERTIES => {bitmap64bit => 1}})); +is("uint32", bitmap_type_fn({TYPE => "BITMAP", PROPERTIES => {}})); + +is("enum foo", mapType({TYPE => "ENUM"}, "foo")); +is("union foo", mapType({TYPE => "UNION"}, "foo")); +is("struct foo", mapType({TYPE => "STRUCT"}, "foo")); +is("uint8_t", mapType({TYPE => "BITMAP", PROPERTIES => {bitmap8bit => 1}}, "foo")); +is("uint8_t", mapType({TYPE => "SCALAR"}, "uint8")); +is("uint32_t", mapType({TYPE => "TYPEDEF", DATA => {TYPE => "SCALAR"}}, "uint32")); + +is("void", mapTypeName(undef)); +is("uint32_t", mapTypeName("uint32")); +is("int32_t", mapTypeName("int")); -- cgit From 5340489807985b3bb4c10eacfa701d643ee7a36c Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 18 Feb 2007 23:57:26 +0000 Subject: r21440: Support different variables in environments. (This used to be commit 1702a663ba4ce6f5803e265a969f2be564fce1e3) --- source4/pidl/tests/samba-ndr.pl | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/samba-ndr.pl b/source4/pidl/tests/samba-ndr.pl index 50b0bd269f..28b41e4486 100755 --- a/source4/pidl/tests/samba-ndr.pl +++ b/source4/pidl/tests/samba-ndr.pl @@ -4,7 +4,7 @@ use strict; use warnings; -use Test::More tests => 31; +use Test::More tests => 32; use FindBin qw($RealBin); use lib "$RealBin"; use Util; @@ -156,22 +156,29 @@ $fn = { ELEMENTS => [ { DIRECTION => ["out"], NAME => "foo" } ] }; is_deeply({ }, GenerateFunctionInEnv($fn)); $fn = { ELEMENTS => [ { NAME => "foo" }, { NAME => "bar" } ] }; -is_deeply({ foo => "r->foo", bar => "r->bar", this => "r" }, GenerateStructEnv($fn)); +is_deeply({ foo => "r->foo", bar => "r->bar", this => "r" }, + GenerateStructEnv($fn, "r")); + +$fn = { ELEMENTS => [ { NAME => "foo" }, { NAME => "bar" } ] }; +is_deeply({ foo => "some->complex.variable->foo", + bar => "some->complex.variable->bar", + this => "some->complex.variable" }, + GenerateStructEnv($fn, "some->complex.variable")); $fn = { ELEMENTS => [ { NAME => "foo", PROPERTIES => { value => 3 }} ] }; -my $env = GenerateStructEnv($fn); +my $env = GenerateStructEnv($fn, "r"); EnvSubstituteValue($env, $fn); is_deeply($env, { foo => 3, this => "r" }); $fn = { ELEMENTS => [ { NAME => "foo" }, { NAME => "bar" } ] }; -$env = GenerateStructEnv($fn); +$env = GenerateStructEnv($fn, "r"); EnvSubstituteValue($env, $fn); is_deeply($env, { foo => 'r->foo', bar => 'r->bar', this => "r" }); $fn = { ELEMENTS => [ { NAME => "foo", PROPERTIES => { value => 0 }} ] }; -$env = GenerateStructEnv($fn); +$env = GenerateStructEnv($fn, "r"); EnvSubstituteValue($env, $fn); is_deeply($env, { foo => 0, this => "r" }); -- cgit From 29cdad41817f5bb3c9c79c4cbb8f94244b21b9e1 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 19 Feb 2007 19:42:51 +0000 Subject: r21455: Fix a bug in our handling of conformant arrays. The conformant array was always pushed, even if just the buffers part of a struct had to be pushed. Pull was not affected. (This used to be commit ffe387920473fb365f740942098085eb40299c84) --- source4/pidl/tests/samba-ndr.pl | 42 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/samba-ndr.pl b/source4/pidl/tests/samba-ndr.pl index 28b41e4486..a528265e64 100755 --- a/source4/pidl/tests/samba-ndr.pl +++ b/source4/pidl/tests/samba-ndr.pl @@ -4,14 +4,14 @@ use strict; use warnings; -use Test::More tests => 32; +use Test::More tests => 34; use FindBin qw($RealBin); use lib "$RealBin"; use Util; use Parse::Pidl::Util qw(MyDumper); use Parse::Pidl::Samba4::NDR::Parser qw(check_null_pointer GenerateFunctionInEnv GenerateFunctionOutEnv GenerateStructEnv - EnvSubstituteValue NeededFunction NeededElement NeededType); + EnvSubstituteValue NeededFunction NeededElement NeededType $res); my $output; sub print_fn($) { my $x = shift; $output.=$x; } @@ -253,3 +253,41 @@ is_deeply($needed, { pull_bla => 1, push_bla => 1, print_bla => 1, print_rep => pull_bar => 1, push_bar => 1, ndr_bar_to_rep => 1, ndr_rep_to_bar => 1}); +$res = ""; +Parse::Pidl::Samba4::NDR::Parser::ParseStructPush({ + NAME => "mystruct", + TYPE => "STRUCT", + PROPERTIES => {}, + ALIGN => 4, + ELEMENTS => [ ]}, "mystruct", "x"); +is($res, "if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); +} +if (ndr_flags & NDR_BUFFERS) { +} +"); + +$res = ""; +my $e = { + NAME => "el1", + TYPE => "mytype", + REPRESENTATION_TYPE => "mytype", + PROPERTIES => {}, + LEVELS => [ + { LEVEL_INDEX => 0, TYPE => "DATA", DATA_TYPE => "mytype" } +] }; +Parse::Pidl::Samba4::NDR::Parser::ParseStructPush({ + NAME => "mystruct", + TYPE => "STRUCT", + PROPERTIES => {}, + ALIGN => 4, + SURROUNDING_ELEMENT => $e, + ELEMENTS => [ $e ]}, "mystruct", "x"); +is($res, "if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_string_array_size(ndr, x->el1))); + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_mytype(ndr, NDR_SCALARS, &x->el1)); +} +if (ndr_flags & NDR_BUFFERS) { +} +"); -- cgit From 4e757aa64c76a4d15db88cfb20cf118cc739789d Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 19 Feb 2007 22:10:23 +0000 Subject: r21457: Cope with anonymous nested types in the NDR layer. This doesn't handled named nested types yet, as these have to be registered. (This used to be commit 9b0416b5d06286c81c73477a24cb591fd4b23d18) --- source4/pidl/tests/ndr.pl | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/ndr.pl b/source4/pidl/tests/ndr.pl index baf06b1eae..26fb6c290b 100755 --- a/source4/pidl/tests/ndr.pl +++ b/source4/pidl/tests/ndr.pl @@ -27,15 +27,13 @@ is_deeply(GetElementLevelTable($e), [ 'IS_DEFERRED' => 0, 'LEVEL_INDEX' => 0, 'DATA_TYPE' => 'uint8', - 'CONVERT_FROM' => undef, 'CONTAINS_DEFERRED' => 0, 'TYPE' => 'DATA', 'IS_SURROUNDING' => 0, - 'CONVERT_TO' => undef } ]); -my $ne = ParseElement($e); +my $ne = ParseElement($e, undef); is($ne->{ORIGINAL}, $e); is($ne->{NAME}, "v"); is($ne->{ALIGN}, 1); @@ -45,11 +43,9 @@ is_deeply($ne->{LEVELS}, [ 'IS_DEFERRED' => 0, 'LEVEL_INDEX' => 0, 'DATA_TYPE' => 'uint8', - 'CONVERT_FROM' => undef, 'CONTAINS_DEFERRED' => 0, 'TYPE' => 'DATA', 'IS_SURROUNDING' => 0, - 'CONVERT_TO' => undef } ]); @@ -77,11 +73,9 @@ is_deeply(GetElementLevelTable($e), [ 'IS_DEFERRED' => 1, 'LEVEL_INDEX' => 1, 'DATA_TYPE' => 'uint8', - 'CONVERT_FROM' => undef, 'CONTAINS_DEFERRED' => 0, 'TYPE' => 'DATA', 'IS_SURROUNDING' => 0, - 'CONVERT_TO' => undef } ]); @@ -117,11 +111,9 @@ is_deeply(GetElementLevelTable($e), [ 'IS_DEFERRED' => 1, 'LEVEL_INDEX' => 2, 'DATA_TYPE' => 'uint8', - 'CONVERT_FROM' => undef, 'CONTAINS_DEFERRED' => 0, 'TYPE' => 'DATA', 'IS_SURROUNDING' => 0, - 'CONVERT_TO' => undef } ]); @@ -149,11 +141,9 @@ is_deeply(GetElementLevelTable($e), [ 'IS_DEFERRED' => 1, 'LEVEL_INDEX' => 1, 'DATA_TYPE' => 'uint8', - 'CONVERT_FROM' => undef, 'CONTAINS_DEFERRED' => 0, 'TYPE' => 'DATA', 'IS_SURROUNDING' => 0, - 'CONVERT_TO' => undef } ]); @@ -182,11 +172,9 @@ is_deeply(GetElementLevelTable($e), [ 'IS_DEFERRED' => 0, 'LEVEL_INDEX' => 1, 'DATA_TYPE' => 'uint8', - 'CONVERT_FROM' => undef, 'CONTAINS_DEFERRED' => 0, 'TYPE' => 'DATA', 'IS_SURROUNDING' => 0, - 'CONVERT_TO' => undef } ]); @@ -200,7 +188,7 @@ $e = { 'PARENT' => { TYPE => 'STRUCT' }, 'LINE' => 42 }; -$ne = ParseElement($e); +$ne = ParseElement($e, undef); is($ne->{REPRESENTATION_TYPE}, "bar"); # representation_type @@ -213,5 +201,5 @@ $e = { 'PARENT' => { TYPE => 'STRUCT' }, 'LINE' => 42 }; -$ne = ParseElement($e); +$ne = ParseElement($e, undef); is($ne->{REPRESENTATION_TYPE}, "uint8"); -- cgit From 8f83985f2890ac2b47a33853812d62bbb90e9cf4 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 20 Feb 2007 01:27:48 +0000 Subject: r21459: Remove name argument, more refactoring. (This used to be commit fad03f6c51b40bca2b60036835b998056fec0faa) --- source4/pidl/tests/samba-ndr.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/samba-ndr.pl b/source4/pidl/tests/samba-ndr.pl index a528265e64..1167f77aee 100755 --- a/source4/pidl/tests/samba-ndr.pl +++ b/source4/pidl/tests/samba-ndr.pl @@ -259,7 +259,7 @@ Parse::Pidl::Samba4::NDR::Parser::ParseStructPush({ TYPE => "STRUCT", PROPERTIES => {}, ALIGN => 4, - ELEMENTS => [ ]}, "mystruct", "x"); + ELEMENTS => [ ]}, "x"); is($res, "if (ndr_flags & NDR_SCALARS) { NDR_CHECK(ndr_push_align(ndr, 4)); } @@ -282,7 +282,7 @@ Parse::Pidl::Samba4::NDR::Parser::ParseStructPush({ PROPERTIES => {}, ALIGN => 4, SURROUNDING_ELEMENT => $e, - ELEMENTS => [ $e ]}, "mystruct", "x"); + ELEMENTS => [ $e ]}, "x"); is($res, "if (ndr_flags & NDR_SCALARS) { NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_string_array_size(ndr, x->el1))); NDR_CHECK(ndr_push_align(ndr, 4)); -- cgit From 90789cb08b84d3b916df3ed11fa9c68dd3075600 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 21 Feb 2007 10:31:14 +0000 Subject: r21484: Fix Needed* for nested datastructures. (This used to be commit ec3c9ebfd0de287411ce399967409f902653d5c6) --- source4/pidl/tests/samba-ndr.pl | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/samba-ndr.pl b/source4/pidl/tests/samba-ndr.pl index 1167f77aee..d956402e64 100755 --- a/source4/pidl/tests/samba-ndr.pl +++ b/source4/pidl/tests/samba-ndr.pl @@ -11,7 +11,8 @@ use Util; use Parse::Pidl::Util qw(MyDumper); use Parse::Pidl::Samba4::NDR::Parser qw(check_null_pointer GenerateFunctionInEnv GenerateFunctionOutEnv GenerateStructEnv - EnvSubstituteValue NeededFunction NeededElement NeededType $res); + EnvSubstituteValue NeededFunction NeededElement NeededType $res + NeededInterface); my $output; sub print_fn($) { my $x = shift; $output.=$x; } @@ -209,46 +210,51 @@ is_deeply($needed, { pull_foo => 1, print_foo => 1, push_foo => 1, # public structs are always needed $needed = {}; -NeededType({ NAME => "bla", DATA => { TYPE => "STRUCT", ELEMENTS => [] } }, - $needed); +NeededType({ NAME => "bla", TYPE => "TYPEDEF", + DATA => { TYPE => "STRUCT", ELEMENTS => [] } }, + $needed, "pull"); is_deeply($needed, { }); $needed = {}; -NeededType({ PROPERTIES => { public => 1 }, NAME => "bla", - DATA => { TYPE => "STRUCT", ELEMENTS => [] } }, +NeededInterface({ TYPES => [ { PROPERTIES => { public => 1 }, NAME => "bla", + TYPE => "TYPEDEF", + DATA => { TYPE => "STRUCT", ELEMENTS => [] } } ] }, $needed); -is_deeply($needed, { pull_bla => 1, print_bla => 1, push_bla => 1 }); +is_deeply($needed, { pull_bla => 1, push_bla => 1, print_bla => 1 }); # make sure types for elements are set too $needed = {}; -NeededType({ PROPERTIES => { public => 1 }, NAME => "bla", +NeededInterface({ TYPES => [ { PROPERTIES => { public => 1 }, NAME => "bla", + TYPE => "TYPEDEF", DATA => { TYPE => "STRUCT", - ELEMENTS => [ { TYPE => "bar", REPRESENTATION_TYPE => "bar" } ] } }, + ELEMENTS => [ { TYPE => "bar", REPRESENTATION_TYPE => "bar" } ] } } ] }, $needed); -is_deeply($needed, { pull_bla => 1, print_bla => 1, push_bla => 1, - pull_bar => 1, print_bar => 1, push_bar => 1}); +is_deeply($needed, { pull_bla => 1, pull_bar => 1, push_bla => 1, push_bar => 1, + print_bla => 1, print_bar => 1}); $needed = {}; -NeededType({ PROPERTIES => { gensize => 1}, NAME => "bla", +NeededInterface({ TYPES => [ { PROPERTIES => { gensize => 1}, NAME => "bla", + TYPE => "TYPEDEF", DATA => { TYPE => "STRUCT", - ELEMENTS => [ { TYPE => "bar", REPRESENTATION_TYPE => "bar" } ] } }, + ELEMENTS => [ { TYPE => "bar", REPRESENTATION_TYPE => "bar" } ] } } ] }, $needed); is_deeply($needed, { ndr_size_bla => 1 }); # make sure types for elements are set too $needed = { pull_bla => 1 }; NeededType({ NAME => "bla", + TYPE => "TYPEDEF", DATA => { TYPE => "STRUCT", ELEMENTS => [ { TYPE => "bar", REPRESENTATION_TYPE => "bar" } ] } }, - $needed); + $needed, "pull"); is_deeply($needed, { pull_bla => 1, pull_bar => 1 }); $needed = {}; -NeededType({ PROPERTIES => { public => 1}, +NeededInterface({ TYPES => [ { PROPERTIES => { public => 1}, NAME => "bla", + TYPE => "TYPEDEF", DATA => { TYPE => "STRUCT", - ELEMENTS => [ { TYPE => "bar", REPRESENTATION_TYPE => "rep" } ] } }, - $needed); + ELEMENTS => [ { TYPE => "bar", REPRESENTATION_TYPE => "rep" } ] } } ] }, $needed); is_deeply($needed, { pull_bla => 1, push_bla => 1, print_bla => 1, print_rep => 1, pull_bar => 1, push_bar => 1, ndr_bar_to_rep => 1, ndr_rep_to_bar => 1}); -- cgit From b76461f425fbfe425a7c0773626f53e394b48386 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 21 Feb 2007 12:35:21 +0000 Subject: r21490: Add some tests for the EJS code More work on supporting nested types in EJS. (This used to be commit cb7faeab88952b59add1c814e1881ee9bb88b7ec) --- source4/pidl/tests/samba-ejs.pl | 42 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100755 source4/pidl/tests/samba-ejs.pl (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/samba-ejs.pl b/source4/pidl/tests/samba-ejs.pl new file mode 100755 index 0000000000..350cba571c --- /dev/null +++ b/source4/pidl/tests/samba-ejs.pl @@ -0,0 +1,42 @@ +#!/usr/bin/perl +# (C) 2007 Jelmer Vernooij +# Published under the GNU General Public License +use strict; +use warnings; + +use Test::More tests => 13; +use FindBin qw($RealBin); +use lib "$RealBin"; +use Util; +use Parse::Pidl::Util qw(MyDumper); +use Parse::Pidl::Samba4::EJS qw(get_pointer_to get_value_of check_null_pointer + $res $res_hdr fn_declare); + +is("&foo", get_pointer_to("foo")); +is("&(&foo)", get_pointer_to(get_pointer_to("foo"))); +is("*foo", get_pointer_to("**foo")); +is("foo", get_pointer_to("*foo")); + +is("foo", get_value_of("&foo")); +is("*foo", get_value_of("foo")); +is("**foo", get_value_of("*foo")); + +$res = ""; +check_null_pointer("bla"); +is($res, ""); + +$res = ""; +check_null_pointer("*bla"); +is($res, "if (bla == NULL) return NT_STATUS_INVALID_PARAMETER_MIX;\n"); + +$res = ""; +$res_hdr = ""; +fn_declare({ PROPERTIES => { public => 1 } }, "myproto(int x)"); +is($res, "_PUBLIC_ myproto(int x)\n"); +is($res_hdr, "myproto(int x);\n"); + +$res = ""; +$res_hdr = ""; +fn_declare({ PROPERTIES => {} }, "mybla(int foo)"); +is($res, "static mybla(int foo)\n"); +is($res_hdr, ""); -- cgit From cb8fceab28c71c7513e0732e1a9e2c9f61bfa31b Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 25 Feb 2007 09:55:57 +0000 Subject: r21532: Add tests for StripPrefixes utility function. (This used to be commit 365052555e0e9224bdfda0c2a10f78cbeee5b06c) --- source4/pidl/tests/wireshark-ndr.pl | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/wireshark-ndr.pl b/source4/pidl/tests/wireshark-ndr.pl index 574060f8ea..f5229560bd 100755 --- a/source4/pidl/tests/wireshark-ndr.pl +++ b/source4/pidl/tests/wireshark-ndr.pl @@ -5,12 +5,12 @@ use strict; use warnings; -use Test::More tests => 3; +use Test::More tests => 6; use FindBin qw($RealBin); use lib "$RealBin"; use Util; use Parse::Pidl::Util qw(MyDumper); -use Parse::Pidl::Wireshark::NDR qw(field2name %res PrintIdl); +use Parse::Pidl::Wireshark::NDR qw(field2name %res PrintIdl StripPrefixes); is("Access Mask", field2name("access_mask")); is("Accessmask", field2name("AccessMask")); @@ -21,3 +21,7 @@ is("/* IDL: foo */ /* IDL: bar */ ", $res{code}); + +is("bla_foo", StripPrefixes("bla_foo", [])); +is("foo", StripPrefixes("bla_foo", ["bla"])); +is("foo_bla", StripPrefixes("foo_bla", ["bla"])); -- cgit From b8c219a270e50f165a326c3657618c78e2ff58c5 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 26 Feb 2007 01:03:19 +0000 Subject: r21534: Add some more tests for wireshark. (This used to be commit b10432096181cf8e7d729e58a5ab54fac5eaa5fe) --- source4/pidl/tests/wireshark-ndr.pl | 49 +++++++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/wireshark-ndr.pl b/source4/pidl/tests/wireshark-ndr.pl index f5229560bd..02eabb8942 100755 --- a/source4/pidl/tests/wireshark-ndr.pl +++ b/source4/pidl/tests/wireshark-ndr.pl @@ -5,12 +5,12 @@ use strict; use warnings; -use Test::More tests => 6; +use Test::More tests => 11; use FindBin qw($RealBin); use lib "$RealBin"; use Util; use Parse::Pidl::Util qw(MyDumper); -use Parse::Pidl::Wireshark::NDR qw(field2name %res PrintIdl StripPrefixes); +use Parse::Pidl::Wireshark::NDR qw(field2name %res PrintIdl StripPrefixes %hf_used RegisterInterfaceHandoff $conformance register_hf_field CheckUsed); is("Access Mask", field2name("access_mask")); is("Accessmask", field2name("AccessMask")); @@ -25,3 +25,48 @@ is("/* IDL: foo */ is("bla_foo", StripPrefixes("bla_foo", [])); is("foo", StripPrefixes("bla_foo", ["bla"])); is("foo_bla", StripPrefixes("foo_bla", ["bla"])); + +%hf_used = (); +$res{code} = ""; +RegisterInterfaceHandoff({}); +is($res{code}, ""); +ok(not defined($hf_used{hf_bla_opnum})); + +%hf_used = (); +$res{code} = ""; +RegisterInterfaceHandoff({UUID => "uuid", NAME => "bla"}); +is($res{code}, 'void proto_reg_handoff_dcerpc_bla(void) +{ + dcerpc_init_uuid(proto_dcerpc_bla, ett_dcerpc_bla, + &uuid_dcerpc_bla, ver_dcerpc_bla, + bla_dissectors, hf_bla_opnum); +} +'); +is($hf_used{hf_bla_opnum}, 1); + +$conformance = {}; +register_hf_field("hf_bla_idx", "bla", "my.filter", "FT_UINT32", "BASE_HEX", "NULL", 0xF, undef); +is_deeply($conformance, { + header_fields => { + "hf_bla_idx" => { + INDEX => "hf_bla_idx", + NAME => "bla", + FILTER => "my.filter", + BASE_TYPE => "BASE_HEX", + FT_TYPE => "FT_UINT32", + VALSSTRING => "NULL", + BLURB => undef, + MASK => 0xF + } + }, + hf_renames => {}, + fielddescription => {} +}); + +%hf_used = ( hf_bla => 1 ); +test_warnings("", sub { + CheckUsed({ header_fields => { INDEX => "hf_bla" }})}); + +%hf_used = ( ); +test_warnings("nofile:0: hf field `hf_bla' not used\n", sub { + CheckUsed({ header_fields => { INDEX => "hf_bla" }})}); -- cgit From 43679c82f4b6f16af2d8b6695499b03ed7555266 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 26 Feb 2007 17:43:01 +0000 Subject: r21545: Fix pidl test. (This used to be commit ed0a7f5091d99a012e366ed3bc877b5228aa62a8) --- source4/pidl/tests/wireshark-ndr.pl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/wireshark-ndr.pl b/source4/pidl/tests/wireshark-ndr.pl index 02eabb8942..a216f59d97 100755 --- a/source4/pidl/tests/wireshark-ndr.pl +++ b/source4/pidl/tests/wireshark-ndr.pl @@ -5,7 +5,7 @@ use strict; use warnings; -use Test::More tests => 11; +use Test::More tests => 13; use FindBin qw($RealBin); use lib "$RealBin"; use Util; @@ -65,8 +65,8 @@ is_deeply($conformance, { %hf_used = ( hf_bla => 1 ); test_warnings("", sub { - CheckUsed({ header_fields => { INDEX => "hf_bla" }})}); + CheckUsed({ header_fields => { foo => { INDEX => "hf_bla" }}})}); %hf_used = ( ); -test_warnings("nofile:0: hf field `hf_bla' not used\n", sub { - CheckUsed({ header_fields => { INDEX => "hf_bla" }})}); +test_warnings("hf field `hf_bla' not used\n", sub { + CheckUsed({ header_fields => { foo => { INDEX => "hf_bla" }}})}); -- cgit From 2916cc628ad18ea16e8f1b8521c42963cc7b0a79 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 27 Feb 2007 12:46:19 +0000 Subject: r21555: Some tests for TYPE in wireshark conformance files. (This used to be commit 2a44c8c9c296462350fcae1960265a6ef0f317d8) --- source4/pidl/tests/wireshark-conf.pl | 38 ++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/wireshark-conf.pl b/source4/pidl/tests/wireshark-conf.pl index 8601a91ed9..0e6e1e78ac 100755 --- a/source4/pidl/tests/wireshark-conf.pl +++ b/source4/pidl/tests/wireshark-conf.pl @@ -5,12 +5,12 @@ use strict; use warnings; -use Test::More tests => 20; +use Test::More tests => 34; use FindBin qw($RealBin); use lib "$RealBin"; use Util; use Parse::Pidl::Util qw(MyDumper); -use Parse::Pidl::Wireshark::Conformance qw(ReadConformanceFH); +use Parse::Pidl::Wireshark::Conformance qw(ReadConformanceFH valid_ft_type valid_base_type); sub parse_conf($) { @@ -60,3 +60,37 @@ is_deeply(parse_conf("CODE START\ndata\nCODE END\n"), { override => "data\n" }); is_deeply(parse_conf("CODE START\ndata\nmore data\nCODE END\n"), { override => "data\nmore data\n" }); test_warnings("nofile:1: Unknown command `CODE'\n", sub { parse_conf("CODE END\n"); } ); + +is_deeply(parse_conf("TYPE winreg_String dissect_myminregstring FT_STRING BASE_DEC 0 0 2\n"), { types => { winreg_String => { + NAME => "winreg_String", + POS => { FILE => "nofile", LINE => 1 }, + USED => 0, + DISSECTOR_NAME => "dissect_myminregstring", + FT_TYPE => "FT_STRING", + BASE_TYPE => "BASE_DEC", + MASK => 0, + VALSSTRING => 0, + ALIGNMENT => 2}}}); + +ok(valid_ft_type("FT_UINT32")); +ok(not valid_ft_type("BLA")); +ok(not valid_ft_type("ft_uint32")); +ok(valid_ft_type("FT_BLA")); + +ok(valid_base_type("BASE_DEC")); +ok(valid_base_type("BASE_HEX")); +ok(not valid_base_type("base_dec")); +ok(not valid_base_type("BLA")); +ok(not valid_base_type("BASEDEC")); + +test_errors("nofile:1: incomplete TYPE command\n", + sub { parse_conf("TYPE mytype dissector\n"); }); + +test_warnings("nofile:1: dissector name does not contain `dissect'\n", + sub { parse_conf("TYPE winreg_String myminregstring FT_STRING BASE_DEC 0 0 2\n"); }); + +test_warnings("nofile:1: invalid FT_TYPE `BLA'\n", + sub { parse_conf("TYPE winreg_String dissect_myminregstring BLA BASE_DEC 0 0 2\n"); }); + +test_warnings("nofile:1: invalid BASE_TYPE `BLOE'\n", + sub { parse_conf("TYPE winreg_String dissect_myminregstring FT_UINT32 BLOE 0 0 2\n"); }); -- cgit From cdb18fd22dc41acd776a0c6555234e8e1b6566bd Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 27 Feb 2007 13:41:56 +0000 Subject: r21559: More tests. (This used to be commit c68573392b0fbc7c6267ac4fe84f7916e3cec779) --- source4/pidl/tests/wireshark-conf.pl | 71 +++++++++++++++++++++++++++++++++++- 1 file changed, 70 insertions(+), 1 deletion(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/wireshark-conf.pl b/source4/pidl/tests/wireshark-conf.pl index 0e6e1e78ac..617a63029a 100755 --- a/source4/pidl/tests/wireshark-conf.pl +++ b/source4/pidl/tests/wireshark-conf.pl @@ -5,7 +5,7 @@ use strict; use warnings; -use Test::More tests => 34; +use Test::More tests => 45; use FindBin qw($RealBin); use lib "$RealBin"; use Util; @@ -94,3 +94,72 @@ test_warnings("nofile:1: invalid FT_TYPE `BLA'\n", test_warnings("nofile:1: invalid BASE_TYPE `BLOE'\n", sub { parse_conf("TYPE winreg_String dissect_myminregstring FT_UINT32 BLOE 0 0 2\n"); }); + +is_deeply(parse_conf("TFS hf_bla \"True string\" \"False String\"\n"), + { tfs => { hf_bla => { + TRUE_STRING => "\"True string\"", + FALSE_STRING => "\"False String\"" } } }); + +test_errors("nofile:1: incomplete TFS command\n", + sub { parse_conf("TFS hf_bla \"Trues\""); } ); + +test_errors("nofile:1: incomplete PARAM_VALUE command\n", + sub { parse_conf("PARAM_VALUE\n"); }); + +is_deeply(parse_conf("PARAM_VALUE Life 42\n"), + { dissectorparams => { + Life => { + DISSECTOR => "Life", + POS => { FILE => "nofile", LINE => 1 }, + PARAM => 42, + USED => 0 + } + } + }); + +is_deeply(parse_conf("STRIP_PREFIX bla_\n"), + { strip_prefixes => [ "bla_" ] }); + +is_deeply(parse_conf("STRIP_PREFIX bla_\nSTRIP_PREFIX bloe\n"), + { strip_prefixes => [ "bla_", "bloe" ] }); + +is_deeply(parse_conf("PROTOCOL atsvc \"Scheduling jobs on remote machines\" \"at\" \"atsvc\"\n"), + { protocols => { + atsvc => { + LONGNAME => "\"Scheduling jobs on remote machines\"", + SHORTNAME => "\"at\"", + FILTERNAME => "\"atsvc\"" + } + } + } +); + +is_deeply(parse_conf("IMPORT bla\n"), { + imports => { + bla => { + NAME => "bla", + DATA => "", + USED => 0, + POS => { FILE => "nofile", LINE => 1 } + } + } + } +); + +is_deeply(parse_conf("IMPORT bla fn1 fn2 fn3\n"), { + imports => { + bla => { + NAME => "bla", + DATA => "fn1 fn2 fn3", + USED => 0, + POS => { FILE => "nofile", LINE => 1 } + } + } + } +); + +test_errors("nofile:1: no dissectorname specified\n", + sub { parse_conf("IMPORT\n"); } ); + +test_errors("nofile:1: incomplete HF_FIELD command\n", + sub { parse_conf("HF_FIELD hf_idx\n"); }); -- cgit From 6f3c968e64ef5677759dafcc88092d3db2b4c6e9 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 27 Feb 2007 20:35:56 +0000 Subject: r21567: Add some more wireshark tests. (This used to be commit 40e2956058fe4aaebf3f7269bce90339d7faf24f) --- source4/pidl/tests/wireshark-ndr.pl | 69 +++++++++++++++++++++++++++++++++++-- 1 file changed, 67 insertions(+), 2 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/wireshark-ndr.pl b/source4/pidl/tests/wireshark-ndr.pl index a216f59d97..cda60c1f5a 100755 --- a/source4/pidl/tests/wireshark-ndr.pl +++ b/source4/pidl/tests/wireshark-ndr.pl @@ -5,12 +5,12 @@ use strict; use warnings; -use Test::More tests => 13; +use Test::More tests => 25; use FindBin qw($RealBin); use lib "$RealBin"; use Util; use Parse::Pidl::Util qw(MyDumper); -use Parse::Pidl::Wireshark::NDR qw(field2name %res PrintIdl StripPrefixes %hf_used RegisterInterfaceHandoff $conformance register_hf_field CheckUsed); +use Parse::Pidl::Wireshark::NDR qw(field2name %res PrintIdl StripPrefixes %hf_used RegisterInterfaceHandoff $conformance register_hf_field CheckUsed ProcessImport ProcessInclude find_type DumpEttList DumpEttDeclaration DumpHfList DumpHfDeclaration DumpFunctionTable); is("Access Mask", field2name("access_mask")); is("Accessmask", field2name("AccessMask")); @@ -70,3 +70,68 @@ test_warnings("", sub { %hf_used = ( ); test_warnings("hf field `hf_bla' not used\n", sub { CheckUsed({ header_fields => { foo => { INDEX => "hf_bla" }}})}); + +$res{hdr} = ""; +ProcessImport("security", "bla"); +is($res{hdr}, "#include \"packet-dcerpc-bla.h\"\n\n"); + +$res{hdr} = ""; +ProcessImport("\"bla.idl\"", "\"foo.idl\""); +is($res{hdr}, "#include \"packet-dcerpc-bla.h\"\n" . + "#include \"packet-dcerpc-foo.h\"\n\n"); + +$res{hdr} = ""; +ProcessInclude("foo.h", "bla.h", "bar.h"); +is($res{hdr}, "#include \"foo.h\"\n" . + "#include \"bla.h\"\n" . + "#include \"bar.h\"\n\n"); + +$conformance = {types => { bla => "brainslug" } }; +is("brainslug", find_type("bla")); + +is(DumpEttList("ett_t1", "ett_bla"), + "\tstatic gint *ett[] = {\n" . + "\t\t&ett_t1,\n" . + "\t\t&ett_bla,\n" . + "\t};\n"); + +is(DumpEttList(), "\tstatic gint *ett[] = {\n\t};\n"); +is(DumpEttList("bla"), "\tstatic gint *ett[] = {\n\t\t&bla,\n\t};\n"); + +is(DumpEttDeclaration("void", "zoid"), + "\n/* Ett declarations */\n" . + "static gint void = -1;\n" . + "static gint zoid = -1;\n" . + "\n"); + +is(DumpEttDeclaration(), "\n/* Ett declarations */\n\n"); + +$conformance = { + header_fields => { + hf_bla => { INDEX => "hf_bla", NAME => "Bla", FILTER => "bla.field", FT_TYPE => "FT_UINT32", BASE_TYPE => "BASE_DEC", VALSSTRING => "NULL", MASK => 0xFF, BLURB => "NULL" } + } +}; + +is(DumpHfList(), "\tstatic hf_register_info hf[] = { + { &hf_bla, + { \"Bla\", \"bla.field\", FT_UINT32, BASE_DEC, NULL, 255, \"NULL\", HFILL }}, + }; +"); + +is(DumpHfDeclaration(), " +/* Header field declarations */ +static gint hf_bla = -1; + +"); + +is(DumpFunctionTable({ + NAME => "someif", + FUNCTIONS => [ { NAME => "fn1", OPNUM => 3 }, { NAME => "someif_fn2", OPNUM => 2 } ] }), +'static dcerpc_sub_dissector someif_dissectors[] = { + { 3, "fn1", + someif_dissect_fn1_request, someif_dissect_fn1_response}, + { 2, "fn2", + someif_dissect_fn2_request, someif_dissect_fn2_response}, + { 0, NULL, NULL, NULL } +}; +'); -- cgit From f5f0e502b3eadacd3ef1ee382f63e02cbbf9ae58 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 27 Feb 2007 21:37:31 +0000 Subject: r21568: More tests. (This used to be commit c7bde9c1f537cbcf8e71177e6c3969699c046ecb) --- source4/pidl/tests/wireshark-ndr.pl | 143 +++++++++++++++++++++++++++++++++++- 1 file changed, 140 insertions(+), 3 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/wireshark-ndr.pl b/source4/pidl/tests/wireshark-ndr.pl index cda60c1f5a..40e22d958c 100755 --- a/source4/pidl/tests/wireshark-ndr.pl +++ b/source4/pidl/tests/wireshark-ndr.pl @@ -5,12 +5,12 @@ use strict; use warnings; -use Test::More tests => 25; +use Test::More tests => 40; use FindBin qw($RealBin); use lib "$RealBin"; use Util; use Parse::Pidl::Util qw(MyDumper); -use Parse::Pidl::Wireshark::NDR qw(field2name %res PrintIdl StripPrefixes %hf_used RegisterInterfaceHandoff $conformance register_hf_field CheckUsed ProcessImport ProcessInclude find_type DumpEttList DumpEttDeclaration DumpHfList DumpHfDeclaration DumpFunctionTable); +use Parse::Pidl::Wireshark::NDR qw(field2name %res PrintIdl StripPrefixes %hf_used RegisterInterfaceHandoff $conformance register_hf_field CheckUsed ProcessImport ProcessInclude find_type DumpEttList DumpEttDeclaration DumpHfList DumpHfDeclaration DumpFunctionTable register_type @ett register_ett); is("Access Mask", field2name("access_mask")); is("Accessmask", field2name("AccessMask")); @@ -45,7 +45,8 @@ is($res{code}, 'void proto_reg_handoff_dcerpc_bla(void) is($hf_used{hf_bla_opnum}, 1); $conformance = {}; -register_hf_field("hf_bla_idx", "bla", "my.filter", "FT_UINT32", "BASE_HEX", "NULL", 0xF, undef); +is("hf_bla_idx", + register_hf_field("hf_bla_idx", "bla", "my.filter", "FT_UINT32", "BASE_HEX", "NULL", 0xF, undef)); is_deeply($conformance, { header_fields => { "hf_bla_idx" => { @@ -63,6 +64,61 @@ is_deeply($conformance, { fielddescription => {} }); +$conformance = { fielddescription => { hf_bla_idx => { DESCRIPTION => "Some Description" }}}; +is("hf_bla_idx", + register_hf_field("hf_bla_idx", "bla", "my.filter", "FT_UINT32", "BASE_HEX", "NULL", 0xF, undef)); +is_deeply($conformance, { + fielddescription => { + hf_bla_idx => { + DESCRIPTION => "Some Description", + USED => 1 + } + }, + header_fields => { + "hf_bla_idx" => { + INDEX => "hf_bla_idx", + NAME => "bla", + FILTER => "my.filter", + BASE_TYPE => "BASE_HEX", + FT_TYPE => "FT_UINT32", + VALSSTRING => "NULL", + BLURB => "Some Description", + MASK => 0xF + } + }, + hf_renames => {}, +}); + +$conformance = { fielddescription => { hf_bla_idx => { DESCRIPTION => "Some Description" }}}; +is("hf_bla_idx", + register_hf_field("hf_bla_idx", "bla", "my.filter", "FT_UINT32", "BASE_HEX", "NULL", 0xF, + "Actual Description")); +is_deeply($conformance, { + fielddescription => { + hf_bla_idx => { DESCRIPTION => "Some Description" } + }, + header_fields => { + "hf_bla_idx" => { + INDEX => "hf_bla_idx", + NAME => "bla", + FILTER => "my.filter", + BASE_TYPE => "BASE_HEX", + FT_TYPE => "FT_UINT32", + VALSSTRING => "NULL", + BLURB => "Actual Description", + MASK => 0xF + } + }, + hf_renames => {}, +}); + + + +$conformance = { hf_renames => { "hf_bla_idx" => { NEWNAME => "hf_bloe_idx" } } }; +register_hf_field("hf_bla_idx", "bla", "my.filter", "FT_UINT32", "BASE_HEX", "NULL", 0xF, undef); +is_deeply($conformance, { + hf_renames => { hf_bla_idx => { USED => 1, NEWNAME => "hf_bloe_idx" } } }); + %hf_used = ( hf_bla => 1 ); test_warnings("", sub { CheckUsed({ header_fields => { foo => { INDEX => "hf_bla" }}})}); @@ -71,6 +127,64 @@ test_warnings("", sub { test_warnings("hf field `hf_bla' not used\n", sub { CheckUsed({ header_fields => { foo => { INDEX => "hf_bla" }}})}); +test_warnings("hf field `hf_id' not used\n", + sub { CheckUsed({ + hf_renames => { + hf_id => { + OLDNAME => "hf_id", + NEWNAME => "hf_newid", + USED => 0 + } + } +}); } ); + +test_warnings("dissector param never used\n", + sub { CheckUsed({ + dissectorparams => { + dissect_foo => { + PARAM => 42, + USED => 0 + } + } +}); } ); + +test_warnings("description never used\n", + sub { CheckUsed({ + fielddescription => { + hf_bla => { + USED => 0 + } + } +}); } ); + +test_warnings("import never used\n", + sub { CheckUsed({ + imports => { + bla => { + USED => 0 + } + } +}); } ); + +test_warnings("nofile:1: type never used\n", + sub { CheckUsed({ + types => { + bla => { + USED => 0, + POS => { FILE => "nofile", LINE => 1 } + } + } +}); } ); + +test_warnings("True/False description never used\n", + sub { CheckUsed({ + tfs => { + hf_bloe => { + USED => 0 + } + } +}); } ); + $res{hdr} = ""; ProcessImport("security", "bla"); is($res{hdr}, "#include \"packet-dcerpc-bla.h\"\n\n"); @@ -135,3 +249,26 @@ is(DumpFunctionTable({ { 0, NULL, NULL, NULL } }; '); + +$conformance = {}; +register_type("bla_type", "dissect_bla", "FT_UINT32", "BASE_HEX", 0xFF, "NULL", 4); +is_deeply($conformance, { + types => { + bla_type => { + NAME => "bla_type", + DISSECTOR_NAME => "dissect_bla", + FT_TYPE => "FT_UINT32", + BASE_TYPE => "BASE_HEX", + MASK => 255, + VALSSTRING => "NULL", + ALIGNMENT => 4 + } + } + } +); + +@ett = (); +register_ett("name"); +is_deeply(\@ett, ["name"]); +register_ett("leela"); +is_deeply(\@ett, ["name", "leela"]); -- cgit From d7a7b7fb0c423c461c24e8157ad926d0cee07da1 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 27 Feb 2007 23:47:07 +0000 Subject: r21572: More work towards supporting tagged types. (This used to be commit 4d28396f0928444406334888f4bc345e74a380df) --- source4/pidl/tests/ndr.pl | 12 ++++++++++-- source4/pidl/tests/ndr_tagtype.pl | 41 ++++++++++++++++++++++++++++++++++++++- source4/pidl/tests/typelist.pl | 14 ++++++++++--- 3 files changed, 61 insertions(+), 6 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/ndr.pl b/source4/pidl/tests/ndr.pl index 26fb6c290b..9824d1e815 100755 --- a/source4/pidl/tests/ndr.pl +++ b/source4/pidl/tests/ndr.pl @@ -4,12 +4,12 @@ use strict; use warnings; -use Test::More tests => 12; +use Test::More tests => 17; use FindBin qw($RealBin); use lib "$RealBin"; use Util; use Parse::Pidl::Util qw(MyDumper); -use Parse::Pidl::NDR qw(GetElementLevelTable ParseElement); +use Parse::Pidl::NDR qw(GetElementLevelTable ParseElement align_type); # Case 1 @@ -203,3 +203,11 @@ $e = { $ne = ParseElement($e, undef); is($ne->{REPRESENTATION_TYPE}, "uint8"); + +is(align_type("uint32"), 4); +is(align_type("uint16"), 2); +is(align_type("uint8"), 1); +is(align_type({ TYPE => "STRUCT", "NAME" => "bla", + ELEMENTS => [ { TYPE => "uint16" } ] }), 4); +is(align_type({ TYPE => "STRUCT", "NAME" => "bla", + ELEMENTS => [ { TYPE => "uint8" } ] }), 4); diff --git a/source4/pidl/tests/ndr_tagtype.pl b/source4/pidl/tests/ndr_tagtype.pl index 067fa096b4..efc5b67746 100755 --- a/source4/pidl/tests/ndr_tagtype.pl +++ b/source4/pidl/tests/ndr_tagtype.pl @@ -3,7 +3,7 @@ # (C) 2005 Jelmer Vernooij. Published under the GNU GPL use strict; -use Test::More tests => 1 * 8; +use Test::More tests => 3 * 8; use FindBin qw($RealBin); use lib "$RealBin"; use Util qw(test_samba4_ndr); @@ -25,3 +25,42 @@ test_samba4_ndr('struct-notypedef', '[public] struct bla { uint8 x; }; ', if (!data_blob_equal(&result_blob, &expected_blob)) return 2; '); + +test_samba4_ndr('struct-notypedef-used', '[public] struct bla { uint8 x; }; + [public] void myfn([in] struct bla r); ', +' + struct ndr_push *ndr = ndr_push_init_ctx(NULL); + struct bla r; + uint8_t expected[] = { 0x0D }; + DATA_BLOB expected_blob = { expected, 1 }; + DATA_BLOB result_blob; + r.x = 13; + + if (NT_STATUS_IS_ERR(ndr_push_myfn(ndr, NDR_IN, &r))) + return 1; + + result_blob = ndr_push_blob(ndr); + + if (!data_blob_equal(&result_blob, &expected_blob)) + return 2; +'); + + +test_samba4_ndr('struct-notypedef-embedded', 'struct bla { uint8 x; }; + [public] struct myfn { struct bla r; }; ', +' + struct ndr_push *ndr = ndr_push_init_ctx(NULL); + struct bla r; + uint8_t expected[] = { 0x0D }; + DATA_BLOB expected_blob = { expected, 1 }; + DATA_BLOB result_blob; + r.x = 13; + + if (NT_STATUS_IS_ERR(ndr_push_myfn(ndr, NDR_IN, &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/typelist.pl b/source4/pidl/tests/typelist.pl index 5c1a7ddd21..d84fe0592c 100755 --- a/source4/pidl/tests/typelist.pl +++ b/source4/pidl/tests/typelist.pl @@ -4,7 +4,7 @@ use strict; use warnings; -use Test::More tests => 33; +use Test::More tests => 38; use FindBin qw($RealBin); use lib "$RealBin"; use Util; @@ -22,15 +22,23 @@ is("uint32_t", mapScalarType("uint32")); is("void", mapScalarType("void")); is("uint64_t", mapScalarType("hyper")); -my $x = { TYPE => "ENUM", NAME => "foo" }; +my $x = { TYPE => "ENUM", NAME => "foo", EXTRADATA => 1 }; addType($x); -is($x, getType("foo")); +is_deeply($x, getType("foo")); is(undef, getType("bloebla")); +is_deeply(getType({ TYPE => "STRUCT" }), { TYPE => "STRUCT" }); +is_deeply(getType({ TYPE => "ENUM", NAME => "foo" }), $x); +is_deeply(getType("uint16"), { + NAME => "uint16", + TYPE => "TYPEDEF", + DATA => { NAME => "uint16", TYPE => "SCALAR" }}); is(0, typeIs("someUnknownType", "ENUM")); is(1, hasType("foo")); is(0, hasType("nonexistant")); +is(0, hasType({TYPE => "ENUM", NAME => "someUnknownType"})); +is(1, hasType({TYPE => "ENUM", NAME => "foo"})); is(1, is_scalar("uint32")); is(0, is_scalar("nonexistant")); -- cgit From c1aef15fe7e7a7558b6ede11babc1932263814e6 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 28 Feb 2007 00:19:57 +0000 Subject: r21573: Remove more code that assumed all types are typedefs. (This used to be commit bbbfbfa870c44a6148c3d4d47ff409098e85fcc3) --- source4/pidl/tests/ndr.pl | 11 +++++++++-- source4/pidl/tests/typelist.pl | 15 ++++++++++++++- 2 files changed, 23 insertions(+), 3 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/ndr.pl b/source4/pidl/tests/ndr.pl index 9824d1e815..3be5992ef0 100755 --- a/source4/pidl/tests/ndr.pl +++ b/source4/pidl/tests/ndr.pl @@ -4,12 +4,12 @@ use strict; use warnings; -use Test::More tests => 17; +use Test::More tests => 22; use FindBin qw($RealBin); use lib "$RealBin"; use Util; use Parse::Pidl::Util qw(MyDumper); -use Parse::Pidl::NDR qw(GetElementLevelTable ParseElement align_type); +use Parse::Pidl::NDR qw(GetElementLevelTable ParseElement align_type mapToScalar); # Case 1 @@ -211,3 +211,10 @@ is(align_type({ TYPE => "STRUCT", "NAME" => "bla", ELEMENTS => [ { TYPE => "uint16" } ] }), 4); is(align_type({ TYPE => "STRUCT", "NAME" => "bla", ELEMENTS => [ { TYPE => "uint8" } ] }), 4); + +is(mapToScalar("someverymuchnotexistingtype"), undef); +is(mapToScalar("uint32"), "uint32"); +is(mapToScalar({TYPE => "ENUM", PARENT => { PROPERTIES => { enum8bit => 1 } } }), "uint8"); +is(mapToScalar({TYPE => "BITMAP", PROPERTIES => { bitmap64bit => 1 } }), + "hyper"); +is(mapToScalar({TYPE => "TYPEDEF", DATA => {TYPE => "ENUM", PARENT => { PROPERTIES => { enum8bit => 1 } } }}), "uint8"); diff --git a/source4/pidl/tests/typelist.pl b/source4/pidl/tests/typelist.pl index d84fe0592c..e538cb2e0d 100755 --- a/source4/pidl/tests/typelist.pl +++ b/source4/pidl/tests/typelist.pl @@ -4,7 +4,7 @@ use strict; use warnings; -use Test::More tests => 38; +use Test::More tests => 50; use FindBin qw($RealBin); use lib "$RealBin"; use Util; @@ -34,14 +34,27 @@ is_deeply(getType("uint16"), { DATA => { NAME => "uint16", TYPE => "SCALAR" }}); is(0, typeIs("someUnknownType", "ENUM")); +is(0, typeIs("foo", "ENUM")); +addType({NAME => "mytypedef", TYPE => "TYPEDEF", DATA => { TYPE => "ENUM" }}); +is(1, typeIs("mytypedef", "ENUM")); +is(0, typeIs("mytypedef", "BITMAP")); +is(1, typeIs({ TYPE => "ENUM"}, "ENUM")); +is(0, typeIs({ TYPE => "BITMAP"}, "ENUM")); +is(1, typeIs("uint32", "SCALAR")); +is(0, typeIs("uint32", "ENUM")); is(1, hasType("foo")); is(0, hasType("nonexistant")); is(0, hasType({TYPE => "ENUM", NAME => "someUnknownType"})); is(1, hasType({TYPE => "ENUM", NAME => "foo"})); +is(1, hasType({TYPE => "ENUM"})); +is(1, hasType({TYPE => "STRUCT"})); is(1, is_scalar("uint32")); is(0, is_scalar("nonexistant")); +is(1, is_scalar({TYPE => "ENUM"})); +is(0, is_scalar({TYPE => "STRUCT"})); +is(1, is_scalar({TYPE => "TYPEDEF", DATA => {TYPE => "ENUM" }})); is(1, scalar_is_reference("string")); is(0, scalar_is_reference("uint32")); -- cgit From a635df47da4c0f8434dc51349600edf9ef0805f1 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 28 Feb 2007 00:28:14 +0000 Subject: r21574: Fix handling of DECLARE. (This used to be commit 6a4033464bf269176f928a5b3b7e63aad1bb1e7a) --- source4/pidl/tests/ndr.pl | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/ndr.pl b/source4/pidl/tests/ndr.pl index 3be5992ef0..17003d59c4 100755 --- a/source4/pidl/tests/ndr.pl +++ b/source4/pidl/tests/ndr.pl @@ -4,7 +4,7 @@ use strict; use warnings; -use Test::More tests => 22; +use Test::More tests => 25; use FindBin qw($RealBin); use lib "$RealBin"; use Util; @@ -204,11 +204,17 @@ $e = { $ne = ParseElement($e, undef); is($ne->{REPRESENTATION_TYPE}, "uint8"); +is(align_type("hyper"), 8); is(align_type("uint32"), 4); is(align_type("uint16"), 2); is(align_type("uint8"), 1); is(align_type({ TYPE => "STRUCT", "NAME" => "bla", ELEMENTS => [ { TYPE => "uint16" } ] }), 4); +is(align_type({ TYPE => "STRUCT", + ELEMENTS => [ { TYPE => "hyper" } ] }), 8); +is(align_type({ TYPE => "DECLARE", DATA => { + TYPE => "STRUCT", + ELEMENTS => [ { TYPE => "hyper" } ] }}), 8); is(align_type({ TYPE => "STRUCT", "NAME" => "bla", ELEMENTS => [ { TYPE => "uint8" } ] }), 4); -- cgit From 240b470f4404b6a3517312827b74f775ae85a855 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 28 Feb 2007 00:35:21 +0000 Subject: r21575: Fix handling of is_scalar() for declares. (This used to be commit f0bc29df7297f8f91175091e5f4b14f4ae4b0591) --- source4/pidl/tests/typelist.pl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/typelist.pl b/source4/pidl/tests/typelist.pl index e538cb2e0d..376bd208f0 100755 --- a/source4/pidl/tests/typelist.pl +++ b/source4/pidl/tests/typelist.pl @@ -4,7 +4,7 @@ use strict; use warnings; -use Test::More tests => 50; +use Test::More tests => 52; use FindBin qw($RealBin); use lib "$RealBin"; use Util; @@ -55,6 +55,8 @@ is(0, is_scalar("nonexistant")); is(1, is_scalar({TYPE => "ENUM"})); is(0, is_scalar({TYPE => "STRUCT"})); is(1, is_scalar({TYPE => "TYPEDEF", DATA => {TYPE => "ENUM" }})); +is(1, is_scalar("mytypedef")); +is(1, is_scalar({TYPE => "DECLARE", DATA => {TYPE => "ENUM" }})); is(1, scalar_is_reference("string")); is(0, scalar_is_reference("uint32")); -- cgit From 4c99e87f9bf30ea3f7e22263ded9f9a0372a73c6 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 28 Feb 2007 01:51:37 +0000 Subject: r21578: Use utility function for naming pull/push/print functions. (This used to be commit e0f626b79c43eb59ad3c6e3fb6c267504764bfef) --- source4/pidl/tests/ndr_tagtype.pl | 4 ++-- source4/pidl/tests/samba-ndr.pl | 44 ++++++++++++++++++++++----------------- 2 files changed, 27 insertions(+), 21 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/ndr_tagtype.pl b/source4/pidl/tests/ndr_tagtype.pl index efc5b67746..d7839426d5 100755 --- a/source4/pidl/tests/ndr_tagtype.pl +++ b/source4/pidl/tests/ndr_tagtype.pl @@ -17,7 +17,7 @@ test_samba4_ndr('struct-notypedef', '[public] struct bla { uint8 x; }; ', DATA_BLOB result_blob; r.x = 13; - if (NT_STATUS_IS_ERR(ndr_push_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r))) + if (NT_STATUS_IS_ERR(ndr_push_STRUCT_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r))) return 1; result_blob = ndr_push_blob(ndr); @@ -56,7 +56,7 @@ test_samba4_ndr('struct-notypedef-embedded', 'struct bla { uint8 x; }; DATA_BLOB result_blob; r.x = 13; - if (NT_STATUS_IS_ERR(ndr_push_myfn(ndr, NDR_IN, &r))) + if (NT_STATUS_IS_ERR(ndr_push_STRUCT_myfn(ndr, NDR_IN, &r))) return 1; result_blob = ndr_push_blob(ndr); diff --git a/source4/pidl/tests/samba-ndr.pl b/source4/pidl/tests/samba-ndr.pl index d956402e64..a806d33417 100755 --- a/source4/pidl/tests/samba-ndr.pl +++ b/source4/pidl/tests/samba-ndr.pl @@ -4,7 +4,7 @@ use strict; use warnings; -use Test::More tests => 34; +use Test::More tests => 38; use FindBin qw($RealBin); use lib "$RealBin"; use Util; @@ -12,7 +12,7 @@ use Parse::Pidl::Util qw(MyDumper); use Parse::Pidl::Samba4::NDR::Parser qw(check_null_pointer GenerateFunctionInEnv GenerateFunctionOutEnv GenerateStructEnv EnvSubstituteValue NeededFunction NeededElement NeededType $res - NeededInterface); + NeededInterface TypeFunctionName); my $output; sub print_fn($) { my $x = shift; $output.=$x; } @@ -185,28 +185,28 @@ is_deeply($env, { foo => 0, this => "r" }); my $needed = {}; NeededElement({ TYPE => "foo", REPRESENTATION_TYPE => "foo" }, "pull", $needed); -is_deeply($needed, { pull_foo => 1 }); +is_deeply($needed, { ndr_pull_foo => 1 }); # old settings should be kept -$needed = { pull_foo => 0 }; +$needed = { ndr_pull_foo => 0 }; NeededElement({ TYPE => "foo", REPRESENTATION_TYPE => "foo" }, "pull", $needed); -is_deeply($needed, { pull_foo => 0 }); +is_deeply($needed, { ndr_pull_foo => 0 }); # print/pull/push are independent of each other -$needed = { pull_foo => 0 }; +$needed = { ndr_pull_foo => 0 }; NeededElement({ TYPE => "foo", REPRESENTATION_TYPE => "foo" }, "print", $needed); -is_deeply($needed, { pull_foo => 0, print_foo => 1 }); +is_deeply($needed, { ndr_pull_foo => 0, ndr_print_foo => 1 }); $needed = { }; NeededFunction({ NAME => "foo", ELEMENTS => [ { TYPE => "bar", REPRESENTATION_TYPE => "bar" } ] }, $needed); -is_deeply($needed, { pull_foo => 1, print_foo => 1, push_foo => 1, - pull_bar => 1, print_bar => 1, push_bar => 1}); +is_deeply($needed, { ndr_pull_foo => 1, ndr_print_foo => 1, ndr_push_foo => 1, + ndr_pull_bar => 1, ndr_print_bar => 1, ndr_push_bar => 1}); # push/pull/print are always set for functions -$needed = { pull_foo => 0 }; +$needed = { ndr_pull_foo => 0 }; NeededFunction({ NAME => "foo", ELEMENTS => [ { TYPE => "bar", REPRESENTATION_TYPE => "bar" } ] }, $needed); -is_deeply($needed, { pull_foo => 1, print_foo => 1, push_foo => 1, - pull_bar => 1, push_bar => 1, print_bar => 1}); +is_deeply($needed, { ndr_pull_foo => 1, ndr_print_foo => 1, ndr_push_foo => 1, + ndr_pull_bar => 1, ndr_push_bar => 1, ndr_print_bar => 1}); # public structs are always needed $needed = {}; @@ -220,7 +220,7 @@ NeededInterface({ TYPES => [ { PROPERTIES => { public => 1 }, NAME => "bla", TYPE => "TYPEDEF", DATA => { TYPE => "STRUCT", ELEMENTS => [] } } ] }, $needed); -is_deeply($needed, { pull_bla => 1, push_bla => 1, print_bla => 1 }); +is_deeply($needed, { ndr_pull_bla => 1, ndr_push_bla => 1, ndr_print_bla => 1 }); # make sure types for elements are set too $needed = {}; @@ -229,8 +229,8 @@ NeededInterface({ TYPES => [ { PROPERTIES => { public => 1 }, NAME => "bla", DATA => { TYPE => "STRUCT", ELEMENTS => [ { TYPE => "bar", REPRESENTATION_TYPE => "bar" } ] } } ] }, $needed); -is_deeply($needed, { pull_bla => 1, pull_bar => 1, push_bla => 1, push_bar => 1, - print_bla => 1, print_bar => 1}); +is_deeply($needed, { ndr_pull_bla => 1, ndr_pull_bar => 1, ndr_push_bla => 1, ndr_push_bar => 1, + ndr_print_bla => 1, ndr_print_bar => 1}); $needed = {}; NeededInterface({ TYPES => [ { PROPERTIES => { gensize => 1}, NAME => "bla", @@ -241,13 +241,13 @@ NeededInterface({ TYPES => [ { PROPERTIES => { gensize => 1}, NAME => "bla", is_deeply($needed, { ndr_size_bla => 1 }); # make sure types for elements are set too -$needed = { pull_bla => 1 }; +$needed = { ndr_pull_bla => 1 }; NeededType({ NAME => "bla", TYPE => "TYPEDEF", DATA => { TYPE => "STRUCT", ELEMENTS => [ { TYPE => "bar", REPRESENTATION_TYPE => "bar" } ] } }, $needed, "pull"); -is_deeply($needed, { pull_bla => 1, pull_bar => 1 }); +is_deeply($needed, { ndr_pull_bla => 1, ndr_pull_bar => 1 }); $needed = {}; NeededInterface({ TYPES => [ { PROPERTIES => { public => 1}, @@ -255,8 +255,9 @@ NeededInterface({ TYPES => [ { PROPERTIES => { public => 1}, TYPE => "TYPEDEF", DATA => { TYPE => "STRUCT", ELEMENTS => [ { TYPE => "bar", REPRESENTATION_TYPE => "rep" } ] } } ] }, $needed); -is_deeply($needed, { pull_bla => 1, push_bla => 1, print_bla => 1, print_rep => 1, - pull_bar => 1, push_bar => 1, +is_deeply($needed, { ndr_pull_bla => 1, ndr_push_bla => 1, ndr_print_bla => 1, + ndr_print_rep => 1, + ndr_pull_bar => 1, ndr_push_bar => 1, ndr_bar_to_rep => 1, ndr_rep_to_bar => 1}); $res = ""; @@ -297,3 +298,8 @@ is($res, "if (ndr_flags & NDR_SCALARS) { if (ndr_flags & NDR_BUFFERS) { } "); + +is(TypeFunctionName("ndr_pull", "uint32"), "ndr_pull_uint32"); +is(TypeFunctionName("ndr_pull", {TYPE => "ENUM", NAME => "bar"}), "ndr_pull_ENUM_bar"); +is(TypeFunctionName("ndr_pull", {TYPE => "TYPEDEF", NAME => "bar", DATA => undef}), "ndr_pull_bar"); +is(TypeFunctionName("ndr_push", {TYPE => "STRUCT", NAME => "bar"}), "ndr_push_STRUCT_bar"); -- cgit From 3bc13d6eeda1a8e5e0ebec8c85c3aaf2ded2b111 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 28 Feb 2007 02:01:58 +0000 Subject: r21579: Use utility function to determine function names in ejs code. (This used to be commit 1736de4c73a82be8357808dc8ec93d3917213449) --- source4/pidl/tests/samba-ejs.pl | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/samba-ejs.pl b/source4/pidl/tests/samba-ejs.pl index 350cba571c..39fc22329c 100755 --- a/source4/pidl/tests/samba-ejs.pl +++ b/source4/pidl/tests/samba-ejs.pl @@ -4,13 +4,13 @@ use strict; use warnings; -use Test::More tests => 13; +use Test::More tests => 17; use FindBin qw($RealBin); use lib "$RealBin"; use Util; use Parse::Pidl::Util qw(MyDumper); use Parse::Pidl::Samba4::EJS qw(get_pointer_to get_value_of check_null_pointer - $res $res_hdr fn_declare); + $res $res_hdr fn_declare TypeFunctionName); is("&foo", get_pointer_to("foo")); is("&(&foo)", get_pointer_to(get_pointer_to("foo"))); @@ -40,3 +40,8 @@ $res_hdr = ""; fn_declare({ PROPERTIES => {} }, "mybla(int foo)"); is($res, "static mybla(int foo)\n"); is($res_hdr, ""); + +is(TypeFunctionName("ejs_pull", "uint32"), "ejs_pull_uint32"); +is(TypeFunctionName("ejs_pull", {TYPE => "ENUM", NAME => "bar"}), "ejs_pull_ENUM_bar"); +is(TypeFunctionName("ejs_pull", {TYPE => "TYPEDEF", NAME => "bar", DATA => undef}), "ejs_pull_bar"); +is(TypeFunctionName("ejs_push", {TYPE => "STRUCT", NAME => "bar"}), "ejs_push_STRUCT_bar"); -- cgit From 5ba8169109253c96f71e0e039b1c0b7a1056eab0 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 28 Feb 2007 13:25:53 +0000 Subject: r21584: Support for tagged types has landed! It's now possible to use "struct foo" without a typedef in IDL files. echo_info4 is the first type that's been converted. (This used to be commit 3ac68e858df9b53cf5e0a84741916214a53b3121) --- source4/pidl/tests/header.pl | 8 +++++++- source4/pidl/tests/ndr.pl | 7 +++++-- source4/pidl/tests/typelist.pl | 3 ++- 3 files changed, 14 insertions(+), 4 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/header.pl b/source4/pidl/tests/header.pl index 3dae33ae6c..7092eb0d14 100755 --- a/source4/pidl/tests/header.pl +++ b/source4/pidl/tests/header.pl @@ -4,7 +4,7 @@ use strict; use warnings; -use Test::More tests => 10; +use Test::More tests => 12; use FindBin qw($RealBin); use lib "$RealBin"; use Util; @@ -36,3 +36,9 @@ like(parse_idl("interface x { void foo ([in,out] uint32 x); };"), like(parse_idl("interface x { void foo (uint32 x); };"), qr/struct foo.*{.*struct\s+{\s+uint32_t x;\s+} in;\s+struct\s+{\s+uint32_t x;\s+} out;.*};/sm, "fn with no props implies in,out"); like(parse_idl("interface p { struct x { int y; }; };"), qr/struct x.*{.*int32_t y;.*}.*;/sm, "interface member generated properly"); + +like(parse_idl("interface p { struct x { struct y z; }; };"), + qr/struct x.*{.*struct y z;.*}.*;/sm, "tagged type struct member"); + +like(parse_idl("interface p { struct x { union y z; }; };"), + qr/struct x.*{.*union y z;.*}.*;/sm, "tagged type union member"); diff --git a/source4/pidl/tests/ndr.pl b/source4/pidl/tests/ndr.pl index 17003d59c4..8245f768e8 100755 --- a/source4/pidl/tests/ndr.pl +++ b/source4/pidl/tests/ndr.pl @@ -4,12 +4,12 @@ use strict; use warnings; -use Test::More tests => 25; +use Test::More tests => 26; use FindBin qw($RealBin); use lib "$RealBin"; use Util; use Parse::Pidl::Util qw(MyDumper); -use Parse::Pidl::NDR qw(GetElementLevelTable ParseElement align_type mapToScalar); +use Parse::Pidl::NDR qw(GetElementLevelTable ParseElement align_type mapToScalar ParseType); # Case 1 @@ -224,3 +224,6 @@ is(mapToScalar({TYPE => "ENUM", PARENT => { PROPERTIES => { enum8bit => 1 } } }) is(mapToScalar({TYPE => "BITMAP", PROPERTIES => { bitmap64bit => 1 } }), "hyper"); is(mapToScalar({TYPE => "TYPEDEF", DATA => {TYPE => "ENUM", PARENT => { PROPERTIES => { enum8bit => 1 } } }}), "uint8"); + +is_deeply(ParseType({TYPE => "STRUCT", NAME => "foo" }, "ref"), + {TYPE => "STRUCT", NAME => "foo" }); diff --git a/source4/pidl/tests/typelist.pl b/source4/pidl/tests/typelist.pl index 376bd208f0..c5c409a525 100755 --- a/source4/pidl/tests/typelist.pl +++ b/source4/pidl/tests/typelist.pl @@ -4,7 +4,7 @@ use strict; use warnings; -use Test::More tests => 52; +use Test::More tests => 53; use FindBin qw($RealBin); use lib "$RealBin"; use Util; @@ -60,6 +60,7 @@ is(1, is_scalar({TYPE => "DECLARE", DATA => {TYPE => "ENUM" }})); is(1, scalar_is_reference("string")); is(0, scalar_is_reference("uint32")); +is(0, scalar_is_reference({TYPE => "STRUCT", NAME => "echo_foobar"})); is("uint8", enum_type_fn({TYPE => "ENUM", PARENT=>{PROPERTIES => {enum8bit => 1}}})); is("uint32", enum_type_fn({TYPE => "ENUM", PARENT=>{PROPERTIES => {v1_enum => 1}}})); -- cgit From f653871d770006620533b7dc50f350991d567712 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 2 Mar 2007 14:05:52 +0000 Subject: r21654: Add simple test for print functions. (This used to be commit 3c9df011a85aa8178a26d66faaaed5c88757800e) --- source4/pidl/tests/samba-ndr.pl | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/samba-ndr.pl b/source4/pidl/tests/samba-ndr.pl index a806d33417..cf79cd006f 100755 --- a/source4/pidl/tests/samba-ndr.pl +++ b/source4/pidl/tests/samba-ndr.pl @@ -4,7 +4,7 @@ use strict; use warnings; -use Test::More tests => 38; +use Test::More tests => 41; use FindBin qw($RealBin); use lib "$RealBin"; use Util; @@ -12,7 +12,7 @@ use Parse::Pidl::Util qw(MyDumper); use Parse::Pidl::Samba4::NDR::Parser qw(check_null_pointer GenerateFunctionInEnv GenerateFunctionOutEnv GenerateStructEnv EnvSubstituteValue NeededFunction NeededElement NeededType $res - NeededInterface TypeFunctionName); + NeededInterface TypeFunctionName ParseElementPrint); my $output; sub print_fn($) { my $x = shift; $output.=$x; } @@ -303,3 +303,23 @@ is(TypeFunctionName("ndr_pull", "uint32"), "ndr_pull_uint32"); is(TypeFunctionName("ndr_pull", {TYPE => "ENUM", NAME => "bar"}), "ndr_pull_ENUM_bar"); is(TypeFunctionName("ndr_pull", {TYPE => "TYPEDEF", NAME => "bar", DATA => undef}), "ndr_pull_bar"); is(TypeFunctionName("ndr_push", {TYPE => "STRUCT", NAME => "bar"}), "ndr_push_STRUCT_bar"); + +# check noprint works +$res = ""; +ParseElementPrint({ NAME => "x", TYPE => "rt", REPRESENTATION_TYPE => "rt", + PROPERTIES => { noprint => 1}, + LEVELS => [ { TYPE => "DATA", DATA_TYPE => "rt"} ]}, "var", { "x" => "r->foobar" } ); +is($res, ""); + +$res = ""; +ParseElementPrint({ NAME => "x", TYPE => "rt", REPRESENTATION_TYPE => "rt", + PROPERTIES => {}, + LEVELS => [ { TYPE => "DATA", DATA_TYPE => "rt" }]}, "var", { "x" => "r->foobar" } ); +is($res, "ndr_print_rt(ndr, \"x\", &var);\n"); + +# make sure that a print function for an element with value() set works +$res = ""; +ParseElementPrint({ NAME => "x", TYPE => "uint32", REPRESENTATION_TYPE => "uint32", + PROPERTIES => { value => "23" }, + LEVELS => [ { TYPE => "DATA", DATA_TYPE => "uint32"} ]}, "var", { "x" => "r->foobar" } ); +is($res, "ndr_print_uint32(ndr, \"x\", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?23:var);\n"); -- cgit From 035adfb94399a2e2d5d4ca26aaa214576f5c0b64 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 4 Mar 2007 14:16:52 +0000 Subject: r21681: Fix bug in the parsing code that parsed "struct foo;" the same as "struct foo {};". Reported by one of the OpenChange folks, thanks! (This used to be commit d65b520f08ea4ee82c35ff334a58aa6ffc403d67) --- source4/pidl/tests/header.pl | 8 +++++++- source4/pidl/tests/parse_idl.pl | 16 +++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/header.pl b/source4/pidl/tests/header.pl index 7092eb0d14..bb09969d0f 100755 --- a/source4/pidl/tests/header.pl +++ b/source4/pidl/tests/header.pl @@ -4,7 +4,7 @@ use strict; use warnings; -use Test::More tests => 12; +use Test::More tests => 14; use FindBin qw($RealBin); use lib "$RealBin"; use Util; @@ -42,3 +42,9 @@ like(parse_idl("interface p { struct x { struct y z; }; };"), like(parse_idl("interface p { struct x { union y z; }; };"), qr/struct x.*{.*union y z;.*}.*;/sm, "tagged type union member"); + +like(parse_idl("interface p { struct x { }; };"), + qr/struct x.*{.*char _empty_;.*}.*;/sm, "empty struct"); + +like(parse_idl("interface p { struct x; };"), + qr/struct x;/sm, "struct declaration"); diff --git a/source4/pidl/tests/parse_idl.pl b/source4/pidl/tests/parse_idl.pl index 265ac7a2bd..727f41a293 100755 --- a/source4/pidl/tests/parse_idl.pl +++ b/source4/pidl/tests/parse_idl.pl @@ -4,7 +4,7 @@ # Published under the GNU General Public License use strict; -use Test::More tests => 62 * 2; +use Test::More tests => 63 * 2 + 2; use FindBin qw($RealBin); use lib "$RealBin"; use Util qw(test_errors); @@ -107,3 +107,17 @@ testfail "import-nosemicolon", "import \"foo.idl\"", ":0: Syntax error near 'foo.idl'\n"; testok "import-multiple", "import \"foo.idl\", \"bar.idl\";"; testok "include-multiple", "include \"foo.idl\", \"bar.idl\";"; +testok "empty-struct", "interface test { struct foo { }; }"; + +my $x = Parse::Pidl::IDL::parse_string("interface foo { struct x {}; }", ""); + +is_deeply($x, + [ { 'FILE' => '', 'NAME' => 'foo', 'DATA' => [ + { 'NAME' => 'x', 'TYPE' => 'STRUCT', ELEMENTS => [] } ], + 'TYPE' => 'INTERFACE', 'LINE' => 0 } ]); + +$x = Parse::Pidl::IDL::parse_string("interface foo { struct x; }", ""); +is_deeply($x, + [ { 'FILE' => '', 'NAME' => 'foo', 'DATA' => [ + { 'NAME' => 'x', 'TYPE' => 'STRUCT' } ], + 'TYPE' => 'INTERFACE', 'LINE' => 0 } ]); -- cgit From faaac73ff69699b84266e82b342690c2dc375df2 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 5 Mar 2007 00:03:44 +0000 Subject: r21690: Test use of typedef /and/ struct name (This used to be commit f6d9cdb8a8eca6ff986504d4481b5165aee770c6) --- source4/pidl/tests/header.pl | 5 ++++- source4/pidl/tests/parse_idl.pl | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/header.pl b/source4/pidl/tests/header.pl index bb09969d0f..331f4dd9fb 100755 --- a/source4/pidl/tests/header.pl +++ b/source4/pidl/tests/header.pl @@ -4,7 +4,7 @@ use strict; use warnings; -use Test::More tests => 14; +use Test::More tests => 15; use FindBin qw($RealBin); use lib "$RealBin"; use Util; @@ -48,3 +48,6 @@ like(parse_idl("interface p { struct x { }; };"), like(parse_idl("interface p { struct x; };"), qr/struct x;/sm, "struct declaration"); + +like(parse_idl("interface p { typedef struct x { int p; } x; };"), + qr/struct x.*{.*int32_t p;.*};/sm, "double struct declaration"); diff --git a/source4/pidl/tests/parse_idl.pl b/source4/pidl/tests/parse_idl.pl index 727f41a293..b82bd80e54 100755 --- a/source4/pidl/tests/parse_idl.pl +++ b/source4/pidl/tests/parse_idl.pl @@ -4,7 +4,7 @@ # Published under the GNU General Public License use strict; -use Test::More tests => 63 * 2 + 2; +use Test::More tests => 64 * 2 + 2; use FindBin qw($RealBin); use lib "$RealBin"; use Util qw(test_errors); @@ -108,6 +108,7 @@ testfail "import-nosemicolon", "import \"foo.idl\"", testok "import-multiple", "import \"foo.idl\", \"bar.idl\";"; testok "include-multiple", "include \"foo.idl\", \"bar.idl\";"; testok "empty-struct", "interface test { struct foo { }; }"; +testok "typedef-double", "interface test { typedef struct foo { } foo; }"; my $x = Parse::Pidl::IDL::parse_string("interface foo { struct x {}; }", ""); -- cgit From a0bfcfa55d9f00ffab59e8cf7529cadf108a5629 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 19 Apr 2007 01:26:15 +0000 Subject: r22357: Don't use 'our' (This used to be commit 7989ee2aa015264dc9334b5e15d4fe6cb55f4e09) --- source4/pidl/tests/wireshark-ndr.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/wireshark-ndr.pl b/source4/pidl/tests/wireshark-ndr.pl index 40e22d958c..724b79ee10 100755 --- a/source4/pidl/tests/wireshark-ndr.pl +++ b/source4/pidl/tests/wireshark-ndr.pl @@ -234,7 +234,7 @@ is(DumpHfList(), "\tstatic hf_register_info hf[] = { is(DumpHfDeclaration(), " /* Header field declarations */ -static gint hf_bla = -1; +static gint hf_bla_idx = -1; "); -- cgit From 3b39a0df0aa941c88a872f24279584cd86558b6c Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 22 Apr 2007 10:42:33 +0000 Subject: r22453: Fix TDR testsuite without using our. (This used to be commit 2c82aea0d3cb43b6d653fa7d64d490eddef26903) --- source4/pidl/tests/tdr.pl | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/tdr.pl b/source4/pidl/tests/tdr.pl index 35e54f53fc..d6cd7a03d4 100755 --- a/source4/pidl/tests/tdr.pl +++ b/source4/pidl/tests/tdr.pl @@ -8,21 +8,23 @@ use Test::More tests => 6; use FindBin qw($RealBin); use lib "$RealBin"; use Util; -use Parse::Pidl::Samba4::TDR qw($ret $ret_hdr ParserType); +use Parse::Pidl::Samba4::TDR qw(ParserType); -ParserType({TYPE => "STRUCT", NAME => "foo", PROPERTIES => {public => 1}}, "pull"); -is($ret, "NTSTATUS tdr_pull_foo (struct tdr_pull *tdr, TALLOC_CTX *mem_ctx, struct foo *v) +my $tdr = new Parse::Pidl::Samba4::TDR(); + +$tdr->ParserType({TYPE => "STRUCT", NAME => "foo", PROPERTIES => {public => 1}}, "pull"); +is($tdr->{ret}, "NTSTATUS tdr_pull_foo (struct tdr_pull *tdr, TALLOC_CTX *mem_ctx, struct foo *v) { return NT_STATUS_OK; } "); -is($ret_hdr, "NTSTATUS tdr_pull_foo (struct tdr_pull *tdr, TALLOC_CTX *mem_ctx, struct foo *v);\n"); +is($tdr->{ret_hdr}, "NTSTATUS tdr_pull_foo (struct tdr_pull *tdr, TALLOC_CTX *mem_ctx, struct foo *v);\n"); -$ret = ""; $ret_hdr = ""; -ParserType({TYPE => "UNION", NAME => "bar", PROPERTIES => {public => 1}}, "pull"); -is($ret, "NTSTATUS tdr_pull_bar(struct tdr_pull *tdr, TALLOC_CTX *mem_ctx, int level, union bar *v) +$tdr = new Parse::Pidl::Samba4::TDR(); +$tdr->ParserType({TYPE => "UNION", NAME => "bar", PROPERTIES => {public => 1}}, "pull"); +is($tdr->{ret}, "NTSTATUS tdr_pull_bar(struct tdr_pull *tdr, TALLOC_CTX *mem_ctx, int level, union bar *v) { switch (level) { } @@ -31,12 +33,11 @@ is($ret, "NTSTATUS tdr_pull_bar(struct tdr_pull *tdr, TALLOC_CTX *mem_ctx, int l } "); -is($ret_hdr, "NTSTATUS tdr_pull_bar(struct tdr_pull *tdr, TALLOC_CTX *mem_ctx, int level, union bar *v);\n"); - -$ret = ""; $ret_hdr = ""; +is($tdr->{ret_hdr}, "NTSTATUS tdr_pull_bar(struct tdr_pull *tdr, TALLOC_CTX *mem_ctx, int level, union bar *v);\n"); -ParserType({TYPE => "UNION", NAME => "bar", PROPERTIES => {}}, "pull"); -is($ret, "static NTSTATUS tdr_pull_bar(struct tdr_pull *tdr, TALLOC_CTX *mem_ctx, int level, union bar *v) +$tdr = new Parse::Pidl::Samba4::TDR(); +$tdr->ParserType({TYPE => "UNION", NAME => "bar", PROPERTIES => {}}, "pull"); +is($tdr->{ret}, "static NTSTATUS tdr_pull_bar(struct tdr_pull *tdr, TALLOC_CTX *mem_ctx, int level, union bar *v) { switch (level) { } @@ -45,4 +46,4 @@ is($ret, "static NTSTATUS tdr_pull_bar(struct tdr_pull *tdr, TALLOC_CTX *mem_ctx } "); -is($ret_hdr, ""); +is($tdr->{ret_hdr}, ""); -- cgit From 68d92f0a123374972ee2aa54dd708f089cb59837 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 22 Apr 2007 13:57:07 +0000 Subject: r22456: Merge wireshark and ejs test improvements. (This used to be commit 0375978403dde8ef5052dcca544f118e5387e887) --- source4/pidl/tests/samba-ejs.pl | 39 ++++++------ source4/pidl/tests/wireshark-ndr.pl | 124 ++++++++++++++++++------------------ 2 files changed, 81 insertions(+), 82 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/samba-ejs.pl b/source4/pidl/tests/samba-ejs.pl index 39fc22329c..adc00e224f 100755 --- a/source4/pidl/tests/samba-ejs.pl +++ b/source4/pidl/tests/samba-ejs.pl @@ -10,7 +10,7 @@ use lib "$RealBin"; use Util; use Parse::Pidl::Util qw(MyDumper); use Parse::Pidl::Samba4::EJS qw(get_pointer_to get_value_of check_null_pointer - $res $res_hdr fn_declare TypeFunctionName); + fn_declare TypeFunctionName); is("&foo", get_pointer_to("foo")); is("&(&foo)", get_pointer_to(get_pointer_to("foo"))); @@ -21,25 +21,24 @@ is("foo", get_value_of("&foo")); is("*foo", get_value_of("foo")); is("**foo", get_value_of("*foo")); -$res = ""; -check_null_pointer("bla"); -is($res, ""); - -$res = ""; -check_null_pointer("*bla"); -is($res, "if (bla == NULL) return NT_STATUS_INVALID_PARAMETER_MIX;\n"); - -$res = ""; -$res_hdr = ""; -fn_declare({ PROPERTIES => { public => 1 } }, "myproto(int x)"); -is($res, "_PUBLIC_ myproto(int x)\n"); -is($res_hdr, "myproto(int x);\n"); - -$res = ""; -$res_hdr = ""; -fn_declare({ PROPERTIES => {} }, "mybla(int foo)"); -is($res, "static mybla(int foo)\n"); -is($res_hdr, ""); +my $ejs = new Parse::Pidl::Samba4::EJS(); + +$ejs->check_null_pointer("bla"); +is($ejs->{res}, ""); + +$ejs = new Parse::Pidl::Samba4::EJS(); +$ejs->check_null_pointer("*bla"); +is($ejs->{res}, "if (bla == NULL) return NT_STATUS_INVALID_PARAMETER_MIX;\n"); + +$ejs = new Parse::Pidl::Samba4::EJS(); +$ejs->fn_declare({ PROPERTIES => { public => 1 } }, "myproto(int x)"); +is($ejs->{res}, "_PUBLIC_ myproto(int x)\n"); +is($ejs->{res_hdr}, "myproto(int x);\n"); + +$ejs = new Parse::Pidl::Samba4::EJS(); +$ejs->fn_declare({ PROPERTIES => {} }, "mybla(int foo)"); +is($ejs->{res}, "static mybla(int foo)\n"); +is($ejs->{res_hdr}, ""); is(TypeFunctionName("ejs_pull", "uint32"), "ejs_pull_uint32"); is(TypeFunctionName("ejs_pull", {TYPE => "ENUM", NAME => "bar"}), "ejs_pull_ENUM_bar"); diff --git a/source4/pidl/tests/wireshark-ndr.pl b/source4/pidl/tests/wireshark-ndr.pl index 724b79ee10..8c2cd47584 100755 --- a/source4/pidl/tests/wireshark-ndr.pl +++ b/source4/pidl/tests/wireshark-ndr.pl @@ -10,44 +10,44 @@ use FindBin qw($RealBin); use lib "$RealBin"; use Util; use Parse::Pidl::Util qw(MyDumper); -use Parse::Pidl::Wireshark::NDR qw(field2name %res PrintIdl StripPrefixes %hf_used RegisterInterfaceHandoff $conformance register_hf_field CheckUsed ProcessImport ProcessInclude find_type DumpEttList DumpEttDeclaration DumpHfList DumpHfDeclaration DumpFunctionTable register_type @ett register_ett); +use strict; +use Parse::Pidl::Wireshark::NDR qw(field2name %res PrintIdl StripPrefixes RegisterInterfaceHandoff register_hf_field ProcessImport ProcessInclude find_type DumpEttList DumpEttDeclaration DumpHfList DumpHfDeclaration DumpFunctionTable register_type register_ett); is("Access Mask", field2name("access_mask")); is("Accessmask", field2name("AccessMask")); -$res{code} = ""; -PrintIdl("foo\nbar\n"); +my $x = new Parse::Pidl::Wireshark::NDR(); +$x->PrintIdl("foo\nbar\n"); is("/* IDL: foo */ /* IDL: bar */ -", $res{code}); +", $x->{res}->{code}); is("bla_foo", StripPrefixes("bla_foo", [])); is("foo", StripPrefixes("bla_foo", ["bla"])); is("foo_bla", StripPrefixes("foo_bla", ["bla"])); -%hf_used = (); -$res{code} = ""; -RegisterInterfaceHandoff({}); -is($res{code}, ""); -ok(not defined($hf_used{hf_bla_opnum})); +$x = new Parse::Pidl::Wireshark::NDR(); +$x->RegisterInterfaceHandoff({}); +is($x->{res}->{code}, ""); +ok(not defined($x->{hf_used}->{hf_bla_opnum})); -%hf_used = (); -$res{code} = ""; -RegisterInterfaceHandoff({UUID => "uuid", NAME => "bla"}); -is($res{code}, 'void proto_reg_handoff_dcerpc_bla(void) +$x = new Parse::Pidl::Wireshark::NDR(); +$x->{res}->{code} = ""; +$x->RegisterInterfaceHandoff({UUID => "uuid", NAME => "bla"}); +is($x->{res}->{code}, 'void proto_reg_handoff_dcerpc_bla(void) { dcerpc_init_uuid(proto_dcerpc_bla, ett_dcerpc_bla, &uuid_dcerpc_bla, ver_dcerpc_bla, bla_dissectors, hf_bla_opnum); } '); -is($hf_used{hf_bla_opnum}, 1); +is($x->{hf_used}->{hf_bla_opnum}, 1); -$conformance = {}; +$x->{conformance} = {}; is("hf_bla_idx", - register_hf_field("hf_bla_idx", "bla", "my.filter", "FT_UINT32", "BASE_HEX", "NULL", 0xF, undef)); -is_deeply($conformance, { + $x->register_hf_field("hf_bla_idx", "bla", "my.filter", "FT_UINT32", "BASE_HEX", "NULL", 0xF, undef)); +is_deeply($x->{conformance}, { header_fields => { "hf_bla_idx" => { INDEX => "hf_bla_idx", @@ -64,10 +64,10 @@ is_deeply($conformance, { fielddescription => {} }); -$conformance = { fielddescription => { hf_bla_idx => { DESCRIPTION => "Some Description" }}}; +$x->{conformance} = { fielddescription => { hf_bla_idx => { DESCRIPTION => "Some Description" }}}; is("hf_bla_idx", - register_hf_field("hf_bla_idx", "bla", "my.filter", "FT_UINT32", "BASE_HEX", "NULL", 0xF, undef)); -is_deeply($conformance, { + $x->register_hf_field("hf_bla_idx", "bla", "my.filter", "FT_UINT32", "BASE_HEX", "NULL", 0xF, undef)); +is_deeply($x->{conformance}, { fielddescription => { hf_bla_idx => { DESCRIPTION => "Some Description", @@ -89,11 +89,11 @@ is_deeply($conformance, { hf_renames => {}, }); -$conformance = { fielddescription => { hf_bla_idx => { DESCRIPTION => "Some Description" }}}; +$x->{conformance} = { fielddescription => { hf_bla_idx => { DESCRIPTION => "Some Description" }}}; is("hf_bla_idx", - register_hf_field("hf_bla_idx", "bla", "my.filter", "FT_UINT32", "BASE_HEX", "NULL", 0xF, + $x->register_hf_field("hf_bla_idx", "bla", "my.filter", "FT_UINT32", "BASE_HEX", "NULL", 0xF, "Actual Description")); -is_deeply($conformance, { +is_deeply($x->{conformance}, { fielddescription => { hf_bla_idx => { DESCRIPTION => "Some Description" } }, @@ -114,21 +114,21 @@ is_deeply($conformance, { -$conformance = { hf_renames => { "hf_bla_idx" => { NEWNAME => "hf_bloe_idx" } } }; -register_hf_field("hf_bla_idx", "bla", "my.filter", "FT_UINT32", "BASE_HEX", "NULL", 0xF, undef); -is_deeply($conformance, { +$x->{conformance} = { hf_renames => { "hf_bla_idx" => { NEWNAME => "hf_bloe_idx" } } }; +$x->register_hf_field("hf_bla_idx", "bla", "my.filter", "FT_UINT32", "BASE_HEX", "NULL", 0xF, undef); +is_deeply($x->{conformance}, { hf_renames => { hf_bla_idx => { USED => 1, NEWNAME => "hf_bloe_idx" } } }); -%hf_used = ( hf_bla => 1 ); +$x->{hf_used} = { hf_bla => 1 }; test_warnings("", sub { - CheckUsed({ header_fields => { foo => { INDEX => "hf_bla" }}})}); + $x->CheckUsed({ header_fields => { foo => { INDEX => "hf_bla" }}})}); -%hf_used = ( ); +$x->{hf_used} = { }; test_warnings("hf field `hf_bla' not used\n", sub { - CheckUsed({ header_fields => { foo => { INDEX => "hf_bla" }}})}); + $x->CheckUsed({ header_fields => { foo => { INDEX => "hf_bla" }}})}); test_warnings("hf field `hf_id' not used\n", - sub { CheckUsed({ + sub { $x->CheckUsed({ hf_renames => { hf_id => { OLDNAME => "hf_id", @@ -139,7 +139,7 @@ test_warnings("hf field `hf_id' not used\n", }); } ); test_warnings("dissector param never used\n", - sub { CheckUsed({ + sub { $x->CheckUsed({ dissectorparams => { dissect_foo => { PARAM => 42, @@ -149,7 +149,7 @@ test_warnings("dissector param never used\n", }); } ); test_warnings("description never used\n", - sub { CheckUsed({ + sub { $x->CheckUsed({ fielddescription => { hf_bla => { USED => 0 @@ -158,7 +158,7 @@ test_warnings("description never used\n", }); } ); test_warnings("import never used\n", - sub { CheckUsed({ + sub { $x->CheckUsed({ imports => { bla => { USED => 0 @@ -167,7 +167,7 @@ test_warnings("import never used\n", }); } ); test_warnings("nofile:1: type never used\n", - sub { CheckUsed({ + sub { $x->CheckUsed({ types => { bla => { USED => 0, @@ -177,7 +177,7 @@ test_warnings("nofile:1: type never used\n", }); } ); test_warnings("True/False description never used\n", - sub { CheckUsed({ + sub { $x->CheckUsed({ tfs => { hf_bloe => { USED => 0 @@ -185,34 +185,34 @@ test_warnings("True/False description never used\n", } }); } ); -$res{hdr} = ""; -ProcessImport("security", "bla"); -is($res{hdr}, "#include \"packet-dcerpc-bla.h\"\n\n"); +$x = new Parse::Pidl::Wireshark::NDR(); +$x->ProcessImport("security", "bla"); +is($x->{res}->{hdr}, "#include \"packet-dcerpc-bla.h\"\n\n"); -$res{hdr} = ""; -ProcessImport("\"bla.idl\"", "\"foo.idl\""); -is($res{hdr}, "#include \"packet-dcerpc-bla.h\"\n" . +$x = new Parse::Pidl::Wireshark::NDR(); +$x->ProcessImport("\"bla.idl\"", "\"foo.idl\""); +is($x->{res}->{hdr}, "#include \"packet-dcerpc-bla.h\"\n" . "#include \"packet-dcerpc-foo.h\"\n\n"); -$res{hdr} = ""; -ProcessInclude("foo.h", "bla.h", "bar.h"); -is($res{hdr}, "#include \"foo.h\"\n" . +$x = new Parse::Pidl::Wireshark::NDR(); +$x->ProcessInclude("foo.h", "bla.h", "bar.h"); +is($x->{res}->{hdr}, "#include \"foo.h\"\n" . "#include \"bla.h\"\n" . "#include \"bar.h\"\n\n"); -$conformance = {types => { bla => "brainslug" } }; -is("brainslug", find_type("bla")); +$x->{conformance} = {types => { bla => "brainslug" } }; +is("brainslug", $x->find_type("bla")); -is(DumpEttList("ett_t1", "ett_bla"), +is(DumpEttList(["ett_t1", "ett_bla"]), "\tstatic gint *ett[] = {\n" . "\t\t&ett_t1,\n" . "\t\t&ett_bla,\n" . "\t};\n"); is(DumpEttList(), "\tstatic gint *ett[] = {\n\t};\n"); -is(DumpEttList("bla"), "\tstatic gint *ett[] = {\n\t\t&bla,\n\t};\n"); +is(DumpEttList(["bla"]), "\tstatic gint *ett[] = {\n\t\t&bla,\n\t};\n"); -is(DumpEttDeclaration("void", "zoid"), +is(DumpEttDeclaration(["void", "zoid"]), "\n/* Ett declarations */\n" . "static gint void = -1;\n" . "static gint zoid = -1;\n" . @@ -220,21 +220,21 @@ is(DumpEttDeclaration("void", "zoid"), is(DumpEttDeclaration(), "\n/* Ett declarations */\n\n"); -$conformance = { +$x->{conformance} = { header_fields => { hf_bla => { INDEX => "hf_bla", NAME => "Bla", FILTER => "bla.field", FT_TYPE => "FT_UINT32", BASE_TYPE => "BASE_DEC", VALSSTRING => "NULL", MASK => 0xFF, BLURB => "NULL" } } }; -is(DumpHfList(), "\tstatic hf_register_info hf[] = { +is($x->DumpHfList(), "\tstatic hf_register_info hf[] = { { &hf_bla, { \"Bla\", \"bla.field\", FT_UINT32, BASE_DEC, NULL, 255, \"NULL\", HFILL }}, }; "); -is(DumpHfDeclaration(), " +is($x->DumpHfDeclaration(), " /* Header field declarations */ -static gint hf_bla_idx = -1; +static gint hf_bla = -1; "); @@ -250,9 +250,9 @@ is(DumpFunctionTable({ }; '); -$conformance = {}; -register_type("bla_type", "dissect_bla", "FT_UINT32", "BASE_HEX", 0xFF, "NULL", 4); -is_deeply($conformance, { +$x->{conformance} = {}; +$x->register_type("bla_type", "dissect_bla", "FT_UINT32", "BASE_HEX", 0xFF, "NULL", 4); +is_deeply($x->{conformance}, { types => { bla_type => { NAME => "bla_type", @@ -267,8 +267,8 @@ is_deeply($conformance, { } ); -@ett = (); -register_ett("name"); -is_deeply(\@ett, ["name"]); -register_ett("leela"); -is_deeply(\@ett, ["name", "leela"]); +$x->{ett} = []; +$x->register_ett("name"); +is_deeply($x->{ett}, ["name"]); +$x->register_ett("leela"); +is_deeply($x->{ett}, ["name", "leela"]); -- cgit From b0d209087939c0de765349c80a22884b956f3f0f Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 22 Apr 2007 14:19:22 +0000 Subject: r22457: Fix tests for Samba3 client generator. (This used to be commit cf5162ad100c1a8201d3309549c8ff0d3bd5a732) --- source4/pidl/tests/samba3-cli.pl | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/samba3-cli.pl b/source4/pidl/tests/samba3-cli.pl index 1d1bae8550..c5537c145e 100755 --- a/source4/pidl/tests/samba3-cli.pl +++ b/source4/pidl/tests/samba3-cli.pl @@ -9,8 +9,7 @@ use FindBin qw($RealBin); use lib "$RealBin"; use Util; use Parse::Pidl::Util qw(MyDumper); -use Parse::Pidl::Samba3::ClientNDR qw(GenerateFunctionInEnv ParseFunction $res - $res_hdr); +use Parse::Pidl::Samba3::ClientNDR qw(GenerateFunctionInEnv ParseFunction); # Make sure GenerateFunctionInEnv and GenerateFunctionOutEnv work my $fn = { ELEMENTS => [ { DIRECTION => ["in"], NAME => "foo" } ] }; @@ -22,9 +21,11 @@ is_deeply({ "foo" => "r.in.foo" }, GenerateFunctionInEnv($fn)); $fn = { ELEMENTS => [ { DIRECTION => ["out"], NAME => "foo" } ] }; is_deeply({ }, GenerateFunctionInEnv($fn)); +my $x = new Parse::Pidl::Samba3::ClientNDR(); + $fn = { NAME => "bar", ELEMENTS => [ ] }; -ParseFunction("foo", $fn); -is($res, "NTSTATUS rpccli_bar(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx) +$x->ParseFunction("foo", $fn); +is($x->{res}, "NTSTATUS rpccli_bar(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx) { \tstruct bar r; \tNTSTATUS status; -- cgit From cc5ad07d84df94f8f2bc16fcb8015f1cf843c1e3 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 22 Apr 2007 15:59:34 +0000 Subject: r22462: Fix test suite for ndr parser without using 'our' (This used to be commit d491e60c70de8d78c333b317a143919c1a68c6d9) --- source4/pidl/tests/Util.pm | 3 ++- source4/pidl/tests/samba-ndr.pl | 33 +++++++++++++++++---------------- 2 files changed, 19 insertions(+), 17 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/Util.pm b/source4/pidl/tests/Util.pm index a65cd89c55..48a08b5749 100644 --- a/source4/pidl/tests/Util.pm +++ b/source4/pidl/tests/Util.pm @@ -54,7 +54,8 @@ sub test_samba4_ndr ok(defined($header), "($name) generate generic header"); my $pndr = Parse::Pidl::NDR::Parse($pidl); ok(defined($pndr), "($name) generate NDR tree"); - my ($ndrheader,$ndrparser) = Parse::Pidl::Samba4::NDR::Parser::Parse($pndr, undef, undef); + my $generator = new Parse::Pidl::Samba4::NDR::Parser(); + my ($ndrheader,$ndrparser) = $generator->Parse($pndr, undef, undef); ok(defined($ndrparser), "($name) generate NDR parser"); ok(defined($ndrheader), "($name) generate NDR header"); diff --git a/source4/pidl/tests/samba-ndr.pl b/source4/pidl/tests/samba-ndr.pl index cf79cd006f..05c3c1c0df 100755 --- a/source4/pidl/tests/samba-ndr.pl +++ b/source4/pidl/tests/samba-ndr.pl @@ -8,10 +8,11 @@ use Test::More tests => 41; use FindBin qw($RealBin); use lib "$RealBin"; use Util; +use strict; use Parse::Pidl::Util qw(MyDumper); use Parse::Pidl::Samba4::NDR::Parser qw(check_null_pointer GenerateFunctionInEnv GenerateFunctionOutEnv GenerateStructEnv - EnvSubstituteValue NeededFunction NeededElement NeededType $res + EnvSubstituteValue NeededFunction NeededElement NeededType NeededInterface TypeFunctionName ParseElementPrint); my $output; @@ -260,21 +261,21 @@ is_deeply($needed, { ndr_pull_bla => 1, ndr_push_bla => 1, ndr_print_bla => 1, ndr_pull_bar => 1, ndr_push_bar => 1, ndr_bar_to_rep => 1, ndr_rep_to_bar => 1}); -$res = ""; -Parse::Pidl::Samba4::NDR::Parser::ParseStructPush({ +my $generator = new Parse::Pidl::Samba4::NDR::Parser(); +$generator->ParseStructPush({ NAME => "mystruct", TYPE => "STRUCT", PROPERTIES => {}, ALIGN => 4, ELEMENTS => [ ]}, "x"); -is($res, "if (ndr_flags & NDR_SCALARS) { +is($generator->{res}, "if (ndr_flags & NDR_SCALARS) { NDR_CHECK(ndr_push_align(ndr, 4)); } if (ndr_flags & NDR_BUFFERS) { } "); -$res = ""; +$generator = new Parse::Pidl::Samba4::NDR::Parser(); my $e = { NAME => "el1", TYPE => "mytype", @@ -283,14 +284,14 @@ my $e = { LEVELS => [ { LEVEL_INDEX => 0, TYPE => "DATA", DATA_TYPE => "mytype" } ] }; -Parse::Pidl::Samba4::NDR::Parser::ParseStructPush({ +$generator->ParseStructPush({ NAME => "mystruct", TYPE => "STRUCT", PROPERTIES => {}, ALIGN => 4, SURROUNDING_ELEMENT => $e, ELEMENTS => [ $e ]}, "x"); -is($res, "if (ndr_flags & NDR_SCALARS) { +is($generator->{res}, "if (ndr_flags & NDR_SCALARS) { NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_string_array_size(ndr, x->el1))); NDR_CHECK(ndr_push_align(ndr, 4)); NDR_CHECK(ndr_push_mytype(ndr, NDR_SCALARS, &x->el1)); @@ -305,21 +306,21 @@ is(TypeFunctionName("ndr_pull", {TYPE => "TYPEDEF", NAME => "bar", DATA => undef is(TypeFunctionName("ndr_push", {TYPE => "STRUCT", NAME => "bar"}), "ndr_push_STRUCT_bar"); # check noprint works -$res = ""; -ParseElementPrint({ NAME => "x", TYPE => "rt", REPRESENTATION_TYPE => "rt", +$generator = new Parse::Pidl::Samba4::NDR::Parser(); +$generator->ParseElementPrint({ NAME => "x", TYPE => "rt", REPRESENTATION_TYPE => "rt", PROPERTIES => { noprint => 1}, LEVELS => [ { TYPE => "DATA", DATA_TYPE => "rt"} ]}, "var", { "x" => "r->foobar" } ); -is($res, ""); +is($generator->{res}, ""); -$res = ""; -ParseElementPrint({ NAME => "x", TYPE => "rt", REPRESENTATION_TYPE => "rt", +$generator = new Parse::Pidl::Samba4::NDR::Parser(); +$generator->ParseElementPrint({ NAME => "x", TYPE => "rt", REPRESENTATION_TYPE => "rt", PROPERTIES => {}, LEVELS => [ { TYPE => "DATA", DATA_TYPE => "rt" }]}, "var", { "x" => "r->foobar" } ); -is($res, "ndr_print_rt(ndr, \"x\", &var);\n"); +is($generator->{res}, "ndr_print_rt(ndr, \"x\", &var);\n"); # make sure that a print function for an element with value() set works -$res = ""; -ParseElementPrint({ NAME => "x", TYPE => "uint32", REPRESENTATION_TYPE => "uint32", +$generator = new Parse::Pidl::Samba4::NDR::Parser(); +$generator->ParseElementPrint({ NAME => "x", TYPE => "uint32", REPRESENTATION_TYPE => "uint32", PROPERTIES => { value => "23" }, LEVELS => [ { TYPE => "DATA", DATA_TYPE => "uint32"} ]}, "var", { "x" => "r->foobar" } ); -is($res, "ndr_print_uint32(ndr, \"x\", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?23:var);\n"); +is($generator->{res}, "ndr_print_uint32(ndr, \"x\", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?23:var);\n"); -- cgit From 771b57b3fcd0daeb3731f18e5b4ef95013150b82 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 25 Apr 2007 16:10:54 +0000 Subject: r22520: Fix the TYPE command. (This used to be commit b81b0d3308bf51c2e22d54024b3d6f1a59c6b283) --- source4/pidl/tests/wireshark-conf.pl | 47 +++++++++++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 6 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/wireshark-conf.pl b/source4/pidl/tests/wireshark-conf.pl index 617a63029a..d6fe3158aa 100755 --- a/source4/pidl/tests/wireshark-conf.pl +++ b/source4/pidl/tests/wireshark-conf.pl @@ -5,7 +5,7 @@ use strict; use warnings; -use Test::More tests => 45; +use Test::More tests => 47; use FindBin qw($RealBin); use lib "$RealBin"; use Util; @@ -61,11 +61,11 @@ is_deeply(parse_conf("CODE START\ndata\nmore data\nCODE END\n"), { override => " test_warnings("nofile:1: Unknown command `CODE'\n", sub { parse_conf("CODE END\n"); } ); -is_deeply(parse_conf("TYPE winreg_String dissect_myminregstring FT_STRING BASE_DEC 0 0 2\n"), { types => { winreg_String => { +is_deeply(parse_conf("TYPE winreg_String dissect_myminregstring(); FT_STRING BASE_DEC 0 0 2\n"), { types => { winreg_String => { NAME => "winreg_String", POS => { FILE => "nofile", LINE => 1 }, USED => 0, - DISSECTOR_NAME => "dissect_myminregstring", + DISSECTOR_NAME => "dissect_myminregstring();", FT_TYPE => "FT_STRING", BASE_TYPE => "BASE_DEC", MASK => 0, @@ -87,13 +87,13 @@ test_errors("nofile:1: incomplete TYPE command\n", sub { parse_conf("TYPE mytype dissector\n"); }); test_warnings("nofile:1: dissector name does not contain `dissect'\n", - sub { parse_conf("TYPE winreg_String myminregstring FT_STRING BASE_DEC 0 0 2\n"); }); + sub { parse_conf("TYPE winreg_String myminregstring; FT_STRING BASE_DEC 0 0 2\n"); }); test_warnings("nofile:1: invalid FT_TYPE `BLA'\n", - sub { parse_conf("TYPE winreg_String dissect_myminregstring BLA BASE_DEC 0 0 2\n"); }); + sub { parse_conf("TYPE winreg_String dissect_myminregstring; BLA BASE_DEC 0 0 2\n"); }); test_warnings("nofile:1: invalid BASE_TYPE `BLOE'\n", - sub { parse_conf("TYPE winreg_String dissect_myminregstring FT_UINT32 BLOE 0 0 2\n"); }); + sub { parse_conf("TYPE winreg_String dissect_myminregstring; FT_UINT32 BLOE 0 0 2\n"); }); is_deeply(parse_conf("TFS hf_bla \"True string\" \"False String\"\n"), { tfs => { hf_bla => { @@ -163,3 +163,38 @@ test_errors("nofile:1: no dissectorname specified\n", test_errors("nofile:1: incomplete HF_FIELD command\n", sub { parse_conf("HF_FIELD hf_idx\n"); }); + +is_deeply(parse_conf("TYPE winreg_String dissect_myminregstring(); FT_STRING BASE_DEC 0 0 0 2\n"), { + types => { + winreg_String => { + NAME => "winreg_String", + POS => { FILE => "nofile", LINE => 1 }, + USED => 0, + DISSECTOR_NAME => "dissect_myminregstring();", + FT_TYPE => "FT_STRING", + BASE_TYPE => "BASE_DEC", + MASK => 0, + VALSSTRING => 0, + ALIGNMENT => 0 + } + } + } +); + + +is_deeply(parse_conf("TYPE winreg_String \"offset = dissect_myminregstring(\@HF\@);\" FT_STRING BASE_DEC 0 0 0 2\n"), { + types => { + winreg_String => { + NAME => "winreg_String", + POS => { FILE => "nofile", LINE => 1 }, + USED => 0, + DISSECTOR_NAME => "offset = dissect_myminregstring(\@HF\@);", + FT_TYPE => "FT_STRING", + BASE_TYPE => "BASE_DEC", + MASK => 0, + VALSSTRING => 0, + ALIGNMENT => 0 + } + } + } +); -- cgit From ffe21e4a7c294a71dcde099dbae10dd1769e77f0 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 22 May 2007 11:23:36 +0000 Subject: r23069: print out the command, to find out the problem on host 'tridge' metze (This used to be commit 3f28a19ea1599f7a94faf7d8ee7ea5b3620abe6e) --- source4/pidl/tests/Util.pm | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/Util.pm b/source4/pidl/tests/Util.pm index 48a08b5749..d4cdd72205 100644 --- a/source4/pidl/tests/Util.pm +++ b/source4/pidl/tests/Util.pm @@ -92,6 +92,7 @@ SKIP: { my $cmd = "$cc $cflags -x c - -o $outfile $flags $ldflags"; $cmd =~ s/\n//g; +print "cmd: $cmd\n"; open CC, "|$cmd"; print CC "#define uint_t unsigned int\n"; print CC "#define _GNU_SOURCE\n"; -- cgit From dbff619f2a80d6c16a28ab803390d0658ddcfc1c Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 22 May 2007 12:45:58 +0000 Subject: r23071: print the command on failure only metze (This used to be commit 65ed39172953507610b41273d4a46470725e2012) --- source4/pidl/tests/Util.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/Util.pm b/source4/pidl/tests/Util.pm index d4cdd72205..897e848440 100644 --- a/source4/pidl/tests/Util.pm +++ b/source4/pidl/tests/Util.pm @@ -92,7 +92,6 @@ SKIP: { my $cmd = "$cc $cflags -x c - -o $outfile $flags $ldflags"; $cmd =~ s/\n//g; -print "cmd: $cmd\n"; open CC, "|$cmd"; print CC "#define uint_t unsigned int\n"; print CC "#define _GNU_SOURCE\n"; @@ -120,6 +119,7 @@ print "cmd: $cmd\n"; ok(-f $outfile, "($name) compile"); my $ret = system($outfile, ()) >> 8; + print "# cmd: $cmd\n" if ($ret != 0); print "# return code: $ret\n" if ($ret != 0); ok($ret == 0, "($name) run"); -- cgit From 74b35321dc043188386d0305508b5276a5290d0d Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 3 Jul 2007 07:28:46 +0000 Subject: r23677: When I removed data_blob_equal, I clearly didn't test the PIDL code. Fix these to use the new data_blob_cmp() Andrew Bartlett (This used to be commit d2fba8faf03c18f4c79e83d5847e5420377d811b) --- source4/pidl/tests/ndr_align.pl | 10 +++++----- source4/pidl/tests/ndr_tagtype.pl | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/ndr_align.pl b/source4/pidl/tests/ndr_align.pl index 405b74597c..0824acc501 100755 --- a/source4/pidl/tests/ndr_align.pl +++ b/source4/pidl/tests/ndr_align.pl @@ -29,7 +29,7 @@ test_samba4_ndr('align-uint8-uint16', result_blob = ndr_push_blob(ndr); - if (!data_blob_equal(&result_blob, &expected_blob)) + if (data_blob_cmp(&result_blob, &expected_blob) != 0) return 2; '); @@ -54,7 +54,7 @@ test_samba4_ndr('align-uint8-uint32', result_blob = ndr_push_blob(ndr); - if (!data_blob_equal(&result_blob, &expected_blob)) + if (data_blob_cmp(&result_blob, &expected_blob) != 0) return 2; '); @@ -81,7 +81,7 @@ test_samba4_ndr('align-uint8-hyper', result_blob = ndr_push_blob(ndr); - if (!data_blob_equal(&result_blob, &expected_blob)) + if (data_blob_cmp(&result_blob, &expected_blob) != 0) return 2; '); @@ -108,7 +108,7 @@ test_samba4_ndr('noalignflag-uint8-uint16', result_blob = ndr_push_blob(ndr); - if (!data_blob_equal(&result_blob, &expected_blob)) + if (data_blob_cmp(&result_blob, &expected_blob) != 0) return 2; '); @@ -138,6 +138,6 @@ test_samba4_ndr('align-blob-align2', result_blob = ndr_push_blob(ndr); - if (!data_blob_equal(&result_blob, &expected_blob)) + if (data_blob_cmp(&result_blob, &expected_blob) != 0) return 2; '); diff --git a/source4/pidl/tests/ndr_tagtype.pl b/source4/pidl/tests/ndr_tagtype.pl index d7839426d5..f8250a90ef 100755 --- a/source4/pidl/tests/ndr_tagtype.pl +++ b/source4/pidl/tests/ndr_tagtype.pl @@ -22,7 +22,7 @@ test_samba4_ndr('struct-notypedef', '[public] struct bla { uint8 x; }; ', result_blob = ndr_push_blob(ndr); - if (!data_blob_equal(&result_blob, &expected_blob)) + if (data_blob_cmp(&result_blob, &expected_blob) != 0) return 2; '); @@ -41,7 +41,7 @@ test_samba4_ndr('struct-notypedef-used', '[public] struct bla { uint8 x; }; result_blob = ndr_push_blob(ndr); - if (!data_blob_equal(&result_blob, &expected_blob)) + if (data_blob_cmp(&result_blob, &expected_blob) != 0) return 2; '); @@ -61,6 +61,6 @@ test_samba4_ndr('struct-notypedef-embedded', 'struct bla { uint8 x; }; result_blob = ndr_push_blob(ndr); - if (!data_blob_equal(&result_blob, &expected_blob)) + if (data_blob_cmp(&result_blob, &expected_blob) != 0) return 2; '); -- cgit From 44dc2839e45f14eb88d43a7640a65bbe72c9ee35 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 15 Aug 2007 08:55:16 +0000 Subject: r24447: fix samba3-cli pidl tests metze (This used to be commit 91fb099b3dd5c58608f1fbf65ed77acbc609598f) --- source4/pidl/tests/samba3-cli.pl | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/samba3-cli.pl b/source4/pidl/tests/samba3-cli.pl index c5537c145e..b2b12d2d43 100755 --- a/source4/pidl/tests/samba3-cli.pl +++ b/source4/pidl/tests/samba3-cli.pl @@ -4,22 +4,26 @@ use strict; use warnings; -use Test::More tests => 4; +use Test::More tests => 7; use FindBin qw($RealBin); use lib "$RealBin"; use Util; use Parse::Pidl::Util qw(MyDumper); -use Parse::Pidl::Samba3::ClientNDR qw(GenerateFunctionInEnv ParseFunction); +use Parse::Pidl::Samba3::ClientNDR qw(ParseFunction); +use Parse::Pidl::Samba4::NDR::Parser qw(GenerateFunctionInEnv GenerateFunctionOutEnv); # Make sure GenerateFunctionInEnv and GenerateFunctionOutEnv work my $fn = { ELEMENTS => [ { DIRECTION => ["in"], NAME => "foo" } ] }; -is_deeply({ "foo" => "r.in.foo" }, GenerateFunctionInEnv($fn)); +is_deeply({ "foo" => "r.in.foo" }, GenerateFunctionInEnv($fn, "r.")); +is_deeply({ "foo" => "r.in.foo" }, GenerateFunctionOutEnv($fn, "r.")); $fn = { ELEMENTS => [ { DIRECTION => ["out", "in"], NAME => "foo" } ] }; -is_deeply({ "foo" => "r.in.foo" }, GenerateFunctionInEnv($fn)); +is_deeply({ "foo" => "r.in.foo" }, GenerateFunctionInEnv($fn, "r.")); +is_deeply({ "foo" => "r.out.foo" }, GenerateFunctionOutEnv($fn, "r.")); $fn = { ELEMENTS => [ { DIRECTION => ["out"], NAME => "foo" } ] }; -is_deeply({ }, GenerateFunctionInEnv($fn)); +is_deeply({ }, GenerateFunctionInEnv($fn, "r.")); +is_deeply({ "foo" => "r.out.foo" }, GenerateFunctionOutEnv($fn, "r.")); my $x = new Parse::Pidl::Samba3::ClientNDR(); -- cgit From b76b6a15225329941c20070d05356aba56044173 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 16 Aug 2007 13:41:48 +0000 Subject: r24492: Parse::Pidl::Samba4::Header::Parse() now takes an $ndr tree not the $pidl tree anymore. metze (This used to be commit 3cbbddb94c9e986d0adbe3b001146b209cd810d9) --- source4/pidl/tests/Util.pm | 8 +++++--- source4/pidl/tests/header.pl | 4 +++- 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/Util.pm b/source4/pidl/tests/Util.pm index 897e848440..dfd219186f 100644 --- a/source4/pidl/tests/Util.pm +++ b/source4/pidl/tests/Util.pm @@ -48,12 +48,14 @@ sub test_samba4_ndr { my ($name,$idl,$c,$extra) = @_; my $pidl = Parse::Pidl::IDL::parse_string("interface echo { $idl }; ", "<$name>"); - ok(defined($pidl), "($name) parse idl"); - my $header = Parse::Pidl::Samba4::Header::Parse($pidl); - ok(defined($header), "($name) generate generic header"); + my $pndr = Parse::Pidl::NDR::Parse($pidl); ok(defined($pndr), "($name) generate NDR tree"); + + my $header = Parse::Pidl::Samba4::Header::Parse($pndr); + ok(defined($header), "($name) generate generic header"); + my $generator = new Parse::Pidl::Samba4::NDR::Parser(); my ($ndrheader,$ndrparser) = $generator->Parse($pndr, undef, undef); ok(defined($ndrparser), "($name) generate NDR parser"); diff --git a/source4/pidl/tests/header.pl b/source4/pidl/tests/header.pl index 331f4dd9fb..c7a57eb009 100755 --- a/source4/pidl/tests/header.pl +++ b/source4/pidl/tests/header.pl @@ -11,12 +11,14 @@ use Util; use Parse::Pidl::Util qw(MyDumper); use Parse::Pidl::Samba4::Header; use Parse::Pidl::IDL qw(parse_string); +use Parse::Pidl::NDR; sub parse_idl($) { my $text = shift; my $idl = Parse::Pidl::IDL::parse_string($text, "nofile"); - return Parse::Pidl::Samba4::Header::Parse($idl); + my $ndr = Parse::Pidl::NDR::Parse($idl); + return Parse::Pidl::Samba4::Header::Parse($ndr); } like(parse_idl(""), qr/\/\* header auto-generated by pidl \*\/\n/sm, "includes work"); -- cgit From 575c8709262bb97ef1b14d128058620a9200e447 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 16 Aug 2007 14:42:22 +0000 Subject: r24493: - it turns out that foreach my $e (@{$union->{ELEMENTS}}) { changes $union->{ELEMENTS} from undef into an empty array. this removes the difference between struct foo { }; and struct foo; So we need to explicit return before. - we should return the same element for layout for structs and unions with no elements. - fix the testsuite to match metze (This used to be commit 5f1f50cd27e3702b79a19dbe1079498cbfc4842b) --- source4/pidl/tests/ndr.pl | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/ndr.pl b/source4/pidl/tests/ndr.pl index 8245f768e8..043d2b9905 100755 --- a/source4/pidl/tests/ndr.pl +++ b/source4/pidl/tests/ndr.pl @@ -4,7 +4,7 @@ use strict; use warnings; -use Test::More tests => 26; +use Test::More tests => 27; use FindBin qw($RealBin); use lib "$RealBin"; use Util; @@ -225,5 +225,31 @@ is(mapToScalar({TYPE => "BITMAP", PROPERTIES => { bitmap64bit => 1 } }), "hyper"); is(mapToScalar({TYPE => "TYPEDEF", DATA => {TYPE => "ENUM", PARENT => { PROPERTIES => { enum8bit => 1 } } }}), "uint8"); -is_deeply(ParseType({TYPE => "STRUCT", NAME => "foo" }, "ref"), - {TYPE => "STRUCT", NAME => "foo" }); +my $t; +$t = { + TYPE => "STRUCT", + NAME => "foo", + SURROUNDING_ELEMENT => undef, + ELEMENTS => undef, + PROPERTIES => undef, + ORIGINAL => { + TYPE => "STRUCT", + NAME => "foo" + }, + ALIGN => undef +}; +is_deeply(ParseType($t->{ORIGINAL}, "ref"), $t); + +$t = { + TYPE => "UNION", + NAME => "foo", + SWITCH_TYPE => "uint32", + ELEMENTS => undef, + PROPERTIES => undef, + HAS_DEFAULT => 0, + ORIGINAL => { + TYPE => "UNION", + NAME => "foo" + } +}; +is_deeply(ParseType($t->{ORIGINAL}, "ref"), $t); -- cgit From 0d7d5a6d492253f184ac58fe45ca22af5a3731de Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sun, 19 Aug 2007 22:09:21 +0000 Subject: r24560: rename some DCERPC_ prefixes into NDR_ metze (This used to be commit f874eca5dab74e930d0ec52abeb06295d2d90476) --- source4/pidl/tests/samba3-cli.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/samba3-cli.pl b/source4/pidl/tests/samba3-cli.pl index b2b12d2d43..733bf93a99 100755 --- a/source4/pidl/tests/samba3-cli.pl +++ b/source4/pidl/tests/samba3-cli.pl @@ -39,7 +39,7 @@ is($x->{res}, "NTSTATUS rpccli_bar(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ \tif (DEBUGLEVEL >= 10) \t\tNDR_PRINT_IN_DEBUG(bar, &r); \t -\tstatus = cli_do_rpc_ndr(cli, mem_ctx, PI_foo, DCERPC_BAR, &r, (ndr_pull_flags_fn_t)ndr_pull_bar, (ndr_push_flags_fn_t)ndr_push_bar); +\tstatus = cli_do_rpc_ndr(cli, mem_ctx, PI_foo, NDR_BAR, &r, (ndr_pull_flags_fn_t)ndr_pull_bar, (ndr_push_flags_fn_t)ndr_push_bar); \t \tif (!NT_STATUS_IS_OK(status)) { \t\treturn status; -- cgit From 02467edf5cc3dbaac8bec15deff4fb606ab76f75 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 21 Aug 2007 12:19:56 +0000 Subject: r24592: pass down the ndr_interface_table in the samba3 client bindings instead of the pull and push functions metze (This used to be commit 9b59534a14700f7bfe56cae448030df59ced0ba5) --- source4/pidl/tests/samba3-cli.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/samba3-cli.pl b/source4/pidl/tests/samba3-cli.pl index 733bf93a99..8c06ed8c27 100755 --- a/source4/pidl/tests/samba3-cli.pl +++ b/source4/pidl/tests/samba3-cli.pl @@ -39,7 +39,7 @@ is($x->{res}, "NTSTATUS rpccli_bar(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ \tif (DEBUGLEVEL >= 10) \t\tNDR_PRINT_IN_DEBUG(bar, &r); \t -\tstatus = cli_do_rpc_ndr(cli, mem_ctx, PI_foo, NDR_BAR, &r, (ndr_pull_flags_fn_t)ndr_pull_bar, (ndr_push_flags_fn_t)ndr_push_bar); +\tstatus = cli_do_rpc_ndr(cli, mem_ctx, PI_FOO, &ndr_table_foo, NDR_BAR, &r); \t \tif (!NT_STATUS_IS_OK(status)) { \t\treturn status; -- cgit From 09c188e7353a74d05a674935c85e548bd09073ae Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 30 Aug 2007 22:25:59 +0000 Subject: r24812: Fix headers for external users. (This used to be commit ff6684adfd96b59381dd941e54070ab9f8984912) --- source4/pidl/tests/Util.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/Util.pm b/source4/pidl/tests/Util.pm index dfd219186f..c7fca95aaa 100644 --- a/source4/pidl/tests/Util.pm +++ b/source4/pidl/tests/Util.pm @@ -102,7 +102,7 @@ SKIP: { print CC "#include \n"; print CC "#include \n"; print CC "#include \n"; - print CC "#include \n"; + print CC "#include \n"; print CC $header; print CC $ndrheader; print CC $extra if ($extra); -- cgit From 7acc0e77a6f6d74d1ccfcf04424a63b224b292a5 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 31 Aug 2007 00:03:54 +0000 Subject: r24815: Support cpp_quote(). (This used to be commit 30c1de30bb4ded16e79316c0ab43809e0e19f75d) --- source4/pidl/tests/header.pl | 5 ++++- source4/pidl/tests/parse_idl.pl | 10 +++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/header.pl b/source4/pidl/tests/header.pl index c7a57eb009..8d0dccf507 100755 --- a/source4/pidl/tests/header.pl +++ b/source4/pidl/tests/header.pl @@ -4,7 +4,7 @@ use strict; use warnings; -use Test::More tests => 15; +use Test::More tests => 16; use FindBin qw($RealBin); use lib "$RealBin"; use Util; @@ -53,3 +53,6 @@ like(parse_idl("interface p { struct x; };"), like(parse_idl("interface p { typedef struct x { int p; } x; };"), qr/struct x.*{.*int32_t p;.*};/sm, "double struct declaration"); + +like(parse_idl("cpp_quote(\"some-foo\")"), + qr/some-foo/sm, "cpp quote"); diff --git a/source4/pidl/tests/parse_idl.pl b/source4/pidl/tests/parse_idl.pl index b82bd80e54..96c7b2adc8 100755 --- a/source4/pidl/tests/parse_idl.pl +++ b/source4/pidl/tests/parse_idl.pl @@ -4,7 +4,7 @@ # Published under the GNU General Public License use strict; -use Test::More tests => 64 * 2 + 2; +use Test::More tests => 65 * 2 + 3; use FindBin qw($RealBin); use lib "$RealBin"; use Util qw(test_errors); @@ -109,6 +109,7 @@ testok "import-multiple", "import \"foo.idl\", \"bar.idl\";"; testok "include-multiple", "include \"foo.idl\", \"bar.idl\";"; testok "empty-struct", "interface test { struct foo { }; }"; testok "typedef-double", "interface test { typedef struct foo { } foo; }"; +testok "cpp-quote", "cpp_quote(\"bla\")"; my $x = Parse::Pidl::IDL::parse_string("interface foo { struct x {}; }", ""); @@ -122,3 +123,10 @@ is_deeply($x, [ { 'FILE' => '', 'NAME' => 'foo', 'DATA' => [ { 'NAME' => 'x', 'TYPE' => 'STRUCT' } ], 'TYPE' => 'INTERFACE', 'LINE' => 0 } ]); + +$x = Parse::Pidl::IDL::parse_string("cpp_quote(\"foobar\")", ""); +is_deeply($x, + [ { 'FILE' => '', 'DATA' => '"foobar"', + 'TYPE' => 'CPP_QUOTE', 'LINE' => 0 } ]); + + -- cgit From 8d182d881d189e9855165b3a423f2d545a97fae8 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 31 Aug 2007 00:31:32 +0000 Subject: r24816: Move the rest of the contents of core.h to more appropriate places. include/ now only contains build system related headers, all other headers are now near the source code they're related to. (This used to be commit 6890a01dbfc6d8041a88ef5c6be52dfcd046fe80) --- source4/pidl/tests/util.pl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/util.pl b/source4/pidl/tests/util.pl index ba2f7b7b49..cb77f34c51 100755 --- a/source4/pidl/tests/util.pl +++ b/source4/pidl/tests/util.pl @@ -4,7 +4,7 @@ use strict; use warnings; -use Test::More tests => 70; +use Test::More tests => 72; use FindBin qw($RealBin); use lib "$RealBin"; use Util; @@ -33,6 +33,9 @@ is("\"\"bla\"\"", make_str("\"\"bla\"\"")); is("\"bla\"\"", make_str("bla\"")); is("\"foo\"bar\"", make_str("foo\"bar")); +is("bla", unmake_str("\"bla\"")); +is("\"bla\"", unmake_str("\"\"bla\"\"")); + # print_uuid() is(undef, print_uuid("invalid")); is("{0x12345778,0x1234,0xabcd,{0xef,0x00},{0x01,0x23,0x45,0x67,0x89,0xac}}", -- cgit From d222c5e7ae8b9b422ad551d379636f62e3d2041f Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 14 Sep 2007 18:06:51 +0000 Subject: r25166: Simplify can_contain_deferred and add tests for it. (This used to be commit 1afc7dd4d33f05d58121defed88faf8fcee3df8f) --- source4/pidl/tests/ndr.pl | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/ndr.pl b/source4/pidl/tests/ndr.pl index 043d2b9905..6e91ad2a6a 100755 --- a/source4/pidl/tests/ndr.pl +++ b/source4/pidl/tests/ndr.pl @@ -4,12 +4,12 @@ use strict; use warnings; -use Test::More tests => 27; +use Test::More tests => 33; use FindBin qw($RealBin); use lib "$RealBin"; use Util; use Parse::Pidl::Util qw(MyDumper); -use Parse::Pidl::NDR qw(GetElementLevelTable ParseElement align_type mapToScalar ParseType); +use Parse::Pidl::NDR qw(GetElementLevelTable ParseElement align_type mapToScalar ParseType can_contain_deferred); # Case 1 @@ -253,3 +253,16 @@ $t = { } }; is_deeply(ParseType($t->{ORIGINAL}, "ref"), $t); + +ok(not can_contain_deferred("uint32")); +ok(can_contain_deferred("some_unknown_type")); +ok(can_contain_deferred({ TYPE => "STRUCT", + ELEMENTS => [ { TYPE => "uint32", POINTERS => 40 } ]})); +ok(can_contain_deferred({ TYPE => "TYPEDEF", + DATA => { TYPE => "STRUCT", + ELEMENTS => [ { TYPE => "uint32", POINTERS => 40 } ]}})); +ok(not can_contain_deferred({ TYPE => "STRUCT", + ELEMENTS => [ { TYPE => "uint32" } ]})); +ok(not can_contain_deferred({ TYPE => "TYPEDEF", + DATA => { TYPE => "STRUCT", + ELEMENTS => [ { TYPE => "uint32" } ]}})); -- cgit From 2e3768843ae8a202e0a3a60224f6717fc34499ab Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 15 Sep 2007 23:03:34 +0000 Subject: r25185: Check that can_contain_deferred returns true if one of the members of a type can contain deferred data. (This used to be commit 9e804e0c21f09b699707bb88d534bde55d265087) --- source4/pidl/tests/ndr.pl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/ndr.pl b/source4/pidl/tests/ndr.pl index 6e91ad2a6a..1512f19d52 100755 --- a/source4/pidl/tests/ndr.pl +++ b/source4/pidl/tests/ndr.pl @@ -4,7 +4,7 @@ use strict; use warnings; -use Test::More tests => 33; +use Test::More tests => 34; use FindBin qw($RealBin); use lib "$RealBin"; use Util; @@ -266,3 +266,5 @@ ok(not can_contain_deferred({ TYPE => "STRUCT", ok(not can_contain_deferred({ TYPE => "TYPEDEF", DATA => { TYPE => "STRUCT", ELEMENTS => [ { TYPE => "uint32" } ]}})); +ok(can_contain_deferred({ TYPE => "STRUCT", + ELEMENTS => [ { TYPE => "someunknowntype" } ]})); -- cgit From 621fcfcd1c8dc4ccbe8f3d58d988b9ce40b3fad3 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 1 Oct 2007 21:38:15 +0000 Subject: r25453: Fix include for NTSTATUS. (This used to be commit 3c2d06d8fc8783362a6ff934e86ea4a4da2c6906) --- source4/pidl/tests/ndr_represent.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/ndr_represent.pl b/source4/pidl/tests/ndr_represent.pl index 52cd06f817..84feeeb9ff 100755 --- a/source4/pidl/tests/ndr_represent.pl +++ b/source4/pidl/tests/ndr_represent.pl @@ -25,7 +25,7 @@ test_samba4_ndr('represent_as-simple', return 2; ', ' -#include +#include NTSTATUS ndr_uint8_to_uint32(uint8_t from, uint32_t *to) { @@ -58,7 +58,7 @@ test_samba4_ndr('transmit_as-simple', return 2; ', ' -#include +#include NTSTATUS ndr_uint8_to_uint32(uint8_t from, uint32_t *to) { -- cgit From 616a64dd395d4a1062317e7ac9e8b812c32b0315 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 31 Oct 2007 16:25:44 +0100 Subject: r25765: pidl: fix compiler warning in ndr_align test metze (This used to be commit 3accc840bee973f56ab34a35e3c181da8cb1023e) --- source4/pidl/tests/ndr_align.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/ndr_align.pl b/source4/pidl/tests/ndr_align.pl index 0824acc501..26336b7772 100755 --- a/source4/pidl/tests/ndr_align.pl +++ b/source4/pidl/tests/ndr_align.pl @@ -70,11 +70,11 @@ test_samba4_ndr('align-uint8-hyper', struct ndr_push *ndr = ndr_push_init_ctx(NULL); struct bla r; uint8_t expected[] = { 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xef, 0xbe, 0xef, 0xbe, 0xef, 0xbe, 0xef, 0xbe }; + 0xef, 0xbe, 0xef, 0xbe, 0xef, 0xbe, 0xef, 0xbe }; DATA_BLOB expected_blob = { expected, 16 }; DATA_BLOB result_blob; r.x = 13; - r.y = 0xbeefbeefbeefbeef; + r.y = 0xbeefbeefbeefbeefLLU; if (NT_STATUS_IS_ERR(ndr_push_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r))) return 1; -- cgit From 0bf387e0f98ee50e90c573f9f9d30074bdde3660 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 31 Oct 2007 16:27:21 +0100 Subject: r25766: pidl: fix bugs in ndr_tagtype tests found by compiler warnings metze (This used to be commit 34af31cfb3b69d1028027da1bceb06b41103e7aa) --- source4/pidl/tests/ndr_tagtype.pl | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/ndr_tagtype.pl b/source4/pidl/tests/ndr_tagtype.pl index f8250a90ef..38daa02ab4 100755 --- a/source4/pidl/tests/ndr_tagtype.pl +++ b/source4/pidl/tests/ndr_tagtype.pl @@ -30,13 +30,13 @@ test_samba4_ndr('struct-notypedef-used', '[public] struct bla { uint8 x; }; [public] void myfn([in] struct bla r); ', ' struct ndr_push *ndr = ndr_push_init_ctx(NULL); - struct bla r; + struct myfn fn; uint8_t expected[] = { 0x0D }; DATA_BLOB expected_blob = { expected, 1 }; DATA_BLOB result_blob; - r.x = 13; + fn.in.r.x = 13; - if (NT_STATUS_IS_ERR(ndr_push_myfn(ndr, NDR_IN, &r))) + if (NT_STATUS_IS_ERR(ndr_push_myfn(ndr, NDR_IN, &fn))) return 1; result_blob = ndr_push_blob(ndr); @@ -47,16 +47,16 @@ test_samba4_ndr('struct-notypedef-used', '[public] struct bla { uint8 x; }; test_samba4_ndr('struct-notypedef-embedded', 'struct bla { uint8 x; }; - [public] struct myfn { struct bla r; }; ', + [public] struct myst { struct bla r; }; ', ' struct ndr_push *ndr = ndr_push_init_ctx(NULL); - struct bla r; + struct myst st; uint8_t expected[] = { 0x0D }; DATA_BLOB expected_blob = { expected, 1 }; DATA_BLOB result_blob; - r.x = 13; + st.r.x = 13; - if (NT_STATUS_IS_ERR(ndr_push_STRUCT_myfn(ndr, NDR_IN, &r))) + if (NT_STATUS_IS_ERR(ndr_push_STRUCT_myst(ndr, NDR_IN, &st))) return 1; result_blob = ndr_push_blob(ndr); -- cgit From 7dee06709e01118dc3b56e79b1050de9bace92a3 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 31 Oct 2007 16:29:32 +0100 Subject: r25767: pidl: make it easier to debug errors in pidl tests we now print the C program that we tried to compile metze (This used to be commit 299e74314c05209bdc9fe2c41cae7094b2f15c11) --- source4/pidl/tests/Util.pm | 69 +++++++++++++++++++++++++++++++--------------- 1 file changed, 47 insertions(+), 22 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/Util.pm b/source4/pidl/tests/Util.pm index c7fca95aaa..82ab130e5a 100644 --- a/source4/pidl/tests/Util.pm +++ b/source4/pidl/tests/Util.pm @@ -47,6 +47,9 @@ use Parse::Pidl::Samba4::Header; sub test_samba4_ndr { my ($name,$idl,$c,$extra) = @_; + + $extra = "" unless defined($extra); + my $pidl = Parse::Pidl::IDL::parse_string("interface echo { $idl }; ", "<$name>"); ok(defined($pidl), "($name) parse idl"); @@ -66,8 +69,49 @@ SKIP: { skip "no samba environment available, skipping compilation", 3 if (system("pkg-config --exists ndr") != 0); - my $test_data_prefix = $ENV{TEST_DATA_PREFIX}; + my $main = " +#define uint_t unsigned int +#define _GNU_SOURCE +#include +#include +#include +#include +#include +#include + +/* header start */ +$header +/* header end */ + +/* ndrheader start */ +$ndrheader +/* ndrheader end */ + +/* extra start */ +$extra +/* extra end */ + +/* ndrparser start */ +$ndrparser +/* ndrparser end */ + +/* main start */ +int main(int argc, const char **argv) +{ + TALLOC_CTX *mem_ctx = talloc_init(NULL); + +$c + + talloc_free(mem_ctx); + return 0; +} +/* main end */ +\n"; + + my $main_debug = "# ".join("\n# ", split("\n", $main)); + + my $test_data_prefix = $ENV{TEST_DATA_PREFIX}; my $outfile; if (defined($test_data_prefix)) { $outfile = "$test_data_prefix/test-$name"; @@ -95,32 +139,13 @@ SKIP: { my $cmd = "$cc $cflags -x c - -o $outfile $flags $ldflags"; $cmd =~ s/\n//g; open CC, "|$cmd"; - print CC "#define uint_t unsigned int\n"; - print CC "#define _GNU_SOURCE\n"; - print CC "#include \n"; - print CC "#include \n"; - print CC "#include \n"; - print CC "#include \n"; - print CC "#include \n"; - print CC "#include \n"; - print CC $header; - print CC $ndrheader; - print CC $extra if ($extra); - print CC $ndrparser; - print CC "int main(int argc, const char **argv) -{ - TALLOC_CTX *mem_ctx = talloc_init(NULL); - - $c - - talloc_free(mem_ctx); - - return 0; }\n"; + print CC $main; close CC; ok(-f $outfile, "($name) compile"); my $ret = system($outfile, ()) >> 8; + print "# code:\n#\n$main_debug\n" if ($ret != 0); print "# cmd: $cmd\n" if ($ret != 0); print "# return code: $ret\n" if ($ret != 0); -- cgit From 1f87eb38fdb76d73ea1dd045d8555a662bf0c77b Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 31 Oct 2007 16:44:42 +0100 Subject: r25768: pidl: NT_STATUS_IS_ERR() is NOT the same as !NT_STATUS_IS_OK() Everything but success should be handled as error in the tests. metze (This used to be commit cadb1cc743a19fc16e61f8246b1e8771c806caea) --- source4/pidl/tests/ndr_align.pl | 10 +++++----- source4/pidl/tests/ndr_alloc.pl | 8 ++++---- source4/pidl/tests/ndr_array.pl | 2 +- source4/pidl/tests/ndr_fullptr.pl | 2 +- source4/pidl/tests/ndr_refptr.pl | 28 ++++++++++++++-------------- source4/pidl/tests/ndr_represent.pl | 4 ++-- source4/pidl/tests/ndr_simple.pl | 2 +- source4/pidl/tests/ndr_string.pl | 6 +++--- source4/pidl/tests/ndr_tagtype.pl | 6 +++--- 9 files changed, 34 insertions(+), 34 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/ndr_align.pl b/source4/pidl/tests/ndr_align.pl index 26336b7772..28b29d9196 100755 --- a/source4/pidl/tests/ndr_align.pl +++ b/source4/pidl/tests/ndr_align.pl @@ -24,7 +24,7 @@ test_samba4_ndr('align-uint8-uint16', r.x = 13; r.y = 0xbeef; - if (NT_STATUS_IS_ERR(ndr_push_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r))) + if (!NT_STATUS_IS_OK(ndr_push_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r))) return 1; result_blob = ndr_push_blob(ndr); @@ -49,7 +49,7 @@ test_samba4_ndr('align-uint8-uint32', r.x = 13; r.y = 0xbeefbeef; - if (NT_STATUS_IS_ERR(ndr_push_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r))) + if (!NT_STATUS_IS_OK(ndr_push_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r))) return 1; result_blob = ndr_push_blob(ndr); @@ -76,7 +76,7 @@ test_samba4_ndr('align-uint8-hyper', r.x = 13; r.y = 0xbeefbeefbeefbeefLLU; - if (NT_STATUS_IS_ERR(ndr_push_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r))) + if (!NT_STATUS_IS_OK(ndr_push_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r))) return 1; result_blob = ndr_push_blob(ndr); @@ -103,7 +103,7 @@ test_samba4_ndr('noalignflag-uint8-uint16', r.x = 13; r.y = 0xbeef; - if (NT_STATUS_IS_ERR(ndr_push_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r))) + if (!NT_STATUS_IS_OK(ndr_push_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r))) return 1; result_blob = ndr_push_blob(ndr); @@ -133,7 +133,7 @@ test_samba4_ndr('align-blob-align2', r.data.data = data; r.data.length = 2; - if (NT_STATUS_IS_ERR(ndr_push_blie(ndr, NDR_SCALARS|NDR_BUFFERS, &r))) + if (!NT_STATUS_IS_OK(ndr_push_blie(ndr, NDR_SCALARS|NDR_BUFFERS, &r))) return 1; result_blob = ndr_push_blob(ndr); diff --git a/source4/pidl/tests/ndr_alloc.pl b/source4/pidl/tests/ndr_alloc.pl index 61df1c3548..b1c7ae08c3 100755 --- a/source4/pidl/tests/ndr_alloc.pl +++ b/source4/pidl/tests/ndr_alloc.pl @@ -23,7 +23,7 @@ test_samba4_ndr("alloc-scalar", 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))) + if (!NT_STATUS_IS_OK(ndr_pull_TestAlloc(ndr, NDR_IN, &r))) return 1; if (r.in.foo.x == NULL) @@ -47,7 +47,7 @@ test_samba4_ndr("alloc-buffer", 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))) + if (!NT_STATUS_IS_OK(ndr_pull_TestAlloc(ndr, NDR_IN, &r))) return 1; if (r.in.foo.x == NULL) @@ -86,7 +86,7 @@ test_samba4_ndr("ref-noalloc", uint8_t x; r.in.t = &x; - if (NT_STATUS_IS_ERR(ndr_pull_TestAlloc(ndr, NDR_IN, &r))) + if (!NT_STATUS_IS_OK(ndr_pull_TestAlloc(ndr, NDR_IN, &r))) return 1; if (*r.in.t != 0x03) @@ -106,7 +106,7 @@ test_samba4_ndr("ref-alloc", ndr->flags |= LIBNDR_FLAG_REF_ALLOC; r.in.t = NULL; - if (NT_STATUS_IS_ERR(ndr_pull_TestAlloc(ndr, NDR_IN, &r))) + if (!NT_STATUS_IS_OK(ndr_pull_TestAlloc(ndr, NDR_IN, &r))) return 1; if (r.in.t == NULL) diff --git a/source4/pidl/tests/ndr_array.pl b/source4/pidl/tests/ndr_array.pl index 27f42cd391..8e40d36a10 100755 --- a/source4/pidl/tests/ndr_array.pl +++ b/source4/pidl/tests/ndr_array.pl @@ -25,7 +25,7 @@ test_samba4_ndr( b.length = 10; ndr = ndr_pull_init_blob(&b, mem_ctx); - if (NT_STATUS_IS_ERR(ndr_pull_Test(ndr, NDR_IN, &r))) + if (!NT_STATUS_IS_OK(ndr_pull_Test(ndr, NDR_IN, &r))) return 1; if (ndr->offset != 10) diff --git a/source4/pidl/tests/ndr_fullptr.pl b/source4/pidl/tests/ndr_fullptr.pl index 482edcf030..2188905b13 100755 --- a/source4/pidl/tests/ndr_fullptr.pl +++ b/source4/pidl/tests/ndr_fullptr.pl @@ -23,7 +23,7 @@ test_samba4_ndr("fullptr-push-dup", r.in.x = &v; r.in.y = &v; - if (NT_STATUS_IS_ERR(ndr_push_echo_TestFull(ndr, NDR_IN, &r))) { + if (!NT_STATUS_IS_OK(ndr_push_echo_TestFull(ndr, NDR_IN, &r))) { fprintf(stderr, "push failed\n"); return 1; } diff --git a/source4/pidl/tests/ndr_refptr.pl b/source4/pidl/tests/ndr_refptr.pl index 4a56e3ca38..d5e73559d9 100755 --- a/source4/pidl/tests/ndr_refptr.pl +++ b/source4/pidl/tests/ndr_refptr.pl @@ -23,7 +23,7 @@ test_samba4_ndr("noptr-push", struct echo_TestRef r; r.in.foo.x = v; - if (NT_STATUS_IS_ERR(ndr_push_echo_TestRef(ndr, NDR_IN, &r))) { + if (!NT_STATUS_IS_OK(ndr_push_echo_TestRef(ndr, NDR_IN, &r))) { fprintf(stderr, "push failed\n"); return 1; } @@ -52,7 +52,7 @@ test_samba4_ndr("ptr-embedded-push", struct echo_TestRef r; r.in.foo.x = &v; - if (NT_STATUS_IS_ERR(ndr_push_echo_TestRef(ndr, NDR_IN, &r))) + if (!NT_STATUS_IS_OK(ndr_push_echo_TestRef(ndr, NDR_IN, &r))) return 1; if (ndr->offset != 6) @@ -78,7 +78,7 @@ test_samba4_ndr("ptr-embedded-push-null", struct echo_TestRef r; r.in.foo.x = NULL; - if (NT_STATUS_IS_ERR(ndr_push_echo_TestRef(ndr, NDR_IN, &r))) + if (!NT_STATUS_IS_OK(ndr_push_echo_TestRef(ndr, NDR_IN, &r))) return 1; if (ndr->offset != 4) @@ -103,7 +103,7 @@ test_samba4_ndr("refptr-embedded-push", struct echo_TestRef r; r.in.foo.x = &v; - if (NT_STATUS_IS_ERR(ndr_push_echo_TestRef(ndr, NDR_IN, &r))) + if (!NT_STATUS_IS_OK(ndr_push_echo_TestRef(ndr, NDR_IN, &r))) return 1; if (ndr->offset != 6) @@ -150,7 +150,7 @@ test_samba4_ndr("ptr-top-push", s.x = 13; r.in.foo = &s; - if (NT_STATUS_IS_ERR(ndr_push_echo_TestRef(ndr, NDR_IN, &r))) + if (!NT_STATUS_IS_OK(ndr_push_echo_TestRef(ndr, NDR_IN, &r))) return 1; if (ndr->offset != 2) @@ -195,7 +195,7 @@ test_samba4_ndr("refptr-top-push", s.x = 13; r.in.foo = &s; - if (NT_STATUS_IS_ERR(ndr_push_echo_TestRef(ndr, NDR_IN, &r))) + if (!NT_STATUS_IS_OK(ndr_push_echo_TestRef(ndr, NDR_IN, &r))) return 1; if (ndr->offset != 2) @@ -239,7 +239,7 @@ test_samba4_ndr("uniqueptr-top-push", s.x = 13; r.in.foo = &s; - if (NT_STATUS_IS_ERR(ndr_push_echo_TestRef(ndr, NDR_IN, &r))) + if (!NT_STATUS_IS_OK(ndr_push_echo_TestRef(ndr, NDR_IN, &r))) return 1; if (ndr->offset != 6) @@ -265,7 +265,7 @@ test_samba4_ndr("uniqueptr-top-push-null", struct echo_TestRef r; r.in.foo = NULL; - if (NT_STATUS_IS_ERR(ndr_push_echo_TestRef(ndr, NDR_IN, &r))) + if (!NT_STATUS_IS_OK(ndr_push_echo_TestRef(ndr, NDR_IN, &r))) return 1; if (ndr->offset != 4) @@ -294,7 +294,7 @@ test_samba4_ndr("ptr-top-out-pull", r.out.foo = &s; - if (NT_STATUS_IS_ERR(ndr_pull_echo_TestRef(ndr, NDR_OUT, &r))) + if (!NT_STATUS_IS_OK(ndr_pull_echo_TestRef(ndr, NDR_OUT, &r))) return 1; if (!r.out.foo) @@ -344,7 +344,7 @@ test_samba4_ndr("refptr-top-out-pull", r.out.foo = &s; - if (NT_STATUS_IS_ERR(ndr_pull_echo_TestRef(ndr, NDR_OUT, &r))) + if (!NT_STATUS_IS_OK(ndr_pull_echo_TestRef(ndr, NDR_OUT, &r))) return 1; if (!r.out.foo) @@ -387,7 +387,7 @@ test_samba4_ndr("ptr-top-push-double", uint16_t *pv = &v; r.in.foo = &pv; - if (NT_STATUS_IS_ERR(ndr_push_echo_TestRef(ndr, NDR_IN, &r))) + if (!NT_STATUS_IS_OK(ndr_push_echo_TestRef(ndr, NDR_IN, &r))) return 1; if (ndr->offset != 6) @@ -413,7 +413,7 @@ test_samba4_ndr("ptr-top-push-double-sndnull", uint16_t *pv = NULL; r.in.foo = &pv; - if (NT_STATUS_IS_ERR(ndr_push_echo_TestRef(ndr, NDR_IN, &r))) + if (!NT_STATUS_IS_OK(ndr_push_echo_TestRef(ndr, NDR_IN, &r))) return 1; if (ndr->offset != 4) @@ -451,7 +451,7 @@ test_samba4_ndr("refptr-top-push-double", uint16_t *pv = &v; r.in.foo = &pv; - if (NT_STATUS_IS_ERR(ndr_push_echo_TestRef(ndr, NDR_IN, &r))) + if (!NT_STATUS_IS_OK(ndr_push_echo_TestRef(ndr, NDR_IN, &r))) return 1; if (ndr->offset != 6) @@ -478,7 +478,7 @@ test_samba4_ndr("refptr-top-push-double-sndnull", uint16_t *pv = NULL; r.in.foo = &pv; - if (NT_STATUS_IS_ERR(ndr_push_echo_TestRef(ndr, NDR_IN, &r))) + if (!NT_STATUS_IS_OK(ndr_push_echo_TestRef(ndr, NDR_IN, &r))) return 1; if (ndr->offset != 4) diff --git a/source4/pidl/tests/ndr_represent.pl b/source4/pidl/tests/ndr_represent.pl index 84feeeb9ff..b5ee312668 100755 --- a/source4/pidl/tests/ndr_represent.pl +++ b/source4/pidl/tests/ndr_represent.pl @@ -18,7 +18,7 @@ test_samba4_ndr('represent_as-simple', struct ndr_pull *ndr = ndr_pull_init_blob(&in_blob, NULL); struct bla r; - if (NT_STATUS_IS_ERR(ndr_pull_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r))) + if (!NT_STATUS_IS_OK(ndr_pull_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r))) return 1; if (r.in.x != 13) @@ -51,7 +51,7 @@ test_samba4_ndr('transmit_as-simple', struct ndr_pull *ndr = ndr_pull_init_blob(&in_blob, NULL); struct bla r; - if (NT_STATUS_IS_ERR(ndr_pull_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r))) + if (!NT_STATUS_IS_OK(ndr_pull_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r))) return 1; if (r.in.x != 13) diff --git a/source4/pidl/tests/ndr_simple.pl b/source4/pidl/tests/ndr_simple.pl index 02803ceea9..b5e4a7592a 100755 --- a/source4/pidl/tests/ndr_simple.pl +++ b/source4/pidl/tests/ndr_simple.pl @@ -20,7 +20,7 @@ test_samba4_ndr("simple", "void Test(); ", b.length = 1; ndr = ndr_pull_init_blob(&b, mem_ctx); - if (NT_STATUS_IS_ERR(ndr_pull_uint8(ndr, NDR_SCALARS, &result))) + if (!NT_STATUS_IS_OK(ndr_pull_uint8(ndr, NDR_SCALARS, &result))) return 1; if (result != 0x02) diff --git a/source4/pidl/tests/ndr_string.pl b/source4/pidl/tests/ndr_string.pl index 23d94be640..4568ec89b8 100755 --- a/source4/pidl/tests/ndr_string.pl +++ b/source4/pidl/tests/ndr_string.pl @@ -18,7 +18,7 @@ test_samba4_ndr("string-pull-empty", struct TestString r; r.in.data = NULL; - if (NT_STATUS_IS_ERR(ndr_pull_TestString(ndr, NDR_IN, &r))) + if (!NT_STATUS_IS_OK(ndr_pull_TestString(ndr, NDR_IN, &r))) return 1; if (r.in.data == NULL) @@ -40,7 +40,7 @@ test_samba4_ndr("string-ascii-pull", struct TestString r; r.in.data = NULL; - if (NT_STATUS_IS_ERR(ndr_pull_TestString(ndr, NDR_IN, &r))) + if (!NT_STATUS_IS_OK(ndr_pull_TestString(ndr, NDR_IN, &r))) return 1; if (r.in.data == NULL) @@ -69,7 +69,7 @@ test_samba4_ndr("string-out", char *str = NULL; r.out.data = &str; - if (NT_STATUS_IS_ERR(ndr_pull_TestString(ndr, NDR_IN, &r))) + if (!NT_STATUS_IS_OK(ndr_pull_TestString(ndr, NDR_IN, &r))) return 1; if (r.out.data == NULL) diff --git a/source4/pidl/tests/ndr_tagtype.pl b/source4/pidl/tests/ndr_tagtype.pl index 38daa02ab4..7f5c24627a 100755 --- a/source4/pidl/tests/ndr_tagtype.pl +++ b/source4/pidl/tests/ndr_tagtype.pl @@ -17,7 +17,7 @@ test_samba4_ndr('struct-notypedef', '[public] struct bla { uint8 x; }; ', DATA_BLOB result_blob; r.x = 13; - if (NT_STATUS_IS_ERR(ndr_push_STRUCT_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r))) + if (!NT_STATUS_IS_OK(ndr_push_STRUCT_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r))) return 1; result_blob = ndr_push_blob(ndr); @@ -36,7 +36,7 @@ test_samba4_ndr('struct-notypedef-used', '[public] struct bla { uint8 x; }; DATA_BLOB result_blob; fn.in.r.x = 13; - if (NT_STATUS_IS_ERR(ndr_push_myfn(ndr, NDR_IN, &fn))) + if (!NT_STATUS_IS_OK(ndr_push_myfn(ndr, NDR_IN, &fn))) return 1; result_blob = ndr_push_blob(ndr); @@ -56,7 +56,7 @@ test_samba4_ndr('struct-notypedef-embedded', 'struct bla { uint8 x; }; DATA_BLOB result_blob; st.r.x = 13; - if (NT_STATUS_IS_ERR(ndr_push_STRUCT_myst(ndr, NDR_IN, &st))) + if (!NT_STATUS_IS_OK(ndr_push_STRUCT_myst(ndr, NDR_IN, &st))) return 1; result_blob = ndr_push_blob(ndr); -- cgit From bd05c0c3fae3a86cb0f8fa33044a8fdb4f5bd992 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 2 Nov 2007 10:35:09 +0100 Subject: r25795: whitespace cleanup... metze (This used to be commit cae48a19530909981a852801095a19a662f65cfe) --- source4/pidl/tests/ndr_simple.pl | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/ndr_simple.pl b/source4/pidl/tests/ndr_simple.pl index b5e4a7592a..466a164df4 100755 --- a/source4/pidl/tests/ndr_simple.pl +++ b/source4/pidl/tests/ndr_simple.pl @@ -9,20 +9,20 @@ use FindBin qw($RealBin); use lib "$RealBin"; use Util qw(test_samba4_ndr); -test_samba4_ndr("simple", "void Test(); ", +test_samba4_ndr("simple", "void 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_OK(ndr_pull_uint8(ndr, NDR_SCALARS, &result))) - return 1; - - if (result != 0x02) - return 2; + 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_OK(ndr_pull_uint8(ndr, NDR_SCALARS, &result))) + return 1; + + if (result != 0x02) + return 2; "); -- cgit From 3e1fb13024eec442bfdd0335bc03689f64d50c0e Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 9 Nov 2007 19:23:25 +0100 Subject: r25915: ndr/pidl: change NTSTAUS into enum ndr_err_code (pidl code) Samba4/NDR/Parser.pm Samba4/NDR/Server.pm Samba3/ServerNDR.pm tests/ metze (This used to be commit 7106f21de8dfc472aa0846b49bfdb7543c63b310) --- source4/pidl/tests/ndr_align.pl | 10 ++++----- source4/pidl/tests/ndr_alloc.pl | 10 ++++----- source4/pidl/tests/ndr_array.pl | 2 +- source4/pidl/tests/ndr_fullptr.pl | 2 +- source4/pidl/tests/ndr_refptr.pl | 44 ++++++++++++++++++------------------- source4/pidl/tests/ndr_represent.pl | 25 +++++++++------------ source4/pidl/tests/ndr_simple.pl | 2 +- source4/pidl/tests/ndr_string.pl | 6 ++--- source4/pidl/tests/ndr_tagtype.pl | 6 ++--- 9 files changed, 51 insertions(+), 56 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/ndr_align.pl b/source4/pidl/tests/ndr_align.pl index 28b29d9196..1f4a0da9bb 100755 --- a/source4/pidl/tests/ndr_align.pl +++ b/source4/pidl/tests/ndr_align.pl @@ -24,7 +24,7 @@ test_samba4_ndr('align-uint8-uint16', r.x = 13; r.y = 0xbeef; - if (!NT_STATUS_IS_OK(ndr_push_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r))) + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r))) return 1; result_blob = ndr_push_blob(ndr); @@ -49,7 +49,7 @@ test_samba4_ndr('align-uint8-uint32', r.x = 13; r.y = 0xbeefbeef; - if (!NT_STATUS_IS_OK(ndr_push_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r))) + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r))) return 1; result_blob = ndr_push_blob(ndr); @@ -76,7 +76,7 @@ test_samba4_ndr('align-uint8-hyper', r.x = 13; r.y = 0xbeefbeefbeefbeefLLU; - if (!NT_STATUS_IS_OK(ndr_push_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r))) + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r))) return 1; result_blob = ndr_push_blob(ndr); @@ -103,7 +103,7 @@ test_samba4_ndr('noalignflag-uint8-uint16', r.x = 13; r.y = 0xbeef; - if (!NT_STATUS_IS_OK(ndr_push_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r))) + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r))) return 1; result_blob = ndr_push_blob(ndr); @@ -133,7 +133,7 @@ test_samba4_ndr('align-blob-align2', r.data.data = data; r.data.length = 2; - if (!NT_STATUS_IS_OK(ndr_push_blie(ndr, NDR_SCALARS|NDR_BUFFERS, &r))) + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_blie(ndr, NDR_SCALARS|NDR_BUFFERS, &r))) return 1; result_blob = ndr_push_blob(ndr); diff --git a/source4/pidl/tests/ndr_alloc.pl b/source4/pidl/tests/ndr_alloc.pl index b1c7ae08c3..e967bb7cdb 100755 --- a/source4/pidl/tests/ndr_alloc.pl +++ b/source4/pidl/tests/ndr_alloc.pl @@ -23,7 +23,7 @@ test_samba4_ndr("alloc-scalar", struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL); struct TestAlloc r; - if (!NT_STATUS_IS_OK(ndr_pull_TestAlloc(ndr, NDR_IN, &r))) + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_pull_TestAlloc(ndr, NDR_IN, &r))) return 1; if (r.in.foo.x == NULL) @@ -47,7 +47,7 @@ test_samba4_ndr("alloc-buffer", struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL); struct TestAlloc r; - if (!NT_STATUS_IS_OK(ndr_pull_TestAlloc(ndr, NDR_IN, &r))) + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_pull_TestAlloc(ndr, NDR_IN, &r))) return 1; if (r.in.foo.x == NULL) @@ -69,7 +69,7 @@ test_samba4_ndr("ref-noalloc-null", struct TestAlloc r; r.in.t = NULL; - if (NT_STATUS_IS_OK(ndr_pull_TestAlloc(ndr, NDR_IN, &r))) + if (NDR_ERR_CODE_IS_SUCCESS(ndr_pull_TestAlloc(ndr, NDR_IN, &r))) return 1; ' ); @@ -86,7 +86,7 @@ test_samba4_ndr("ref-noalloc", uint8_t x; r.in.t = &x; - if (!NT_STATUS_IS_OK(ndr_pull_TestAlloc(ndr, NDR_IN, &r))) + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_pull_TestAlloc(ndr, NDR_IN, &r))) return 1; if (*r.in.t != 0x03) @@ -106,7 +106,7 @@ test_samba4_ndr("ref-alloc", ndr->flags |= LIBNDR_FLAG_REF_ALLOC; r.in.t = NULL; - if (!NT_STATUS_IS_OK(ndr_pull_TestAlloc(ndr, NDR_IN, &r))) + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_pull_TestAlloc(ndr, NDR_IN, &r))) return 1; if (r.in.t == NULL) diff --git a/source4/pidl/tests/ndr_array.pl b/source4/pidl/tests/ndr_array.pl index 8e40d36a10..174d702c07 100755 --- a/source4/pidl/tests/ndr_array.pl +++ b/source4/pidl/tests/ndr_array.pl @@ -25,7 +25,7 @@ test_samba4_ndr( b.length = 10; ndr = ndr_pull_init_blob(&b, mem_ctx); - if (!NT_STATUS_IS_OK(ndr_pull_Test(ndr, NDR_IN, &r))) + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_pull_Test(ndr, NDR_IN, &r))) return 1; if (ndr->offset != 10) diff --git a/source4/pidl/tests/ndr_fullptr.pl b/source4/pidl/tests/ndr_fullptr.pl index 2188905b13..27d4e69447 100755 --- a/source4/pidl/tests/ndr_fullptr.pl +++ b/source4/pidl/tests/ndr_fullptr.pl @@ -23,7 +23,7 @@ test_samba4_ndr("fullptr-push-dup", r.in.x = &v; r.in.y = &v; - if (!NT_STATUS_IS_OK(ndr_push_echo_TestFull(ndr, NDR_IN, &r))) { + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestFull(ndr, NDR_IN, &r))) { fprintf(stderr, "push failed\n"); return 1; } diff --git a/source4/pidl/tests/ndr_refptr.pl b/source4/pidl/tests/ndr_refptr.pl index d5e73559d9..0fb4810285 100755 --- a/source4/pidl/tests/ndr_refptr.pl +++ b/source4/pidl/tests/ndr_refptr.pl @@ -23,7 +23,7 @@ test_samba4_ndr("noptr-push", struct echo_TestRef r; r.in.foo.x = v; - if (!NT_STATUS_IS_OK(ndr_push_echo_TestRef(ndr, NDR_IN, &r))) { + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r))) { fprintf(stderr, "push failed\n"); return 1; } @@ -52,7 +52,7 @@ test_samba4_ndr("ptr-embedded-push", struct echo_TestRef r; r.in.foo.x = &v; - if (!NT_STATUS_IS_OK(ndr_push_echo_TestRef(ndr, NDR_IN, &r))) + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r))) return 1; if (ndr->offset != 6) @@ -78,7 +78,7 @@ test_samba4_ndr("ptr-embedded-push-null", struct echo_TestRef r; r.in.foo.x = NULL; - if (!NT_STATUS_IS_OK(ndr_push_echo_TestRef(ndr, NDR_IN, &r))) + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r))) return 1; if (ndr->offset != 4) @@ -103,7 +103,7 @@ test_samba4_ndr("refptr-embedded-push", struct echo_TestRef r; r.in.foo.x = &v; - if (!NT_STATUS_IS_OK(ndr_push_echo_TestRef(ndr, NDR_IN, &r))) + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r))) return 1; if (ndr->offset != 6) @@ -130,7 +130,7 @@ test_samba4_ndr("refptr-embedded-push-null", struct echo_TestRef r; r.in.foo.x = NULL; - if (NT_STATUS_IS_OK(ndr_push_echo_TestRef(ndr, NDR_IN, &r))) + if (NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r))) return 1; /* Windows gives [client runtime error 0x6f4] */ '); @@ -150,7 +150,7 @@ test_samba4_ndr("ptr-top-push", s.x = 13; r.in.foo = &s; - if (!NT_STATUS_IS_OK(ndr_push_echo_TestRef(ndr, NDR_IN, &r))) + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r))) return 1; if (ndr->offset != 2) @@ -173,7 +173,7 @@ test_samba4_ndr("ptr-top-push-null", struct echo_TestRef r; r.in.foo = NULL; - if (NT_STATUS_IS_OK(ndr_push_echo_TestRef(ndr, NDR_IN, &r))) + if (NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r))) return 1; /* Windows gives [client runtime error 0x6f4] */ @@ -195,7 +195,7 @@ test_samba4_ndr("refptr-top-push", s.x = 13; r.in.foo = &s; - if (!NT_STATUS_IS_OK(ndr_push_echo_TestRef(ndr, NDR_IN, &r))) + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r))) return 1; if (ndr->offset != 2) @@ -218,7 +218,7 @@ test_samba4_ndr("refptr-top-push-null", struct echo_TestRef r; r.in.foo = NULL; - if (NT_STATUS_IS_OK(ndr_push_echo_TestRef(ndr, NDR_IN, &r))) + if (NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r))) return 1; /* Windows gives [client runtime error 0x6f4] */ @@ -239,7 +239,7 @@ test_samba4_ndr("uniqueptr-top-push", s.x = 13; r.in.foo = &s; - if (!NT_STATUS_IS_OK(ndr_push_echo_TestRef(ndr, NDR_IN, &r))) + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r))) return 1; if (ndr->offset != 6) @@ -265,7 +265,7 @@ test_samba4_ndr("uniqueptr-top-push-null", struct echo_TestRef r; r.in.foo = NULL; - if (!NT_STATUS_IS_OK(ndr_push_echo_TestRef(ndr, NDR_IN, &r))) + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r))) return 1; if (ndr->offset != 4) @@ -294,7 +294,7 @@ test_samba4_ndr("ptr-top-out-pull", r.out.foo = &s; - if (!NT_STATUS_IS_OK(ndr_pull_echo_TestRef(ndr, NDR_OUT, &r))) + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_pull_echo_TestRef(ndr, NDR_OUT, &r))) return 1; if (!r.out.foo) @@ -320,7 +320,7 @@ test_samba4_ndr("ptr-top-out-pull-null", r.out.foo = NULL; - if (NT_STATUS_IS_OK(ndr_pull_echo_TestRef(ndr, NDR_OUT, &r))) + if (NDR_ERR_CODE_IS_SUCCESS(ndr_pull_echo_TestRef(ndr, NDR_OUT, &r))) return 1; /* Windows gives [client runtime error 0x6f4] */ @@ -344,7 +344,7 @@ test_samba4_ndr("refptr-top-out-pull", r.out.foo = &s; - if (!NT_STATUS_IS_OK(ndr_pull_echo_TestRef(ndr, NDR_OUT, &r))) + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_pull_echo_TestRef(ndr, NDR_OUT, &r))) return 1; if (!r.out.foo) @@ -370,7 +370,7 @@ test_samba4_ndr("refptr-top-out-pull-null", r.out.foo = NULL; - if (NT_STATUS_IS_OK(ndr_pull_echo_TestRef(ndr, NDR_OUT, &r))) + if (NDR_ERR_CODE_IS_SUCCESS(ndr_pull_echo_TestRef(ndr, NDR_OUT, &r))) return 1; /* Windows gives [client runtime error 0x6f4] */ @@ -387,7 +387,7 @@ test_samba4_ndr("ptr-top-push-double", uint16_t *pv = &v; r.in.foo = &pv; - if (!NT_STATUS_IS_OK(ndr_push_echo_TestRef(ndr, NDR_IN, &r))) + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r))) return 1; if (ndr->offset != 6) @@ -413,7 +413,7 @@ test_samba4_ndr("ptr-top-push-double-sndnull", uint16_t *pv = NULL; r.in.foo = &pv; - if (!NT_STATUS_IS_OK(ndr_push_echo_TestRef(ndr, NDR_IN, &r))) + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r))) return 1; if (ndr->offset != 4) @@ -433,7 +433,7 @@ test_samba4_ndr("ptr-top-push-double-fstnull", struct echo_TestRef r; r.in.foo = NULL; - if (NT_STATUS_IS_OK(ndr_push_echo_TestRef(ndr, NDR_IN, &r))) + if (NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r))) return 1; /* Windows gives [client runtime error 0x6f4] */ @@ -451,7 +451,7 @@ test_samba4_ndr("refptr-top-push-double", uint16_t *pv = &v; r.in.foo = &pv; - if (!NT_STATUS_IS_OK(ndr_push_echo_TestRef(ndr, NDR_IN, &r))) + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r))) return 1; if (ndr->offset != 6) @@ -478,7 +478,7 @@ test_samba4_ndr("refptr-top-push-double-sndnull", uint16_t *pv = NULL; r.in.foo = &pv; - if (!NT_STATUS_IS_OK(ndr_push_echo_TestRef(ndr, NDR_IN, &r))) + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r))) return 1; if (ndr->offset != 4) @@ -498,7 +498,7 @@ test_samba4_ndr("refptr-top-push-double-fstnull", struct echo_TestRef r; r.in.foo = NULL; - if (NT_STATUS_IS_OK(ndr_push_echo_TestRef(ndr, NDR_IN, &r))) + if (NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r))) return 1; /* Windows gives [client runtime error 0x6f4] */ @@ -517,7 +517,7 @@ test_samba4_ndr("ignore-ptr", r.in.foo = &v; r.in.bar = &v; - if (NT_STATUS_IS_OK(ndr_push_echo_TestRef(ndr, NDR_IN, &r))) + if (NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r))) return 1; if (ndr->offset != 4) diff --git a/source4/pidl/tests/ndr_represent.pl b/source4/pidl/tests/ndr_represent.pl index b5ee312668..8c52015642 100755 --- a/source4/pidl/tests/ndr_represent.pl +++ b/source4/pidl/tests/ndr_represent.pl @@ -18,25 +18,23 @@ test_samba4_ndr('represent_as-simple', struct ndr_pull *ndr = ndr_pull_init_blob(&in_blob, NULL); struct bla r; - if (!NT_STATUS_IS_OK(ndr_pull_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r))) + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_pull_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r))) return 1; if (r.in.x != 13) return 2; ', ' -#include - -NTSTATUS ndr_uint8_to_uint32(uint8_t from, uint32_t *to) +enum ndr_err_code ndr_uint8_to_uint32(uint8_t from, uint32_t *to) { *to = from; - return NT_STATUS_OK; + return NDR_ERR_SUCCESS; } -NTSTATUS ndr_uint32_to_uint8(uint32_t from, uint8_t *to) +enum ndr_err_code ndr_uint32_to_uint8(uint32_t from, uint8_t *to) { *to = from; - return NT_STATUS_OK; + return NDR_ERR_SUCCESS; } ' ); @@ -51,26 +49,23 @@ test_samba4_ndr('transmit_as-simple', struct ndr_pull *ndr = ndr_pull_init_blob(&in_blob, NULL); struct bla r; - if (!NT_STATUS_IS_OK(ndr_pull_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r))) + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_pull_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r))) return 1; if (r.in.x != 13) return 2; ', ' -#include - -NTSTATUS ndr_uint8_to_uint32(uint8_t from, uint32_t *to) +enum ndr_err_code ndr_uint8_to_uint32(uint8_t from, uint32_t *to) { *to = from; - return NT_STATUS_OK; + return NDR_ERR_SUCCESS; } -NTSTATUS ndr_uint32_to_uint8(uint32_t from, uint8_t *to) +enum ndr_err_code ndr_uint32_to_uint8(uint32_t from, uint8_t *to) { *to = from; - return NT_STATUS_OK; + return NDR_ERR_SUCCESS; } ' ); - diff --git a/source4/pidl/tests/ndr_simple.pl b/source4/pidl/tests/ndr_simple.pl index 466a164df4..e5e4197a4f 100755 --- a/source4/pidl/tests/ndr_simple.pl +++ b/source4/pidl/tests/ndr_simple.pl @@ -20,7 +20,7 @@ test_samba4_ndr("simple", "void Test(); ", b.length = 1; ndr = ndr_pull_init_blob(&b, mem_ctx); - if (!NT_STATUS_IS_OK(ndr_pull_uint8(ndr, NDR_SCALARS, &result))) + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_pull_uint8(ndr, NDR_SCALARS, &result))) return 1; if (result != 0x02) diff --git a/source4/pidl/tests/ndr_string.pl b/source4/pidl/tests/ndr_string.pl index 4568ec89b8..834ef5a289 100755 --- a/source4/pidl/tests/ndr_string.pl +++ b/source4/pidl/tests/ndr_string.pl @@ -18,7 +18,7 @@ test_samba4_ndr("string-pull-empty", struct TestString r; r.in.data = NULL; - if (!NT_STATUS_IS_OK(ndr_pull_TestString(ndr, NDR_IN, &r))) + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_pull_TestString(ndr, NDR_IN, &r))) return 1; if (r.in.data == NULL) @@ -40,7 +40,7 @@ test_samba4_ndr("string-ascii-pull", struct TestString r; r.in.data = NULL; - if (!NT_STATUS_IS_OK(ndr_pull_TestString(ndr, NDR_IN, &r))) + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_pull_TestString(ndr, NDR_IN, &r))) return 1; if (r.in.data == NULL) @@ -69,7 +69,7 @@ test_samba4_ndr("string-out", char *str = NULL; r.out.data = &str; - if (!NT_STATUS_IS_OK(ndr_pull_TestString(ndr, NDR_IN, &r))) + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_pull_TestString(ndr, NDR_IN, &r))) return 1; if (r.out.data == NULL) diff --git a/source4/pidl/tests/ndr_tagtype.pl b/source4/pidl/tests/ndr_tagtype.pl index 7f5c24627a..4d6bcb53af 100755 --- a/source4/pidl/tests/ndr_tagtype.pl +++ b/source4/pidl/tests/ndr_tagtype.pl @@ -17,7 +17,7 @@ test_samba4_ndr('struct-notypedef', '[public] struct bla { uint8 x; }; ', DATA_BLOB result_blob; r.x = 13; - if (!NT_STATUS_IS_OK(ndr_push_STRUCT_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r))) + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_STRUCT_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r))) return 1; result_blob = ndr_push_blob(ndr); @@ -36,7 +36,7 @@ test_samba4_ndr('struct-notypedef-used', '[public] struct bla { uint8 x; }; DATA_BLOB result_blob; fn.in.r.x = 13; - if (!NT_STATUS_IS_OK(ndr_push_myfn(ndr, NDR_IN, &fn))) + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_myfn(ndr, NDR_IN, &fn))) return 1; result_blob = ndr_push_blob(ndr); @@ -56,7 +56,7 @@ test_samba4_ndr('struct-notypedef-embedded', 'struct bla { uint8 x; }; DATA_BLOB result_blob; st.r.x = 13; - if (!NT_STATUS_IS_OK(ndr_push_STRUCT_myst(ndr, NDR_IN, &st))) + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_STRUCT_myst(ndr, NDR_IN, &st))) return 1; result_blob = ndr_push_blob(ndr); -- cgit From 6f1efbba065e0f0c9eaaa4a3c8c40ecfa1277107 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 3 Dec 2007 17:51:50 +0100 Subject: r26262: Add test for WERROR return code handling for Samba 3 client code. (This used to be commit 6017b16f504dc7b092c22200951cb206b0a7e602) --- source4/pidl/tests/samba3-cli.pl | 41 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/samba3-cli.pl b/source4/pidl/tests/samba3-cli.pl index 8c06ed8c27..5086300e46 100755 --- a/source4/pidl/tests/samba3-cli.pl +++ b/source4/pidl/tests/samba3-cli.pl @@ -4,7 +4,7 @@ use strict; use warnings; -use Test::More tests => 7; +use Test::More tests => 8; use FindBin qw($RealBin); use lib "$RealBin"; use Util; @@ -59,3 +59,42 @@ is($x->{res}, "NTSTATUS rpccli_bar(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ } "); + +$x = new Parse::Pidl::Samba3::ClientNDR(); + +$fn = { NAME => "bar", ELEMENTS => [ ], RETURN_TYPE => "WERROR" }; +$x->ParseFunction("foo", $fn); +is($x->{res}, "NTSTATUS rpccli_bar(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, WERROR *werror) +{ +\tstruct bar r; +\tNTSTATUS status; +\t +\t/* In parameters */ +\t +\tif (DEBUGLEVEL >= 10) +\t\tNDR_PRINT_IN_DEBUG(bar, &r); +\t +\tstatus = cli_do_rpc_ndr(cli, mem_ctx, PI_FOO, &ndr_table_foo, NDR_BAR, &r); +\t +\tif (!NT_STATUS_IS_OK(status)) { +\t\treturn status; +\t} +\t +\tif (DEBUGLEVEL >= 10) +\t\tNDR_PRINT_OUT_DEBUG(bar, &r); +\t +\tif (NT_STATUS_IS_ERR(status)) { +\t\treturn status; +\t} +\t +\t/* Return variables */ +\t +\t/* Return result */ +\tif (werror) { +\t\t*werror = r.out.result; +\t} +\t +\treturn werror_to_ntstatus(r.out.result); +} + +"); -- cgit From 584044d5e7148c5135518500ba81caece092c04a Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 14 Dec 2007 00:27:38 +0100 Subject: r26444: Fix pidl tests. (This used to be commit bc643f1014cef7f0bc66ad0edfa22395c69b8352) --- source4/pidl/tests/ndr_align.pl | 10 ++++----- source4/pidl/tests/ndr_alloc.pl | 10 ++++----- source4/pidl/tests/ndr_array.pl | 2 +- source4/pidl/tests/ndr_fullptr.pl | 2 +- source4/pidl/tests/ndr_refptr.pl | 44 ++++++++++++++++++------------------- source4/pidl/tests/ndr_represent.pl | 4 ++-- source4/pidl/tests/ndr_simple.pl | 2 +- source4/pidl/tests/ndr_string.pl | 9 +++++--- source4/pidl/tests/ndr_tagtype.pl | 6 ++--- 9 files changed, 46 insertions(+), 43 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/ndr_align.pl b/source4/pidl/tests/ndr_align.pl index 1f4a0da9bb..cc089eaa1f 100755 --- a/source4/pidl/tests/ndr_align.pl +++ b/source4/pidl/tests/ndr_align.pl @@ -16,7 +16,7 @@ test_samba4_ndr('align-uint8-uint16', } bla; ', ' - struct ndr_push *ndr = ndr_push_init_ctx(NULL); + 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 }; @@ -41,7 +41,7 @@ test_samba4_ndr('align-uint8-uint32', } bla; ', ' - struct ndr_push *ndr = ndr_push_init_ctx(NULL); + 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 }; @@ -67,7 +67,7 @@ test_samba4_ndr('align-uint8-hyper', } bla; ', ' - struct ndr_push *ndr = ndr_push_init_ctx(NULL); + 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 }; @@ -93,7 +93,7 @@ test_samba4_ndr('noalignflag-uint8-uint16', } bla; ', ' - struct ndr_push *ndr = ndr_push_init_ctx(NULL); + 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 }; @@ -121,7 +121,7 @@ test_samba4_ndr('align-blob-align2', } blie; ', ' - struct ndr_push *ndr = ndr_push_init_ctx(NULL); + struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL); struct blie r; uint8_t data[] = { 0x01, 0x02 }; uint8_t expected[] = { 0x0D, 0x00, 0x0E }; diff --git a/source4/pidl/tests/ndr_alloc.pl b/source4/pidl/tests/ndr_alloc.pl index e967bb7cdb..399fbd21d6 100755 --- a/source4/pidl/tests/ndr_alloc.pl +++ b/source4/pidl/tests/ndr_alloc.pl @@ -20,7 +20,7 @@ test_samba4_ndr("alloc-scalar", ',' uint8_t data[] = { 0xde, 0xad, 0xbe, 0xef, 0x03 }; DATA_BLOB b = { data, 5 }; - struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL); + struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL, NULL); struct TestAlloc r; if (!NDR_ERR_CODE_IS_SUCCESS(ndr_pull_TestAlloc(ndr, NDR_IN, &r))) @@ -44,7 +44,7 @@ test_samba4_ndr("alloc-buffer", ',' uint8_t data[] = { 0xde, 0xad, 0xbe, 0xef, 0x03 }; DATA_BLOB b = { data, 5 }; - struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL); + struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL, NULL); struct TestAlloc r; if (!NDR_ERR_CODE_IS_SUCCESS(ndr_pull_TestAlloc(ndr, NDR_IN, &r))) @@ -65,7 +65,7 @@ test_samba4_ndr("ref-noalloc-null", ',' uint8_t data[] = { 0x03 }; DATA_BLOB b = { data, 1 }; - struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL); + struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL, NULL); struct TestAlloc r; r.in.t = NULL; @@ -81,7 +81,7 @@ test_samba4_ndr("ref-noalloc", ',' uint8_t data[] = { 0x03 }; DATA_BLOB b = { data, 1 }; - struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL); + struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL, NULL); struct TestAlloc r; uint8_t x; r.in.t = &x; @@ -101,7 +101,7 @@ test_samba4_ndr("ref-alloc", ',' uint8_t data[] = { 0x03 }; DATA_BLOB b = { data, 1 }; - struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL); + struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL, NULL); struct TestAlloc r; ndr->flags |= LIBNDR_FLAG_REF_ALLOC; r.in.t = NULL; diff --git a/source4/pidl/tests/ndr_array.pl b/source4/pidl/tests/ndr_array.pl index 174d702c07..2a6b5bbd57 100755 --- a/source4/pidl/tests/ndr_array.pl +++ b/source4/pidl/tests/ndr_array.pl @@ -23,7 +23,7 @@ test_samba4_ndr( b.data = data; b.length = 10; - ndr = ndr_pull_init_blob(&b, mem_ctx); + ndr = ndr_pull_init_blob(&b, mem_ctx, NULL); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_pull_Test(ndr, NDR_IN, &r))) return 1; diff --git a/source4/pidl/tests/ndr_fullptr.pl b/source4/pidl/tests/ndr_fullptr.pl index 27d4e69447..cc6fca7ab3 100755 --- a/source4/pidl/tests/ndr_fullptr.pl +++ b/source4/pidl/tests/ndr_fullptr.pl @@ -17,7 +17,7 @@ test_samba4_ndr("fullptr-push-dup", [public] uint16 echo_TestFull([in,ptr] uint32 *x, [in,ptr] uint32 *y); ', ' - struct ndr_push *ndr = ndr_push_init(); + struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL); uint32_t v = 13; struct echo_TestFull r; r.in.x = &v; diff --git a/source4/pidl/tests/ndr_refptr.pl b/source4/pidl/tests/ndr_refptr.pl index 0fb4810285..d5dd83957a 100755 --- a/source4/pidl/tests/ndr_refptr.pl +++ b/source4/pidl/tests/ndr_refptr.pl @@ -18,7 +18,7 @@ test_samba4_ndr("noptr-push", [public] uint16 echo_TestRef([in] xstruct foo); ', ' - struct ndr_push *ndr = ndr_push_init_ctx(NULL); + struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL); uint16_t v = 13; struct echo_TestRef r; r.in.foo.x = v; @@ -48,7 +48,7 @@ test_samba4_ndr("ptr-embedded-push", ', ' uint16_t v = 13; - struct ndr_push *ndr = ndr_push_init_ctx(NULL); + struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL); struct echo_TestRef r; r.in.foo.x = &v; @@ -74,7 +74,7 @@ test_samba4_ndr("ptr-embedded-push-null", [public] uint16 echo_TestRef([in] xstruct foo); ', ' - struct ndr_push *ndr = ndr_push_init_ctx(NULL); + struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL); struct echo_TestRef r; r.in.foo.x = NULL; @@ -99,7 +99,7 @@ test_samba4_ndr("refptr-embedded-push", ', ' uint16_t v = 13; - struct ndr_push *ndr = ndr_push_init_ctx(NULL); + struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL); struct echo_TestRef r; r.in.foo.x = &v; @@ -126,7 +126,7 @@ test_samba4_ndr("refptr-embedded-push-null", [public] uint16 echo_TestRef([in] xstruct foo); ', ' - struct ndr_push *ndr = ndr_push_init_ctx(NULL); + struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL); struct echo_TestRef r; r.in.foo.x = NULL; @@ -144,7 +144,7 @@ test_samba4_ndr("ptr-top-push", [public] uint16 echo_TestRef([in] xstruct *foo); ', ' - struct ndr_push *ndr = ndr_push_init_ctx(NULL); + struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL); struct echo_TestRef r; struct xstruct s; s.x = 13; @@ -169,7 +169,7 @@ test_samba4_ndr("ptr-top-push-null", [public] uint16 echo_TestRef([in] xstruct *foo); ', ' - struct ndr_push *ndr = ndr_push_init_ctx(NULL); + struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL); struct echo_TestRef r; r.in.foo = NULL; @@ -189,7 +189,7 @@ test_samba4_ndr("refptr-top-push", [public] uint16 echo_TestRef([in,ref] xstruct *foo); ', ' - struct ndr_push *ndr = ndr_push_init_ctx(NULL); + struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL); struct echo_TestRef r; struct xstruct s; s.x = 13; @@ -214,7 +214,7 @@ test_samba4_ndr("refptr-top-push-null", [public] uint16 echo_TestRef([in,ref] xstruct *foo); ', ' - struct ndr_push *ndr = ndr_push_init_ctx(NULL); + struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL); struct echo_TestRef r; r.in.foo = NULL; @@ -233,7 +233,7 @@ test_samba4_ndr("uniqueptr-top-push", [public] uint16 echo_TestRef([in,unique] xstruct *foo); ', ' - struct ndr_push *ndr = ndr_push_init_ctx(NULL); + struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL); struct echo_TestRef r; struct xstruct s; s.x = 13; @@ -261,7 +261,7 @@ test_samba4_ndr("uniqueptr-top-push-null", [public] uint16 echo_TestRef([in,unique] xstruct *foo); ', ' - struct ndr_push *ndr = ndr_push_init_ctx(NULL); + struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL); struct echo_TestRef r; r.in.foo = NULL; @@ -288,7 +288,7 @@ test_samba4_ndr("ptr-top-out-pull", ' uint8_t data[] = { 0x0D, 0x00 }; DATA_BLOB b = { data, 2 }; - struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL); + struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL, NULL); struct xstruct s; struct echo_TestRef r; @@ -315,7 +315,7 @@ test_samba4_ndr("ptr-top-out-pull-null", ' uint8_t data[] = { 0x0D, 0x00 }; DATA_BLOB b = { data, 2 }; - struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL); + struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL, NULL); struct echo_TestRef r; r.out.foo = NULL; @@ -338,7 +338,7 @@ test_samba4_ndr("refptr-top-out-pull", ' uint8_t data[] = { 0x0D, 0x00 }; DATA_BLOB b = { data, 2 }; - struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL); + struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL, NULL); struct xstruct s; struct echo_TestRef r; @@ -365,7 +365,7 @@ test_samba4_ndr("refptr-top-out-pull-null", ' uint8_t data[] = { 0x0D, 0x00 }; DATA_BLOB b = { data, 2 }; - struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL); + struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL, NULL); struct echo_TestRef r; r.out.foo = NULL; @@ -381,7 +381,7 @@ test_samba4_ndr("ptr-top-push-double", ' [public] void echo_TestRef([in] uint16 **foo); ', -' struct ndr_push *ndr = ndr_push_init_ctx(NULL); +' struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL); struct echo_TestRef r; uint16_t v = 13; uint16_t *pv = &v; @@ -408,7 +408,7 @@ test_samba4_ndr("ptr-top-push-double-sndnull", ' [public] void echo_TestRef([in] uint16 **foo); ', -' struct ndr_push *ndr = ndr_push_init_ctx(NULL); +' struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL); struct echo_TestRef r; uint16_t *pv = NULL; r.in.foo = &pv; @@ -429,7 +429,7 @@ test_samba4_ndr("ptr-top-push-double-fstnull", ' [public] void echo_TestRef([in] uint16 **foo); ', -' struct ndr_push *ndr = ndr_push_init_ctx(NULL); +' struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL); struct echo_TestRef r; r.in.foo = NULL; @@ -445,7 +445,7 @@ test_samba4_ndr("refptr-top-push-double", ' [public] void echo_TestRef([in,ref] uint16 **foo); ', -' struct ndr_push *ndr = ndr_push_init_ctx(NULL); +' struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL); struct echo_TestRef r; uint16_t v = 13; uint16_t *pv = &v; @@ -473,7 +473,7 @@ test_samba4_ndr("refptr-top-push-double-sndnull", ' [public] void echo_TestRef([in,ref] uint16 **foo); ', -' struct ndr_push *ndr = ndr_push_init_ctx(NULL); +' struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL); struct echo_TestRef r; uint16_t *pv = NULL; r.in.foo = &pv; @@ -494,7 +494,7 @@ test_samba4_ndr("refptr-top-push-double-fstnull", ' [public] void echo_TestRef([in,ref] uint16 **foo); ', -' struct ndr_push *ndr = ndr_push_init_ctx(NULL); +' struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL); struct echo_TestRef r; r.in.foo = NULL; @@ -511,7 +511,7 @@ test_samba4_ndr("ignore-ptr", ' [public] void echo_TestRef([in,ignore] uint16 *foo, [in] uint16 *bar); ', -' struct ndr_push *ndr = ndr_push_init_ctx(NULL); +' struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL); struct echo_TestRef r; uint16_t v = 10; r.in.foo = &v; diff --git a/source4/pidl/tests/ndr_represent.pl b/source4/pidl/tests/ndr_represent.pl index 8c52015642..2d65fb92b0 100755 --- a/source4/pidl/tests/ndr_represent.pl +++ b/source4/pidl/tests/ndr_represent.pl @@ -15,7 +15,7 @@ test_samba4_ndr('represent_as-simple', ' uint8_t expected[] = { 0x0D }; DATA_BLOB in_blob = { expected, 1 }; - struct ndr_pull *ndr = ndr_pull_init_blob(&in_blob, NULL); + struct ndr_pull *ndr = ndr_pull_init_blob(&in_blob, NULL, NULL); struct bla r; if (!NDR_ERR_CODE_IS_SUCCESS(ndr_pull_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r))) @@ -46,7 +46,7 @@ test_samba4_ndr('transmit_as-simple', ' uint8_t expected[] = { 0x0D }; DATA_BLOB in_blob = { expected, 1 }; - struct ndr_pull *ndr = ndr_pull_init_blob(&in_blob, NULL); + struct ndr_pull *ndr = ndr_pull_init_blob(&in_blob, NULL, NULL); struct bla r; if (!NDR_ERR_CODE_IS_SUCCESS(ndr_pull_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r))) diff --git a/source4/pidl/tests/ndr_simple.pl b/source4/pidl/tests/ndr_simple.pl index e5e4197a4f..15e07d5693 100755 --- a/source4/pidl/tests/ndr_simple.pl +++ b/source4/pidl/tests/ndr_simple.pl @@ -18,7 +18,7 @@ test_samba4_ndr("simple", "void Test(); ", b.data = data; b.length = 1; - ndr = ndr_pull_init_blob(&b, mem_ctx); + ndr = ndr_pull_init_blob(&b, mem_ctx, NULL); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_pull_uint8(ndr, NDR_SCALARS, &result))) return 1; diff --git a/source4/pidl/tests/ndr_string.pl b/source4/pidl/tests/ndr_string.pl index 834ef5a289..2f2d941665 100755 --- a/source4/pidl/tests/ndr_string.pl +++ b/source4/pidl/tests/ndr_string.pl @@ -14,7 +14,8 @@ test_samba4_ndr("string-pull-empty", ' uint8_t data[] = { 0x00, 0x00, 0x00, 0x00 }; DATA_BLOB b = { data, 4 }; - struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL); + struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL, + smb_iconv_convenience_init(NULL, "ASCII", "UTF8", true)); struct TestString r; r.in.data = NULL; @@ -36,7 +37,8 @@ test_samba4_ndr("string-ascii-pull", 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 ndr_pull *ndr = ndr_pull_init_blob(&b, NULL, + smb_iconv_convenience_init(NULL, "ASCII", "UTF8", true)); struct TestString r; r.in.data = NULL; @@ -64,7 +66,8 @@ test_samba4_ndr("string-out", 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 ndr_pull *ndr = ndr_pull_init_blob(&b, NULL, + smb_iconv_convenience_init(NULL, "ASCII", "UTF8", true)); struct TestString r; char *str = NULL; r.out.data = &str; diff --git a/source4/pidl/tests/ndr_tagtype.pl b/source4/pidl/tests/ndr_tagtype.pl index 4d6bcb53af..3f9b717bfe 100755 --- a/source4/pidl/tests/ndr_tagtype.pl +++ b/source4/pidl/tests/ndr_tagtype.pl @@ -10,7 +10,7 @@ use Util qw(test_samba4_ndr); test_samba4_ndr('struct-notypedef', '[public] struct bla { uint8 x; }; ', ' - struct ndr_push *ndr = ndr_push_init_ctx(NULL); + struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL); struct bla r; uint8_t expected[] = { 0x0D }; DATA_BLOB expected_blob = { expected, 1 }; @@ -29,7 +29,7 @@ test_samba4_ndr('struct-notypedef', '[public] struct bla { uint8 x; }; ', test_samba4_ndr('struct-notypedef-used', '[public] struct bla { uint8 x; }; [public] void myfn([in] struct bla r); ', ' - struct ndr_push *ndr = ndr_push_init_ctx(NULL); + struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL); struct myfn fn; uint8_t expected[] = { 0x0D }; DATA_BLOB expected_blob = { expected, 1 }; @@ -49,7 +49,7 @@ test_samba4_ndr('struct-notypedef-used', '[public] struct bla { uint8 x; }; test_samba4_ndr('struct-notypedef-embedded', 'struct bla { uint8 x; }; [public] struct myst { struct bla r; }; ', ' - struct ndr_push *ndr = ndr_push_init_ctx(NULL); + struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL); struct myst st; uint8_t expected[] = { 0x0D }; DATA_BLOB expected_blob = { expected, 1 }; -- cgit From 70ca53749862a9cf0c511ca3f89ac132d53ab1ac Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 10 Jan 2008 20:38:14 +0100 Subject: pidl: Fix samba3-cli test after Günthers formatting fixes. (This used to be commit bd4ce069b4b6d3fdc182b16060c20e6fe8e8a87d) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source4/pidl/tests/samba3-cli.pl | 69 +++++++++++++++++++++++++--------------- 1 file changed, 44 insertions(+), 25 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/samba3-cli.pl b/source4/pidl/tests/samba3-cli.pl index 5086300e46..1b2a3c9785 100755 --- a/source4/pidl/tests/samba3-cli.pl +++ b/source4/pidl/tests/samba3-cli.pl @@ -29,31 +29,40 @@ my $x = new Parse::Pidl::Samba3::ClientNDR(); $fn = { NAME => "bar", ELEMENTS => [ ] }; $x->ParseFunction("foo", $fn); -is($x->{res}, "NTSTATUS rpccli_bar(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx) +is($x->{res}, +"NTSTATUS rpccli_bar(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx) { \tstruct bar r; \tNTSTATUS status; -\t + \t/* In parameters */ -\t -\tif (DEBUGLEVEL >= 10) + +\tif (DEBUGLEVEL >= 10) { \t\tNDR_PRINT_IN_DEBUG(bar, &r); -\t -\tstatus = cli_do_rpc_ndr(cli, mem_ctx, PI_FOO, &ndr_table_foo, NDR_BAR, &r); -\t +\t} + + status = cli_do_rpc_ndr(cli, + mem_ctx, + PI_FOO, + &ndr_table_foo, + NDR_BAR, + &r); + \tif (!NT_STATUS_IS_OK(status)) { \t\treturn status; \t} -\t -\tif (DEBUGLEVEL >= 10) + +\tif (DEBUGLEVEL >= 10) { \t\tNDR_PRINT_OUT_DEBUG(bar, &r); -\t +\t} + \tif (NT_STATUS_IS_ERR(status)) { \t\treturn status; \t} -\t + \t/* Return variables */ -\t + \t/* Return result */ \treturn NT_STATUS_OK; } @@ -64,36 +73,46 @@ $x = new Parse::Pidl::Samba3::ClientNDR(); $fn = { NAME => "bar", ELEMENTS => [ ], RETURN_TYPE => "WERROR" }; $x->ParseFunction("foo", $fn); -is($x->{res}, "NTSTATUS rpccli_bar(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, WERROR *werror) +is($x->{res}, +"NTSTATUS rpccli_bar(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror) { \tstruct bar r; \tNTSTATUS status; -\t + \t/* In parameters */ -\t -\tif (DEBUGLEVEL >= 10) + +\tif (DEBUGLEVEL >= 10) { \t\tNDR_PRINT_IN_DEBUG(bar, &r); -\t -\tstatus = cli_do_rpc_ndr(cli, mem_ctx, PI_FOO, &ndr_table_foo, NDR_BAR, &r); -\t +\t} + + status = cli_do_rpc_ndr(cli, + mem_ctx, + PI_FOO, + &ndr_table_foo, + NDR_BAR, + &r); + \tif (!NT_STATUS_IS_OK(status)) { \t\treturn status; \t} -\t -\tif (DEBUGLEVEL >= 10) + +\tif (DEBUGLEVEL >= 10) { \t\tNDR_PRINT_OUT_DEBUG(bar, &r); -\t +\t} + \tif (NT_STATUS_IS_ERR(status)) { \t\treturn status; \t} -\t + \t/* Return variables */ -\t + \t/* Return result */ \tif (werror) { \t\t*werror = r.out.result; \t} -\t + \treturn werror_to_ntstatus(r.out.result); } -- cgit From 6963e9b90bc1bfa1e370701e792f34fb0c3e6944 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 12 Jan 2008 21:14:44 +0100 Subject: pidl: Move tests for the CUtil module to a separate file. (This used to be commit ce40890ef0166ad11dd835249f52e2ab5876efba) --- source4/pidl/tests/cutil.pl | 21 +++++++++++++++++++++ source4/pidl/tests/samba-ejs.pl | 13 ++----------- 2 files changed, 23 insertions(+), 11 deletions(-) create mode 100755 source4/pidl/tests/cutil.pl (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/cutil.pl b/source4/pidl/tests/cutil.pl new file mode 100755 index 0000000000..78c8bce45e --- /dev/null +++ b/source4/pidl/tests/cutil.pl @@ -0,0 +1,21 @@ +#!/usr/bin/perl +# (C) 2007 Jelmer Vernooij +# Published under the GNU General Public License +use strict; +use warnings; + +use Test::More tests => 7; +use FindBin qw($RealBin); +use lib "$RealBin"; +use Util; +use Parse::Pidl::Util qw(MyDumper); +use Parse::Pidl::CUtil qw(get_pointer_to get_value_of); + +is("&foo", get_pointer_to("foo")); +is("&(&foo)", get_pointer_to(get_pointer_to("foo"))); +is("*foo", get_pointer_to("**foo")); +is("foo", get_pointer_to("*foo")); + +is("foo", get_value_of("&foo")); +is("*foo", get_value_of("foo")); +is("**foo", get_value_of("*foo")); diff --git a/source4/pidl/tests/samba-ejs.pl b/source4/pidl/tests/samba-ejs.pl index adc00e224f..094d37a103 100755 --- a/source4/pidl/tests/samba-ejs.pl +++ b/source4/pidl/tests/samba-ejs.pl @@ -4,23 +4,14 @@ use strict; use warnings; -use Test::More tests => 17; +use Test::More tests => 10; use FindBin qw($RealBin); use lib "$RealBin"; use Util; use Parse::Pidl::Util qw(MyDumper); -use Parse::Pidl::Samba4::EJS qw(get_pointer_to get_value_of check_null_pointer +use Parse::Pidl::Samba4::EJS qw(check_null_pointer fn_declare TypeFunctionName); -is("&foo", get_pointer_to("foo")); -is("&(&foo)", get_pointer_to(get_pointer_to("foo"))); -is("*foo", get_pointer_to("**foo")); -is("foo", get_pointer_to("*foo")); - -is("foo", get_value_of("&foo")); -is("*foo", get_value_of("foo")); -is("**foo", get_value_of("*foo")); - my $ejs = new Parse::Pidl::Samba4::EJS(); $ejs->check_null_pointer("bla"); -- cgit From 1b906190091718eb16ea3754c671ebccb78a0b33 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 12 Jan 2008 21:21:14 +0100 Subject: pidl: Remove declare tests, add more tests for typedef. (This used to be commit 254bf85c2eb69fc2ee22d3a92a6b027a25594250) --- source4/pidl/tests/ndr.pl | 11 +++++++++-- source4/pidl/tests/typelist.pl | 3 +-- 2 files changed, 10 insertions(+), 4 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/ndr.pl b/source4/pidl/tests/ndr.pl index 1512f19d52..09f1d4969b 100755 --- a/source4/pidl/tests/ndr.pl +++ b/source4/pidl/tests/ndr.pl @@ -4,7 +4,7 @@ use strict; use warnings; -use Test::More tests => 34; +use Test::More tests => 37; use FindBin qw($RealBin); use lib "$RealBin"; use Util; @@ -212,9 +212,16 @@ is(align_type({ TYPE => "STRUCT", "NAME" => "bla", ELEMENTS => [ { TYPE => "uint16" } ] }), 4); is(align_type({ TYPE => "STRUCT", ELEMENTS => [ { TYPE => "hyper" } ] }), 8); -is(align_type({ TYPE => "DECLARE", DATA => { +is(align_type({ TYPE => "TYPEDEF", DATA => { TYPE => "STRUCT", ELEMENTS => [ { TYPE => "hyper" } ] }}), 8); +# typedef of struct without body +is(align_type({ TYPE => "TYPEDEF", DATA => { + TYPE => "STRUCT", ELEMENTS => undef }}), 4); +# struct without body +is(align_type({ TYPE => "STRUCT", ELEMENTS => undef }), 4); +# empty struct +is(align_type({ TYPE => "STRUCT", ELEMENTS => [] }), 1); is(align_type({ TYPE => "STRUCT", "NAME" => "bla", ELEMENTS => [ { TYPE => "uint8" } ] }), 4); diff --git a/source4/pidl/tests/typelist.pl b/source4/pidl/tests/typelist.pl index c5c409a525..90cb853a52 100755 --- a/source4/pidl/tests/typelist.pl +++ b/source4/pidl/tests/typelist.pl @@ -4,7 +4,7 @@ use strict; use warnings; -use Test::More tests => 53; +use Test::More tests => 52; use FindBin qw($RealBin); use lib "$RealBin"; use Util; @@ -56,7 +56,6 @@ is(1, is_scalar({TYPE => "ENUM"})); is(0, is_scalar({TYPE => "STRUCT"})); is(1, is_scalar({TYPE => "TYPEDEF", DATA => {TYPE => "ENUM" }})); is(1, is_scalar("mytypedef")); -is(1, is_scalar({TYPE => "DECLARE", DATA => {TYPE => "ENUM" }})); is(1, scalar_is_reference("string")); is(0, scalar_is_reference("uint32")); -- cgit From 0e4be859f2b681492d6f9556769afe256e9d0167 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 12 Jan 2008 21:37:46 +0100 Subject: pidl: Add more parsing tests. (This used to be commit e44ee3e60ac4eb56cca02b58fdecb171269daca4) --- source4/pidl/tests/parse_idl.pl | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/parse_idl.pl b/source4/pidl/tests/parse_idl.pl index 96c7b2adc8..d14c374740 100755 --- a/source4/pidl/tests/parse_idl.pl +++ b/source4/pidl/tests/parse_idl.pl @@ -4,7 +4,7 @@ # Published under the GNU General Public License use strict; -use Test::More tests => 65 * 2 + 3; +use Test::More tests => 65 * 2 + 5; use FindBin qw($RealBin); use lib "$RealBin"; use Util qw(test_errors); @@ -129,4 +129,20 @@ is_deeply($x, [ { 'FILE' => '', 'DATA' => '"foobar"', 'TYPE' => 'CPP_QUOTE', 'LINE' => 0 } ]); +# A typedef of a struct without body +$x = Parse::Pidl::IDL::parse_string("interface foo { typedef struct x y; }", ""); +is_deeply($x, + [ { 'FILE' => '', 'NAME' => 'foo', 'DATA' => [ + { 'FILE' => '', 'LINE' => 0, 'NAME' => 'y', 'TYPE' => 'TYPEDEF', DATA => { + TYPE => 'STRUCT', NAME => 'x' } } ], + 'TYPE' => 'INTERFACE', 'LINE' => 0 } ]); + +# A typedef of a struct with empty body +$x = Parse::Pidl::IDL::parse_string("interface foo { typedef struct {} y; }", ""); + +is_deeply($x, + [ { 'FILE' => '', 'NAME' => 'foo', 'DATA' => [ + { 'FILE' => '', 'LINE' => 0, 'NAME' => 'y', 'TYPE' => 'TYPEDEF', DATA => { + TYPE => 'STRUCT', ELEMENTS => [] } } ], + 'TYPE' => 'INTERFACE', 'LINE' => 0 } ]); -- cgit From ad559581406313741276e39cf0d28b4d3acdaab1 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 12 Jan 2008 23:10:28 +0100 Subject: pidl: Add function for determining whether a type has a body. (This used to be commit 893f4102c93c1c2cd6b836f12644d06d9e31800c) --- source4/pidl/tests/ndr.pl | 6 +++++- source4/pidl/tests/typelist.pl | 7 +++++-- 2 files changed, 10 insertions(+), 3 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/ndr.pl b/source4/pidl/tests/ndr.pl index 09f1d4969b..ba7fef361b 100755 --- a/source4/pidl/tests/ndr.pl +++ b/source4/pidl/tests/ndr.pl @@ -4,7 +4,7 @@ use strict; use warnings; -use Test::More tests => 37; +use Test::More tests => 39; use FindBin qw($RealBin); use lib "$RealBin"; use Util; @@ -275,3 +275,7 @@ ok(not can_contain_deferred({ TYPE => "TYPEDEF", ELEMENTS => [ { TYPE => "uint32" } ]}})); ok(can_contain_deferred({ TYPE => "STRUCT", ELEMENTS => [ { TYPE => "someunknowntype" } ]})); +# Make sure the elements for a enum without body aren't filled in +ok(not defined(ParseType({TYPE => "ENUM", NAME => "foo" }, "ref")->{ELEMENTS})); +# Make sure the elements for a bitmap without body aren't filled in +ok(not defined(ParseType({TYPE => "BITMAP", NAME => "foo" }, "ref")->{ELEMENTS})); diff --git a/source4/pidl/tests/typelist.pl b/source4/pidl/tests/typelist.pl index 90cb853a52..54f4d34586 100755 --- a/source4/pidl/tests/typelist.pl +++ b/source4/pidl/tests/typelist.pl @@ -4,11 +4,11 @@ use strict; use warnings; -use Test::More tests => 52; +use Test::More tests => 54; use FindBin qw($RealBin); use lib "$RealBin"; use Util; -use Parse::Pidl::Typelist qw(hasType getType mapTypeName expandAlias +use Parse::Pidl::Typelist qw(hasType typeHasBody getType mapTypeName expandAlias mapScalarType addType typeIs is_scalar scalar_is_reference enum_type_fn bitmap_type_fn mapType); @@ -80,3 +80,6 @@ is("uint32_t", mapType({TYPE => "TYPEDEF", DATA => {TYPE => "SCALAR"}}, "uint32" is("void", mapTypeName(undef)); is("uint32_t", mapTypeName("uint32")); is("int32_t", mapTypeName("int")); + +ok(not typeHasBody({TYPE => "TYPEDEF", DATA => { TYPE => "STRUCT" }})); +ok(typeHasBody({TYPE => "TYPEDEF", DATA => { TYPE => "STRUCT", ELEMENTS => [] }})); -- cgit From 3f9812f951bb110700077503a96b9d7d8cfdb2dc Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 12 Jan 2008 23:38:05 +0100 Subject: pidl/ejs: Fix bug that filled in the body for types without body. (This used to be commit 4f4dfa6042178c157a09df61d72a42af7aa5c67b) --- source4/pidl/tests/parse_idl.pl | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/parse_idl.pl b/source4/pidl/tests/parse_idl.pl index d14c374740..93f772ef41 100755 --- a/source4/pidl/tests/parse_idl.pl +++ b/source4/pidl/tests/parse_idl.pl @@ -4,7 +4,7 @@ # Published under the GNU General Public License use strict; -use Test::More tests => 65 * 2 + 5; +use Test::More tests => 65 * 2 + 6; use FindBin qw($RealBin); use lib "$RealBin"; use Util qw(test_errors); @@ -143,6 +143,13 @@ $x = Parse::Pidl::IDL::parse_string("interface foo { typedef struct {} y; }", "< is_deeply($x, [ { 'FILE' => '', 'NAME' => 'foo', 'DATA' => [ - { 'FILE' => '', 'LINE' => 0, 'NAME' => 'y', 'TYPE' => 'TYPEDEF', DATA => { - TYPE => 'STRUCT', ELEMENTS => [] } } ], + { 'FILE' => '', 'LINE' => 0, 'NAME' => 'y', 'TYPE' => 'TYPEDEF', DATA => { TYPE => 'STRUCT', ELEMENTS => [] } } ], + 'TYPE' => 'INTERFACE', 'LINE' => 0 } ]); + +# A typedef of a bitmap with no body +$x = Parse::Pidl::IDL::parse_string("interface foo { typedef bitmap x y; }", ""); + +is_deeply($x, + [ { 'FILE' => '', 'NAME' => 'foo', 'DATA' => [ + { 'FILE' => '', 'LINE' => 0, 'NAME' => 'y', 'TYPE' => 'TYPEDEF', DATA => { TYPE => 'BITMAP', NAME => 'x' } } ], 'TYPE' => 'INTERFACE', 'LINE' => 0 } ]); -- cgit From b36a0aedd2dbe47429bfc2dda6ea802a92efb526 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 13 Jan 2008 00:05:24 +0100 Subject: pidl: Avoid accidently filling in empty body for types without body. (This used to be commit 1fe5c1ad07c574dc094f59f728025dfcafa0cf22) --- source4/pidl/tests/ndr.pl | 4 +++- source4/pidl/tests/parse_idl.pl | 11 ++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/ndr.pl b/source4/pidl/tests/ndr.pl index ba7fef361b..7fcc7ef40e 100755 --- a/source4/pidl/tests/ndr.pl +++ b/source4/pidl/tests/ndr.pl @@ -4,7 +4,7 @@ use strict; use warnings; -use Test::More tests => 39; +use Test::More tests => 40; use FindBin qw($RealBin); use lib "$RealBin"; use Util; @@ -279,3 +279,5 @@ ok(can_contain_deferred({ TYPE => "STRUCT", ok(not defined(ParseType({TYPE => "ENUM", NAME => "foo" }, "ref")->{ELEMENTS})); # Make sure the elements for a bitmap without body aren't filled in ok(not defined(ParseType({TYPE => "BITMAP", NAME => "foo" }, "ref")->{ELEMENTS})); +# Make sure the elements for a union without body aren't filled in +ok(not defined(ParseType({TYPE => "UNION", NAME => "foo" }, "ref")->{ELEMENTS})); diff --git a/source4/pidl/tests/parse_idl.pl b/source4/pidl/tests/parse_idl.pl index 93f772ef41..9d43ddccc7 100755 --- a/source4/pidl/tests/parse_idl.pl +++ b/source4/pidl/tests/parse_idl.pl @@ -4,7 +4,7 @@ # Published under the GNU General Public License use strict; -use Test::More tests => 65 * 2 + 6; +use Test::More tests => 65 * 2 + 7; use FindBin qw($RealBin); use lib "$RealBin"; use Util qw(test_errors); @@ -153,3 +153,12 @@ is_deeply($x, [ { 'FILE' => '', 'NAME' => 'foo', 'DATA' => [ { 'FILE' => '', 'LINE' => 0, 'NAME' => 'y', 'TYPE' => 'TYPEDEF', DATA => { TYPE => 'BITMAP', NAME => 'x' } } ], 'TYPE' => 'INTERFACE', 'LINE' => 0 } ]); + + +# A typedef of a union with no body +$x = Parse::Pidl::IDL::parse_string("interface foo { typedef union x y; }", ""); + +is_deeply($x, + [ { 'FILE' => '', 'NAME' => 'foo', 'DATA' => [ + { 'FILE' => '', 'LINE' => 0, 'NAME' => 'y', 'TYPE' => 'TYPEDEF', DATA => { TYPE => 'UNION', NAME => 'x' } } ], + 'TYPE' => 'INTERFACE', 'LINE' => 0 } ]); -- cgit From a99dff8660ca2d168523b7264d9208a8a12ca5cc Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 13 Jan 2008 18:15:12 +0100 Subject: pidl: Move Generate*Env functions to Parse::Pidl::Samba4::Header because they only work with the structures generated by that file. (This used to be commit 9aeb7f31b0fc3b9679e5af07e65e79bc8073c4e1) --- source4/pidl/tests/header.pl | 54 ++++++++++++++++++++++++++++++++++++++-- source4/pidl/tests/samba-ndr.pl | 51 ++----------------------------------- source4/pidl/tests/samba3-cli.pl | 2 +- 3 files changed, 55 insertions(+), 52 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/header.pl b/source4/pidl/tests/header.pl index 8d0dccf507..db59484444 100755 --- a/source4/pidl/tests/header.pl +++ b/source4/pidl/tests/header.pl @@ -4,12 +4,14 @@ use strict; use warnings; -use Test::More tests => 16; +use Test::More tests => 27; use FindBin qw($RealBin); use lib "$RealBin"; use Util; use Parse::Pidl::Util qw(MyDumper); -use Parse::Pidl::Samba4::Header; +use Parse::Pidl::Samba4::Header qw( + GenerateFunctionInEnv GenerateFunctionOutEnv GenerateStructEnv + EnvSubstituteValue); use Parse::Pidl::IDL qw(parse_string); use Parse::Pidl::NDR; @@ -56,3 +58,51 @@ like(parse_idl("interface p { typedef struct x { int p; } x; };"), like(parse_idl("cpp_quote(\"some-foo\")"), qr/some-foo/sm, "cpp quote"); + +# Make sure GenerateFunctionInEnv and GenerateFunctionOutEnv work +my $fn = { ELEMENTS => [ { DIRECTION => ["in"], NAME => "foo" } ] }; +is_deeply({ "foo" => "r->in.foo" }, GenerateFunctionInEnv($fn)); + +$fn = { ELEMENTS => [ { DIRECTION => ["out"], NAME => "foo" } ] }; +is_deeply({ "foo" => "r->out.foo" }, GenerateFunctionOutEnv($fn)); + +$fn = { ELEMENTS => [ { DIRECTION => ["out", "in"], NAME => "foo" } ] }; +is_deeply({ "foo" => "r->in.foo" }, GenerateFunctionInEnv($fn)); + +$fn = { ELEMENTS => [ { DIRECTION => ["out", "in"], NAME => "foo" } ] }; +is_deeply({ "foo" => "r->out.foo" }, GenerateFunctionOutEnv($fn)); + +$fn = { ELEMENTS => [ { DIRECTION => ["in"], NAME => "foo" } ] }; +is_deeply({ "foo" => "r->in.foo" }, GenerateFunctionOutEnv($fn)); + +$fn = { ELEMENTS => [ { DIRECTION => ["out"], NAME => "foo" } ] }; +is_deeply({ }, GenerateFunctionInEnv($fn)); + +$fn = { ELEMENTS => [ { NAME => "foo" }, { NAME => "bar" } ] }; +is_deeply({ foo => "r->foo", bar => "r->bar", this => "r" }, + GenerateStructEnv($fn, "r")); + +$fn = { ELEMENTS => [ { NAME => "foo" }, { NAME => "bar" } ] }; +is_deeply({ foo => "some->complex.variable->foo", + bar => "some->complex.variable->bar", + this => "some->complex.variable" }, + GenerateStructEnv($fn, "some->complex.variable")); + +$fn = { ELEMENTS => [ { NAME => "foo", PROPERTIES => { value => 3 }} ] }; + +my $env = GenerateStructEnv($fn, "r"); +EnvSubstituteValue($env, $fn); +is_deeply($env, { foo => 3, this => "r" }); + +$fn = { ELEMENTS => [ { NAME => "foo" }, { NAME => "bar" } ] }; +$env = GenerateStructEnv($fn, "r"); +EnvSubstituteValue($env, $fn); +is_deeply($env, { foo => 'r->foo', bar => 'r->bar', this => "r" }); + +$fn = { ELEMENTS => [ { NAME => "foo", PROPERTIES => { value => 0 }} ] }; + +$env = GenerateStructEnv($fn, "r"); +EnvSubstituteValue($env, $fn); +is_deeply($env, { foo => 0, this => "r" }); + + diff --git a/source4/pidl/tests/samba-ndr.pl b/source4/pidl/tests/samba-ndr.pl index 05c3c1c0df..a14111961f 100755 --- a/source4/pidl/tests/samba-ndr.pl +++ b/source4/pidl/tests/samba-ndr.pl @@ -4,15 +4,14 @@ use strict; use warnings; -use Test::More tests => 41; +use Test::More tests => 30; use FindBin qw($RealBin); use lib "$RealBin"; use Util; use strict; use Parse::Pidl::Util qw(MyDumper); use Parse::Pidl::Samba4::NDR::Parser qw(check_null_pointer - GenerateFunctionInEnv GenerateFunctionOutEnv GenerateStructEnv - EnvSubstituteValue NeededFunction NeededElement NeededType + NeededFunction NeededElement NeededType NeededInterface TypeFunctionName ParseElementPrint); my $output; @@ -138,52 +137,6 @@ test_warnings("nofile:2: unknown dereferenced expression `r->in.bla'\n", is($output, "if (r->in.bla == NULL) return;"); -# Make sure GenerateFunctionInEnv and GenerateFunctionOutEnv work -$fn = { ELEMENTS => [ { DIRECTION => ["in"], NAME => "foo" } ] }; -is_deeply({ "foo" => "r->in.foo" }, GenerateFunctionInEnv($fn)); - -$fn = { ELEMENTS => [ { DIRECTION => ["out"], NAME => "foo" } ] }; -is_deeply({ "foo" => "r->out.foo" }, GenerateFunctionOutEnv($fn)); - -$fn = { ELEMENTS => [ { DIRECTION => ["out", "in"], NAME => "foo" } ] }; -is_deeply({ "foo" => "r->in.foo" }, GenerateFunctionInEnv($fn)); - -$fn = { ELEMENTS => [ { DIRECTION => ["out", "in"], NAME => "foo" } ] }; -is_deeply({ "foo" => "r->out.foo" }, GenerateFunctionOutEnv($fn)); - -$fn = { ELEMENTS => [ { DIRECTION => ["in"], NAME => "foo" } ] }; -is_deeply({ "foo" => "r->in.foo" }, GenerateFunctionOutEnv($fn)); - -$fn = { ELEMENTS => [ { DIRECTION => ["out"], NAME => "foo" } ] }; -is_deeply({ }, GenerateFunctionInEnv($fn)); - -$fn = { ELEMENTS => [ { NAME => "foo" }, { NAME => "bar" } ] }; -is_deeply({ foo => "r->foo", bar => "r->bar", this => "r" }, - GenerateStructEnv($fn, "r")); - -$fn = { ELEMENTS => [ { NAME => "foo" }, { NAME => "bar" } ] }; -is_deeply({ foo => "some->complex.variable->foo", - bar => "some->complex.variable->bar", - this => "some->complex.variable" }, - GenerateStructEnv($fn, "some->complex.variable")); - -$fn = { ELEMENTS => [ { NAME => "foo", PROPERTIES => { value => 3 }} ] }; - -my $env = GenerateStructEnv($fn, "r"); -EnvSubstituteValue($env, $fn); -is_deeply($env, { foo => 3, this => "r" }); - -$fn = { ELEMENTS => [ { NAME => "foo" }, { NAME => "bar" } ] }; -$env = GenerateStructEnv($fn, "r"); -EnvSubstituteValue($env, $fn); -is_deeply($env, { foo => 'r->foo', bar => 'r->bar', this => "r" }); - -$fn = { ELEMENTS => [ { NAME => "foo", PROPERTIES => { value => 0 }} ] }; - -$env = GenerateStructEnv($fn, "r"); -EnvSubstituteValue($env, $fn); -is_deeply($env, { foo => 0, this => "r" }); - my $needed = {}; NeededElement({ TYPE => "foo", REPRESENTATION_TYPE => "foo" }, "pull", $needed); is_deeply($needed, { ndr_pull_foo => 1 }); diff --git a/source4/pidl/tests/samba3-cli.pl b/source4/pidl/tests/samba3-cli.pl index 1b2a3c9785..f5b51b7d34 100755 --- a/source4/pidl/tests/samba3-cli.pl +++ b/source4/pidl/tests/samba3-cli.pl @@ -10,7 +10,7 @@ use lib "$RealBin"; use Util; use Parse::Pidl::Util qw(MyDumper); use Parse::Pidl::Samba3::ClientNDR qw(ParseFunction); -use Parse::Pidl::Samba4::NDR::Parser qw(GenerateFunctionInEnv GenerateFunctionOutEnv); +use Parse::Pidl::Samba4::Header qw(GenerateFunctionInEnv GenerateFunctionOutEnv); # Make sure GenerateFunctionInEnv and GenerateFunctionOutEnv work my $fn = { ELEMENTS => [ { DIRECTION => ["in"], NAME => "foo" } ] }; -- cgit From 39cc507d1b7b0454d8f380fc3127fa966a0f972c Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 16 Jan 2008 14:54:29 +0100 Subject: pidl: Fix imported function for ServerNDR and add test to make sure it doesn't regress again. (This used to be commit 0e036948307c8ca5013e20a17a10d109830e4df1) --- source4/pidl/tests/samba3-srv.pl | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 source4/pidl/tests/samba3-srv.pl (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/samba3-srv.pl b/source4/pidl/tests/samba3-srv.pl new file mode 100644 index 0000000000..dc96518fd0 --- /dev/null +++ b/source4/pidl/tests/samba3-srv.pl @@ -0,0 +1,14 @@ +#!/usr/bin/perl +# (C) 2008 Jelmer Vernooij +# Published under the GNU General Public License +use strict; +use warnings; + +use Test::More tests => 0; +use FindBin qw($RealBin); +use lib "$RealBin"; +use Util; +use Parse::Pidl::Util qw(MyDumper); +use Parse::Pidl::Samba3::ServerNDR; + + -- cgit From 3e53ad6f4a5767fd1a26a35a0060b03a6e77161c Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 16 Jan 2008 15:07:00 +0100 Subject: pidl: Add simple test for ServerNDR. (This used to be commit 5b2ea43ed8613ac10ebe7feda0cf070c8079137a) --- source4/pidl/tests/samba3-srv.pl | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/samba3-srv.pl b/source4/pidl/tests/samba3-srv.pl index dc96518fd0..d1e2bc9545 100644 --- a/source4/pidl/tests/samba3-srv.pl +++ b/source4/pidl/tests/samba3-srv.pl @@ -4,11 +4,15 @@ use strict; use warnings; -use Test::More tests => 0; +use Test::More tests => 1; use FindBin qw($RealBin); use lib "$RealBin"; use Util; -use Parse::Pidl::Util qw(MyDumper); -use Parse::Pidl::Samba3::ServerNDR; +use Parse::Pidl::Util qw(MyDumper has_property); +use Parse::Pidl::Samba3::ServerNDR qw(DeclLevel); +my $l = { TYPE => "DATA", DATA_TYPE => "uint32" }; +my $e = { FILE => "foo", LINE => 0, PROPERTIES => { }, TYPE => "uint32", + LEVELS => [ $l ] }; +is("uint32_t", DeclLevel($e, 0)); -- cgit From dca5fab18065be56e3a7fd0ee1507214eb667534 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 30 Jan 2008 20:25:40 +0100 Subject: pidl: be consistent and always ask pkg-config only for 'ndr' metze (This used to be commit ab2e1394d0a66ca13750e1b6f4ced07f4a0f3453) --- source4/pidl/tests/Util.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/Util.pm b/source4/pidl/tests/Util.pm index 82ab130e5a..4ad216a6a1 100644 --- a/source4/pidl/tests/Util.pm +++ b/source4/pidl/tests/Util.pm @@ -134,7 +134,7 @@ $c $cc = "cc"; } - my $flags = `pkg-config --libs --cflags ndr samba-config`; + my $flags = `pkg-config --libs --cflags ndr`; my $cmd = "$cc $cflags -x c - -o $outfile $flags $ldflags"; $cmd =~ s/\n//g; -- cgit From 19898379bd23e4df1249aa78f50a2947ab63c7cf Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 1 Feb 2008 10:30:47 +0100 Subject: LOOKS OK... pidl: get the pointer types correct when an element has multiple pointers Only the first level gets the pointer type from the pointer property, the others get them from the pointer_default() interface property see http://msdn2.microsoft.com/en-us/library/aa378984(VS.85).aspx (Here they talk about the rightmost pointer, but testing shows they mean the leftmost pointer.) metze (This used to be commit 0569139ca2960ec5478829c3e66f7ff69bdb55cd) --- source4/pidl/tests/ndr.pl | 289 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 282 insertions(+), 7 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/ndr.pl b/source4/pidl/tests/ndr.pl index 7fcc7ef40e..758c3dddb7 100755 --- a/source4/pidl/tests/ndr.pl +++ b/source4/pidl/tests/ndr.pl @@ -4,7 +4,7 @@ use strict; use warnings; -use Test::More tests => 40; +use Test::More tests => 46; use FindBin qw($RealBin); use lib "$RealBin"; use Util; @@ -22,7 +22,7 @@ my $e = { 'PARENT' => { TYPE => 'STRUCT' }, 'LINE' => 42 }; -is_deeply(GetElementLevelTable($e), [ +is_deeply(GetElementLevelTable($e, "unique"), [ { 'IS_DEFERRED' => 0, 'LEVEL_INDEX' => 0, @@ -33,7 +33,7 @@ is_deeply(GetElementLevelTable($e), [ } ]); -my $ne = ParseElement($e, undef); +my $ne = ParseElement($e, "unique"); is($ne->{ORIGINAL}, $e); is($ne->{NAME}, "v"); is($ne->{ALIGN}, 1); @@ -60,7 +60,7 @@ $e = { 'TYPE' => 'uint8', 'LINE' => 42 }; -is_deeply(GetElementLevelTable($e), [ +is_deeply(GetElementLevelTable($e, "unique"), [ { LEVEL_INDEX => 0, IS_DEFERRED => 0, @@ -90,7 +90,7 @@ $e = { 'PARENT' => { TYPE => 'STRUCT' }, 'LINE' => 42 }; -is_deeply(GetElementLevelTable($e), [ +is_deeply(GetElementLevelTable($e, "unique"), [ { LEVEL_INDEX => 0, IS_DEFERRED => 0, @@ -128,7 +128,7 @@ $e = { 'PARENT' => { TYPE => 'STRUCT' }, 'LINE' => 42 }; -is_deeply(GetElementLevelTable($e), [ +is_deeply(GetElementLevelTable($e, "unique"), [ { LEVEL_INDEX => 0, IS_DEFERRED => 0, @@ -147,6 +147,97 @@ is_deeply(GetElementLevelTable($e), [ } ]); +# Case 3 : ref pointers +# +$e = { + 'FILE' => 'foo.idl', + 'NAME' => 'v', + 'PROPERTIES' => {"ref" => 1}, + 'POINTERS' => 3, + 'TYPE' => 'uint8', + 'PARENT' => { TYPE => 'STRUCT' }, + 'LINE' => 42 }; + +is_deeply(GetElementLevelTable($e, "unique"), [ + { + LEVEL_INDEX => 0, + IS_DEFERRED => 0, + TYPE => 'POINTER', + POINTER_TYPE => "ref", + POINTER_INDEX => 0, + LEVEL => 'EMBEDDED' + }, + { + LEVEL_INDEX => 1, + IS_DEFERRED => 1, + TYPE => 'POINTER', + POINTER_TYPE => "unique", + POINTER_INDEX => 1, + LEVEL => 'EMBEDDED' + }, + { + LEVEL_INDEX => 2, + IS_DEFERRED => 1, + TYPE => 'POINTER', + POINTER_TYPE => "unique", + POINTER_INDEX => 2, + LEVEL => 'EMBEDDED' + }, + { + 'IS_DEFERRED' => 1, + 'LEVEL_INDEX' => 3, + 'DATA_TYPE' => 'uint8', + 'CONTAINS_DEFERRED' => 0, + 'TYPE' => 'DATA', + 'IS_SURROUNDING' => 0, + } +]); + +# Case 3 : ref pointers +# +$e = { + 'FILE' => 'foo.idl', + 'NAME' => 'v', + 'PROPERTIES' => {"ref" => 1}, + 'POINTERS' => 3, + 'TYPE' => 'uint8', + 'PARENT' => { TYPE => 'STRUCT' }, + 'LINE' => 42 }; + +is_deeply(GetElementLevelTable($e, "ref"), [ + { + LEVEL_INDEX => 0, + IS_DEFERRED => 0, + TYPE => 'POINTER', + POINTER_TYPE => "ref", + POINTER_INDEX => 0, + LEVEL => 'EMBEDDED' + }, + { + LEVEL_INDEX => 1, + IS_DEFERRED => 1, + TYPE => 'POINTER', + POINTER_TYPE => "ref", + POINTER_INDEX => 1, + LEVEL => 'EMBEDDED' + }, + { + LEVEL_INDEX => 2, + IS_DEFERRED => 1, + TYPE => 'POINTER', + POINTER_TYPE => "ref", + POINTER_INDEX => 2, + LEVEL => 'EMBEDDED' + }, + { + 'IS_DEFERRED' => 1, + 'LEVEL_INDEX' => 3, + 'DATA_TYPE' => 'uint8', + 'CONTAINS_DEFERRED' => 0, + 'TYPE' => 'DATA', + 'IS_SURROUNDING' => 0, + } +]); # Case 4 : top-level ref pointers # @@ -159,7 +250,7 @@ $e = { 'PARENT' => { TYPE => 'FUNCTION' }, 'LINE' => 42 }; -is_deeply(GetElementLevelTable($e), [ +is_deeply(GetElementLevelTable($e, "unique"), [ { LEVEL_INDEX => 0, IS_DEFERRED => 0, @@ -178,6 +269,190 @@ is_deeply(GetElementLevelTable($e), [ } ]); +# Case 4 : top-level ref pointers, triple with pointer_default("unique") +# +$e = { + 'FILE' => 'foo.idl', + 'NAME' => 'v', + 'PROPERTIES' => {"ref" => 1}, + 'POINTERS' => 3, + 'TYPE' => 'uint8', + 'PARENT' => { TYPE => 'FUNCTION' }, + 'LINE' => 42 }; + +is_deeply(GetElementLevelTable($e, "unique"), [ + { + LEVEL_INDEX => 0, + IS_DEFERRED => 0, + TYPE => 'POINTER', + POINTER_TYPE => "ref", + POINTER_INDEX => 0, + LEVEL => 'TOP' + }, + { + LEVEL_INDEX => 1, + IS_DEFERRED => 0, + TYPE => 'POINTER', + POINTER_TYPE => "unique", + POINTER_INDEX => 1, + LEVEL => 'EMBEDDED' + }, + { + LEVEL_INDEX => 2, + IS_DEFERRED => 0, + TYPE => 'POINTER', + POINTER_TYPE => "unique", + POINTER_INDEX => 2, + LEVEL => 'EMBEDDED' + }, + { + 'IS_DEFERRED' => 0, + 'LEVEL_INDEX' => 3, + 'DATA_TYPE' => 'uint8', + 'CONTAINS_DEFERRED' => 0, + 'TYPE' => 'DATA', + 'IS_SURROUNDING' => 0, + } +]); + +# Case 4 : top-level unique pointers, triple with pointer_default("unique") +# +$e = { + 'FILE' => 'foo.idl', + 'NAME' => 'v', + 'PROPERTIES' => {"unique" => 1, "in" => 1}, + 'POINTERS' => 3, + 'TYPE' => 'uint8', + 'PARENT' => { TYPE => 'FUNCTION' }, + 'LINE' => 42 }; + +is_deeply(GetElementLevelTable($e, "unique"), [ + { + LEVEL_INDEX => 0, + IS_DEFERRED => 0, + TYPE => 'POINTER', + POINTER_TYPE => "unique", + POINTER_INDEX => 0, + LEVEL => 'TOP' + }, + { + LEVEL_INDEX => 1, + IS_DEFERRED => 0, + TYPE => 'POINTER', + POINTER_TYPE => "unique", + POINTER_INDEX => 1, + LEVEL => 'EMBEDDED' + }, + { + LEVEL_INDEX => 2, + IS_DEFERRED => 0, + TYPE => 'POINTER', + POINTER_TYPE => "unique", + POINTER_INDEX => 2, + LEVEL => 'EMBEDDED' + }, + { + 'IS_DEFERRED' => 0, + 'LEVEL_INDEX' => 3, + 'DATA_TYPE' => 'uint8', + 'CONTAINS_DEFERRED' => 0, + 'TYPE' => 'DATA', + 'IS_SURROUNDING' => 0, + } +]); + +# Case 4 : top-level unique pointers, triple with pointer_default("ref") +# +$e = { + 'FILE' => 'foo.idl', + 'NAME' => 'v', + 'PROPERTIES' => {"unique" => 1, "in" => 1}, + 'POINTERS' => 3, + 'TYPE' => 'uint8', + 'PARENT' => { TYPE => 'FUNCTION' }, + 'LINE' => 42 }; + +is_deeply(GetElementLevelTable($e, "ref"), [ + { + LEVEL_INDEX => 0, + IS_DEFERRED => 0, + TYPE => 'POINTER', + POINTER_TYPE => "unique", + POINTER_INDEX => 0, + LEVEL => 'TOP' + }, + { + LEVEL_INDEX => 1, + IS_DEFERRED => 0, + TYPE => 'POINTER', + POINTER_TYPE => "ref", + POINTER_INDEX => 1, + LEVEL => 'EMBEDDED' + }, + { + LEVEL_INDEX => 2, + IS_DEFERRED => 0, + TYPE => 'POINTER', + POINTER_TYPE => "ref", + POINTER_INDEX => 2, + LEVEL => 'EMBEDDED' + }, + { + 'IS_DEFERRED' => 0, + 'LEVEL_INDEX' => 3, + 'DATA_TYPE' => 'uint8', + 'CONTAINS_DEFERRED' => 0, + 'TYPE' => 'DATA', + 'IS_SURROUNDING' => 0, + } +]); + +# Case 4 : top-level ref pointers, triple with pointer_default("ref") +# +$e = { + 'FILE' => 'foo.idl', + 'NAME' => 'v', + 'PROPERTIES' => {"ref" => 1}, + 'POINTERS' => 3, + 'TYPE' => 'uint8', + 'PARENT' => { TYPE => 'FUNCTION' }, + 'LINE' => 42 }; + +is_deeply(GetElementLevelTable($e, "ref"), [ + { + LEVEL_INDEX => 0, + IS_DEFERRED => 0, + TYPE => 'POINTER', + POINTER_TYPE => "ref", + POINTER_INDEX => 0, + LEVEL => 'TOP' + }, + { + LEVEL_INDEX => 1, + IS_DEFERRED => 0, + TYPE => 'POINTER', + POINTER_TYPE => "ref", + POINTER_INDEX => 1, + LEVEL => 'EMBEDDED' + }, + { + LEVEL_INDEX => 2, + IS_DEFERRED => 0, + TYPE => 'POINTER', + POINTER_TYPE => "ref", + POINTER_INDEX => 2, + LEVEL => 'EMBEDDED' + }, + { + 'IS_DEFERRED' => 0, + 'LEVEL_INDEX' => 3, + 'DATA_TYPE' => 'uint8', + 'CONTAINS_DEFERRED' => 0, + 'TYPE' => 'DATA', + 'IS_SURROUNDING' => 0, + } +]); + # representation_type $e = { 'FILE' => 'foo.idl', -- cgit From 2670c954466683bc3769fae4505baa78ec43a253 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 1 Feb 2008 23:09:37 +0100 Subject: WORKS!!!...pidl/NDR: fix handling of multilevel pointers in function elements The 2nd or higher level of wire pointers needs to be marked as deferred. metze (This used to be commit 6fcf2456d0e81898b5779ef1650f38b4c5363a80) --- source4/pidl/tests/ndr.pl | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/ndr.pl b/source4/pidl/tests/ndr.pl index 758c3dddb7..504b7ec8de 100755 --- a/source4/pidl/tests/ndr.pl +++ b/source4/pidl/tests/ndr.pl @@ -299,14 +299,14 @@ is_deeply(GetElementLevelTable($e, "unique"), [ }, { LEVEL_INDEX => 2, - IS_DEFERRED => 0, + IS_DEFERRED => 1, TYPE => 'POINTER', POINTER_TYPE => "unique", POINTER_INDEX => 2, LEVEL => 'EMBEDDED' }, { - 'IS_DEFERRED' => 0, + 'IS_DEFERRED' => 1, 'LEVEL_INDEX' => 3, 'DATA_TYPE' => 'uint8', 'CONTAINS_DEFERRED' => 0, @@ -337,7 +337,7 @@ is_deeply(GetElementLevelTable($e, "unique"), [ }, { LEVEL_INDEX => 1, - IS_DEFERRED => 0, + IS_DEFERRED => 1, TYPE => 'POINTER', POINTER_TYPE => "unique", POINTER_INDEX => 1, @@ -345,14 +345,14 @@ is_deeply(GetElementLevelTable($e, "unique"), [ }, { LEVEL_INDEX => 2, - IS_DEFERRED => 0, + IS_DEFERRED => 1, TYPE => 'POINTER', POINTER_TYPE => "unique", POINTER_INDEX => 2, LEVEL => 'EMBEDDED' }, { - 'IS_DEFERRED' => 0, + 'IS_DEFERRED' => 1, 'LEVEL_INDEX' => 3, 'DATA_TYPE' => 'uint8', 'CONTAINS_DEFERRED' => 0, @@ -383,7 +383,7 @@ is_deeply(GetElementLevelTable($e, "ref"), [ }, { LEVEL_INDEX => 1, - IS_DEFERRED => 0, + IS_DEFERRED => 1, TYPE => 'POINTER', POINTER_TYPE => "ref", POINTER_INDEX => 1, @@ -391,14 +391,14 @@ is_deeply(GetElementLevelTable($e, "ref"), [ }, { LEVEL_INDEX => 2, - IS_DEFERRED => 0, + IS_DEFERRED => 1, TYPE => 'POINTER', POINTER_TYPE => "ref", POINTER_INDEX => 2, LEVEL => 'EMBEDDED' }, { - 'IS_DEFERRED' => 0, + 'IS_DEFERRED' => 1, 'LEVEL_INDEX' => 3, 'DATA_TYPE' => 'uint8', 'CONTAINS_DEFERRED' => 0, @@ -437,14 +437,14 @@ is_deeply(GetElementLevelTable($e, "ref"), [ }, { LEVEL_INDEX => 2, - IS_DEFERRED => 0, + IS_DEFERRED => 1, TYPE => 'POINTER', POINTER_TYPE => "ref", POINTER_INDEX => 2, LEVEL => 'EMBEDDED' }, { - 'IS_DEFERRED' => 0, + 'IS_DEFERRED' => 1, 'LEVEL_INDEX' => 3, 'DATA_TYPE' => 'uint8', 'CONTAINS_DEFERRED' => 0, -- cgit From e22c627ea1e700c30568399cf94df5b88b05f216 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 2 Feb 2008 11:13:03 +0100 Subject: pidl: revert changes it didn't want to push...sorry! 8ebf16c0741085fa769fcc2929f275ab49b1ea5d Works!!!...pidl/Samba4::NDR::Parser: fix support for embedded "ref" pointers 6fcf2456d0e81898b5779ef1650f38b4c5363a80 WORKS!!!...pidl/NDR: fix handling of multilevel pointers in function elements 0569139ca2960ec5478829c3e66f7ff69bdb55cd LOOKS OK... pidl: get the pointer types correct when an element has multiple pointe rs 13afc89a87716063180723f0e9cb4f76daca837e CHECKED... pidl/Samba4::NDR::Parser: correctly get the name of an array element 29c104944bcad30c6a2a3fa70d527bf0ee8969de CHECKED... TODO:MSG pidl/Samba4::NDR::Parser: fix ... 3369015f5d8c425e1a9f9d861471028f03f163bb CHECKED... pidl/Samba4::NDR::Parser: move logic for extra get_pointer_of() into a f unction metze (This used to be commit 0bcc8e53d1470ba9dfe93e5d6925b8f4c20c7c66) --- source4/pidl/tests/ndr.pl | 289 ++-------------------------------------------- 1 file changed, 7 insertions(+), 282 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/ndr.pl b/source4/pidl/tests/ndr.pl index 504b7ec8de..7fcc7ef40e 100755 --- a/source4/pidl/tests/ndr.pl +++ b/source4/pidl/tests/ndr.pl @@ -4,7 +4,7 @@ use strict; use warnings; -use Test::More tests => 46; +use Test::More tests => 40; use FindBin qw($RealBin); use lib "$RealBin"; use Util; @@ -22,7 +22,7 @@ my $e = { 'PARENT' => { TYPE => 'STRUCT' }, 'LINE' => 42 }; -is_deeply(GetElementLevelTable($e, "unique"), [ +is_deeply(GetElementLevelTable($e), [ { 'IS_DEFERRED' => 0, 'LEVEL_INDEX' => 0, @@ -33,7 +33,7 @@ is_deeply(GetElementLevelTable($e, "unique"), [ } ]); -my $ne = ParseElement($e, "unique"); +my $ne = ParseElement($e, undef); is($ne->{ORIGINAL}, $e); is($ne->{NAME}, "v"); is($ne->{ALIGN}, 1); @@ -60,7 +60,7 @@ $e = { 'TYPE' => 'uint8', 'LINE' => 42 }; -is_deeply(GetElementLevelTable($e, "unique"), [ +is_deeply(GetElementLevelTable($e), [ { LEVEL_INDEX => 0, IS_DEFERRED => 0, @@ -90,7 +90,7 @@ $e = { 'PARENT' => { TYPE => 'STRUCT' }, 'LINE' => 42 }; -is_deeply(GetElementLevelTable($e, "unique"), [ +is_deeply(GetElementLevelTable($e), [ { LEVEL_INDEX => 0, IS_DEFERRED => 0, @@ -128,7 +128,7 @@ $e = { 'PARENT' => { TYPE => 'STRUCT' }, 'LINE' => 42 }; -is_deeply(GetElementLevelTable($e, "unique"), [ +is_deeply(GetElementLevelTable($e), [ { LEVEL_INDEX => 0, IS_DEFERRED => 0, @@ -147,97 +147,6 @@ is_deeply(GetElementLevelTable($e, "unique"), [ } ]); -# Case 3 : ref pointers -# -$e = { - 'FILE' => 'foo.idl', - 'NAME' => 'v', - 'PROPERTIES' => {"ref" => 1}, - 'POINTERS' => 3, - 'TYPE' => 'uint8', - 'PARENT' => { TYPE => 'STRUCT' }, - 'LINE' => 42 }; - -is_deeply(GetElementLevelTable($e, "unique"), [ - { - LEVEL_INDEX => 0, - IS_DEFERRED => 0, - TYPE => 'POINTER', - POINTER_TYPE => "ref", - POINTER_INDEX => 0, - LEVEL => 'EMBEDDED' - }, - { - LEVEL_INDEX => 1, - IS_DEFERRED => 1, - TYPE => 'POINTER', - POINTER_TYPE => "unique", - POINTER_INDEX => 1, - LEVEL => 'EMBEDDED' - }, - { - LEVEL_INDEX => 2, - IS_DEFERRED => 1, - TYPE => 'POINTER', - POINTER_TYPE => "unique", - POINTER_INDEX => 2, - LEVEL => 'EMBEDDED' - }, - { - 'IS_DEFERRED' => 1, - 'LEVEL_INDEX' => 3, - 'DATA_TYPE' => 'uint8', - 'CONTAINS_DEFERRED' => 0, - 'TYPE' => 'DATA', - 'IS_SURROUNDING' => 0, - } -]); - -# Case 3 : ref pointers -# -$e = { - 'FILE' => 'foo.idl', - 'NAME' => 'v', - 'PROPERTIES' => {"ref" => 1}, - 'POINTERS' => 3, - 'TYPE' => 'uint8', - 'PARENT' => { TYPE => 'STRUCT' }, - 'LINE' => 42 }; - -is_deeply(GetElementLevelTable($e, "ref"), [ - { - LEVEL_INDEX => 0, - IS_DEFERRED => 0, - TYPE => 'POINTER', - POINTER_TYPE => "ref", - POINTER_INDEX => 0, - LEVEL => 'EMBEDDED' - }, - { - LEVEL_INDEX => 1, - IS_DEFERRED => 1, - TYPE => 'POINTER', - POINTER_TYPE => "ref", - POINTER_INDEX => 1, - LEVEL => 'EMBEDDED' - }, - { - LEVEL_INDEX => 2, - IS_DEFERRED => 1, - TYPE => 'POINTER', - POINTER_TYPE => "ref", - POINTER_INDEX => 2, - LEVEL => 'EMBEDDED' - }, - { - 'IS_DEFERRED' => 1, - 'LEVEL_INDEX' => 3, - 'DATA_TYPE' => 'uint8', - 'CONTAINS_DEFERRED' => 0, - 'TYPE' => 'DATA', - 'IS_SURROUNDING' => 0, - } -]); # Case 4 : top-level ref pointers # @@ -250,7 +159,7 @@ $e = { 'PARENT' => { TYPE => 'FUNCTION' }, 'LINE' => 42 }; -is_deeply(GetElementLevelTable($e, "unique"), [ +is_deeply(GetElementLevelTable($e), [ { LEVEL_INDEX => 0, IS_DEFERRED => 0, @@ -269,190 +178,6 @@ is_deeply(GetElementLevelTable($e, "unique"), [ } ]); -# Case 4 : top-level ref pointers, triple with pointer_default("unique") -# -$e = { - 'FILE' => 'foo.idl', - 'NAME' => 'v', - 'PROPERTIES' => {"ref" => 1}, - 'POINTERS' => 3, - 'TYPE' => 'uint8', - 'PARENT' => { TYPE => 'FUNCTION' }, - 'LINE' => 42 }; - -is_deeply(GetElementLevelTable($e, "unique"), [ - { - LEVEL_INDEX => 0, - IS_DEFERRED => 0, - TYPE => 'POINTER', - POINTER_TYPE => "ref", - POINTER_INDEX => 0, - LEVEL => 'TOP' - }, - { - LEVEL_INDEX => 1, - IS_DEFERRED => 0, - TYPE => 'POINTER', - POINTER_TYPE => "unique", - POINTER_INDEX => 1, - LEVEL => 'EMBEDDED' - }, - { - LEVEL_INDEX => 2, - IS_DEFERRED => 1, - TYPE => 'POINTER', - POINTER_TYPE => "unique", - POINTER_INDEX => 2, - LEVEL => 'EMBEDDED' - }, - { - 'IS_DEFERRED' => 1, - 'LEVEL_INDEX' => 3, - 'DATA_TYPE' => 'uint8', - 'CONTAINS_DEFERRED' => 0, - 'TYPE' => 'DATA', - 'IS_SURROUNDING' => 0, - } -]); - -# Case 4 : top-level unique pointers, triple with pointer_default("unique") -# -$e = { - 'FILE' => 'foo.idl', - 'NAME' => 'v', - 'PROPERTIES' => {"unique" => 1, "in" => 1}, - 'POINTERS' => 3, - 'TYPE' => 'uint8', - 'PARENT' => { TYPE => 'FUNCTION' }, - 'LINE' => 42 }; - -is_deeply(GetElementLevelTable($e, "unique"), [ - { - LEVEL_INDEX => 0, - IS_DEFERRED => 0, - TYPE => 'POINTER', - POINTER_TYPE => "unique", - POINTER_INDEX => 0, - LEVEL => 'TOP' - }, - { - LEVEL_INDEX => 1, - IS_DEFERRED => 1, - TYPE => 'POINTER', - POINTER_TYPE => "unique", - POINTER_INDEX => 1, - LEVEL => 'EMBEDDED' - }, - { - LEVEL_INDEX => 2, - IS_DEFERRED => 1, - TYPE => 'POINTER', - POINTER_TYPE => "unique", - POINTER_INDEX => 2, - LEVEL => 'EMBEDDED' - }, - { - 'IS_DEFERRED' => 1, - 'LEVEL_INDEX' => 3, - 'DATA_TYPE' => 'uint8', - 'CONTAINS_DEFERRED' => 0, - 'TYPE' => 'DATA', - 'IS_SURROUNDING' => 0, - } -]); - -# Case 4 : top-level unique pointers, triple with pointer_default("ref") -# -$e = { - 'FILE' => 'foo.idl', - 'NAME' => 'v', - 'PROPERTIES' => {"unique" => 1, "in" => 1}, - 'POINTERS' => 3, - 'TYPE' => 'uint8', - 'PARENT' => { TYPE => 'FUNCTION' }, - 'LINE' => 42 }; - -is_deeply(GetElementLevelTable($e, "ref"), [ - { - LEVEL_INDEX => 0, - IS_DEFERRED => 0, - TYPE => 'POINTER', - POINTER_TYPE => "unique", - POINTER_INDEX => 0, - LEVEL => 'TOP' - }, - { - LEVEL_INDEX => 1, - IS_DEFERRED => 1, - TYPE => 'POINTER', - POINTER_TYPE => "ref", - POINTER_INDEX => 1, - LEVEL => 'EMBEDDED' - }, - { - LEVEL_INDEX => 2, - IS_DEFERRED => 1, - TYPE => 'POINTER', - POINTER_TYPE => "ref", - POINTER_INDEX => 2, - LEVEL => 'EMBEDDED' - }, - { - 'IS_DEFERRED' => 1, - 'LEVEL_INDEX' => 3, - 'DATA_TYPE' => 'uint8', - 'CONTAINS_DEFERRED' => 0, - 'TYPE' => 'DATA', - 'IS_SURROUNDING' => 0, - } -]); - -# Case 4 : top-level ref pointers, triple with pointer_default("ref") -# -$e = { - 'FILE' => 'foo.idl', - 'NAME' => 'v', - 'PROPERTIES' => {"ref" => 1}, - 'POINTERS' => 3, - 'TYPE' => 'uint8', - 'PARENT' => { TYPE => 'FUNCTION' }, - 'LINE' => 42 }; - -is_deeply(GetElementLevelTable($e, "ref"), [ - { - LEVEL_INDEX => 0, - IS_DEFERRED => 0, - TYPE => 'POINTER', - POINTER_TYPE => "ref", - POINTER_INDEX => 0, - LEVEL => 'TOP' - }, - { - LEVEL_INDEX => 1, - IS_DEFERRED => 0, - TYPE => 'POINTER', - POINTER_TYPE => "ref", - POINTER_INDEX => 1, - LEVEL => 'EMBEDDED' - }, - { - LEVEL_INDEX => 2, - IS_DEFERRED => 1, - TYPE => 'POINTER', - POINTER_TYPE => "ref", - POINTER_INDEX => 2, - LEVEL => 'EMBEDDED' - }, - { - 'IS_DEFERRED' => 1, - 'LEVEL_INDEX' => 3, - 'DATA_TYPE' => 'uint8', - 'CONTAINS_DEFERRED' => 0, - 'TYPE' => 'DATA', - 'IS_SURROUNDING' => 0, - } -]); - # representation_type $e = { 'FILE' => 'foo.idl', -- cgit From 31fac9d66b0cba7a00b0887715cf7b7104108180 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 2 Feb 2008 10:18:33 +0100 Subject: pidl: remove 'pointer_default_top()' support metze (This used to be commit 145d6c8ea0eafc69cdeca45fbf296148b890133d) --- source4/pidl/tests/ndr_compat.pl | 6 ------ 1 file changed, 6 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/ndr_compat.pl b/source4/pidl/tests/ndr_compat.pl index 735d929e27..11b585c118 100755 --- a/source4/pidl/tests/ndr_compat.pl +++ b/source4/pidl/tests/ndr_compat.pl @@ -19,9 +19,3 @@ sub parse_idl($) test_warnings("", sub {parse_idl("void x();"); }); test_warnings("nofile:0: top-level [out] pointer `x' is not a [ref] pointer\n", sub {parse_idl("void x([out,unique] int *x);"); }); - -test_warnings("nofile:0: pointer_default_top() is a pidl extension and should not be used\n", sub { - my $pidl = Parse::Pidl::IDL::parse_string("[pointer_default_top(unique)] interface echo { void x(); }; ", "nofile"); - Parse::Pidl::NDR::Parse($pidl); -}); - -- cgit From 1ea5b06307b6057297700ce2b65b2055994869e2 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 1 Feb 2008 10:30:47 +0100 Subject: pidl: get the pointer types correct when an element has multiple pointers Only the first level gets the pointer type from the pointer property, the others get them from the pointer_default() interface property see http://msdn2.microsoft.com/en-us/library/aa378984(VS.85).aspx (Here they talk about the rightmost pointer, but testing shows they mean the leftmost pointer.) metze (This used to be commit aa8518521b2a6a7110c84c4981c53acce7389ee9) --- source4/pidl/tests/ndr.pl | 289 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 282 insertions(+), 7 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/ndr.pl b/source4/pidl/tests/ndr.pl index 7fcc7ef40e..758c3dddb7 100755 --- a/source4/pidl/tests/ndr.pl +++ b/source4/pidl/tests/ndr.pl @@ -4,7 +4,7 @@ use strict; use warnings; -use Test::More tests => 40; +use Test::More tests => 46; use FindBin qw($RealBin); use lib "$RealBin"; use Util; @@ -22,7 +22,7 @@ my $e = { 'PARENT' => { TYPE => 'STRUCT' }, 'LINE' => 42 }; -is_deeply(GetElementLevelTable($e), [ +is_deeply(GetElementLevelTable($e, "unique"), [ { 'IS_DEFERRED' => 0, 'LEVEL_INDEX' => 0, @@ -33,7 +33,7 @@ is_deeply(GetElementLevelTable($e), [ } ]); -my $ne = ParseElement($e, undef); +my $ne = ParseElement($e, "unique"); is($ne->{ORIGINAL}, $e); is($ne->{NAME}, "v"); is($ne->{ALIGN}, 1); @@ -60,7 +60,7 @@ $e = { 'TYPE' => 'uint8', 'LINE' => 42 }; -is_deeply(GetElementLevelTable($e), [ +is_deeply(GetElementLevelTable($e, "unique"), [ { LEVEL_INDEX => 0, IS_DEFERRED => 0, @@ -90,7 +90,7 @@ $e = { 'PARENT' => { TYPE => 'STRUCT' }, 'LINE' => 42 }; -is_deeply(GetElementLevelTable($e), [ +is_deeply(GetElementLevelTable($e, "unique"), [ { LEVEL_INDEX => 0, IS_DEFERRED => 0, @@ -128,7 +128,7 @@ $e = { 'PARENT' => { TYPE => 'STRUCT' }, 'LINE' => 42 }; -is_deeply(GetElementLevelTable($e), [ +is_deeply(GetElementLevelTable($e, "unique"), [ { LEVEL_INDEX => 0, IS_DEFERRED => 0, @@ -147,6 +147,97 @@ is_deeply(GetElementLevelTable($e), [ } ]); +# Case 3 : ref pointers +# +$e = { + 'FILE' => 'foo.idl', + 'NAME' => 'v', + 'PROPERTIES' => {"ref" => 1}, + 'POINTERS' => 3, + 'TYPE' => 'uint8', + 'PARENT' => { TYPE => 'STRUCT' }, + 'LINE' => 42 }; + +is_deeply(GetElementLevelTable($e, "unique"), [ + { + LEVEL_INDEX => 0, + IS_DEFERRED => 0, + TYPE => 'POINTER', + POINTER_TYPE => "ref", + POINTER_INDEX => 0, + LEVEL => 'EMBEDDED' + }, + { + LEVEL_INDEX => 1, + IS_DEFERRED => 1, + TYPE => 'POINTER', + POINTER_TYPE => "unique", + POINTER_INDEX => 1, + LEVEL => 'EMBEDDED' + }, + { + LEVEL_INDEX => 2, + IS_DEFERRED => 1, + TYPE => 'POINTER', + POINTER_TYPE => "unique", + POINTER_INDEX => 2, + LEVEL => 'EMBEDDED' + }, + { + 'IS_DEFERRED' => 1, + 'LEVEL_INDEX' => 3, + 'DATA_TYPE' => 'uint8', + 'CONTAINS_DEFERRED' => 0, + 'TYPE' => 'DATA', + 'IS_SURROUNDING' => 0, + } +]); + +# Case 3 : ref pointers +# +$e = { + 'FILE' => 'foo.idl', + 'NAME' => 'v', + 'PROPERTIES' => {"ref" => 1}, + 'POINTERS' => 3, + 'TYPE' => 'uint8', + 'PARENT' => { TYPE => 'STRUCT' }, + 'LINE' => 42 }; + +is_deeply(GetElementLevelTable($e, "ref"), [ + { + LEVEL_INDEX => 0, + IS_DEFERRED => 0, + TYPE => 'POINTER', + POINTER_TYPE => "ref", + POINTER_INDEX => 0, + LEVEL => 'EMBEDDED' + }, + { + LEVEL_INDEX => 1, + IS_DEFERRED => 1, + TYPE => 'POINTER', + POINTER_TYPE => "ref", + POINTER_INDEX => 1, + LEVEL => 'EMBEDDED' + }, + { + LEVEL_INDEX => 2, + IS_DEFERRED => 1, + TYPE => 'POINTER', + POINTER_TYPE => "ref", + POINTER_INDEX => 2, + LEVEL => 'EMBEDDED' + }, + { + 'IS_DEFERRED' => 1, + 'LEVEL_INDEX' => 3, + 'DATA_TYPE' => 'uint8', + 'CONTAINS_DEFERRED' => 0, + 'TYPE' => 'DATA', + 'IS_SURROUNDING' => 0, + } +]); # Case 4 : top-level ref pointers # @@ -159,7 +250,7 @@ $e = { 'PARENT' => { TYPE => 'FUNCTION' }, 'LINE' => 42 }; -is_deeply(GetElementLevelTable($e), [ +is_deeply(GetElementLevelTable($e, "unique"), [ { LEVEL_INDEX => 0, IS_DEFERRED => 0, @@ -178,6 +269,190 @@ is_deeply(GetElementLevelTable($e), [ } ]); +# Case 4 : top-level ref pointers, triple with pointer_default("unique") +# +$e = { + 'FILE' => 'foo.idl', + 'NAME' => 'v', + 'PROPERTIES' => {"ref" => 1}, + 'POINTERS' => 3, + 'TYPE' => 'uint8', + 'PARENT' => { TYPE => 'FUNCTION' }, + 'LINE' => 42 }; + +is_deeply(GetElementLevelTable($e, "unique"), [ + { + LEVEL_INDEX => 0, + IS_DEFERRED => 0, + TYPE => 'POINTER', + POINTER_TYPE => "ref", + POINTER_INDEX => 0, + LEVEL => 'TOP' + }, + { + LEVEL_INDEX => 1, + IS_DEFERRED => 0, + TYPE => 'POINTER', + POINTER_TYPE => "unique", + POINTER_INDEX => 1, + LEVEL => 'EMBEDDED' + }, + { + LEVEL_INDEX => 2, + IS_DEFERRED => 0, + TYPE => 'POINTER', + POINTER_TYPE => "unique", + POINTER_INDEX => 2, + LEVEL => 'EMBEDDED' + }, + { + 'IS_DEFERRED' => 0, + 'LEVEL_INDEX' => 3, + 'DATA_TYPE' => 'uint8', + 'CONTAINS_DEFERRED' => 0, + 'TYPE' => 'DATA', + 'IS_SURROUNDING' => 0, + } +]); + +# Case 4 : top-level unique pointers, triple with pointer_default("unique") +# +$e = { + 'FILE' => 'foo.idl', + 'NAME' => 'v', + 'PROPERTIES' => {"unique" => 1, "in" => 1}, + 'POINTERS' => 3, + 'TYPE' => 'uint8', + 'PARENT' => { TYPE => 'FUNCTION' }, + 'LINE' => 42 }; + +is_deeply(GetElementLevelTable($e, "unique"), [ + { + LEVEL_INDEX => 0, + IS_DEFERRED => 0, + TYPE => 'POINTER', + POINTER_TYPE => "unique", + POINTER_INDEX => 0, + LEVEL => 'TOP' + }, + { + LEVEL_INDEX => 1, + IS_DEFERRED => 0, + TYPE => 'POINTER', + POINTER_TYPE => "unique", + POINTER_INDEX => 1, + LEVEL => 'EMBEDDED' + }, + { + LEVEL_INDEX => 2, + IS_DEFERRED => 0, + TYPE => 'POINTER', + POINTER_TYPE => "unique", + POINTER_INDEX => 2, + LEVEL => 'EMBEDDED' + }, + { + 'IS_DEFERRED' => 0, + 'LEVEL_INDEX' => 3, + 'DATA_TYPE' => 'uint8', + 'CONTAINS_DEFERRED' => 0, + 'TYPE' => 'DATA', + 'IS_SURROUNDING' => 0, + } +]); + +# Case 4 : top-level unique pointers, triple with pointer_default("ref") +# +$e = { + 'FILE' => 'foo.idl', + 'NAME' => 'v', + 'PROPERTIES' => {"unique" => 1, "in" => 1}, + 'POINTERS' => 3, + 'TYPE' => 'uint8', + 'PARENT' => { TYPE => 'FUNCTION' }, + 'LINE' => 42 }; + +is_deeply(GetElementLevelTable($e, "ref"), [ + { + LEVEL_INDEX => 0, + IS_DEFERRED => 0, + TYPE => 'POINTER', + POINTER_TYPE => "unique", + POINTER_INDEX => 0, + LEVEL => 'TOP' + }, + { + LEVEL_INDEX => 1, + IS_DEFERRED => 0, + TYPE => 'POINTER', + POINTER_TYPE => "ref", + POINTER_INDEX => 1, + LEVEL => 'EMBEDDED' + }, + { + LEVEL_INDEX => 2, + IS_DEFERRED => 0, + TYPE => 'POINTER', + POINTER_TYPE => "ref", + POINTER_INDEX => 2, + LEVEL => 'EMBEDDED' + }, + { + 'IS_DEFERRED' => 0, + 'LEVEL_INDEX' => 3, + 'DATA_TYPE' => 'uint8', + 'CONTAINS_DEFERRED' => 0, + 'TYPE' => 'DATA', + 'IS_SURROUNDING' => 0, + } +]); + +# Case 4 : top-level ref pointers, triple with pointer_default("ref") +# +$e = { + 'FILE' => 'foo.idl', + 'NAME' => 'v', + 'PROPERTIES' => {"ref" => 1}, + 'POINTERS' => 3, + 'TYPE' => 'uint8', + 'PARENT' => { TYPE => 'FUNCTION' }, + 'LINE' => 42 }; + +is_deeply(GetElementLevelTable($e, "ref"), [ + { + LEVEL_INDEX => 0, + IS_DEFERRED => 0, + TYPE => 'POINTER', + POINTER_TYPE => "ref", + POINTER_INDEX => 0, + LEVEL => 'TOP' + }, + { + LEVEL_INDEX => 1, + IS_DEFERRED => 0, + TYPE => 'POINTER', + POINTER_TYPE => "ref", + POINTER_INDEX => 1, + LEVEL => 'EMBEDDED' + }, + { + LEVEL_INDEX => 2, + IS_DEFERRED => 0, + TYPE => 'POINTER', + POINTER_TYPE => "ref", + POINTER_INDEX => 2, + LEVEL => 'EMBEDDED' + }, + { + 'IS_DEFERRED' => 0, + 'LEVEL_INDEX' => 3, + 'DATA_TYPE' => 'uint8', + 'CONTAINS_DEFERRED' => 0, + 'TYPE' => 'DATA', + 'IS_SURROUNDING' => 0, + } +]); + # representation_type $e = { 'FILE' => 'foo.idl', -- cgit From c713b58a00b7cb5ef34b101ba5b74c8d9ec505ba Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 1 Feb 2008 23:09:37 +0100 Subject: pidl/NDR: fix handling of multilevel pointers in function elements The 2nd or higher level of wire pointers needs to be marked as deferred. metze (This used to be commit d7970d70329e0d4f9de30ccfcedd03e583817fa2) --- source4/pidl/tests/ndr.pl | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/ndr.pl b/source4/pidl/tests/ndr.pl index 758c3dddb7..504b7ec8de 100755 --- a/source4/pidl/tests/ndr.pl +++ b/source4/pidl/tests/ndr.pl @@ -299,14 +299,14 @@ is_deeply(GetElementLevelTable($e, "unique"), [ }, { LEVEL_INDEX => 2, - IS_DEFERRED => 0, + IS_DEFERRED => 1, TYPE => 'POINTER', POINTER_TYPE => "unique", POINTER_INDEX => 2, LEVEL => 'EMBEDDED' }, { - 'IS_DEFERRED' => 0, + 'IS_DEFERRED' => 1, 'LEVEL_INDEX' => 3, 'DATA_TYPE' => 'uint8', 'CONTAINS_DEFERRED' => 0, @@ -337,7 +337,7 @@ is_deeply(GetElementLevelTable($e, "unique"), [ }, { LEVEL_INDEX => 1, - IS_DEFERRED => 0, + IS_DEFERRED => 1, TYPE => 'POINTER', POINTER_TYPE => "unique", POINTER_INDEX => 1, @@ -345,14 +345,14 @@ is_deeply(GetElementLevelTable($e, "unique"), [ }, { LEVEL_INDEX => 2, - IS_DEFERRED => 0, + IS_DEFERRED => 1, TYPE => 'POINTER', POINTER_TYPE => "unique", POINTER_INDEX => 2, LEVEL => 'EMBEDDED' }, { - 'IS_DEFERRED' => 0, + 'IS_DEFERRED' => 1, 'LEVEL_INDEX' => 3, 'DATA_TYPE' => 'uint8', 'CONTAINS_DEFERRED' => 0, @@ -383,7 +383,7 @@ is_deeply(GetElementLevelTable($e, "ref"), [ }, { LEVEL_INDEX => 1, - IS_DEFERRED => 0, + IS_DEFERRED => 1, TYPE => 'POINTER', POINTER_TYPE => "ref", POINTER_INDEX => 1, @@ -391,14 +391,14 @@ is_deeply(GetElementLevelTable($e, "ref"), [ }, { LEVEL_INDEX => 2, - IS_DEFERRED => 0, + IS_DEFERRED => 1, TYPE => 'POINTER', POINTER_TYPE => "ref", POINTER_INDEX => 2, LEVEL => 'EMBEDDED' }, { - 'IS_DEFERRED' => 0, + 'IS_DEFERRED' => 1, 'LEVEL_INDEX' => 3, 'DATA_TYPE' => 'uint8', 'CONTAINS_DEFERRED' => 0, @@ -437,14 +437,14 @@ is_deeply(GetElementLevelTable($e, "ref"), [ }, { LEVEL_INDEX => 2, - IS_DEFERRED => 0, + IS_DEFERRED => 1, TYPE => 'POINTER', POINTER_TYPE => "ref", POINTER_INDEX => 2, LEVEL => 'EMBEDDED' }, { - 'IS_DEFERRED' => 0, + 'IS_DEFERRED' => 1, 'LEVEL_INDEX' => 3, 'DATA_TYPE' => 'uint8', 'CONTAINS_DEFERRED' => 0, -- cgit From d696a5045240447f5618ecda6cf4a408f709fed2 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 9 Feb 2008 16:25:34 +0100 Subject: Fix test count after pointer_default_top() removal. (This used to be commit 9a4b9facc869a8f7363932a591437251b44cd7bb) --- source4/pidl/tests/ndr_compat.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/ndr_compat.pl b/source4/pidl/tests/ndr_compat.pl index 11b585c118..355e7f6732 100755 --- a/source4/pidl/tests/ndr_compat.pl +++ b/source4/pidl/tests/ndr_compat.pl @@ -3,7 +3,7 @@ # Published under the GNU General Public License use strict; -use Test::More tests => 3; +use Test::More tests => 2; use FindBin qw($RealBin); use lib "$RealBin"; use Util; -- cgit From 23582ce0f429a6396fb89d29156ee955ff8e0228 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 13 Feb 2008 02:28:41 +0100 Subject: Add simple test for ETT_FIELD. (This used to be commit aea50426366dbe971d25d2a948db57885ce224b9) --- source4/pidl/tests/wireshark-conf.pl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/wireshark-conf.pl b/source4/pidl/tests/wireshark-conf.pl index d6fe3158aa..c06ac16de4 100755 --- a/source4/pidl/tests/wireshark-conf.pl +++ b/source4/pidl/tests/wireshark-conf.pl @@ -5,7 +5,7 @@ use strict; use warnings; -use Test::More tests => 47; +use Test::More tests => 48; use FindBin qw($RealBin); use lib "$RealBin"; use Util; @@ -164,6 +164,9 @@ test_errors("nofile:1: no dissectorname specified\n", test_errors("nofile:1: incomplete HF_FIELD command\n", sub { parse_conf("HF_FIELD hf_idx\n"); }); +test_errors("nofile:1: incomplete ETT_FIELD command\n", + sub { parse_conf("ETT_FIELD\n"); }); + is_deeply(parse_conf("TYPE winreg_String dissect_myminregstring(); FT_STRING BASE_DEC 0 0 0 2\n"), { types => { winreg_String => { -- cgit From 35dd0b0f4ad6ab0d9365d2858b60bf82e4877bda Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 19 Feb 2008 02:02:48 +0100 Subject: Add test for INCLUDE command. (This used to be commit d1aa25249d64513f785430cab7437b5c7ca8db27) --- source4/pidl/tests/wireshark-conf.pl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/wireshark-conf.pl b/source4/pidl/tests/wireshark-conf.pl index c06ac16de4..9da5c7d1ed 100755 --- a/source4/pidl/tests/wireshark-conf.pl +++ b/source4/pidl/tests/wireshark-conf.pl @@ -5,7 +5,7 @@ use strict; use warnings; -use Test::More tests => 48; +use Test::More tests => 49; use FindBin qw($RealBin); use lib "$RealBin"; use Util; @@ -35,7 +35,6 @@ test_warnings("nofile:1: Unknown command `foobar'\n", test_warnings("nofile:1: incomplete HF_RENAME command\n", sub { parse_conf("HF_RENAME\n"); }); - is_deeply(parse_conf("HF_RENAME foo bar\n")->{hf_renames}->{foo}, { OLDNAME => "foo", NEWNAME => "bar", POS => {FILE => "nofile", LINE => 1}, USED => 0}); @@ -47,6 +46,9 @@ test_warnings("nofile:1: incomplete MANUAL command\n", is_deeply(parse_conf("MANUAL foo\n"), { manual => {foo => 1}}); +test_errors("nofile:1: incomplete INCLUDE command\n", + sub { parse_conf("INCLUDE\n"); } ); + test_warnings("nofile:1: incomplete FIELD_DESCRIPTION command\n", sub { parse_conf("FIELD_DESCRIPTION foo\n"); }); -- cgit From c30f9add8cc5b060b73381f53671ecd01c31cdd8 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 6 Apr 2008 00:57:14 +0200 Subject: Add test for authservice struct. (This used to be commit da8b8364b06a79a10d4ebdc0e451463b3105730e) --- source4/pidl/tests/samba-ndr.pl | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/samba-ndr.pl b/source4/pidl/tests/samba-ndr.pl index a14111961f..114ca01cfa 100755 --- a/source4/pidl/tests/samba-ndr.pl +++ b/source4/pidl/tests/samba-ndr.pl @@ -4,7 +4,7 @@ use strict; use warnings; -use Test::More tests => 30; +use Test::More tests => 31; use FindBin qw($RealBin); use lib "$RealBin"; use Util; @@ -277,3 +277,17 @@ $generator->ParseElementPrint({ NAME => "x", TYPE => "uint32", REPRESENTATION_TY PROPERTIES => { value => "23" }, LEVELS => [ { TYPE => "DATA", DATA_TYPE => "uint32"} ]}, "var", { "x" => "r->foobar" } ); is($generator->{res}, "ndr_print_uint32(ndr, \"x\", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?23:var);\n"); + +$generator = new Parse::Pidl::Samba4::NDR::Parser(); +$generator->AuthServiceStruct("bridge", "\"rot13\",\"onetimepad\""); +is($generator->{res}, "static const char * const bridge_authservice_strings[] = { + \"rot13\", + \"onetimepad\", +}; + +static const struct ndr_interface_string_array bridge_authservices = { + .count = 2, + .names = bridge_authservice_strings +}; + +"); -- cgit From 7bb2ebb884c35676a6cf03efe6ecc15b3e232a43 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 15 Apr 2008 16:00:07 +0200 Subject: Fix size to memcpy call in generated Samba 3 client code. Reported-By: vl (This used to be commit a28807569d0cf32968bacdc0bd88197b19fbae49) --- source4/pidl/tests/samba3-cli.pl | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/samba3-cli.pl b/source4/pidl/tests/samba3-cli.pl index f5b51b7d34..80725d28cf 100755 --- a/source4/pidl/tests/samba3-cli.pl +++ b/source4/pidl/tests/samba3-cli.pl @@ -4,12 +4,12 @@ use strict; use warnings; -use Test::More tests => 8; +use Test::More tests => 9; use FindBin qw($RealBin); use lib "$RealBin"; use Util; use Parse::Pidl::Util qw(MyDumper); -use Parse::Pidl::Samba3::ClientNDR qw(ParseFunction); +use Parse::Pidl::Samba3::ClientNDR qw(ParseFunction ParseOutputArgument); use Parse::Pidl::Samba4::Header qw(GenerateFunctionInEnv GenerateFunctionOutEnv); # Make sure GenerateFunctionInEnv and GenerateFunctionOutEnv work @@ -117,3 +117,12 @@ is($x->{res}, } "); + +$x = new Parse::Pidl::Samba3::ClientNDR(); + +$fn = { NAME => "bar", ELEMENTS => [ ], RETURN_TYPE => "WERROR" }; +my $e = { NAME => "foo", ORIGINAL => { FILE => "f", LINE => -1 }, + LEVELS => [ { TYPE => "ARRAY", SIZE_IS => "mysize" }, { TYPE => "DATA", DATA_TYPE => "int" } ]}; + +$x->ParseOutputArgument($fn, $e); +is($x->{res}, "memcpy(foo, r.out.foo, mysize * sizeof(*foo));\n"); -- cgit From 150d7a16236732abfe23082bdeef62d8e36beeb4 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 13 Aug 2008 16:58:12 +0200 Subject: pidl: fix samba4.pidl.samba3-cli test metze (This used to be commit 0449a5c8267873d7986c7c50adce57029192c456) --- source4/pidl/tests/samba3-cli.pl | 2 -- 1 file changed, 2 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/samba3-cli.pl b/source4/pidl/tests/samba3-cli.pl index 80725d28cf..d762954159 100755 --- a/source4/pidl/tests/samba3-cli.pl +++ b/source4/pidl/tests/samba3-cli.pl @@ -44,7 +44,6 @@ is($x->{res}, status = cli_do_rpc_ndr(cli, mem_ctx, - PI_FOO, &ndr_table_foo, NDR_BAR, &r); @@ -89,7 +88,6 @@ is($x->{res}, status = cli_do_rpc_ndr(cli, mem_ctx, - PI_FOO, &ndr_table_foo, NDR_BAR, &r); -- cgit From c8ef2956c62ca6d804db40ac093638d67b479b71 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 19 Aug 2008 13:24:05 +0200 Subject: pidl/NDR::Parser: pass $ndr to ->PUSH_FN_BLOB() metze (This used to be commit 71b0d64866eb1a4f6dc73eeb57b5f0fe5d8a5780) --- source4/pidl/tests/samba-ndr.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/samba-ndr.pl b/source4/pidl/tests/samba-ndr.pl index 114ca01cfa..ae67e66bb9 100755 --- a/source4/pidl/tests/samba-ndr.pl +++ b/source4/pidl/tests/samba-ndr.pl @@ -220,7 +220,7 @@ $generator->ParseStructPush({ TYPE => "STRUCT", PROPERTIES => {}, ALIGN => 4, - ELEMENTS => [ ]}, "x"); + ELEMENTS => [ ]}, "ndr", "x"); is($generator->{res}, "if (ndr_flags & NDR_SCALARS) { NDR_CHECK(ndr_push_align(ndr, 4)); } @@ -243,7 +243,7 @@ $generator->ParseStructPush({ PROPERTIES => {}, ALIGN => 4, SURROUNDING_ELEMENT => $e, - ELEMENTS => [ $e ]}, "x"); + ELEMENTS => [ $e ]}, "ndr", "x"); is($generator->{res}, "if (ndr_flags & NDR_SCALARS) { NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_string_array_size(ndr, x->el1))); NDR_CHECK(ndr_push_align(ndr, 4)); -- cgit From ef7e12b914f4e4f53a230b96d6a2f9b25c68f961 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 19 Aug 2008 20:12:03 +0200 Subject: pidl/NDR::Parser: pass $ndr to ->PRINT_FN_BLOB() metze (This used to be commit a143806364051141604ebb40eb5a4ef72958b55f) --- source4/pidl/tests/samba-ndr.pl | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/samba-ndr.pl b/source4/pidl/tests/samba-ndr.pl index ae67e66bb9..cdfe0514f1 100755 --- a/source4/pidl/tests/samba-ndr.pl +++ b/source4/pidl/tests/samba-ndr.pl @@ -262,20 +262,23 @@ is(TypeFunctionName("ndr_push", {TYPE => "STRUCT", NAME => "bar"}), "ndr_push_ST $generator = new Parse::Pidl::Samba4::NDR::Parser(); $generator->ParseElementPrint({ NAME => "x", TYPE => "rt", REPRESENTATION_TYPE => "rt", PROPERTIES => { noprint => 1}, - LEVELS => [ { TYPE => "DATA", DATA_TYPE => "rt"} ]}, "var", { "x" => "r->foobar" } ); + LEVELS => [ { TYPE => "DATA", DATA_TYPE => "rt"} ]}, + "ndr", "var", { "x" => "r->foobar" } ); is($generator->{res}, ""); $generator = new Parse::Pidl::Samba4::NDR::Parser(); $generator->ParseElementPrint({ NAME => "x", TYPE => "rt", REPRESENTATION_TYPE => "rt", PROPERTIES => {}, - LEVELS => [ { TYPE => "DATA", DATA_TYPE => "rt" }]}, "var", { "x" => "r->foobar" } ); + LEVELS => [ { TYPE => "DATA", DATA_TYPE => "rt" }]}, + "ndr", "var", { "x" => "r->foobar" } ); is($generator->{res}, "ndr_print_rt(ndr, \"x\", &var);\n"); # make sure that a print function for an element with value() set works $generator = new Parse::Pidl::Samba4::NDR::Parser(); $generator->ParseElementPrint({ NAME => "x", TYPE => "uint32", REPRESENTATION_TYPE => "uint32", PROPERTIES => { value => "23" }, - LEVELS => [ { TYPE => "DATA", DATA_TYPE => "uint32"} ]}, "var", { "x" => "r->foobar" } ); + LEVELS => [ { TYPE => "DATA", DATA_TYPE => "uint32"} ]}, + "ndr", "var", { "x" => "r->foobar" } ); is($generator->{res}, "ndr_print_uint32(ndr, \"x\", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?23:var);\n"); $generator = new Parse::Pidl::Samba4::NDR::Parser(); -- cgit