Update the way of working of the coverage so that it produces

more useful information about the line coveraged, and avoid
expanding low level macros.
This commit is contained in:
Patrick Pelissier committed 2017-07-10 17:35:16 +02:00
1 parent fc323a5feb
commit 672c2d509d
11 files changed
+51 -18

No files matched your search

+3 -3
View File
@@ -1,6 +1,6 @@
#NOTE: GMP is only used for the tests
CC=gcc -std=c99
WCFLAGS=-Wall -W -pedantic -Wshadow -Wpointer-arith -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wswitch-default -Wswitch-enum -Wcast-align -Wpointer-arith -Wbad-function-cast -Wstrict-overflow=5 -Wstrict-prototypes -Winline -Wundef -Wnested-externs -Wcast-qual -Wshadow -Wunreachable-code -Wlogical-op -Wstrict-aliasing=2 -Wredundant-decls -Wold-style-definition -Wno-unused-function -DSTART_COVERAGE="" -DEND_COVERAGE=""
WCFLAGS=-Wall -W -pedantic -Wshadow -Wpointer-arith -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wswitch-default -Wswitch-enum -Wcast-align -Wpointer-arith -Wbad-function-cast -Wstrict-overflow=5 -Wstrict-prototypes -Winline -Wundef -Wnested-externs -Wcast-qual -Wshadow -Wunreachable-code -Wlogical-op -Wstrict-aliasing=2 -Wredundant-decls -Wold-style-definition -Wno-unused-function
XCFLAGS=
CFLAGS=$(WCFLAGS) $(XCFLAGS)
CPPFLAGS=-I..
@@ -96,11 +96,11 @@ coverage-dir:
coverage-dir/%.c: %.c coverage-dir
awk '/START_COVERAGE/ { printit=1} (printit == 0) { print }' $< > coverage-dir/first.c
awk ' printit { print } /END_COVERAGE/ { printit=1}' $< > coverage-dir/end.c
$(CC) -E -std=c99 -I.. -DNDEBUG $< |grep -v '^#' |awk ' /END_COVERAGE/ { printit=0} printit { print } /START_COVERAGE/ { printit=1 }' |perl -pi -e 's/;/;\n/g ; s/}/}\n/g ; s/{/{\n/g' > coverage-dir/middle.c
$(CC) -E -std=c99 -I. -I.. -DNDEBUG -DWITHIN_COVERAGE $< |grep -v '^#' |awk ' /END_COVERAGE/ { printit=0} printit { print } /START_COVERAGE/ { printit=1 }' |perl -pi -e 's/;/;\n/g ; s/}/}\n/g ; s/{/{\n/g' > coverage-dir/middle.c
cat coverage-dir/first.c coverage-dir/middle.c coverage-dir/end.c > coverage-dir/$<
coverage-test/%.c: coverage-dir/%.c
$(CC) -ftest-coverage -fprofile-arcs -g -I.. $< -o $(EXE) $(LDFLAGS)
$(CC) -ftest-coverage -fprofile-arcs -g -I. -I.. $< -o $(EXE) $(LDFLAGS)
$(EXE)
gcov $$(basename $< .c).gcno
+1
View File
@@ -7,6 +7,7 @@ ARRAY_DEF(int, int)
LIST_DEF(int, int)
LIST_DEF(string, string_t, STRING_OPLIST)
#include "coverage.h"
START_COVERAGE
ALGO_DEF(algo_array, ARRAY_OPLIST(int))
+1 -1
View File
@@ -49,9 +49,9 @@ static void my_mpz_str(string_t str, const mpz_t z, bool append)
free(s);
}
#include "coverage.h"
START_COVERAGE
ARRAY_DEF(uint, unsigned int)
ARRAY_DEF(mpz, mpz_t,
(INIT(mpz_init), INIT_SET(mpz_init_set), SET(mpz_set), CLEAR(mpz_clear), \
OUT_STR(my_mpz_out_str), IN_STR(my_mpz_in_str), EQUAL(my_mpz_equal_p), \
+11 -10
View File
@@ -27,15 +27,6 @@
#include "m-array.h"
#include "m-string.h"
START_COVERAGE
DICT_DEF2(str, string_t, STRING_OPLIST, string_t, STRING_OPLIST)
END_COVERAGE
DICT_SET_DEF2(setstr, string_t, STRING_OPLIST)
ARRAY_DEF(string, string_t, STRING_OPLIST)
array_string_t v_str;
static inline bool oor_equal_p(int k, unsigned char n)
{
return k == (int)-n-1;
@@ -44,8 +35,18 @@ static inline void oor_set(int *k, unsigned char n)
{
*k = (int)-n-1;
}
DICT_OA_DEF2(oa_int, int, M_OPEXTEND(M_DEFAULT_OPLIST, OOR_EQUAL(oor_equal_p), OOR_SET(oor_set M_IPTR)), int, M_DEFAULT_OPLIST)
#include "coverage.h"
START_COVERAGE
DICT_DEF2(str, string_t, STRING_OPLIST, string_t, STRING_OPLIST)
DICT_OA_DEF2(oa_int, int, M_OPEXTEND(M_DEFAULT_OPLIST, OOR_EQUAL(oor_equal_p), OOR_SET(oor_set M_IPTR)), int, M_DEFAULT_OPLIST)
END_COVERAGE
DICT_SET_DEF2(setstr, string_t, STRING_OPLIST)
/* Helper structure */
ARRAY_DEF(string, string_t, STRING_OPLIST)
array_string_t v_str;
static void init_data(int data_size)
{
+1
View File
@@ -31,6 +31,7 @@ typedef struct test_s {
ILIST_INTERFACE (tname, struct test_s);
} test_t;
#include "coverage.h"
START_COVERAGE
ILIST_DEF(tname, test_t)
END_COVERAGE
+1
View File
@@ -26,6 +26,7 @@
#include "m-mempool.h"
#include "coverage.h"
START_COVERAGE
MEMPOOL_DEF(uint, unsigned int)
END_COVERAGE
+1 -1
View File
@@ -40,7 +40,7 @@ static void uint_get_str(string_t str, unsigned int u, bool append)
(append ? string_cat_printf : string_printf) (str, "%u", u);
}
#include "coverage.h"
START_COVERAGE
RBTREE_DEF(uint, unsigned int, M_OPEXTEND(M_DEFAULT_OPLIST, IN_STR(uint_in_str M_IPTR), OUT_STR(uint_out_str), GET_STR(uint_get_str)) )
RBTREE_DEF(float, float)
+26 -3
View File
@@ -1,12 +1,35 @@
/*
* Copyright (c) 2017, Patrick Pelissier
* All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* + Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* + Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (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 <gmp.h>
#include <assert.h>
#include "m-shared.h"
#include "coverage.h"
START_COVERAGE
SHARED_PTR_DEF(int, int)
#include <gmp.h>
SHARED_PTR_DEF(mpz, mpz_t, M_CLASSIC_OPLIST(mpz))
END_COVERAGE
static int f(const shared_int_t p)
{
+4
View File
@@ -21,11 +21,15 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <gmp.h> // For testing purpose only.
#include "m-snapshot.h"
#include "coverage.h"
START_COVERAGE
SNAPSHOT_DEF(uint, unsigned int)
SNAPSHOT_DEF(mpz, mpz_t,
(INIT(mpz_init), INIT_SET(mpz_init_set), SET(mpz_set), CLEAR(mpz_clear)))
END_COVERAGE
static void test_uint(void)
{
+1
View File
@@ -26,6 +26,7 @@
#include "m-string.h"
#include "m-tuple.h"
#include "coverage.h"
START_COVERAGE
TUPLE_DEF2(pair,
(key, string_t, (INIT(string_init), INIT_SET(string_init_set), SET(string_set), CLEAR(string_clear))),
+1
View File
@@ -26,6 +26,7 @@
#include "m-string.h"
#include "m-variant.h"
#include "coverage.h"
START_COVERAGE
VARIANT_DEF2(pair,
(key, int, M_DEFAULT_OPLIST),