Skip to content

Commit ff6ea4c

Browse files
author
ribu
committed
Added gcov
1 parent 2f3cbb2 commit ff6ea4c

File tree

4 files changed

+38
-2
lines changed

4 files changed

+38
-2
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
unittest/gmon.out
22
unittest/_*.txt
3+
unittest/*.gcov
4+
unittest/*.gcda
5+
unittest/*.gcno
36

47
# -----------------------------------------------------------------------------
58
# Compiled sources

unittest/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Or, add `-fsanitize=address` to run the address sanitizer:
2828
cd ../mapcodelib
2929
gcc -O -c mapcoder.c
3030
cd ../unittest
31-
gcc -O unittest.c -lm -lpthread -fsanitize=address -o unittest
31+
gcc -O unittest.c -lm -lpthread -fsanitize=address -o unittest ../mapcodelib/mapcoder.o
3232

3333
And add the environment variable `ASAN_OPTIONS` to your shell:
3434

unittest/clean.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
echo "Clean test files..."
33
if [ -f unittest.c ]
44
then
5-
rm -f _*.txt gmon.out
5+
rm -f _*.txt gmon.out *.gcda *.gcno *.gcov ../mapcodelib/*.gcda ../mapcodelib/*.gcno ../mapcodelib/*.gcov
66
fi

unittest/run_gcov.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/sh
2+
OPTS="-Wall -Werror -Wno-pointer-to-int-cast -fprofile-arcs -ftest-coverage"
3+
LIB="../mapcodelib/mapcoder.o"
4+
5+
TEST=`which gcov`
6+
if [ "$TEST" = "" ]
7+
then
8+
echo "No gcov found on this machine - skipping script..."
9+
exit 1
10+
fi
11+
12+
echo "!! -------------------------------------------------------------"
13+
echo "Run gcov test coverage..."
14+
date
15+
echo "!! -------------------------------------------------------------"
16+
17+
echo ""
18+
echo "Run gcov with: -DNO_POSIX_THREADS -O0"
19+
cd ../mapcodelib
20+
gcc $OPTS -O0 -c mapcoder.c
21+
cd ../unittest
22+
gcc $OPTS -DNO_POSIX_THREADS -O0 unittest.c -lm -o unittest $LIB
23+
./unittest
24+
cd ../mapcodelib
25+
gcov unittest.c
26+
cd ../unittest
27+
gcov unittest.c
28+
echo "!! -------------------------------------------------------------"
29+
echo "!! Coverage reports in: *.gcov files"
30+
echo "!! -------------------------------------------------------------"
31+
32+
echo ""
33+
echo "Report in: $REPORT"

0 commit comments

Comments
 (0)