Skip to content

Commit cfce43e

Browse files
committed
Portability: tests should run successfully (if incompletely) with old gcc versions.
Fix spelling. Signed-off-by: Henry Cox <[email protected]>
1 parent 4e4dc0f commit cfce43e

File tree

6 files changed

+81
-33
lines changed

6 files changed

+81
-33
lines changed

tests/gendiffcov/errs/msgtest.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,19 @@ elif [ "${VER[0]}" -ge 14 ] ; then
5151
COVERAGE_OPTS="-fcondition-coverage"
5252
fi
5353
54+
NO_INITIAL_CAPTURE=0
55+
if [[ "${VER[0]}" -gt 4 && "${VER[0]}" -lt 7 ]] ; then
56+
# no data generated by initial capture
57+
IGNORE_EMPTY="--ignore empty"
58+
NO_INITIAL_CAPTURE=1
59+
fi
60+
61+
if [ 1 == $NO_INITIAL_CAPTURE ] ; then
62+
# all test test use --initial
63+
echo 'all tests skipped'
64+
exit 0
65+
fi
66+
5467
echo `which gcov`
5568
echo `which lcov`
5669

tests/lcov/exception/exception.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,18 @@ if [ 0 != $? ] ; then
3030
echo "Error: unexpected error from gcc"
3131
exit 1
3232
fi
33+
NO_INITIAL_CAPTURE=0
3334
if [[ "${VER[0]}" -gt 4 && "${VER[0]}" -lt 7 ]] ; then
3435
# no data generated by initial capture
3536
IGNORE_EMPTY="--ignore empty"
37+
NO_INITIAL_CAPTURE=1
3638
fi
3739
if [ "${VER[0]}" -lt 8 ] ; then
3840
# cannot generate branch data unless 'intermediate'
3941
IGNORE_USAGE="--ignore usage"
4042
fi
4143
$COVER $CAPTURE $LCOV_OPTS --initial -o initial.info $IGNORE_EMPTY $IGNORE_USAGE
42-
if [ 0 != $? ] ; then
44+
if [ $NO_INITIAL_CAPTURE != $? ] ; then
4345
echo "Error: unexpected error code from lcov --initial"
4446
if [ $KEEP_GOING == 0 ] ; then
4547
exit 1

tests/lcov/extract/extract.sh

Lines changed: 35 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,13 @@ if [ "${VER[0]}" -lt 8 ] ; then
6363
DERIVE_END='--rc derive_function_end_line=0'
6464
fi
6565
66-
67-
$COVER $CAPTURE . $LCOV_OPTS --initial -o initial.info $IGNORE_EMPTY $IGNORE_USAGE
68-
if [ 0 != $? ] ; then
69-
echo "Error: unexpected error code from lcov --initial"
70-
if [ $KEEP_GOING == 0 ] ; then
71-
exit 1
66+
if [ 1 != $NO_INITIAL_CAPTURE ] ; then
67+
$COVER $CAPTURE . $LCOV_OPTS --initial -o initial.info $IGNORE_EMPTY $IGNORE_USAGE
68+
if [ 0 != $? ] ; then
69+
echo "Error: unexpected error code from lcov --initial"
70+
if [ $KEEP_GOING == 0 ] ; then
71+
exit 1
72+
fi
7273
fi
7374
fi
7475
@@ -77,16 +78,17 @@ if [ 0 != $? ] ; then
7778
echo "Error: unexpected error from gcc"
7879
exit 1
7980
fi
80-
# capture 'all' - which will pick up the unused file
81-
$COVER $CAPTURE . $LCOV_OPTS --all -o all_initial.info $IGNORE_EMPTY $IGNORE_USAGE
82-
if [ 0 != $? ] ; then
83-
echo "Error: unexpected error code from lcov --capture --all"
84-
if [ $KEEP_GOING == 0 ] ; then
85-
exit 1
86-
fi
87-
fi
8881
8982
if [ "$NO_INITIAL_CAPTURE" != 1 ] ; then
83+
# capture 'all' - which will pick up the unused file
84+
$COVER $CAPTURE . $LCOV_OPTS --all -o all_initial.info $IGNORE_EMPTY $IGNORE_USAGE
85+
if [ 0 != $? ] ; then
86+
echo "Error: unexpected error code from lcov --capture --all"
87+
if [ $KEEP_GOING == 0 ] ; then
88+
exit 1
89+
fi
90+
fi
91+
9092
# does the result contain file 'uused'
9193
grep -E "SF:.+unused.c$" all_initial.info
9294
if [ $? != 0 ] ; then
@@ -891,27 +893,29 @@ mkdir -pv ./mytest
891893
echo "int main(){}" > './mytest/main space.cpp'
892894
( cd ./mytest ; ${CXX} -c 'main space.cpp' --coverage )
893895
894-
$COVER $CAPTURE mytest -i -o spaces.info
895-
if [ 0 != $? ] ; then
896-
echo "Error: unexpected error from filename containing space"
897-
if [ $KEEP_GOING == 0 ] ; then
898-
exit 1
896+
if [ 1 != $NO_INITIAL_CAPTURE ] ; then
897+
$COVER $CAPTURE mytest -i -o spaces.info
898+
if [ 0 != $? ] ; then
899+
echo "Error: unexpected error from filename containing space"
900+
if [ $KEEP_GOING == 0 ] ; then
901+
exit 1
902+
fi
899903
fi
900-
fi
901904
902-
$COVER $LCOV_TOOL --list spaces.info
903-
if [ 0 != $? ] ; then
904-
echo "Error: unable to list filename containing space"
905-
if [ $KEEP_GOING == 0 ] ; then
906-
exit 1
905+
$COVER $LCOV_TOOL --list spaces.info
906+
if [ 0 != $? ] ; then
907+
echo "Error: unable to list filename containing space"
908+
if [ $KEEP_GOING == 0 ] ; then
909+
exit 1
910+
fi
907911
fi
908-
fi
909912
910-
$COVER $GENHTML_TOOL -o spaces spaces.info
911-
if [ 0 != $? ] ; then
912-
echo "Error: unable to generate HTML for filename containing space"
913-
if [ $KEEP_GOING == 0 ] ; then
914-
exit 1
913+
$COVER $GENHTML_TOOL -o spaces spaces.info
914+
if [ 0 != $? ] ; then
915+
echo "Error: unable to generate HTML for filename containing space"
916+
if [ $KEEP_GOING == 0 ] ; then
917+
exit 1
918+
fi
915919
fi
916920
fi
917921

tests/lcov/follow/follow.sh

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,24 @@ if [[ 1 == $CLEAN_ONLY ]] ; then
1111
exit 0
1212
fi
1313

14-
1514
LCOV_OPTS="$PARALLEL $PROFILE"
1615
# gcc/4.8.5 (and possibly other old versions) generate inconsistent line/function data
1716
IFS='.' read -r -a VER <<< `${CC} -dumpversion`
1817
if [ "${VER[0]}" -lt 5 ] ; then
1918
IGNORE="--ignore inconsistent"
2019
fi
20+
NO_INITIAL_CAPTURE=0
21+
if [[ "${VER[0]}" -gt 4 && "${VER[0]}" -lt 7 ]] ; then
22+
# no data generated by initial capture
23+
IGNORE_EMPTY="--ignore empty"
24+
NO_INITIAL_CAPTURE=1
25+
fi
26+
27+
if [ 1 == $NO_INITIAL_CAPTURE ] ; then
28+
# all test test use --initial
29+
echo 'all tests skipped'
30+
exit 0
31+
fi
2132
2233
2334
mkdir -p rundir

tests/lcov/initializer/initializer.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ if [ "${VER[0]}" -lt 5 ] ; then
2626
exit 0
2727
fi
2828
29+
if [[ "${VER[0]}" -lt 8 ]] ; then
30+
# c++17 not supported
31+
echo "no c++ support"
32+
exit 0
33+
fi
34+
2935
if ! type ${CXX} >/dev/null 2>&1 ; then
3036
echo "Missing tool: ${CXX}" >&2
3137
exit 2

tests/lcov/multiple/multiple.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ IFS='.' read -r -a VER <<< `${CC} -dumpversion`
99
if [ "${VER[0]}" -lt 5 ] ; then
1010
IGNORE="--ignore inconsistent"
1111
fi
12+
NO_INITIAL_CAPTURE=0
13+
if [[ "${VER[0]}" -gt 4 && "${VER[0]}" -lt 7 ]] ; then
14+
# no data generated by initial capture
15+
IGNORE_EMPTY="--ignore empty"
16+
NO_INITIAL_CAPTURE=1
17+
fi
1218
1319
rm -rf rundir
1420
@@ -30,6 +36,12 @@ echo 'int b (int x) { return x + 2;}' > b/b.c
3036
( cd a ; ${CC} -c --coverage a.c -o a.o )
3137
( cd b ; ${CC} -c --coverage b.c -o b.o )
3238
39+
if [ 1 == $NO_INITIAL_CAPTURE ] ; then
40+
# all test test use --initial
41+
echo 'all tests skipped'
42+
exit 0
43+
fi
44+
3345
$COVER $LCOV_TOOL -o out.info --capture --initial --no-external -d a -d b
3446
if [ 0 != $? ] ; then
3547
echo "Error: unexpected error code from lcov --initial"

0 commit comments

Comments
 (0)