]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
coccinelle: dynamic testing through make check
authorEric Leblond <eric@regit.org>
Fri, 5 Jul 2013 10:33:17 +0000 (12:33 +0200)
committerVictor Julien <victor@inliniac.net>
Sat, 13 Jul 2013 13:12:56 +0000 (15:12 +0200)
This patch modify build system to have make to create the
struct-flags.cocci file by running struct-flags.py.

This way 'make check' is running the test defined from source
code.

qa/coccinelle/Makefile.am
qa/coccinelle/struct-flags.cocci [new file with mode: 0644]
qa/coccinelle/tcp-struct-flags.cocci [deleted file]

index b5af7dffaa56d50201326320b2a48342e0057715..71dfabf47e67ecc6aeffe5cdb33bb3ee28704fab 100644 (file)
@@ -1,7 +1,21 @@
-EXTRA_DIST= access-pkt-packet.cocci banned-functions.cocci direct-packet.cocci \
-               pktnotset-packet.cocci run_check.sh
+EXTRA_DIST= access-pkt-packet.cocci \
+    action-pkt.cocci \
+    banned-functions.cocci \
+    direct-packet.cocci \
+    malloc-error-check.cocci \
+    pktnotset-packet.cocci \
+    size_t.cocci \
+    struct-flags.cocci \
+    sz3.cocci \
+    run_check.sh struct-flags.py
+
+struct-flags.cocci:
+       $(srcdir)/struct-flags.py > $(top_builddir)/qa/coccinelle/struct-flags.cocci
 
 if HAVE_COCCINELLE
 check:
        $(top_srcdir)/qa/coccinelle/run_check.sh
 endif
+
+distclean-local:
+       -rm $(top_builddir)/qa/coccinelle/struct-flags.cocci
diff --git a/qa/coccinelle/struct-flags.cocci b/qa/coccinelle/struct-flags.cocci
new file mode 100644 (file)
index 0000000..d7204aa
--- /dev/null
@@ -0,0 +1,69 @@
+@flags@
+TcpSegment *struct0;
+identifier struct_flags0 =~ "^(?!SEGMENTTCP_FLAG).+";
+TcpStream *struct1;
+identifier struct_flags1 =~ "^(?!STREAMTCP_STREAM_FLAG_).+";
+TcpSession *struct2;
+identifier struct_flags2 =~ "^(?!STREAMTCP_FLAG).+";
+Packet *struct3;
+identifier struct_flags3 =~ "^(?!FLOW_PKT_).+";
+SignatureHeader *struct4;
+identifier struct_flags4 =~ "^(?!SIG_FLAG).+";
+Signature *struct5;
+identifier struct_flags5 =~ "^(?!SIG_FLAG).+";
+Signature *struct6;
+identifier struct_flags6 =~ "^(?!SIG_FLAG_INIT_).+";
+position p1;
+@@
+
+(
+struct0->flags@p1 |= struct_flags0
+|
+struct0->flags@p1 & struct_flags0
+|
+struct0->flags@p1 &= ~struct_flags0
+|
+struct1->flags@p1 |= struct_flags1
+|
+struct1->flags@p1 & struct_flags1
+|
+struct1->flags@p1 &= ~struct_flags1
+|
+struct2->flags@p1 |= struct_flags2
+|
+struct2->flags@p1 & struct_flags2
+|
+struct2->flags@p1 &= ~struct_flags2
+|
+struct3->flowflags@p1 |= struct_flags3
+|
+struct3->flowflags@p1 & struct_flags3
+|
+struct3->flowflags@p1 &= ~struct_flags3
+|
+struct4->flags@p1 |= struct_flags4
+|
+struct4->flags@p1 & struct_flags4
+|
+struct4->flags@p1 &= ~struct_flags4
+|
+struct5->flags@p1 |= struct_flags5
+|
+struct5->flags@p1 & struct_flags5
+|
+struct5->flags@p1 &= ~struct_flags5
+|
+struct6->init_flags@p1 |= struct_flags6
+|
+struct6->init_flags@p1 & struct_flags6
+|
+struct6->init_flags@p1 &= ~struct_flags6
+)
+
+@script:python@
+p1 << flags.p1;
+@@
+
+print "Invalid usage of flags field at %s:%s, flags value is incorrect (wrong family)." % (p1[0].file, p1[0].line)
+import sys
+sys.exit(1)
diff --git a/qa/coccinelle/tcp-struct-flags.cocci b/qa/coccinelle/tcp-struct-flags.cocci
deleted file mode 100644 (file)
index 5c8b34d..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-@flags@
-TcpSession *ssn;
-identifier ssn_flags =~ "^(?!STREAMTCP_FLAG).+";
-TcpStream *stream;
-identifier stream_flags =~ "^(?!STREAMTCP_STREAM_FLAG).+";
-TcpSegment *segment;
-identifier segment_flags =~ "^(?!SEGMENTTCP_FLAG)_.+";
-position p1;
-@@
-
-(
-ssn->flags@p1 |= ssn_flags
-|
-ssn->flags@p1 & ssn_flags
-|
-ssn->flags@p1 &= ~ssn_flags
-|
-stream->flags@p1 |= stream_flags
-|
-stream->flags@p1 & stream_flags
-|
-stream->flags@p1 &= ~stream_flags
-|
-segment->flags@p1 |= segment_flags
-|
-segment->flags@p1 &= ~segment_flags
-|
-segment->flags@p1 & segment_flags
-)
-
-
-@script:python@
-p1 << flags.p1;
-@@
-
-print "Invalid usage of flags field at %s:%s, flags value is incorrect (wrong family)." % (p1[0].file, p1[0].line)
-import sys
-sys.exit(1)