178 lines
6.9 KiB
Diff
178 lines
6.9 KiB
Diff
diff -u b/src/journal.sh b/src/journal.sh
|
|
--- b/src/journal.sh
|
|
+++ b/src/journal.sh
|
|
@@ -115,12 +115,13 @@
|
|
export __INTERNAL_METAFILE_INDENT_LEVEL=0
|
|
__INTERNAL_PHASE_TYPE=()
|
|
__INTERNAL_PHASE_NAME=()
|
|
- export __INTERNAL_PRESISTENT_DATA="$BEAKERLIB_DIR/PersistentData"
|
|
+ export __INTERNAL_PERSISTENT_DATA="$BEAKERLIB_DIR/PersistentData"
|
|
+ export __INTERNAL_TEST_RESULTS="$BEAKERLIB_DIR/TestResults"
|
|
export __INTERNAL_JOURNAL_OPEN=''
|
|
__INTERNAL_PersistentDataLoad
|
|
export __INTERNAL_PHASES_FAILED=0
|
|
export __INTERNAL_PHASES_PASSED=0
|
|
- export __INTERNAL_PHASES_SKIPED=0
|
|
+ export __INTERNAL_PHASES_SKIPPED=0
|
|
export __INTERNAL_PHASES_WORST_RESULT='PASS'
|
|
export __INTERNAL_TEST_STATE=0
|
|
__INTERNAL_PHASE_TXTLOG_START=()
|
|
@@ -249,6 +250,7 @@
|
|
|
|
echo "#End of metafile" >> $__INTERNAL_BEAKERLIB_METAFILE
|
|
__INTERNAL_JournalXMLCreate
|
|
+ __INTERNAL_TestResultsSave
|
|
}
|
|
|
|
|
|
@@ -346,11 +348,11 @@
|
|
|
|
__INTERNAL_update_journal_txt() {
|
|
local textfile
|
|
- local duration=$(($__INTERNAL_TIMESTAMP - $__INTERNAL_STARTTIME))
|
|
local endtime
|
|
+ __INTERNAL_DURATION=$(($__INTERNAL_TIMESTAMP - $__INTERNAL_STARTTIME))
|
|
printf -v endtime "%($__INTERNAL_TIMEFORMAT_LONG)T %s" $__INTERNAL_TIMESTAMP "(still running)"
|
|
[[ -n "$__INTERNAL_ENDTIME" ]] && printf -v endtime "%($__INTERNAL_TIMEFORMAT_LONG)T" $__INTERNAL_ENDTIME
|
|
- local sed_patterns="0,/ Test finished : /s/^( Test finished : ).*\$/\1$endtime/;0,/ Test duration : /s/^( Test duration : ).*\$/\1$duration seconds/"
|
|
+ local sed_patterns="0,/ Test finished : /s/^( Test finished : ).*\$/\1$endtime/;0,/ Test duration : /s/^( Test duration : ).*\$/\1$__INTERNAL_DURATION seconds/"
|
|
for textfile in "$__INTERNAL_BEAKERLIB_JOURNAL_COLORED" "$__INTERNAL_BEAKERLIB_JOURNAL_TXT"; do
|
|
sed -r -i "$sed_patterns" "$textfile"
|
|
done
|
|
@@ -439,6 +441,43 @@
|
|
return 0
|
|
}
|
|
|
|
+
|
|
+# Creation of TestResults file
|
|
+# Each line of the file contains TESTRESULT_VAR=$RESULT_VALUE
|
|
+# so the file can be sourced afterwards
|
|
+__INTERNAL_TestResultsSave(){
|
|
+ # Set exit code of the test according to worst phase result
|
|
+ case "$__INTERNAL_PHASES_WORST_RESULT" in
|
|
+ PASS)
|
|
+ __TESTRESULT_RESULT_ECODE="0"
|
|
+ ;;
|
|
+ WARN)
|
|
+ __TESTRESULT_RESULT_ECODE="10"
|
|
+ ;;
|
|
+ FAIL)
|
|
+ __TESTRESULT_RESULT_ECODE="20"
|
|
+ ;;
|
|
+ *)
|
|
+ __TESTRESULT_RESULT_ECODE="30"
|
|
+ ;;
|
|
+ esac
|
|
+
|
|
+ cat > "$__INTERNAL_TEST_RESULTS" <<EOF
|
|
+# This is a result file of the test in a 'sourceable' form.
|
|
+# Description of individual variables can be found in beakerlib man page.
|
|
+TESTRESULT_RESULT_STRING=$__INTERNAL_PHASES_WORST_RESULT
|
|
+TESTRESULT_RESULT_ECODE=$__TESTRESULT_RESULT_ECODE
|
|
+TESTRESULT_PHASES_PASSED=$__INTERNAL_PHASES_PASSED
|
|
+TESTRESULT_PHASES_FAILED=$__INTERNAL_PHASES_FAILED
|
|
+TESTRESULT_PHASES_SKIPPED=$__INTERNAL_PHASES_SKIPPED
|
|
+TESTRESULT_ASSERTS_FAILED=$__INTERNAL_TEST_STATE
|
|
+TESTRESULT_STARTTIME=$__INTERNAL_STARTTIME
|
|
+TESTRESULT_ENDTIME=$__INTERNAL_ENDTIME
|
|
+TESTRESULT_DURATION=$__INTERNAL_DURATION
|
|
+TESTRESULT_BEAKERLIB_DIR=$BEAKERLIB_DIR
|
|
+EOF
|
|
+}
|
|
+
|
|
# backward compatibility
|
|
rlCreateLogFromJournal(){
|
|
rlLogWarning "rlCreateLogFromJournal is obsoleted by rlJournalPrintText"
|
|
@@ -891,29 +930,29 @@
|
|
}
|
|
|
|
|
|
-# whenever any of the persistend variable is touched,
|
|
+# whenever any of the persistent variable is touched,
|
|
# functions __INTERNAL_PersistentDataLoad and __INTERNAL_PersistentDataSave
|
|
# should be called before and after that respectively.
|
|
|
|
__INTERNAL_PersistentDataSave() {
|
|
- cat > "$__INTERNAL_PRESISTENT_DATA" <<EOF
|
|
+ cat > "$__INTERNAL_PERSISTENT_DATA" <<EOF
|
|
__INTERNAL_STARTTIME=$__INTERNAL_STARTTIME
|
|
__INTERNAL_TEST_STATE=$__INTERNAL_TEST_STATE
|
|
__INTERNAL_PHASES_PASSED=$__INTERNAL_PHASES_PASSED
|
|
__INTERNAL_PHASES_FAILED=$__INTERNAL_PHASES_FAILED
|
|
-__INTERNAL_PHASES_SKIPED=$__INTERNAL_PHASES_SKIPED
|
|
+__INTERNAL_PHASES_SKIPPED=$__INTERNAL_PHASES_SKIPPED
|
|
__INTERNAL_JOURNAL_OPEN=$__INTERNAL_JOURNAL_OPEN
|
|
__INTERNAL_PHASES_WORST_RESULT=$__INTERNAL_PHASES_WORST_RESULT
|
|
EOF
|
|
-declare -p __INTERNAL_PHASE_FAILED >> $__INTERNAL_PRESISTENT_DATA
|
|
-declare -p __INTERNAL_PHASE_PASSED >> $__INTERNAL_PRESISTENT_DATA
|
|
-declare -p __INTERNAL_PHASE_STARTTIME >> $__INTERNAL_PRESISTENT_DATA
|
|
-declare -p __INTERNAL_PHASE_TXTLOG_START >> $__INTERNAL_PRESISTENT_DATA
|
|
-declare -p __INTERNAL_PHASE_METRICS >> $__INTERNAL_PRESISTENT_DATA
|
|
+declare -p __INTERNAL_PHASE_FAILED >> $__INTERNAL_PERSISTENT_DATA
|
|
+declare -p __INTERNAL_PHASE_PASSED >> $__INTERNAL_PERSISTENT_DATA
|
|
+declare -p __INTERNAL_PHASE_STARTTIME >> $__INTERNAL_PERSISTENT_DATA
|
|
+declare -p __INTERNAL_PHASE_TXTLOG_START >> $__INTERNAL_PERSISTENT_DATA
|
|
+declare -p __INTERNAL_PHASE_METRICS >> $__INTERNAL_PERSISTENT_DATA
|
|
}
|
|
|
|
__INTERNAL_PersistentDataLoad() {
|
|
- [[ -r "$__INTERNAL_PRESISTENT_DATA" ]] && . "$__INTERNAL_PRESISTENT_DATA"
|
|
+ [[ -r "$__INTERNAL_PERSISTENT_DATA" ]] && . "$__INTERNAL_PERSISTENT_DATA"
|
|
}
|
|
|
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
only in patch2:
|
|
unchanged:
|
|
--- a/src/beakerlib.sh
|
|
+++ b/src/beakerlib.sh
|
|
@@ -96,6 +96,48 @@ See the BKRDOC section for more information about Automated documentation genera
|
|
|
|
=for comment beakerlib-manual-footer
|
|
|
|
+=head1 OUTPUT FILES
|
|
+
|
|
+Location of test results related output files can be configured by setting BEAKERLIB_DIR variable before running the test. If it is not set, temporary directory is created.
|
|
+
|
|
+=head2 journal.txt
|
|
+
|
|
+Journal in human readable form.
|
|
+
|
|
+=head2 journal.xml
|
|
+
|
|
+Journal in XML format, requires python. This dependency can be avoided if the test is run with variable BEAKERLIB_JOURNAL set to 0 in which case journal.xml is not created.
|
|
+
|
|
+=head3 XSLT
|
|
+
|
|
+XML journal can be transformed through XSLT template. Which template is used is configurable by setting BEAKERLIB_JOURNAL variable. Value can be either filename in which case beakerlib will try to use $INSTALL_DIR/xslt-template/$filename (e.g.: /usr/share/beakerlib/xstl-templates/xunit.xsl) or it can be path to a template anywhere on the system.
|
|
+
|
|
+=head2 TestResults
|
|
+
|
|
+Overall results of the test in a 'sourceable' form. Each line contains a pair VAR=VALUE. All variable names have 'TESTRESULT_' prefix.
|
|
+
|
|
+=head3 List of variables:
|
|
+
|
|
+TESTRESULT_RESULT_STRING - Result of the test in a string, e.g.: PASS, FAIL, WARN.
|
|
+
|
|
+TESTRESULT_RESULT_ECODE - Result of the test as an integer, 0 equals to PASS.
|
|
+
|
|
+TESTRESULT_PHASES_PASSED - Number of phases that ended with PASS.
|
|
+
|
|
+TESTRESULT_PHASES_FAILED - Number of phases that ended with non-PASS result.
|
|
+
|
|
+TESTRESULT_PHASES_SKIPPED - Number of skipped phases.
|
|
+
|
|
+TESTRESULT_ASSERTS_FAILED - Number of asserts that ended with non-PASS result in the whole test.
|
|
+
|
|
+TESTRESULT_STARTTIME - Time when test started in seconds since epoch.
|
|
+
|
|
+TESTRESULT_ENDTIME - Time when test ended in seconds since epoch.
|
|
+
|
|
+TESTRESULT_DURATION - Duration of the test run in seconds.
|
|
+
|
|
+TESTRESULT_BEAKERLIB_DIR - Directory with test results files.
|
|
+
|
|
=head1 EXAMPLES
|
|
|
|
=head2 Simple
|