From 6867e5520011d0ade9b70ba4346f7ed6213b7a5d Mon Sep 17 00:00:00 2001 From: Sebastian Chlad Date: Tue, 5 May 2020 12:31:58 +0200 Subject: [PATCH] check: Add option for report generation As of now the tests results are generated over multiple files for each test device and each test separetly. This patch is introducing new -R option, following the idea from xfstests, so that general report could be prepared --- check | 24 +++++++++++++++++++++++- common/reports | 30 ++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 common/reports diff --git a/check b/check index 0a4e539a..bc31a325 100755 --- a/check +++ b/check @@ -386,6 +386,10 @@ _call_test() { _write_test_run _output_test_run + if [[ $GENERATE_REPORT -eq 1 ]]; then + _generate_test_report + fi + if [[ ${TEST_RUN["status"]} = fail ]]; then case "${TEST_RUN["reason"]}" in output) @@ -585,6 +589,15 @@ _check() { # shellcheck disable=SC2034 SRCDIR="$(realpath src)" + if [[ $GENERATE_REPORT -eq 1 && $REPORT_FORMAT != 'text' ]]; then + _error "Supported report formats: text" + else + # shellcheck disable=SC1091 + . "common/reports" + _report_main + fi + + local test_dev for test_dev in "${TEST_DEVS[@]}"; do if [[ ! -e $test_dev ]]; then @@ -644,6 +657,9 @@ Test runs: -x, --exclude=TEST exclude a test (or test group) from the list of tests to run + -R, --report=format generate report in specified format for each TEST_DEVS + Supported formats: text + Miscellaneous: -c, --config=FILE load configuration from FILE instead of the default (\"./config\"); if this option is used multiple times, @@ -663,7 +679,7 @@ Miscellaneous: esac } -if ! TEMP=$(getopt -o 'do:q::x:c:h' --long 'device-only,quick::,exclude:,output:,config:,help' -n "$0" -- "$@"); then +if ! TEMP=$(getopt -o 'do:q::x:R:c:h' --long 'device-only,quick::,exclude:,output:,report:,config:,help' -n "$0" -- "$@"); then exit 1 fi @@ -672,6 +688,7 @@ unset TEMP LOADED_CONFIG=0 OPTION_EXCLUDE=() +GENERATE_REPORT=0 while true; do case "$1" in '-d'|'--device-only') @@ -692,6 +709,11 @@ while true; do OPTION_EXCLUDE+=("$2") shift 2 ;; + '-R'|'--report') + GENERATE_REPORT=1 + REPORT_FORMAT="$2" + shift 2 + ;; '-c'|'--config') # shellcheck source=/dev/null . "$2" diff --git a/common/reports b/common/reports new file mode 100644 index 00000000..305ed972 --- /dev/null +++ b/common/reports @@ -0,0 +1,30 @@ +#!/bin/bash + +_generate_test_report() { + local device + device="$(basename "$RESULTS_DIR")" + + #xunit to follow + if [[ $REPORT_FORMAT == 'text' ]]; then + printf '\n%s\n' "$device" >> "$AGGRES" + printf '%s\n' "$TEST_NAME" >> "$AGGRES" + + local key value + for key in "${!TEST_RUN[@]}"; do + value="${TEST_RUN["$key"]}" + printf '%s\t%s\n' "$key" "$value" >> "$AGGRES" + done + fi +} + +_report_main() { + AGGRES="${OUTPUT}/report_${REPORT_FORMAT}" + + echo "genereting report ... ${REPORT_FORMAT} (in ${AGGRES})" + + #xunit to follow + if [[ $REPORT_FORMAT == 'text' ]]; then + echo "$REPORT_FORMAT report generated on $(date)" > "$AGGRES" + fi +} +