summaryrefslogtreecommitdiff
path: root/source4/pidl/tests
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2007-02-07 19:03:19 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:44:48 -0500
commitecf2c1effb778a95fd863a5e87ec7e378d228b57 (patch)
tree8b94782e07399490d6390e066c557af8c04aefc1 /source4/pidl/tests
parent2811e18da0d8dae2e2560c11a28450ae8b2a98d5 (diff)
downloadsamba-ecf2c1effb778a95fd863a5e87ec7e378d228b57.tar.gz
samba-ecf2c1effb778a95fd863a5e87ec7e378d228b57.tar.bz2
samba-ecf2c1effb778a95fd863a5e87ec7e378d228b57.zip
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)
Diffstat (limited to 'source4/pidl/tests')
-rwxr-xr-xsource4/pidl/tests/ndr_deprecations.pl28
-rwxr-xr-x[-rw-r--r--]source4/pidl/tests/ndr_represent.pl36
-rwxr-xr-xsource4/pidl/tests/util.pl23
3 files changed, 85 insertions, 2 deletions
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 <jelmer@samba.org>
+# 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
index 880ecba827..52cd06f817 100644..100755
--- 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 <libcli/util/nterr.h>
+
+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));