Skip to content

Commit

Permalink
.github: scripts: gen_coverage_reports.sh: Integrated new genhtml int…
Browse files Browse the repository at this point in the history
…o CI

Signed-off-by: Jan Bylicki <[email protected]>
  • Loading branch information
jbylicki committed Jul 16, 2024
1 parent b45cb9a commit 0dbbd4d
Showing 1 changed file with 48 additions and 25 deletions.
73 changes: 48 additions & 25 deletions .github/scripts/gen_coverage_reports.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,42 +8,66 @@ generate_coverage_reports(){
# Args
# OUTPUT_DIR - directory, where index.html will be placed
# GIT_SHA - git revision
check_args_count $# 2
OUTPUT_DIR=$1
GENHTML_OPTS=$2
echo -e "${COLOR_WHITE}========== generate_coverage_reports =========${COLOR_CLEAR}"
echo -e "${COLOR_WHITE}OUTPUT_DIR = ${OUTPUT_DIR}${COLOR_CLEAR}"
echo -e "${COLOR_WHITE}GENHTML_OPTS = ${GENHTML_OPTS}${COLOR_CLEAR}"

for info_file in `find . -name '*.info'`; do
lcov --extract ${info_file} \*design\* -o ${info_file}
done

for COVERAGE in branch toggle all functional; do
DIR=${OUTPUT_DIR}/${COVERAGE}
# Summary
mkdir -p ${DIR}
FILES=`find . -name "coverage_*_${COVERAGE}.info" -printf "%P\n"`
BRANCH_MERGED="./merged_branch.info"
TOGGLE_MERGED="./merged_toggle.info"
BRANCH_MERGED_SUMMMARY="./merged_branch.summary"
TOGGLE_MERGED_SUMMMARY="./merged_toggle.summary"

if [ -z "$FILES" ]; then
echo -e "${COLOR_WHITE}There are no files for coverage ${COVERAGE} ${COLOR_YELLOW}WARNING${COLOR_CLEAR}"
else
# genhtml -o ${DIR} -t "all" ${GENHTML_OPTS} ${FILES}
genhtml -o ${DIR} -t "all" --header-title "RTL ${COVERAGE} coverage report" ${GENHTML_OPTS} ${FILES}
find ${DIR}/ -name "*.html" -exec sed -i "s/Line Coverage/${COVERAGE^} Coverage/g" {} +
declare -A branch_files
declare -A toggle_files

# Individual per-test
for FILE in ${FILES}; do
TEST=${FILE/coverage_/}
TEST=${TEST/_${COVERAGE}.info/}
FILES=`find . -name "coverage_*.info" -printf "%P\n"`

mkdir -p ${DIR}_${TEST}
# genhtml -o ${DIR}_${TEST} -t ${TEST} ${GENHTML_OPTS} ${FILE}
genhtml -o ${DIR}_${TEST} -t ${TEST} --header-title "RTL ${COVERAGE} coverage report" ${GENHTML_OPTS} ${FILE}
find ${DIR}_${TEST}/ -name "*.html" -exec sed -i "s/Line Coverage/${COVERAGE^} Coverage/g" {} +
done
for file in $FILES; do
if [[ $file == *_branch.info ]]; then
name_body=${file%_branch.info}
branch_files[$name_body]=$file
elif [[ $file == *_toggle.info ]]; then
name_body=${file%_toggle.info}
toggle_files[$name_body]=$file
fi
done

for name_body in "${!branch_files[@]}"; do
branch_file=${branch_files[$name_body]}
toggle_file=${toggle_files[$name_body]}
test_name=${name_body#coverage_}
if [[ -f "$branch_file" ]]; then
lcov -l $branch_file > "$name_body"_branch.summary
fi
if [[ -f "$toggle_file" ]]; then
lcov -l $toggle_file > "$name_body"_toggle.summary
fi
mkdir -p $OUTPUT_DIR/all_"$test_name"/
python3 $SELF_DIR/indexgen/genhtml.py "$name_body"_toggle.summary "$name_body"_branch.summary --output-dir $OUTPUT_DIR/all_"$test_name"/ --test-name "$test_name"
cp $SELF_DIR/indexgen/dashboard-styles/gcov.css $OUTPUT_DIR/all_"$test_name"/
done

for branch_file in "${branch_files[@]}"; do
lcov -a "$branch_file" -o "$BRANCH_MERGED"
done
if [[ -f $BRANCH_MERGED ]]; then
lcov -l "$BRANCH_MERGED" > $BRANCH_MERGED_SUMMMARY
fi

for toggle_file in "${toggle_files[@]}"; do
lcov -a "$toggle_file" -o "$TOGGLE_MERGED"
done
if [[ -f $TOGGLE_MERGED ]]; then
lcov -l "$TOGGLE_MERGED" > $TOGGLE_MERGED_SUMMMARY
fi

mkdir -p $OUTPUT_DIR/all
python3 $SELF_DIR/indexgen/genhtml.py "$TOGGLE_MERGED_SUMMMARY" "$BRANCH_MERGED_SUMMMARY" --output-dir $OUTPUT_DIR/all/ --test-name all
cp $SELF_DIR/indexgen/dashboard-styles/gcov.css $OUTPUT_DIR/all/
}

#--------------#
Expand All @@ -60,11 +84,10 @@ fi
set -e
OUTPUT_DIR=report
mkdir -p ${OUTPUT_DIR}
GENHTML_OPTS="--no-function-coverage --no-source"

echo -e "${COLOR_WHITE}========== gen_coverage_reports ==============${COLOR_CLEAR}"

generate_coverage_reports ${OUTPUT_DIR} "${GENHTML_OPTS}"
generate_coverage_reports ${OUTPUT_DIR}

echo -e "${COLOR_WHITE}gen_coverage_reports ${COLOR_GREEN}SUCCEEDED${COLOR_CLEAR}"
echo -e "${COLOR_WHITE}========== gen_coverage_reports ==============${COLOR_CLEAR}"

0 comments on commit 0dbbd4d

Please sign in to comment.