Rev 11603: Add some more wireshark tests. in file:///home/jelmer/bzr.samba/SAMBA_4_0/

Jelmer Vernooij jelmer at samba.org
Tue Feb 27 20:32:35 GMT 2007


At file:///home/jelmer/bzr.samba/SAMBA_4_0/

------------------------------------------------------------
revno: 11603
revision-id: jelmer at samba.org-20070227203216-ewscmau41yygf7vn
parent: svn-v2:21564 at 0c0555d6-39d7-0310-84fc-f1cc0bd64818-branches%2fSAMBA_4_0
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: SAMBA_4_0
timestamp: Tue 2007-02-27 21:32:16 +0100
message:
  Add some more wireshark tests.
modified:
  source/pidl/lib/Parse/Pidl/Wireshark/NDR.pm svn-v2:16824 at 0c0555d6-39d7-0310-84fc-f1cc0bd64818-branches%2fSAMBA_4_0-source%2fpidl%2flib%2fParse%2fPidl%2fWireshark%2fNDR.pm
  source/pidl/tests/wireshark-ndr.pl svn-v2:21411 at 0c0555d6-39d7-0310-84fc-f1cc0bd64818-branches%2fSAMBA_4_0-source%2fpidl%2ftests%2fwireshark%2dndr.pl
=== modified file 'source/pidl/lib/Parse/Pidl/Wireshark/NDR.pm'
--- a/source/pidl/lib/Parse/Pidl/Wireshark/NDR.pm	2007-02-26 01:03:19 +0000
+++ b/source/pidl/lib/Parse/Pidl/Wireshark/NDR.pm	2007-02-27 20:32:16 +0000
@@ -18,7 +18,7 @@
 
 use Exporter;
 @ISA = qw(Exporter);
- at EXPORT_OK = qw(field2name @ett %res PrintIdl StripPrefixes %hf_used RegisterInterfaceHandoff $conformance register_hf_field CheckUsed);
+ at EXPORT_OK = qw(field2name @ett %res PrintIdl StripPrefixes %hf_used RegisterInterfaceHandoff $conformance register_hf_field CheckUsed ProcessImport ProcessInclude find_type DumpEttList DumpEttDeclaration DumpHfList DumpHfDeclaration DumpFunctionTable);
 
 use strict;
 use Parse::Pidl qw(error warning);
@@ -671,7 +671,7 @@
 	indent;
 
 	$res{code}.=DumpHfList()."\n";
-	$res{code}.="\n".DumpEttList()."\n";
+	$res{code}.="\n".DumpEttList(@ett)."\n";
 	
 	if (defined($x->{UUID})) {
 	    # These can be changed to non-pidl_code names if the old dissectors
@@ -730,8 +730,9 @@
 {
 	my @includes = @_;
 	foreach (@includes) {
-		pidl_hdr "#include \"$_\"\n";
+		pidl_hdr "#include \"$_\"";
 	}
+	pidl_hdr "";
 }
 
 sub ProcessImport
@@ -741,8 +742,9 @@
 		next if($_ eq "security");
 		s/\.idl\"$//;
 		s/^\"//;
-		pidl_hdr "#include \"packet-dcerpc-$_\.h\"\n";
+		pidl_hdr "#include \"packet-dcerpc-$_\.h\"";
 	}
+	pidl_hdr "";
 }
 
 sub ProcessInterface($)
@@ -924,7 +926,7 @@
 		ProcessInclude(@{$_->{PATHS}}) if ($_->{TYPE} eq "INCLUDE");
 	}
 
-	$res{ett} = DumpEttDeclaration();
+	$res{ett} = DumpEttDeclaration(@ett);
 	$res{hf} = DumpHfDeclaration();
 
 	my $parser = $notice;
@@ -956,8 +958,9 @@
 	push (@ett, $name);	
 }
 
-sub DumpEttList()
+sub DumpEttList
 {
+	my @ett = @_;
 	my $res = "\tstatic gint *ett[] = {\n";
 	foreach (@ett) {
 		$res .= "\t\t&$_,\n";
@@ -966,8 +969,9 @@
 	return "$res\t};\n";
 }
 
-sub DumpEttDeclaration()
+sub DumpEttDeclaration
 {
+	my @ett = @_;
 	my $res = "\n/* Ett declarations */\n";
 	foreach (@ett) {
 		$res .= "static gint $_ = -1;\n";

=== modified file 'source/pidl/tests/wireshark-ndr.pl'
--- a/source/pidl/tests/wireshark-ndr.pl	2007-02-26 17:43:01 +0000
+++ b/source/pidl/tests/wireshark-ndr.pl	2007-02-27 20:32:16 +0000
@@ -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 @@
 %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 }
+};
+');



More information about the samba-cvs mailing list