summaryrefslogtreecommitdiff
path: root/source4/pidl/tests
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2007-04-22 13:57:07 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:51:22 -0500
commit68d92f0a123374972ee2aa54dd708f089cb59837 (patch)
tree7f085e62bd60f38e4f4aebb66f05add770bc9987 /source4/pidl/tests
parent4924d03e6dbd84e8aec4f1e9f2ccc8619a5f6768 (diff)
downloadsamba-68d92f0a123374972ee2aa54dd708f089cb59837.tar.gz
samba-68d92f0a123374972ee2aa54dd708f089cb59837.tar.bz2
samba-68d92f0a123374972ee2aa54dd708f089cb59837.zip
r22456: Merge wireshark and ejs test improvements.
(This used to be commit 0375978403dde8ef5052dcca544f118e5387e887)
Diffstat (limited to 'source4/pidl/tests')
-rwxr-xr-xsource4/pidl/tests/samba-ejs.pl39
-rwxr-xr-xsource4/pidl/tests/wireshark-ndr.pl124
2 files changed, 81 insertions, 82 deletions
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"]);