diff --git a/tests/Makefile b/tests/Makefile index b0aae93e..3f2637e6 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -68,7 +68,7 @@ all: awk ' printit { print } /END_COVERAGE/ { printit=1}' $< > $<.end.c $(CC) $(CPPFLAGS) -E -DNDEBUG -DWITHIN_COVERAGE $< |grep -v '^#' |awk ' /END_COVERAGE/ { printit=0} printit { print } /START_COVERAGE/ { printit=1 }' |perl -p -e "s/;(?![\"'])/;\n/g ; s/}(?![\"'])/}\n/g ; s/{(?![\"'])/{\n/g" > $<.middle.c cat $<.first.c $<.middle.c $<.end.c > $<.c - $(CC) $(CPPFLAGS) -ftest-coverage -fprofile-arcs -O -g $<.c -o $<.exe $(LDFLAGS) + $(CC) $(CPPFLAGS) -DBUILD_COVERAGE -ftest-coverage -fprofile-arcs -O -g $<.c -o $<.exe $(LDFLAGS) $(LOG_COMPILER) ./$<.exe LANG=C gcov -b $<.gcno > `basename $< .c`.synt cat `basename $< .c`.synt diff --git a/tests/coverage.h b/tests/coverage.h index 1bb4690b..9ef57a47 100644 --- a/tests/coverage.h +++ b/tests/coverage.h @@ -40,10 +40,9 @@ It'll contain the macro expanded & annotated. */ -#ifdef WITHIN_COVERAGE +#if defined(WITHIN_COVERAGE) || defined (BUILD_COVERAGE) /* For coverage build, expand the typical macros assert, avoid expanding then to not disturb coverage measurement */ -#undef assert #undef M_ASSERT #define M_ASSERT(...) (void)0 #undef M_ASSERT_SLOW @@ -127,7 +126,11 @@ /* Overwrite M_UNLIKELY_NOMEM so that it can never fails, to avoid spurious coverage */ #undef M_UNLIKELY_NOMEM #define M_UNLIKELY_NOMEM(...) 0 +#endif + +#ifdef WITHIN_COVERAGE /* For coverage build, do not expand other likes NULL, etc. */ +#undef assert #undef M_STATIC_FAILURE #undef NULL #undef M_LIKELY diff --git a/tests/test-mbitset.c b/tests/test-mbitset.c index 9c9908a3..8973a594 100644 --- a/tests/test-mbitset.c +++ b/tests/test-mbitset.c @@ -21,8 +21,9 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include - #include "m-string.h" +#include "coverage.h" + #include "m-bitset.h" static void test1(void) diff --git a/tests/test-mgenint.c b/tests/test-mgenint.c index dca895f6..10390ddb 100644 --- a/tests/test-mgenint.c +++ b/tests/test-mgenint.c @@ -23,6 +23,8 @@ #include #include "m-thread.h" #include "m-atomic.h" +#include "m-core.h" +#include "coverage.h" #include "m-genint.h" diff --git a/tests/test-mserial-bin.c b/tests/test-mserial-bin.c index 7199aaa7..4cc54820 100644 --- a/tests/test-mserial-bin.c +++ b/tests/test-mserial-bin.c @@ -20,12 +20,14 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "m-serial-bin.h" #include "m-tuple.h" #include "m-array.h" #include "m-variant.h" #include "m-list.h" #include "m-dict.h" +#include "coverage.h" + +#include "m-serial-bin.h" // Serial bin is not supported for standard types if not C11 #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L diff --git a/tests/test-mserial-json.c b/tests/test-mserial-json.c index b376709c..e25f2f4d 100644 --- a/tests/test-mserial-json.c +++ b/tests/test-mserial-json.c @@ -20,12 +20,14 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "m-serial-json.h" #include "m-tuple.h" #include "m-array.h" #include "m-variant.h" #include "m-list.h" #include "m-dict.h" +#include "coverage.h" + +#include "m-serial-json.h" // Serial json is not supported for standard types if not C11 #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L diff --git a/tests/test-mstring.c b/tests/test-mstring.c index ca6cd567..2d335d13 100644 --- a/tests/test-mstring.c +++ b/tests/test-mstring.c @@ -22,6 +22,9 @@ */ #define M_USE_ADDITIONAL_CHECKS 1 +#include "m-core.h" +#include "coverage.h" + #include "m-string.h" BOUNDED_STRING_DEF(string16, 16) diff --git a/tests/test-mworker.c b/tests/test-mworker.c index 30339deb..46d6fab4 100644 --- a/tests/test-mworker.c +++ b/tests/test-mworker.c @@ -20,8 +20,9 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include -#include +#include "m-core.h" +#include "coverage.h" + #include "m-worker.h" /* Compute Fibonacci number using thread systems. */