mirror of https://github.com/OISF/suricata
coccinelle: dynamic testing through make check
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.pull/421/merge
parent
e05fd7f1d0
commit
9212ff7e59
@ -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
|
||||
|
||||
@ -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)
|
||||
@ -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)
|
||||
Loading…
Reference in New Issue