[Spice-devel] [PATCH v4 33/41] dissector: Add check on output strings
Frediano Ziglio
fziglio at redhat.com
Thu Jul 23 08:54:50 PDT 2015
Make sure the generated dissector contains all strings from
the protocol file.
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
codegen/Makefile.am | 2 +-
codegen/check_strings | 33 +++++++++++++++++++++++++++++++++
2 files changed, 34 insertions(+), 1 deletion(-)
create mode 100755 codegen/check_strings
diff --git a/codegen/Makefile.am b/codegen/Makefile.am
index 0e69584..282df76 100644
--- a/codegen/Makefile.am
+++ b/codegen/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/codegen/check_strings b/codegen/check_strings
new file mode 100755
index 0000000..0dd08ef
--- /dev/null
+++ b/codegen/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.1.0
More information about the Spice-devel
mailing list