Skip to content

Commit b4c120a

Browse files
committed
Run the regresion tests over multiple gcc versions
Whilst investigating issues with dodgey coverage being reported to coveralls, it was found that the issue was dependent on the version of g++/gcov used. Extending the existing test suite to multiple gcc versions shows this up. The issue is that in version 8, gcov changed the format of its output, which makes the assumptions made in the current parser invalid. Tools such as LCOV have already migrated to use gcov's new JSON format to work around this issue. For now the affected tests are marked as known failure to prevent a failing build.
1 parent 927887e commit b4c120a

File tree

16 files changed

+107
-50
lines changed

16 files changed

+107
-50
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ pip-log.txt
2525
.coverage
2626
.tox
2727
nosetests.xml
28-
*_test_output
28+
*_test_output*
2929
*.gcov
3030
output.json
3131
*.gcno

.travis.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,25 @@ python:
99

1010
addons:
1111
apt:
12+
sources:
13+
- ubuntu-toolchain-r-test
1214
packages:
1315
- lcov
16+
- g++-4.8
17+
- g++-5
18+
- g++-6
19+
- g++-7
20+
- g++-8
21+
- g++-9
22+
- g++-9
23+
# Required for latest lcov build - TODO: remove the need for this...
24+
- libperlio-gzip-perl
25+
- libjson-perl
1426

1527
install:
1628
- python setup.py --quiet install
1729

1830
script:
1931
- nosetests
20-
- ./test.bash
32+
- git clone https://github.com/linux-test-project/lcov.git
33+
- PATH="$PWD/lcov/bin:$PATH" ./test.bash --gcc-version 4.8 --gcc-version 5 --gcc-version 6 --gcc-version 7 --gcc-version 8 --gcc-version 9

test-src/excluded_files/Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
part_unused.o: part_unused.h part_unused.cpp
2-
g++ --coverage -c -o part_unused.o part_unused.cpp
2+
$(CXX) --coverage -c -o part_unused.o part_unused.cpp
33

44
toy.o: extra_lib/toy.cpp extra_lib/toy.h
5-
g++ --coverage -c -o toy.o extra_lib/toy.cpp
5+
$(CXX) --coverage -c -o toy.o extra_lib/toy.cpp
66

77
a_toy.o: another_extra_lib/another_toy.cpp another_extra_lib/another_toy.h
8-
g++ --coverage -c -o a_toy.o another_extra_lib/another_toy.cpp
8+
$(CXX) --coverage -c -o a_toy.o another_extra_lib/another_toy.cpp
99

1010
foo: foo.cpp part_unused.o toy.o a_toy.o extra_lib/toy.h another_extra_lib/another_toy.h
11-
g++ --coverage -o foo foo.cpp part_unused.o toy.o a_toy.o
11+
$(CXX) --coverage -o foo foo.cpp part_unused.o toy.o a_toy.o
1212

1313
clean:
1414
rm -f foo *.gcno *.gcda output *.gcov output.json part_unused.o toy.o a_toy.o

test-src/included_files/Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
part_unused.o: part_unused.h part_unused.cpp
2-
g++ --coverage -c -o part_unused.o part_unused.cpp
2+
$(CXX) --coverage -c -o part_unused.o part_unused.cpp
33

44
toy.o: extra_lib/toy.cpp extra_lib/toy.h
5-
g++ --coverage -c -o toy.o extra_lib/toy.cpp
5+
$(CXX) --coverage -c -o toy.o extra_lib/toy.cpp
66

77
a_toy.o: another_extra_lib/another_toy.cpp another_extra_lib/another_toy.h
8-
g++ --coverage -c -o a_toy.o another_extra_lib/another_toy.cpp
8+
$(CXX) --coverage -c -o a_toy.o another_extra_lib/another_toy.cpp
99

1010
foo: foo.cpp part_unused.o toy.o a_toy.o extra_lib/toy.h another_extra_lib/another_toy.h
11-
g++ --coverage -o foo foo.cpp part_unused.o toy.o a_toy.o
11+
$(CXX) --coverage -o foo foo.cpp part_unused.o toy.o a_toy.o
1212

1313
clean:
1414
rm -f foo *.gcno *.gcda output *.gcov output.json part_unused.o toy.o a_toy.o

test-src/missing_files/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
unused.o: unused.h unused.cpp
2-
gcc --coverage -c -o unused.o unused.cpp
2+
$(CXX) --coverage -c -o unused.o unused.cpp
33
foo: foo.c unused.o
4-
gcc --coverage -o foo foo.c
4+
$(CXX) --coverage -o foo foo.c
55

66
clean:
77
rm -f foo *.gcno *.gcda output *.gcov output.json unused.o

test-src/missing_files/config.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ gcov_expected_output="expected_gcov.json"
66
# Override to change the file that contains the expected output for the lcov run
77
lcov_expected_output="expected_lcov.json"
88

9-
gcc_version=$(g++ -v 2>&1 | awk '/gcc version/ {print $3}')
9+
gcc_version=$($CXX -v 2>&1 | awk '/gcc version/ {print $3}')
1010
if [[ "$gcc_version" < "5.5" ]]; then
11-
echo "LEGACY G++ detected: skipping GCOV missing files test"
11+
echo "LEGACY G++ detected ($gcc_version: $CXX): skipping GCOV missing files test"
1212
modes="lcov"
1313
else
1414
modes="gcov lcov"

test-src/out_of_tree/build_tree/Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@ SOURCE_TREE=../source_tree
22
INCLUDE_FLAGS=-I$(SOURCE_TREE)/llib
33

44
lib.o: $(SOURCE_TREE)/llib/lib.cpp $(SOURCE_TREE)/llib/lib.h
5-
g++ --coverage -c -o $@ $(SOURCE_TREE)/llib/lib.cpp
5+
$(CXX) --coverage -c -o $@ $(SOURCE_TREE)/llib/lib.cpp
66

77
lib.a: lib.o
88
ar cr $@ $+
99

1010
a: $(SOURCE_TREE)/A/a.cpp lib.a
11-
g++ --coverage $(INCLUDE_FLAGS) -o a $+
11+
$(CXX) --coverage $(INCLUDE_FLAGS) -o a $+
1212

1313
b: $(SOURCE_TREE)/B/b.cpp lib.a
14-
g++ --coverage $(INCLUDE_FLAGS) -o b $+
14+
$(CXX) --coverage $(INCLUDE_FLAGS) -o b $+
1515

1616
prepare_test: a b
1717

test-src/simple/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
foo: foo.c
2-
gcc --coverage -o foo foo.c
2+
$(CXX) --coverage -o foo foo.c
33

44
clean:
55
rm -f foo *.gcno *.gcda output *.gcov output.json

test-src/static_lib/Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
llib/lib.o: llib/lib.cpp llib/lib.h
2-
g++ --coverage -c -o $@ llib/lib.cpp
2+
$(CXX) --coverage -c -o $@ llib/lib.cpp
33

44
llib/lib.a: llib/lib.o
55
ar cr $@ $+
66

77
A/a: A/a.cpp llib/lib.a
8-
cd A && g++ --coverage -I../llib -o a a.cpp ../llib/lib.a
8+
cd A && $(CXX) --coverage -I../llib -o a a.cpp ../llib/lib.a
99

1010
B/b: B/b.cpp llib/lib.a
11-
cd B && g++ --coverage -I../llib -o b b.cpp ../llib/lib.a
11+
cd B && $(CXX) --coverage -I../llib -o b b.cpp ../llib/lib.a
1212

1313
prepare_test: A/a B/b
1414

test-src/static_lib/config.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
11
#!/bin/bash
2+
gcc_version=$($CXX -v 2>&1 | awk '/gcc version/ {print $3}')
3+
if [[ "$gcc_version" < "8" ]]; then
4+
gcov_fail_reason=""
5+
else
6+
gcov_fail_reason="cpp-coveralls parser does not support modern gcov's output"
7+
fi

0 commit comments

Comments
 (0)