code-coverage: Add options to branch coverage to pass them to genhtml
diff --git a/coverage-tool/coverage-reporting/branch_coverage.sh b/coverage-tool/coverage-reporting/branch_coverage.sh
index f9d9a57..9b946a8 100755
--- a/coverage-tool/coverage-reporting/branch_coverage.sh
+++ b/coverage-tool/coverage-reporting/branch_coverage.sh
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
##############################################################################
-# Copyright (c) 2020, ARM Limited and Contributors. All rights reserved.
+# Copyright (c) 2025, ARM Limited and Contributors. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
##############################################################################
@@ -54,11 +54,14 @@
Required.\n"
printf "\t --json-path Intermediate json file name. Optional defaults to \
'output_file.json'\n"
+ printf "\t --genhtml-<parameter>=arg Arguments to be passed to \
+ genhtml[Optional]\n"
printf "\t --outdir Report folder. Optional defaults to 'out'\n"
printf "\t -h|--help Display usage\n"
printf "Example of usage:\n"
printf "./branch_coverage.sh --config config_file.json \
- --workspace /server_side/source/ --outdir html_report\n"
+ --workspace /server_side/source/ --outdir html_report \
+ --genhtml-title='My code coverage'\n"
exit 1
}
@@ -80,7 +83,9 @@
###############################################################################
parse_arguments()
{
- while [ $# -gt 1 ]
+ genhtml_args=()
+ genhtml_params=()
+ while [ $# -ge 1 ]
do
key="$1"
case $key in
@@ -100,6 +105,13 @@
OUTDIR="$2"
shift
;;
+ --genhtml-*)
+ input="${key#--genhtml-}"
+ key="${input%%=*}"
+ value="${input#*=}"
+ genhtml_params+=("--${key}")
+ genhtml_args+=("${value}")
+ ;;
-h|--help)
usage
;;
@@ -113,7 +125,7 @@
}
-parse_arguments $@
+parse_arguments "$@"
if [ -z "$LOCAL_WORKSPACE" ] || [ -z "$CONFIG_JSON" ]; then
usage
@@ -132,12 +144,20 @@
# clear may fail within a container-enviroment due to lack of
# TERM enviroment, so ignore this and other possible errors
clear || true
+#declare -p genhtml_params
+#declare -p genhtml_args
echo "Generating intermediate layer file '$JSON_PATH'..."
python3 intermediate_layer.py --config-json "$CONFIG_JSON" --local-workspace $LOCAL_WORKSPACE
echo "Converting intermediate layer file to info file..."
python3 generate_info_file.py --workspace $LOCAL_WORKSPACE --json $JSON_PATH
echo "Generating LCOV report at '$OUTDIR'..."
-genhtml --branch-coverage coverage.info --output-directory $OUTDIR
+s=""
+for (( j=0; j<${#genhtml_params[@]}; j++ ));
+do
+ s="${s} ${genhtml_params[$j]} "\"${genhtml_args[$j]}\"
+done
+
+eval genhtml --branch-coverage coverage.info --output-directory $OUTDIR $s || (genhtml --version;genhtml --help)
mv coverage.info $OUTDIR/coverage.info
mv error_log.txt $OUTDIR/error_log.txt