]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
qa: generate struct-flags.cocci at each run
authorEric Leblond <eric@regit.org>
Thu, 21 Nov 2019 17:26:49 +0000 (18:26 +0100)
committerVictor Julien <victor@inliniac.net>
Thu, 5 Dec 2019 12:40:02 +0000 (13:40 +0100)
.gitignore
qa/coccinelle/Makefile.am
qa/coccinelle/run_check.sh
qa/coccinelle/struct-flags.cocci [deleted file]

index 2a53abc66cad56c9c5787b25e91019bb86dbe922..4af7bc8e945e0c3818dca04becc36e20ec768e12 100644 (file)
@@ -44,6 +44,7 @@ src/suricata
 stamp-h1
 src/build-info.h
 qa/log/
+qa/coccinelle/struct-flags.cocci
 
 /suricata-update/*
 !/suricata-update/Makefile.am
index 3a85bc3904b52a6fff6e6e7a13071441d2f26246..60ec6a5bf59146ac59c243e454d51d30ec2a606b 100644 (file)
@@ -7,7 +7,6 @@ EXTRA_DIST= access-pkt-packet.cocci \
     realloc.cocci \
     siginit.cocci \
     size_t.cocci \
-    struct-flags.cocci \
     sz3.cocci \
     uint.cocci \
     run_check.sh struct-flags.py
@@ -16,8 +15,8 @@ if HAVE_COCCINELLE
 struct-flags.cocci:
        $(srcdir)/struct-flags.py > $(top_builddir)/qa/coccinelle/struct-flags.cocci
 
-check:
-       TOP_SRCDIR=$(abs_top_srcdir) $(top_srcdir)/qa/coccinelle/run_check.sh
+check: struct-flags.cocci
+       TOP_BUILDDIR=${abs_top_builddir} TOP_SRCDIR=$(abs_top_srcdir) $(top_srcdir)/qa/coccinelle/run_check.sh
 
 distclean-local:
        -rm $(top_builddir)/qa/coccinelle/struct-flags.cocci
index f04829d34c6a7d6884f3d6a320722807ecb6834f..325e1732fa5ad8026ec582ba678583eb7f1c0d18 100755 (executable)
@@ -23,6 +23,12 @@ elif [ "${TOP_SRCDIR}" != "" ]; then
        PREFIX=${TOP_SRCDIR}/
 fi
 
+if [ "${TOP_BUILDDIR}" != "" ]; then
+       BUILT_COCCI_FILES=$(ls ${TOP_BUILDDIR}/qa/coccinelle/*.cocci)
+else
+       BUILT_COCCI_FILES=""
+fi
+
 if [ -z "$CONCURRENCY_LEVEL" ]; then
        CONCURRENCY_LEVEL=1
        echo "No concurrency"
@@ -30,7 +36,7 @@ else
        echo "Using concurrency level $CONCURRENCY_LEVEL"
 fi
 
-for SMPL in ${PREFIX}qa/coccinelle/*.cocci; do
+for SMPL in ${PREFIX}qa/coccinelle/*.cocci ${BUILT_COCCI_FILES}; do
        echo "Testing cocci file: $SMPL"
        if command -v parallel >/dev/null; then
                echo -n $LIST | parallel -d ' ' -j $CONCURRENCY_LEVEL spatch --very-quiet -sp_file $SMPL --undefined UNITTESTS $PREFIX{} || if [ -z "$NOT_TERMINAL" ]; then exit 1; fi
diff --git a/qa/coccinelle/struct-flags.cocci b/qa/coccinelle/struct-flags.cocci
deleted file mode 100644 (file)
index 7050043..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-@flags@
-SignatureInitData *struct0;
-identifier struct_flags0 =~ "^(?!SIG_FLAG_INIT_).+";
-Signature *struct1;
-identifier struct_flags1 =~ "^(?!SIG_FLAG).+";
-Flow *struct2;
-identifier struct_flags2 =~ "^(?!FLOWFILE_).+";
-Flow *struct3;
-identifier struct_flags3 =~ "^(?!FLOW_END_FLAG_).+";
-TcpStream *struct4;
-identifier struct_flags4 =~ "^(?!STREAMTCP_STREAM_FLAG_).+";
-TcpSession *struct5;
-identifier struct_flags5 =~ "^(?!STREAMTCP_FLAG).+";
-TcpStreamCnf *struct6;
-identifier struct_flags6 =~ "^(?!STREAMTCP_INIT_).+";
-Packet *struct7;
-identifier struct_flags7 =~ "^(?!FLOW_PKT_).+";
-position p1;
-@@
-
-(
-struct0->init_flags@p1 |= struct_flags0
-|
-struct0->init_flags@p1 & struct_flags0
-|
-struct0->init_flags@p1 &= ~struct_flags0
-|
-struct1->flags@p1 |= struct_flags1
-|
-struct1->flags@p1 & struct_flags1
-|
-struct1->flags@p1 &= ~struct_flags1
-|
-struct2->file_flags@p1 |= struct_flags2
-|
-struct2->file_flags@p1 & struct_flags2
-|
-struct2->file_flags@p1 &= ~struct_flags2
-|
-struct3->flow_end_flags@p1 |= struct_flags3
-|
-struct3->flow_end_flags@p1 & struct_flags3
-|
-struct3->flow_end_flags@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->flags@p1 |= struct_flags6
-|
-struct6->flags@p1 & struct_flags6
-|
-struct6->flags@p1 &= ~struct_flags6
-|
-struct7->flowflags@p1 |= struct_flags7
-|
-struct7->flowflags@p1 & struct_flags7
-|
-struct7->flowflags@p1 &= ~struct_flags7
-)
-
-@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)