[PATCH v3 44/51] test: Add check on output strings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>
---
 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 e169d88..000a41b 100644
--- a/codegen/Makefile.am
+++ b/codegen/Makefile.am
@@ -45,7 +45,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);
+@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

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]