Skip to content

Commit 49608c4

Browse files
committed
Use environment variable to force parallel execution - to enable more thorough testing.
Signed-off-by: Henry Cox <[email protected]>
1 parent c21c05f commit 49608c4

File tree

5 files changed

+42
-31
lines changed

5 files changed

+42
-31
lines changed

Makefile

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -238,19 +238,27 @@ ifeq ($(COVERAGE), 1)
238238
# write to .../tests/cover_db
239239
export COVER_DB := $(shell echo `pwd`/tests/cover_db)
240240
export PYCOV_DB := $(shell echo `pwd`/tests/pycov.dat)
241-
export HTML_RPT := ./lcov_coverage
241+
export HTML_RPT := $(shell echo `pwd`/lcov_coverage)
242+
#export LCOV_FORCE_PARALLEL = 1
242243
endif
243244
export TESTCASE_ARGS
244245

245246
test: check
246247

248+
# for COVERAGE mode check: run once with LCOV_FORCE_PARALLEL=1 and
249+
# once without - so we can merge the result
247250
check:
248-
if [ "x$(COVERAGE)" != 'x' ] && [ ! -d $(COVER_DB) ]; then \
249-
mkdir $(COVER_DB) ; \
250-
fi
251+
if [ "x$(COVERAGE)" != 'x' ] ; then \
252+
if [ ! -d $(COVER_DB) ]; then \
253+
mkdir $(COVER_DB) ; \
254+
fi ; \
255+
echo "*** Run once, force parallel ***" ; \
256+
LCOV_FORCE_PARALLEL=1 $(MAKE) -s -C tests check LCOV_HOME=`pwd` ; \
257+
echo "*** Run again, no force ***" ; \
258+
fi
251259
@$(MAKE) -s -C tests check LCOV_HOME=`pwd`
252-
@if [ "x$(COVERAGE)" != 'x' ] ; then \
253-
$(MAKE) -s -C tests report ; \
260+
@if [ "x$(COVERAGE)" != 'x' ] ; then \
261+
$(MAKE) -s -C tests report ; \
254262
fi
255263

256264
# Files to be checked for coding style issue issues -

lib/lcovutil.pm

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6025,8 +6025,7 @@ sub _processFilterWorklist
60256025
my $parallel = $lcovutil::lcov_filter_parallel;
60266026
# not much point in parallel calculation if the number of files is small
60276027
my $workList = $fileList;
6028-
PARALLEL:
6029-
if (scalar(@$fileList) > 50 &&
6028+
if ((exists($ENV{LCOV_FORCE_PARALLEL}) || scalar(@$fileList) > 50) &&
60306029
$parallel &&
60316030
1 < $lcovutil::maxParallelism) {
60326031

@@ -6057,23 +6056,24 @@ sub _processFilterWorklist
60576056
$chunkSize = 1;
60586057
}
60596058
}
6060-
last PARALLEL if $chunkSize == 1;
6061-
$workList = [];
6062-
my $idx = 0;
6063-
my $current = [];
6064-
# maybe sort files by number of lines, then distribute larger ones
6065-
# across chunks? Or sort so total number of lines is balanced
6066-
foreach my $f (@$fileList) {
6067-
push(@$current, $f);
6068-
if (++$idx == $chunkSize) {
6069-
$idx = 0;
6070-
push(@$workList, $current);
6071-
$current = [];
6059+
if ($chunkSize != 1) {
6060+
$workList = [];
6061+
my $idx = 0;
6062+
my $current = [];
6063+
# maybe sort files by number of lines, then distribute larger ones
6064+
# across chunks? Or sort so total number of lines is balanced
6065+
foreach my $f (@$fileList) {
6066+
push(@$current, $f);
6067+
if (++$idx == $chunkSize) {
6068+
$idx = 0;
6069+
push(@$workList, $current);
6070+
$current = [];
6071+
}
60726072
}
6073+
push(@$workList, $current) if (@$current);
6074+
lcovutil::info("Filter: chunkSize $chunkSize nChunks " .
6075+
scalar(@$workList) . "\n");
60736076
}
6074-
push(@$workList, $current) if (@$current);
6075-
lcovutil::info("Filter: chunkSize $chunkSize nChunks " .
6076-
scalar(@$workList) . "\n");
60776077
}
60786078

60796079
my $srcReader = ReadCurrentSource->new();
@@ -7233,7 +7233,9 @@ sub merge
72337233
}
72347234

72357235
if (1 != $lcovutil::maxParallelism &&
7236-
1 < $nTests) {
7236+
(exists($ENV{LCOV_FORCE_PARALLEL}) ||
7237+
1 < $nTests)
7238+
) {
72377239
# parallel implementation is to segment the file list into N
72387240
# segments, then parse-and-merge scalar(@merge)/N files in each slave,
72397241
# then merge the slave result.

tests/Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
ifeq ($(COVERAGE), 1)
22
ifeq ($(COVER_DB),)
3-
export COVER_DB := $(shell `pwd`/cover_db)
4-
export PYCOV_DB := $(shell `pwd`/pycov.dat)
5-
export HTML_RPT := $(shell `pwd`/lcov_coverage)
3+
export COVER_DB := $(shell echo `pwd`/cover_db)
4+
export PYCOV_DB := $(shell echo `pwd`/pycov.dat)
5+
export HTML_RPT := $(shell echo `pwd`/lcov_coverage)
66
endif
77
endif
88

tests/gendiffcov/insensitive/insensitive.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ while [ $# -gt 0 ] ; do
3535
LOCAL_COVERAGE=0
3636
shift
3737
fi
38-
COVER="perl -MDevel::Cover=-db,${COVER_DB},-coverage,statement,branch,condition,subroutine "
38+
COVER="perl -MDevel::Cover=-db,${COVER_DB},-coverage,statement,branch,condition,subroutine,-silent,1 "
3939
;;
4040

4141
--home | -home )

tests/gendiffcov/simple/script.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,11 @@ DIFFCOV_OPTS="--function-coverage --branch-coverage --highlight --demangle-cpp -
129129
#DIFFCOV_OPTS='--function-coverage --branch-coverage --highlight --demangle-cpp'
130130

131131
rm -f test.cpp *.gcno *.gcda a.out *.info *.info.gz diff.txt diff_r.txt diff_broken.txt *.log *.err *.json dumper* results.xlsx annotate.{cpp,exe} c d ./cover_db_py
132-
rm -rf ./cover_db ./baseline ./current ./differential* ./reverse ./diff_no_baseline ./no_baseline ./no_annotation ./no_owners differential_nobranch reverse_nobranch baseline-filter* noncode_differential* broken mismatchPath elidePath ./cover_db ./criteria ./mismatched ./navigation differential_prop proportion ./annotate ./current-* ./current_prefix* select select2 html_report
132+
rm -rf ./baseline ./current ./differential* ./reverse ./diff_no_baseline ./no_baseline ./no_annotation ./no_owners differential_nobranch reverse_nobranch baseline-filter* noncode_differential* broken mismatchPath elidePath ./cover_db ./criteria ./mismatched ./navigation differential_prop proportion ./annotate ./current-* ./current_prefix* select select2 html_report
133133

134134
if [ "x$COVER" != 'x' ] && [ 0 != $LOCAL_COVERAGE ] ; then
135-
cover -delete
135+
cover -delete -db $COVER_DB
136+
rm -rf $PYCOV_DB
136137
fi
137138

138139
if [[ 1 == $CLEAN_ONLY ]] ; then
@@ -1254,7 +1255,7 @@ fi
12541255
12551256
if [ "x$COVER" != "x" ] && [ 0 != $LOCAL_COVERAGE ] ; then
12561257
cover
1257-
${LCOV_HOME}/bin/perl2lcov -o perlcov.info --testname simple --version-script $GET_VERSION ./cover_db
1258+
${LCOV_HOME}/bin/perl2lcov -o perlcov.info --testname simple --version-script $GET_VERSION $COVER_DB
12581259
${LCOV_HOME}/bin/py2lcov -o pycov.info --testname simple --version-script $GET_VERSION $PYCOV_DB
12591260
${LCOV_HOME}/bin/genhtml -o html_report perlcov.info pycov.info --branch --flat --show-navigation --show-proportion --version-script $GET_VERSION --annotate-script $P4ANNOTATE --parallel --ignore empty,usage
12601261
echo "see HTML report 'html_report'"

0 commit comments

Comments
 (0)