Rev 11604: More tests. in file:///home/jelmer/bzr.samba/SAMBA_4_0/

Jelmer Vernooij jelmer at samba.org
Tue Feb 27 21:34:07 GMT 2007


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

------------------------------------------------------------
revno: 11604
revision-id: jelmer at samba.org-20070227213357-po1j24g7hxzb0zub
parent: svn-v2:21567 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 22:33:57 +0100
message:
  More 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-27 20:35:56 +0000
+++ b/source/pidl/lib/Parse/Pidl/Wireshark/NDR.pm	2007-02-27 21:33:57 +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 ProcessImport ProcessInclude find_type DumpEttList DumpEttDeclaration DumpHfList DumpHfDeclaration DumpFunctionTable);
+ 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 register_type register_ett);
 
 use strict;
 use Parse::Pidl qw(error warning);

=== modified file 'source/pidl/tests/wireshark-ndr.pl'
--- a/source/pidl/tests/wireshark-ndr.pl	2007-02-27 20:35:56 +0000
+++ b/source/pidl/tests/wireshark-ndr.pl	2007-02-27 21:33:57 +0000
@@ -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($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 @@
 		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("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 @@
 	{ 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
+			}
+		}
+	}
+);
+
+ at ett = ();
+register_ett("name");
+is_deeply(\@ett, ["name"]);
+register_ett("leela");
+is_deeply(\@ett, ["name", "leela"]);



More information about the samba-cvs mailing list