xref: /openbmc/qemu/scripts/ci/coverage-summary.sh (revision 3ea85609)
1*04250c69SPhilippe Mathieu-Daudé#!/bin/sh
2*04250c69SPhilippe Mathieu-Daudé#
3*04250c69SPhilippe Mathieu-Daudé# Author: Alex Bennée <alex.bennee@linaro.org>
4*04250c69SPhilippe Mathieu-Daudé#
5*04250c69SPhilippe Mathieu-Daudé# Summerise the state of code coverage with gcovr and tweak the output
6*04250c69SPhilippe Mathieu-Daudé# to be more sane on CI runner. As we expect to be executed on a
7*04250c69SPhilippe Mathieu-Daudé# throw away CI instance we do spam temp files all over the shop. You
8*04250c69SPhilippe Mathieu-Daudé# most likely don't want to execute this script but just call gcovr
9*04250c69SPhilippe Mathieu-Daudé# directly. See also "make coverage-report"
10*04250c69SPhilippe Mathieu-Daudé#
11*04250c69SPhilippe Mathieu-Daudé# This code is licensed under the GPL version 2 or later.  See
12*04250c69SPhilippe Mathieu-Daudé# the COPYING file in the top-level directory.
13*04250c69SPhilippe Mathieu-Daudé
14*04250c69SPhilippe Mathieu-Daudé# first generate the coverage report
15*04250c69SPhilippe Mathieu-Daudégcovr -p -o raw-report.txt
16*04250c69SPhilippe Mathieu-Daudé
17*04250c69SPhilippe Mathieu-Daudé# strip the full-path and line markers
18*04250c69SPhilippe Mathieu-Daudésed s@$PWD\/@@ raw-report.txt | sed s/[0-9]\*[,-]//g > simplified.txt
19*04250c69SPhilippe Mathieu-Daudé
20*04250c69SPhilippe Mathieu-Daudé# reflow lines that got split
21*04250c69SPhilippe Mathieu-Daudéawk '/.[ch]$/ { printf("%s", $0); next } 1' simplified.txt > rejoined.txt
22*04250c69SPhilippe Mathieu-Daudé
23*04250c69SPhilippe Mathieu-Daudé# columnify
24*04250c69SPhilippe Mathieu-Daudécolumn -t rejoined.txt > final.txt
25*04250c69SPhilippe Mathieu-Daudé
26*04250c69SPhilippe Mathieu-Daudé# and dump, stripping out 0% coverage
27*04250c69SPhilippe Mathieu-Daudégrep -v "0%" final.txt
28