[Spice-devel] [PATCH v6 34/42] dissector: Add check on output strings

Frediano Ziglio fziglio at redhat.com
Thu Aug 13 06:12:13 PDT 2015


Make sure the generated dissector contains all strings from
the protocol file.

Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
 tests/Makefile.am   |  2 +-
 tests/check_strings | 33 +++++++++++++++++++++++++++++++++
 2 files changed, 34 insertions(+), 1 deletion(-)
 create mode 100755 tests/check_strings

diff --git a/tests/Makefile.am b/tests/Makefile.am
index 6a3d166..b86d279 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -42,7 +42,7 @@ dissector.h: $(top_srcdir)/spice.proto $(MARSHALLERS_DEPS)
 packet-spice.h: $(top_srcdir)/spice.proto $(MARSHALLERS_DEPS)
 	$(AM_V_GEN)$(PYTHON) $(top_srcdir)/spice_codegen.py --generate-wireshark-dissector $< $@ >/dev/null
 
-TESTS = check_dissector
+TESTS = check_dissector check_strings
 check_PROGRAMS = dissector_test compile_check
 
 dissector_test_SOURCES = dissector_test.c test.c test.h
diff --git a/tests/check_strings b/tests/check_strings
new file mode 100755
index 0000000..0dd08ef
--- /dev/null
+++ b/tests/check_strings
@@ -0,0 +1,33 @@
+#!/usr/bin/perl
+
+# This scripts check that all strings in the protocol
+# file are found in the output dissector
+use strict;
+
+my $proto = '../spice.proto';
+my $out = 'dissector.c';
+
+open(IN, '<', $out) or die "Error opening output file $out";
+my @all = <IN>;
+close(IN);
+ at all = map { $_ =~ s/" G_GINT64_MODIFIER "//g; $_ } @all;
+my $all = join('', @all);
+
+sub check($) {
+	my $what = shift;
+	open(IN, '<', $proto) or die "Error opening protocol file $proto";
+	while (<IN>) {
+		if (m/\@$what\(("[^"]+")/) {
+			if (index($all, $1) < 0) {
+				print "$1 not found!\n";
+			}
+		}
+	}
+	close(IN);
+}
+
+check('ws');
+check('ws_desc');
+check('ws_txt');
+check('ws_txt_n');
+
-- 
2.4.3



More information about the Spice-devel mailing list