WIP: computing coverage of the tests.

This commit is contained in:
Patrick Pelissier committed 2017-03-02 22:35:22 +01:00
1 parent eb15fcc6c7
commit 2af4cb2fc2
9 files changed
+43 -17

No files matched your search

+14 -2
View File
@@ -1,6 +1,6 @@
#NOTE: GMP is only used for the tests
CC=gcc -std=c99
CFLAGS=-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
CFLAGS=-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=""
CPPFLAGS=-I..
RM=rm -f
VALGRIND=
@@ -64,4 +64,16 @@ gene-array:
clean:
$(RM) $(EXE) *.s *~ *.o ./a.dat
$(RM) -r coverage *.gcda *.gcno all.info test.tar README.html
$(RM) -rf coverage *.gcda *.gcno *.gcov all.info test.tar coverage-dir
coverage-dir:
mkdir -p 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 }' > coverage-dir/middle.c
cat coverage-dir/first.c coverage-dir/middle.c coverage-dir/end.c > coverage-dir/$<
coverage: coverage-dir
for i in test-m*.c ; do echo $$i ; make coverage-dir/$$i && $(CC) -ftest-coverage -fprofile-arcs -std=c99 -I.. coverage-dir/$$i -o $(EXE) -lgmp -pthread && $(EXE) && gcov $$i ; done
+5 -5
View File
@@ -4,16 +4,16 @@
#include "m-algo.h"
ARRAY_DEF(int, int)
ALGO_DEF(algo_array, ARRAY_OPLIST(int))
LIST_DEF(int, int)
LIST_DEF(string, string_t, STRING_OPLIST)
START_COVERAGE
ALGO_DEF(algo_array, ARRAY_OPLIST(int))
ALGO_DEF(algo_list, LIST_OPLIST(int))
LIST_DEF(string, string_t, STRING_OPLIST)
ALGO_DEF(algo_string, LIST_OPLIST(string, STRING_OPLIST))
END_COVERAGE
static void test_list(void)
{
+5 -3
View File
@@ -24,9 +24,6 @@
#include <gmp.h>
#include "m-array.h"
ARRAY_DEF(uint, unsigned int)
#define ARRAY_UINT_OPLIST ARRAY_OPLIST(uint)
static void my_mpz_out_str(FILE *f, const mpz_t z)
{
mpz_out_str (f, 10, z);
@@ -52,10 +49,15 @@ static void my_mpz_str(string_t str, const mpz_t z, bool append)
free(s);
}
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), \
GET_STR(my_mpz_str) ))
END_COVERAGE
#define ARRAY_UINT_OPLIST ARRAY_OPLIST(uint)
static void test_uint(void)
{
+3
View File
@@ -27,7 +27,10 @@
#include "m-array.h"
#include "m-string.h"
START_COVERAGE
DICT_DEF2(str, string_t, STRING_OPLIST, string_t, STRING_OPLIST)
END_COVERAGE
ARRAY_DEF(string, string_t, STRING_OPLIST)
array_string_t v;
+3 -1
View File
@@ -31,8 +31,10 @@ typedef struct test_s {
ILIST_INTERFACE (tname, struct test_s);
} test_t;
START_COVERAGE
ILIST_DEF(tname, test_t)
END_COVERAGE
static void test(void)
{
test_t x1, x2, x3;
+5 -4
View File
@@ -22,11 +22,9 @@
*/
#include <stdio.h>
#include <gmp.h> // For testing purpose only.
#include "m-string.h"
#include "m-list.h"
LIST_DEF(uint, unsigned int)
#define LIST_UINT_OPLIST LIST_OPLIST(uint)
static void my_mpz_out_str(FILE *f, const mpz_t z)
{
mpz_out_str (f, 10, z);
@@ -42,7 +40,6 @@ static bool my_mpz_equal_p(const mpz_t z1, const mpz_t z2)
return mpz_cmp (z1, z2) == 0;
}
#include "m-string.h"
static void my_mpz_str(string_t str, const mpz_t z, bool append)
{
char *s = mpz_get_str(NULL, 10, z);
@@ -51,9 +48,13 @@ static void my_mpz_str(string_t str, const mpz_t z, bool append)
free(s);
}
START_COVERAGE
LIST_DEF(uint, unsigned int)
LIST_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), \
GET_STR(my_mpz_str)))
END_COVERAGE
#define LIST_UINT_OPLIST LIST_OPLIST(uint)
static void test_uint(void)
{
+4 -2
View File
@@ -24,10 +24,12 @@
#include <gmp.h> // For testing purpose only.
#include "m-rbtree.h"
START_COVERAGE
RBTREE_DEF(uint, unsigned int)
#define UINT_OPLIST RBTREE_OPLIST(uint)
RBTREE_DEF(float, float)
END_COVERAGE
#define UINT_OPLIST RBTREE_OPLIST(uint)
#define FLOAT_OP RBTREE_OPLIST(float)
static void test_uint(void)
+2
View File
@@ -26,9 +26,11 @@
#include "m-string.h"
#include "m-tuple.h"
START_COVERAGE
TUPLE_DEF2(pair,
(key, string_t, (INIT(string_init), INIT_SET(string_init_set), SET(string_set), CLEAR(string_clear))),
(value, mpz_t, (INIT(mpz_init), INIT_SET(mpz_init_set), SET(mpz_set), CLEAR(mpz_clear) )))
END_COVERAGE
// No cmp defined
TUPLE_DEF2(triple,
+2
View File
@@ -26,9 +26,11 @@
#include "m-string.h"
#include "m-variant.h"
START_COVERAGE
VARIANT_DEF2(pair,
(key, int, M_DEFAULT_OPLIST),
(value, float, M_DEFAULT_OPLIST) )
END_COVERAGE
static void test_pair(void)
{