Skip to content

Commit 533db4e

Browse files
committed
lcov: Fix capture for package files containing graph files
Depending on whether package files contain graph files, data should be collected from the unpacked package file directly, or from the build directory after linking data files. This approach fixes problems when capturing coverage data via a package from a directory containing graph files. Signed-off-by: Peter Oberparleiter <[email protected]>
1 parent a2a8b37 commit 533db4e

File tree

1 file changed

+39
-3
lines changed

1 file changed

+39
-3
lines changed

bin/lcov

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1363,6 +1363,35 @@ sub link_data($$$)
13631363
}
13641364
}
13651365

1366+
#
1367+
# find_graph_cb(datadir, rel, count_ref)
1368+
#
1369+
# Count number of files found.
1370+
#
1371+
1372+
sub find_graph_cb($$$)
1373+
{
1374+
my ($dir, $rel, $count_ref) = @_;
1375+
1376+
($$count_ref)++;
1377+
}
1378+
1379+
#
1380+
# find_graph(dir)
1381+
#
1382+
# Search DIR for a graph file. Return non-zero if one was found, zero otherwise.
1383+
#
1384+
1385+
sub find_graph($)
1386+
{
1387+
my ($dir) = @_;
1388+
my $count = 0;
1389+
1390+
lcov_find($dir, \&find_graph_cb, \$count, '\.gcno$', '\.bb$', '\.bbg$');
1391+
1392+
return $count > 0 ? 1 : 0;
1393+
}
1394+
13661395
#
13671396
# package_capture()
13681397
#
@@ -1398,9 +1427,16 @@ sub package_capture()
13981427
} else {
13991428
# Build directory needs to be passed to geninfo
14001429
$base_directory = $build;
1401-
link_data($dir, $base_directory, 1);
1402-
lcov_geninfo($base_directory);
1403-
link_data($dir, $base_directory, 0);
1430+
if (find_graph($dir)) {
1431+
# Package contains graph files - collect from there
1432+
lcov_geninfo($dir);
1433+
} else {
1434+
# No graph files found, link data files next to
1435+
# graph files
1436+
link_data($dir, $base_directory, 1);
1437+
lcov_geninfo($base_directory);
1438+
link_data($dir, $base_directory, 0);
1439+
}
14041440
}
14051441
}
14061442

0 commit comments

Comments
 (0)