diff options
Diffstat (limited to 'source4/pidl/tests')
-rw-r--r-- | source4/pidl/tests/Util.pm | 7 | ||||
-rw-r--r-- | source4/pidl/tests/ndr_represent.pl | 40 |
2 files changed, 44 insertions, 3 deletions
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; +} +' +); + +} |