Project

General

Profile

Actions

Feature #1025

open

seperate #ifdef UNITTEST code into their own files

Added by Mark Solaris about 11 years ago. Updated over 4 years ago.

Status:
New
Priority:
Normal
Assignee:
Target version:
Effort:
Difficulty:
Label:

Description

It would be useful if the UNITTEST code was put into their own files:

suricata-1.4.6/src root# ls -al unit*.c
-rw-r--r--   1 root     root       15695 Nov  3 23:54 unit-test-decode-icmp4.c
-rw-r--r--   1 root     root       46984 Nov  3 23:34 unit-test-decode-ipv4.c
-rw-r--r--   1 root     root      223181 Nov  3 23:17 unit-test-detect.c
-rw-r--r--   1 root     root      136477 Nov  3 23:07 unit-test-stream-tcp.c

and then the Makefile.in is updated to reference it:

# diff -u ../../suricata-1.4.6.orig/src/Makefile.in Makefile.in
--- ../../suricata-1.4.6.orig/src/Makefile.in   Tue Sep 24 20:28:49 2013
+++ Makefile.in Sun Nov  3 23:56:13 2013
@@ -225,6 +225,8 @@
        tmqh-simple.h tm-queuehandlers.c tm-queuehandlers.h \
        tm-queues.c tm-queues.h tm-threads.c tm-threads.h \
        tm-threads-common.h unix-manager.c unix-manager.h \
+       unit-test-decode-icmp4.c \
+       unit-test-decode-ipv4.c unit-test-detect.c unit-test-stream-tcp.c \
        util-action.c util-action.h util-atomic.c util-atomic.h \
        util-bloomfilter-counting.c util-bloomfilter-counting.h \
        util-bloomfilter.c util-bloomfilter.h util-buffer.c \
@@ -392,6 +394,8 @@
        tmqh-packetpool.$(OBJEXT) tmqh-ringbuffer.$(OBJEXT) \
        tmqh-simple.$(OBJEXT) tm-queuehandlers.$(OBJEXT) \
        tm-queues.$(OBJEXT) tm-threads.$(OBJEXT) \
+       unit-test-decode-icmp4.$(OBJEXT) unit-test-decode-ipv4.$(OBJEXT) \
+       unit-test-detect.$(OBJEXT) unit-test-stream-tcp.$(OBJEXT) \
        unix-manager.$(OBJEXT) util-action.$(OBJEXT) \
        util-atomic.$(OBJEXT) util-bloomfilter-counting.$(OBJEXT) \
        util-bloomfilter.$(OBJEXT) util-buffer.$(OBJEXT) \
@@ -773,6 +777,8 @@
        tmqh-simple.h tm-queuehandlers.c tm-queuehandlers.h \
        tm-queues.c tm-queues.h tm-threads.c tm-threads.h \
        tm-threads-common.h unix-manager.c unix-manager.h \
+       unit-test-decode-icmp4.c unit-test-decode-ipv4.c \
+       unit-test-detect.c unit-test-stream-tcp.c \
        util-action.c util-action.h util-atomic.c util-atomic.h \
        util-bloomfilter-counting.c util-bloomfilter-counting.h \
        util-bloomfilter.c util-bloomfilter.h util-buffer.c \
@@ -1179,6 +1185,10 @@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tmqh-packetpool.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tmqh-ringbuffer.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tmqh-simple.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unit-test-decode-icmp4.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unit-test-decode-ipv4.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unit-test-detect.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unit-test-stream-tcp.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unix-manager.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/util-action.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/util-affinity.Po@am__quote@

It makes the actual code much easier to work with (greps are shorter etc) and you can see which files you don't need to immediately update when doing changes.

It's a preference of mine so I've listed it as a feature.

Thanks.


Related issues 2 (2 open0 closed)

Related to Suricata - Task #2975: convert unittests to new FAIL/PASS APIAssignedCommunity TicketActions
Blocked by Suricata - Task #3166: src code file reorgIn ProgressJason IshActions
Actions #1

Updated by Victor Julien about 11 years ago

  • Target version set to 3.0RC2

Will consider this for 2.1. I've always wanted the tests to stay close to the code they test, but I agree things are a bit out of control. Also, testing code coverage with gcov is hampered by mixing in the tests.

I think I would prefer a scheme like decode-ipv4-unittests.c

Actions #2

Updated by Victor Julien about 10 years ago

  • Target version changed from 3.0RC2 to 70
Actions #3

Updated by Andreas Herz almost 9 years ago

  • Assignee set to OISF Dev
Actions #4

Updated by Victor Julien over 5 years ago

  • Subject changed from 1.4.6: seperate #ifdef UNITTEST code into their own files to seperate #ifdef UNITTEST code into their own files
Actions #5

Updated by Andreas Herz over 5 years ago

  • Target version changed from 70 to TBD
Actions #6

Updated by Victor Julien over 5 years ago

  • Target version changed from TBD to 70
Actions #7

Updated by Victor Julien about 5 years ago

  • Blocked by Task #3166: src code file reorg added
Actions #8

Updated by Victor Julien about 5 years ago

  • Related to Task #2975: convert unittests to new FAIL/PASS API added
Actions #9

Updated by Victor Julien over 4 years ago

  • Target version changed from 70 to TBD
Actions

Also available in: Atom PDF