Skip to content

Commit b80c147

Browse files
committed
Bugfix: fix #253 - broken geninfo_adjust_src_path RC option.
Also deprecate the option in favor of 'substitute = ....' - which is more general and does better error checking. Signed-off-by: Henry Cox <henry.cox@mediatek.com>
1 parent 54a6d97 commit b80c147

File tree

3 files changed

+38
-20
lines changed

3 files changed

+38
-20
lines changed

bin/geninfo

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -320,25 +320,18 @@ $buildDirSearchPath =
320320
# Check regexp
321321
if (defined($rc_adjust_src_path)) {
322322
my ($pattern, $replace) = split(/\s*=>\s*/, $rc_adjust_src_path);
323-
local $SIG{__DIE__};
324-
my $src_pattern;
325-
eval '$src_pattern = qr>' . $pattern . '>;';
326-
if (!defined($src_pattern)) {
327-
my $msg = $@;
328-
329-
chomp($msg);
330-
$msg =~ s/at \(eval.*$//;
323+
# If no replacement is specified, simply remove pattern
324+
$replace = '' unless defined($replace);
325+
my $p = "s#$pattern#$replace#g";
326+
$p .= 'i' if $lcovutil::case_insensitive;
327+
my $text = 'abc';
328+
my $str = eval { '$test =~ ' . $p . ';' };
329+
if ($@) {
331330
lcovutil::ignorable_error($lcovutil::ERROR_FORMAT,
332-
"invalid pattern in geninfo_adjust_src_path: $msg\n");
333-
331+
"Invalid 'geninfo_adjust_src_path=$rc_adjust_src_path' syntax: '$@'"
332+
);
334333
} else {
335-
if (!defined($replace)) {
336-
# If no replacement is specified, simply remove pattern
337-
$replace = "";
338-
}
339-
my $p = 's#$pattern#$replace#g';
340-
push(@lcovutil::file_subst_patterns,
341-
[lcovutil::transform_pattern($p), $p, 0]);
334+
push(@lcovutil::file_subst_patterns, [$p, 0]);
342335
}
343336
}
344337

lib/lcovutil.pm

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1022,6 +1022,7 @@ my %deprecated_rc = ("genhtml_demangle_cpp" => "demangle_cpp",
10221022
"genhtml_demangle_cpp_params" => "demangle_cpp",
10231023
"geninfo_checksum" => "checksum",
10241024
"geninfo_no_exception_branch" => "no_exception_branch",
1025+
'geninfo_adjust_src_path' => 'substitute',
10251026
"lcov_branch_coverage" => "branch_coverage",
10261027
"lcov_function_coverage" => "function_coverage",
10271028
"genhtml_function_coverage" => "function_coverage",
@@ -1294,7 +1295,7 @@ sub parseOptions
12941295
lcovutil::ignorable_warning($lcovutil::ERROR_DEPRECATED,
12951296
"RC option '$key' is deprecated. Consider using '" .
12961297
$deprecated_rc{$key} .
1297-
". instead. (Backward-compatible support will be removed in the future"
1298+
"'. instead. (Backward-compatible support will be removed in the future"
12981299
);
12991300
}
13001301
}

tests/lcov/extract/extract.sh

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,30 @@ if [ $COUNT != '1' ] ; then
170170
exit 1
171171
fi
172172
173+
# use legacy RC 'geninfo_adjust_src_path option (had been a bug)
174+
$COVER $LCOV_HOME/bin/lcov --capture $LCOV_OPTS --capture --no-external --directory . -o rcOptBug $PARALLEL $PROFILE --rc "geninfo_adjust_src_path='/tmp/foo => /build/bar'" --ignore unused 2>&1 | tee rcOptBug.log
175+
if [ 0 != $? ] ; then
176+
echo "Error: extract with RC option failed"
177+
if [ $KEEP_GOING == 0 ] ; then
178+
exit 1
179+
fi
180+
fi
181+
grep -E "'substitute' pattern .+ is unused" rcOptBug.log
182+
if [ 0 != $? ] ; then
183+
echo "Error: missing RC pattern unused message"
184+
if [ $KEEP_GOING == 0 ] ; then
185+
exit 1
186+
fi
187+
fi
188+
grep -E "RC option 'geninfo_adjust_src_path' is deprecated" rcOptBug.log
189+
if [ 0 != $? ] ; then
190+
echo "Error: missing RC pattern unused message"
191+
if [ $KEEP_GOING == 0 ] ; then
192+
exit 1
193+
fi
194+
fi
195+
196+
173197
# workaround: depending on compiler verision, we see a coverpoint on the
174198
# close brace line (gcc/6 for example) or we don't (gcc/10 for example)
175199
BRACE_LINE='^DA:28'
@@ -422,7 +446,7 @@ done
422446
chmod ugo-rx separate/run/my/test/no_read
423447
$COVER $LCOV_HOME/bin/lcov --capture --branch-coverage $PARALLEL $PROFILE --build-directory separate/copy -d separate/run/my/test -o unreadable.info $FILTER $IGNORE 2>&1 | tee err.log
424448
if [ 0 == ${PIPESTATUS[0]} ] ; then
425-
echo "Error: expected fail from unreadable dire"
449+
echo "Error: expected fail from unreadable dir"
426450
if [ $KEEP_GOING == 0 ] ; then
427451
exit 1
428452
fi
@@ -438,7 +462,7 @@ fi
438462
439463
$COVER $LCOV_HOME/bin/lcov --capture --branch-coverage $PARALLEL $PROFILE --build-directory separate/copy -d separate/run/my/test -o unreadable.info $FILTER $IGNORE --ignore utility 2>&1 | tee warn.log
440464
if [ 0 != ${PIPESTATUS[0]} ] ; then
441-
echo "Error: extract from unreadbale failed"
465+
echo "Error: extract from unreadable failed"
442466
if [ $KEEP_GOING == 0 ] ; then
443467
exit 1
444468
fi

0 commit comments

Comments
 (0)