From 3598a75d03299f982edc48386f85f4df01b10037 Mon Sep 17 00:00:00 2001 From: Sam James Date: Mon, 19 Aug 2024 06:36:35 +0100 Subject: [PATCH] lcov --- ci/ciimage/ubuntu-rolling/install.sh | 70 ++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/ci/ciimage/ubuntu-rolling/install.sh b/ci/ciimage/ubuntu-rolling/install.sh index b811fde47e7d..4d8430436f4a 100755 --- a/ci/ciimage/ubuntu-rolling/install.sh +++ b/ci/ciimage/ubuntu-rolling/install.sh @@ -82,6 +82,76 @@ cp LICENSE /usr/share/doc/zig cd .. rm -rf "$ZIG_BASE" +cd / +# Hack for https://github.com/linux-test-project/lcov/issues/245 +# https://github.com/linux-test-project/lcov/commit/bf135caf5f626e02191c42bd2773e08a0bb9b7e5 +patch -p1 <<-EOF +--- a/usr/bin/genhtml ++++ b/usr/bin/genhtml +@@ -5971,11 +5971,35 @@ sub gen_html() + $no_prefix = 1; + } + } else { +- my $msg = "Using user-specified filename prefix "; +- for my $i (0 .. $#dir_prefix) { +- $dir_prefix[$i] =~ s/$lcovutil::dirseparator+$//; ++ my $msg = "Using user-specified filename prefix "; ++ my $dirs = $current_data->directories(); ++ my $i = 0; ++ # somewhat of a hack: the layout code doesn't react well when ++ # the 'prefix' directory contains source files (as opposed to ++ # containing a directory which contains source files). ++ # Rather than trying to handle that special case, just munge the ++ # prefix to be something we like better. ++ while ($i <= $#dir_prefix) { ++ my $p = $dir_prefix[$i]; ++ # remove redundant /'s ++ $p =~ s/$lcovutil::dirseparator+$//; ++ $p = substr($p, 0, -1) ++ if $lcovutil::dirseparator eq substr($p, -1); ++ while (exists($dirs->{$p}) && $p) { ++ $p = File::Basename::dirname($p); ++ } ++ unless ($p) { ++ lcovutil::info("skipping prefix $dir_prefix[$i]\n"); ++ splice(@dir_prefix, $i, 1); ++ next; ++ } ++ lcovutil::info( ++ "using prefix '$p' (rather than '$dir_prefix[$i]')\n") ++ if ($p ne $dir_prefix[$i]); ++ $dir_prefix[$i] = $p; + $msg .= ", " unless 0 == $i; +- $msg .= "\"" . $dir_prefix[$i] . "\""; ++ $msg .= "\"" . $p . "\""; ++ ++$i; + } + info($msg . "\n"); + } +--- a/usr/lib/lcov/lcovutil.pm ++++ b/usr/lib/lcov/lcovutil.pm +@@ -5213,6 +5213,19 @@ sub files + return keys %{$self->[FILES]}; + } + ++sub directories ++{ ++ my $self = shift; ++ # return hash of directories whcih contain source files ++ my %dirs; ++ foreach my $f ($self->files()) { ++ my $d = File::Basename::dirname($f); ++ $dirs{$d} = [] unless exists($dirs{$d}); ++ push(@{$dirs{$d}}, $f); ++ } ++ return \%dirs; ++} ++ + sub file_exists + { + my ($self, $name) = @_; +EOF + # cleanup apt-get -y clean apt-get -y autoclean