From e5f17555430c57dd9e537a14bf6362f5d0e70251 Mon Sep 17 00:00:00 2001 From: Packit Service Date: Dec 09 2020 08:22:03 +0000 Subject: Prepare for a new update Reverting patches so we can apply the latest update and changes can be seen in the spec file and sources. --- diff --git a/src/analyze.sh b/src/analyze.sh index f8f3137..87f5102 100644 --- a/src/analyze.sh +++ b/src/analyze.sh @@ -76,7 +76,6 @@ Return 0 if... TODO =cut rlDejaSum(){ - local IFS rlLog "Summarizing files: $1 $2" rlLogDebug "Calling beakerlib-deja-summarize routine" beakerlib-deja-summarize $1 $2 | while read line diff --git a/src/beakerlib.sh b/src/beakerlib.sh index 5d936a5..ad57505 100644 --- a/src/beakerlib.sh +++ b/src/beakerlib.sh @@ -96,48 +96,6 @@ 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 @@ -316,14 +274,10 @@ https://github.com/beakerlib/beakerlib/wiki/man =item Issues list -https://bugzilla.redhat.com/buglist.cgi?component=beakerlib&&order=bug_status%2Cassigned_to%2Cpriority - https://github.com/beakerlib/beakerlib/issues =item Reporting issues -https://bugzilla.redhat.com/enter_bug.cgi?product=Fedora&component=beakerlib - https://github.com/beakerlib/beakerlib/issues/new =back diff --git a/src/journal.sh b/src/journal.sh index 3683498..03d4fad 100644 --- a/src/journal.sh +++ b/src/journal.sh @@ -115,12 +115,12 @@ rlJournalStart(){ export __INTERNAL_METAFILE_INDENT_LEVEL=0 __INTERNAL_PHASE_TYPE=() __INTERNAL_PHASE_NAME=() - export __INTERNAL_PERSISTENT_DATA="$BEAKERLIB_DIR/PersistentData" - export __INTERNAL_TEST_RESULTS="$BEAKERLIB_DIR/TestResults" + export __INTERNAL_PRESISTENT_DATA="$BEAKERLIB_DIR/PersistentData" export __INTERNAL_JOURNAL_OPEN='' + __INTERNAL_PersistentDataLoad export __INTERNAL_PHASES_FAILED=0 export __INTERNAL_PHASES_PASSED=0 - export __INTERNAL_PHASES_SKIPPED=0 + export __INTERNAL_PHASES_SKIPED=0 export __INTERNAL_PHASES_WORST_RESULT='PASS' export __INTERNAL_TEST_STATE=0 __INTERNAL_PHASE_TXTLOG_START=() @@ -129,20 +129,16 @@ rlJournalStart(){ __INTERNAL_PHASE_STARTTIME=() __INTERNAL_PHASE_METRICS=() export __INTERNAL_PHASE_OPEN=0 - __INTERNAL_PersistentDataLoad if [[ -z "$__INTERNAL_JOURNAL_OPEN" ]]; then # Create Header for XML journal __INTERNAL_CreateHeader # Create log element for XML journal - __INTERNAL_WriteToMetafile log || { - __INTERNAL_LogText "could not write to metafile" FATAL - exit 1 - } - __INTERNAL_JOURNAL_OPEN=1 - # Increase level of indent - __INTERNAL_METAFILE_INDENT_LEVEL=1 + __INTERNAL_WriteToMetafile log fi + __INTERNAL_JOURNAL_OPEN=1 + # Increase level of indent + __INTERNAL_METAFILE_INDENT_LEVEL=1 # display a warning message if run in POSIX mode if [ $POSIXFIXED == "YES" ] ; then @@ -242,8 +238,6 @@ rlJournalEnd(){ __INTERNAL_ENDTIME=$__INTERNAL_TIMESTAMP __INTERNAL_update_journal_txt - __INTERNAL_PrintHeadLog "${__INTERNAL_TEST_NAME}" 2>&1 - if [ -n "$TESTID" ] ; then __INTERNAL_JournalXMLCreate $BEAKERLIB_COMMAND_SUBMIT_LOG -T $TESTID -l $__INTERNAL_BEAKERLIB_JOURNAL \ @@ -254,17 +248,7 @@ rlJournalEnd(){ fi echo "#End of metafile" >> $__INTERNAL_BEAKERLIB_METAFILE - - __INTERNAL_PrintFootLog $__INTERNAL_STARTTIME \ - $__INTERNAL_ENDTIME \ - Phases \ - $__INTERNAL_PHASES_PASSED \ - $__INTERNAL_PHASES_FAILED \ - $__INTERNAL_PHASES_WORST_RESULT \ - "OVERALL" - __INTERNAL_JournalXMLCreate - __INTERNAL_TestResultsSave } @@ -283,25 +267,8 @@ rlJournalEnd(){ #=cut __INTERNAL_JournalXMLCreate() { - local res=0 - [[ "$BEAKERLIB_JOURNAL" == "0" ]] || { - if which /usr/libexec/platform-python &> /dev/null; then - $__INTERNAL_JOURNALIST $__INTERNAL_XSLT --metafile \ - "$__INTERNAL_BEAKERLIB_METAFILE" --journal "$__INTERNAL_BEAKERLIB_JOURNAL" - res=$? - if [[ $res -eq 2 ]]; then - rlLogError "cannot create journal.xml due to missing some python module" - elif [[ $res -eq 3 ]]; then - rlLogError "cannot create journal.xml due to missing python lxml module" - elif [[ $res -ne 0 ]]; then - rlLogError "journal.xml creation failed!" - fi - else - rlLogError "cannot create journal.xml due to missing python interpreter" - let res++ - fi - } - return $res + [[ "$BEAKERLIB_JOURNAL" == "0" ]] || $__INTERNAL_JOURNALIST $__INTERNAL_XSLT --metafile \ + "$__INTERNAL_BEAKERLIB_METAFILE" --journal "$__INTERNAL_BEAKERLIB_JOURNAL" } @@ -379,11 +346,11 @@ rlPrintJournal() { __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$__INTERNAL_DURATION seconds/" + local sed_patterns="0,/ Test finished : /s/^( Test finished : ).*\$/\1$endtime/;0,/ Test duration : /s/^( Test duration : ).*\$/\1$duration seconds/" for textfile in "$__INTERNAL_BEAKERLIB_JOURNAL_COLORED" "$__INTERNAL_BEAKERLIB_JOURNAL_TXT"; do sed -r -i "$sed_patterns" "$textfile" done @@ -462,44 +429,14 @@ rlJournalPrintText(){ [[ -t 1 ]] && textfile="$__INTERNAL_BEAKERLIB_JOURNAL_COLORED" || textfile="$__INTERNAL_BEAKERLIB_JOURNAL_TXT" cat "$textfile" - return 0 -} - + local tmp="$__INTERNAL_LogText_no_file" + __INTERNAL_LogText_no_file=1 + __INTERNAL_PrintHeadLog "${TEST}" 2>&1 + __INTERNAL_LogText "Phases: $__INTERNAL_PHASES_PASSED good, $__INTERNAL_PHASES_FAILED bad" LOG 2>&1 + __INTERNAL_LogText "RESULT: $TEST" $__INTERNAL_PHASES_WORST_RESULT 2>&1 + __INTERNAL_LogText_no_file=$tmp -# 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" <&2 # Printing __INTERNAL_PrintHeadLog "$MSG" - if [[ "$BEAKERLIB_NESTED_PHASES" == "0" ]]; then + if [[ -z "$BEAKERLIB_NESTED_PHASES" ]]; then __INTERNAL_METAFILE_INDENT_LEVEL=2 __INTERNAL_PHASE_TYPE=( "$1" ) __INTERNAL_PHASE_NAME=( "$MSG" ) __INTERNAL_PHASE_FAILED=( 0 ) __INTERNAL_PHASE_PASSED=( 0 ) __INTERNAL_PHASE_STARTTIME=( $__INTERNAL_TIMESTAMP ) - __INTERNAL_PHASE_TXTLOG_START=( $TXTLOG_START ) + __INTERNAL_PHASE_TXTLOG_START=( $(wc -l $__INTERNAL_BEAKERLIB_JOURNAL_TXT) ) __INTERNAL_PHASE_OPEN=${#__INTERNAL_PHASE_NAME[@]} __INTERNAL_PHASE_METRICS=( "" ) else @@ -625,19 +562,18 @@ rljClosePhase(){ rlLogDebug "rljClosePhase: Phase $name closed" __INTERNAL_SET_TIMESTAMP local endtime="$__INTERNAL_TIMESTAMP" - __INTERNAL_PrintFootLog $__INTERNAL_PHASE_STARTTIME \ - $endtime \ - Assertions \ - $__INTERNAL_PHASE_PASSED \ - $__INTERNAL_PHASE_FAILED \ - $result + __INTERNAL_LogText "________________________________________________________________________________" + __INTERNAL_LogText "Duration: $((endtime - __INTERNAL_PHASE_STARTTIME))s" LOG + __INTERNAL_LogText "Assertions: $__INTERNAL_PHASE_PASSED good, $__INTERNAL_PHASE_FAILED bad" LOG + __INTERNAL_LogText "RESULT: $name" $result + __INTERNAL_LogText '' local logfile="$(mktemp)" tail -n +$((__INTERNAL_PHASE_TXTLOG_START+1)) $__INTERNAL_BEAKERLIB_JOURNAL_TXT > $logfile - rlReport "$(echo "${name//[^[:alnum:]]/-}" | tr -s '-')" "$result" "$score" "$logfile" + rlReport "$(echo "$name" | sed 's/[^[:alnum:]]\+/-/g')" "$result" "$score" "$logfile" rm -f $logfile # Reset of state variables - if [[ "$BEAKERLIB_NESTED_PHASES" == "0" ]]; then + if [[ -z "$BEAKERLIB_NESTED_PHASES" ]]; then __INTERNAL_METAFILE_INDENT_LEVEL=1 __INTERNAL_PHASE_TYPE=() __INTERNAL_PHASE_NAME=() @@ -668,7 +604,6 @@ rljClosePhase(){ # $2 result # $3 command rljAddTest(){ - local IFS __INTERNAL_PersistentDataLoad if [ $__INTERNAL_PHASE_OPEN -eq 0 ]; then rlPhaseStart "FAIL" "Asserts collected outside of a phase" @@ -747,7 +682,6 @@ __INTERNAL_DeterminePackage(){ # Creates header __INTERNAL_CreateHeader(){ - local IFS __INTERNAL_PrintHeadLog "TEST PROTOCOL" 2> /dev/null @@ -788,7 +722,7 @@ __INTERNAL_CreateHeader(){ package="${packagename:-$test_version}" local test_built [[ -n "$package" ]] && test_built=$(rpm -q --qf '%{BUILDTIME}\n' $package) && { - test_built="$(echo "$test_built" | head -n 1 )" + test_built="$(ehco "$test_built" | head -n 1 )" printf -v test_built "%($__INTERNAL_TIMEFORMAT_LONG)T" "$test_built" __INTERNAL_WriteToMetafile testversion -- "$test_built" __INTERNAL_LogText " Test built : $test_built" 2> /dev/null @@ -803,9 +737,9 @@ __INTERNAL_CreateHeader(){ __INTERNAL_LogText " Test duration : " 2> /dev/null # Test name - __INTERNAL_TEST_NAME="${TEST:-unknown}" - __INTERNAL_WriteToMetafile testname -- "${__INTERNAL_TEST_NAME}" - __INTERNAL_LogText " Test name : ${__INTERNAL_TEST_NAME}" 2> /dev/null + TEST="${TEST:-unknown}" + __INTERNAL_WriteToMetafile testname -- "${TEST}" + __INTERNAL_LogText " Test name : ${TEST}" 2> /dev/null # OS release local release=$(cat /etc/redhat-release) @@ -841,7 +775,7 @@ __INTERNAL_CreateHeader(){ local count=0 local type="unknown" local cpu_regex="^model\sname.*: (.*)$" - while read -r line; do + while read line; do if [[ "$line" =~ $cpu_regex ]]; then type="${BASH_REMATCH[1]}" let count++ @@ -855,7 +789,7 @@ __INTERNAL_CreateHeader(){ if [[ -f "/proc/meminfo" ]]; then size=0 local ram_regex="^MemTotal: *(.*) kB$" - while read -r line; do + while read line; do if [[ "$line" =~ $ram_regex ]]; then size=`expr ${BASH_REMATCH[1]} / 1024` break @@ -918,13 +852,13 @@ __INTERNAL_WriteToMetafile(){ while [[ $# -gt 0 ]]; do case $1 in --) - line+=" -- $(echo -n "$2" | base64 -w 0)" + line+=" -- \"$(echo -n "$2" | base64 -w 0)\"" printf -v lineraw "%s -- %q" "$lineraw" "$2" shift 2 break ;; --*) - line+=" $1=$(echo -n "$2" | base64 -w 0)" + line+=" $1=\"$(echo -n "$2" | base64 -w 0)\"" printf -v lineraw "%s %s=%q" "$lineraw" "$1" "$2" shift ;; @@ -944,9 +878,9 @@ __INTERNAL_WriteToMetafile(){ printf -v indent '%*s' $__INTERNAL_METAFILE_INDENT_LEVEL - line="$indent${element:+$element }--timestamp=${__INTERNAL_TIMESTAMP}$line" - lineraw="$indent${element:+$element }--timestamp=${__INTERNAL_TIMESTAMP}$lineraw" - [[ -n "$DEBUG" ]] && echo "#${lineraw:1}" >> $__INTERNAL_BEAKERLIB_METAFILE + line="$indent${element:+$element }--timestamp=\"${__INTERNAL_TIMESTAMP}\"$line" + lineraw="$indent${element:+$element }--timestamp=\"${__INTERNAL_TIMESTAMP}\"$lineraw" + echo "#${lineraw:1}" >> $__INTERNAL_BEAKERLIB_METAFILE echo "$line" >> $__INTERNAL_BEAKERLIB_METAFILE } @@ -957,69 +891,29 @@ __INTERNAL_PrintHeadLog() { } -# $1 - start time -# $2 - end time -# $3 - stat name -# $4 - stat good -# $5 - stat bad -# $6 - result -# $7 - result prefix ' RESULT: ' -__INTERNAL_PrintFootLog(){ - local result_colored - local starttime="$1" - local endtime="$2" - local stat_name="$3" - local stat_good="$4" - local stat_bad="$5" - local result="$6" - local result_pref="$7" - [[ -n "$result_pref" ]] && result_pref+=" " - __INTERNAL_colorize_prio "$result" result_colored - __INTERNAL_LogText "::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::" - __INTERNAL_LogText ":: Duration: $((endtime - starttime))s" - __INTERNAL_LogText ":: $stat_name: $stat_good good, $stat_bad bad" - __INTERNAL_LogText ":: ${result_pref}RESULT: $result" '' '' \ - ":: ${result_pref}RESULT: $result_colored" - __INTERNAL_LogText '' -} - - -# whenever any of the persistent variable is touched, +# whenever any of the persistend variable is touched, # functions __INTERNAL_PersistentDataLoad and __INTERNAL_PersistentDataSave # should be called before and after that respectively. -__INTERNAL_PersistentDataSave_sed='s/^declare/\0 -g/' -# ugly workaround for bash-4.1.2 and older, where -g does not exist -# there might be an issue when there's a line break in the variables and there's -# "")'" or "()'" at the end of the line. This should not never happen, the worst -# case might happen in the phase name but is is not expected to contain line -# breaks -declare -g &> /dev/null || __INTERNAL_PersistentDataSave_sed="s/(^declare -a[^=]+=)'\(/\1(/;s/([\"(]\))'$/\1/;s/declare\s+\S+\s+([^=]+=)/\1/" - __INTERNAL_PersistentDataSave() { - declare -p \ - __INTERNAL_STARTTIME \ - __INTERNAL_TEST_STATE \ - __INTERNAL_PHASES_PASSED \ - __INTERNAL_PHASES_FAILED \ - __INTERNAL_PHASES_SKIPPED \ - __INTERNAL_JOURNAL_OPEN \ - __INTERNAL_PHASE_OPEN \ - __INTERNAL_PHASES_WORST_RESULT \ - __INTERNAL_METAFILE_INDENT_LEVEL \ - __INTERNAL_PHASE_TYPE \ - __INTERNAL_PHASE_NAME \ - __INTERNAL_PHASE_FAILED \ - __INTERNAL_PHASE_PASSED \ - __INTERNAL_PHASE_STARTTIME \ - __INTERNAL_PHASE_TXTLOG_START \ - __INTERNAL_PHASE_METRICS \ - __INTERNAL_TEST_NAME \ - | sed -r "$__INTERNAL_PersistentDataSave_sed" > "$__INTERNAL_PERSISTENT_DATA" + cat > "$__INTERNAL_PRESISTENT_DATA" <> $__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 } __INTERNAL_PersistentDataLoad() { - [[ -r "$__INTERNAL_PERSISTENT_DATA" ]] && . "$__INTERNAL_PERSISTENT_DATA" + [[ -r "$__INTERNAL_PRESISTENT_DATA" ]] && . "$__INTERNAL_PRESISTENT_DATA" } # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/src/libraries.sh b/src/libraries.sh index eb1c611..821f6ae 100644 --- a/src/libraries.sh +++ b/src/libraries.sh @@ -268,10 +268,9 @@ __INTERNAL_envdebugget() { __INTERNAL_envdebugdiff() { rlLogDebug "rlImport: library $1 changes following environment; changed functions are marked with asterisk (*)" diff -U0 <(echo "$__INTERNAL_envdebugvariables") <(__INTERNAL_envdebugget 1) | tail -n +3 | grep -E -v '^@@' - local line fn print='' print2 LF=$'\n' - local IFS - - while read -r line; do + local line fn print='' print2 LF=" +" + while IFS= read line; do [[ "$line" =~ ^(.)([^[:space:]]+)[[:space:]]\(\) ]] && { [[ -n "$print" ]] && { echo "$fn" diff --git a/src/logging.sh b/src/logging.sh index 59709df..680f14c 100644 --- a/src/logging.sh +++ b/src/logging.sh @@ -53,69 +53,47 @@ Implements also phase support with automatic assert evaluation. # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ __INTERNAL_PrintText() { - local __INTERNAL_LogText_no_file=1 + local tmp="$__INTERNAL_LogText_no_file" + __INTERNAL_LogText_no_file=1 __INTERNAL_LogText "$@" + __INTERNAL_LogText_no_file=$tmp } -# $1 - text to color -# $2 - variable to put the color sequence to -# $3 - variable to put the uncolor sequence to -__INTERNAL_get_prio_colors() { - local prio="$1" var_color="$2" var_uncolor="$3" - local ____COLOR='' ____UNCOLOR='' - if [[ -t 2 ]]; then - ____UNCOLOR="$__INTERNAL_color_reset" - case ${prio^^} in - DEBUG*) - ____COLOR="$__INTERNAL_color_purple" - ;; - PASS) - ____COLOR="$__INTERNAL_color_green" - ;; - FAIL|FATAL) - ____COLOR="$__INTERNAL_color_light_red" - ;; - LOG) - ____COLOR="$__INTERNAL_color_cyan" - ;; - LOG|INFO|BEGIN) - ____COLOR="$__INTERNAL_color_blue" - ;; - WARN*|SKIP*) - ____COLOR="$__INTERNAL_color_yellow" - ;; - esac - fi - eval "$var_color=\"${____COLOR}\"" - eval "$var_uncolor=\"${____UNCOLOR}\"" -} - -# $1 - text to color -# $2 - variable to put the result to -__INTERNAL_colorize_prio() { - local prio="$1" var="$2" - local COLOR='' UNCOLOR='' - __INTERNAL_get_prio_colors "$prio" COLOR UNCOLOR - eval "$var=\"$COLOR$prio$UNCOLOR\"" -} - -# $1 - MESSAGE -# $2 - prio -# $3 - LOGFILE -# $4 - MESSAGE_COLORED, if empty MESSAGE is used __INTERNAL_LogText() { local MESSAGE="$1" - local MESSAGE_COLORED="${4:-"$MESSAGE"}" + local MESSAGE_COLORED="${MESSAGE}" local prio="$2" local LOGFILE=${3:-$OUTPUTFILE} local res=0 local COLOR='' UNCOLOR='' + if [[ -t 2 ]]; then + UNCOLOR="$__INTERNAL_color_reset" + case ${prio^^} in + DEBUG*) + COLOR="$__INTERNAL_color_purple" + ;; + PASS) + COLOR="$__INTERNAL_color_green" + ;; + FAIL|FATAL) + COLOR="$__INTERNAL_color_light_red" + ;; + LOG) + COLOR="$__INTERNAL_color_cyan" + ;; + LOG|INFO|BEGIN) + COLOR="$__INTERNAL_color_blue" + ;; + WARN*|SKIP*) + COLOR="$__INTERNAL_color_yellow" + ;; + esac + fi [[ -n "$prio" ]] && { local left=$(( (10+${#prio})/2 )) local prefix prefix_colored timestamp __INTERNAL_SET_TIMESTAMP printf -v timestamp "%($__INTERNAL_TIMEFORMAT_SHORT)T" "$__INTERNAL_TIMESTAMP" - __INTERNAL_get_prio_colors "$prio" COLOR UNCOLOR printf -v prefix_colored ":: [ %s ] :: [%s%*s%*s%s] ::" "$timestamp" "$COLOR" "$left" "${prio}" "$(( 10-$left ))" '' "$UNCOLOR" printf -v prefix ":: [ %s ] :: [%*s%*s] ::" "$timestamp" "$left" "${prio}" "$(( 10-$left ))" MESSAGE="$prefix $MESSAGE" @@ -199,7 +177,7 @@ __INTERNAL_color_set() { [[ -t 1 ]] || T="" [[ -t 2 ]] || T="" case $T in - xterm*|screen|linux|rxvt*) + xterm*|screen|linux) __INTERNAL_color_black="\e[0;30m" __INTERNAL_color_dark_gray="\e[1;30m" __INTERNAL_color_red="\e[0;31m" @@ -261,12 +239,7 @@ DEBUG=${DEBUG:-""} rlLogDebug() { if [ "$DEBUG" == 'true' -o "$DEBUG" == '1' -o "$LOG_LEVEL" == "DEBUG" ]; then - if [[ -n "$DEBUG_TO_CONSOLE_ONLY" ]]; then - local __INTERNAL_LogText_no_file=1 - __INTERNAL_LogText "$1" "DEBUG" - else - rlLog "$1" "$2" "DEBUG" - fi + rlLog "$1" "$2" "DEBUG" && rljAddMessage "$1" "DEBUG" fi } rlLogInfo() { rlLog "$1" "$2" "INFO"; } @@ -556,7 +529,6 @@ Name of a package(s) you want to log. rlShowPackageVersion() { local score=0 - local IFS if [ $# -eq 0 ]; then rlLogWarning "rlShowPackageVersion: Too few options" return 1 diff --git a/src/python/daemonize.py b/src/python/daemonize.py index 4819903..efb4e08 100755 --- a/src/python/daemonize.py +++ b/src/python/daemonize.py @@ -1,4 +1,4 @@ -#!/usr/libexec/platform-python +#!/usr/bin/env python # Authors: Jiri Jaburek # @@ -18,7 +18,6 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -from __future__ import print_function import os, sys from pwd import getpwnam @@ -97,8 +96,8 @@ def daemonize(command, alias=None, pidfile=None, true_daemon=True, su=None, iore # with original stderr (in case of errors), but with new uid/gid if ioredir: os.open(ioredir[0], os.O_RDWR) - os.open(ioredir[1], os.O_RDWR | os.O_CREAT | os.O_TRUNC, 0o666) - os.open(ioredir[2], os.O_RDWR | os.O_CREAT | os.O_TRUNC, 0o666) + os.open(ioredir[1], os.O_RDWR | os.O_CREAT | os.O_TRUNC, 0666) + os.open(ioredir[2], os.O_RDWR | os.O_CREAT | os.O_TRUNC, 0666) os.umask(0) @@ -117,7 +116,7 @@ def daemonize(command, alias=None, pidfile=None, true_daemon=True, su=None, iore # argument parsing def error(msg): - print("error: " + str(msg), file=sys.stderr) + print >> sys.stderr, "error: " + str(msg) sys.exit(1) parser = OptionParser(usage='%prog [options] COMMAND') diff --git a/src/python/journal-compare.py b/src/python/journal-compare.py index 14ea23e..1fc8915 100755 --- a/src/python/journal-compare.py +++ b/src/python/journal-compare.py @@ -1,6 +1,6 @@ -#!/usr/libexec/platform-python +#!/usr/bin/python -# Copyright (c) 2006 Red Hat, Inc. All rights reserved. This copyrighted material +# Copyright (c) 2006 Red Hat, Inc. All rights reserved. This copyrighted material # is made available to anyone wishing to use, modify, copy, or # redistribute it subject to the terms and conditions of the GNU General # Public License v.2. @@ -15,7 +15,6 @@ # # Author: Petr Muller -from __future__ import print_function import xml.dom.minidom import sys @@ -126,9 +125,9 @@ class TestSet: self.results = {} def addTestResult(self, name, result): - if name not in self.results: - self.results[name] = Test(name) - self.results[name].addResult(result) + if not self.results.has_key(name): + self.results[name] = Test(name) + self.results[name].addResult(result) def compare(self, other): result_list = [] @@ -136,7 +135,7 @@ class TestSet: try: result_list.append(self.results[key].compare(other.results[key])) except KeyError: - print("[WARN] Could not find corresponding test for: %s" % key) + print "[WARN] Could not find corresponding test for: %s" % key return result_list try: @@ -162,7 +161,7 @@ for i in walk_through: new_type, new_name = new_phases[i].getAttribute("type"), new_phases[i].getAttribute("name") if old_type == new_type and old_name == new_name: - print( "Types match, so we are comparing phase %s of type %s" % (old_type, new_type)) + print "Types match, so we are comparing phase %s of type %s" % (old_type, new_type) old_tests = TestSet() new_tests = TestSet() old_metrics = {} @@ -180,20 +179,20 @@ for i in walk_through: tolerance = float(metric.getAttribute("tolerance")) metrics[key] = Metric(key, value, metric.getAttribute("type"), tolerance) - print("==== Actual compare ====") - print(" * Metrics * ") + print "==== Actual compare ====" + print " * Metrics * " metric_results = [] for key in old_metrics.keys(): metric_results.append(old_metrics[key].compare(new_metrics[key])) for metric in metric_results: for message in metric.messages: - print("[%s] %s (%s)" % (metric.result, metric.name, message)) - print(" * Tests * ") + print "[%s] %s (%s)" % (metric.result, metric.name, message) + print " * Tests * " test_results = old_tests.compare(new_tests) for test in test_results: - print("[%s] %s" % (test.result, test.name)) + print "[%s] %s" % (test.result, test.name) for message in test.messages: - print("\t - %s" % message) + print "\t - %s" % message else: - print("We are not doing any compare, types dont match") + print "We are not doing any compare, types dont match" diff --git a/src/python/journalling.py b/src/python/journalling.py index a1db06d..ed29882 100755 --- a/src/python/journalling.py +++ b/src/python/journalling.py @@ -1,4 +1,4 @@ -#!/usr/libexec/platform-python +#!/usr/bin/python # Authors: Jakub Heger # Dalibor Pospisil @@ -20,25 +20,17 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# TODO fix xml pretty print +import sys +import os +import time +import re +from optparse import OptionParser +from lxml import etree +import shlex +import base64 -try: - import os - import re - import sys - import six - import time - import base64 - from optparse import OptionParser -except ImportError as e: - sys.stderr.write("Python ImportError: " + str(e) + "\nExiting unsuccessfully.\n") - exit(2) -try: - from lxml import etree -except ImportError as e: - sys.stderr.write("Python ImportError: " + str(e) + "\nExiting unsuccessfully.\n") - exit(3) +# TODO fix xml pretty print xmlForbidden = [0, 1, 2, 3, 4, 5, 6, 7, 8, 11, 12, 14, 15, 16, 17, 18, 19, 20, @@ -60,19 +52,18 @@ class Stack: return self.items[-1] -# Saves the XML journal to a file. def saveJournal(journal, journal_path): try: output = open(journal_path, 'wb') output.write(etree.tostring(journal, xml_declaration=True, encoding='utf-8', pretty_print=True)) output.close() return 0 - except IOError as e: + except IOError, e: sys.stderr.write('Failed to save journal to %s: %s' % (journal_path, str(e))) return 1 -# Adds attributes starttime and endtime to a element. +# Adds attributes starttime and endtime to a element def addStartEndTime(element, starttime, endtime): element.set("starttime", starttime) element.set("endtime", endtime) @@ -82,7 +73,7 @@ def addStartEndTime(element, starttime, endtime): return 0 -# Find first and last timestamp to fill in starttime and endtime attributes of given element. +# Find first and last timestamp to fill in starttime and endtime elements of given element def getStartEndTime(element): starttime = "" endtime = "" @@ -97,7 +88,7 @@ def getStartEndTime(element): # Parses and decodes lines given to it # Returns number of spaces before element, name of the element, -# its attributes in a dictionary, and content of the element. +# its attributes in a dictionary, and content of the element def parseLine(line): TIME_FORMAT = "%Y-%m-%d %H:%M:%S %Z" CONTENT_FLAG = 0 @@ -109,12 +100,12 @@ def parseLine(line): # Count number of leading spaces indent = len(line) - len(line.lstrip()) - # Splitting the line into a list - splitted = line.split() + # using shlex to get rid of the quotes + splitted = shlex.split(line) - # If the line is not empty + # if the line is not empty if splitted: - # If first 2 characters are '-', it is not new element, but ending of pair element + # if first 2 characters are '-', it is not new element, but ending of pair element if splitted[0][0] == '-' and splitted[0][1] == '-': element = "" else: @@ -123,82 +114,45 @@ def parseLine(line): else: return 0, "", {}, "" - # Parsing the rest of the line + # parsing the rest of the line for part in splitted: - # If flag is set, string is an elements content + # if flag is set, string is an elements content if CONTENT_FLAG == 1: - # String is decoded from base64 - try: - content = base64.b64decode(part) - except TypeError as e: - sys.stderr.write('Failed to decode string \'%s\' from base64.\ - \nError: %s\nExiting unsuccessfully.\n' % (part[1:-1], e)) - exit(1) - # End parsing after content is stored + content = base64.b64decode(part) + # end parsing after content is stored break - # Test if string is an elements content indicator + # test if string is an elements content indicator if part == '--': CONTENT_FLAG = 1 continue - - # Test if string is the elements time attribute + # test if string is an elements time attribute if re.match(r'^--timestamp=', part): attribute_name = "timestamp" - # Value is string after '=' sign attribute_value = part.split('=', 1)[1] - try: - attributes[attribute_name] = time.strftime(TIME_FORMAT, time.localtime(int(attribute_value))) - except ValueError as e: - sys.stderr.write('Failed to convert timestamp attribute to int.\ - \nError: %s\nExiting unsuccessfully.\n' % (e)) - exit(1) + attributes[attribute_name] = time.strftime(TIME_FORMAT, time.localtime(int(attribute_value))) continue - - # Test if string is the elements regular attribute + # test if string is an elements regular attribute if re.match(r'^--[a-zA-Z0-9]+=', part): attribute_name = part.split('=', 1)[0][2:] - # Value is string after '=' sign attribute_value = part.split('=', 1)[1] - try: - attributes[attribute_name] = base64.b64decode(attribute_value) - except TypeError as e: - sys.stderr.write('Failed to decode string \'%s\' from base64.\ - \nError: %s\nExiting unsuccessfully.\n' % (attribute_value, e)) - exit(1) + attributes[attribute_name] = base64.b64decode(attribute_value) continue return indent, element, attributes, content -# Returns XML element created with +# Returns xml element created with # information given as parameters def createElement(element, attributes, content): - # In python 3 decoding from base64 causes retyping into bytes. - if isinstance(element, bytes): - # First bytes are decoded from utf8. - element = element.decode('utf8', 'replace') - # And then retyped to string, using 'six' module which adds python 2/3 compatible methods. - # XML not compatible characters are then also stripped from the string. - element = six.text_type(element).translate(xmlTrans) - - try: - new_el = etree.Element(element) - except ValueError as e: - sys.stderr.write('Failed to create element with name %s\nError: %s\nExiting unsuccessfully.\n' % (element, e)) - exit(1) - - if isinstance(content, bytes): - content = content.decode('utf8', 'replace') - new_el.text = six.text_type(content).translate(xmlTrans) + element = unicode(element, 'utf-8', errors='replace').translate(xmlTrans) + new_el = etree.Element(element) - for key, value in attributes.items(): - if isinstance(key, bytes): - key = key.decode('utf8', 'replace') - key = six.text_type(key).translate(xmlTrans) + content = unicode(content, 'utf-8', errors='replace').translate(xmlTrans) + new_el.text = content - if isinstance(value, bytes): - value = value.decode('utf8', 'replace') - value = six.text_type(value).translate(xmlTrans) + for key, value in attributes.iteritems(): + key = unicode(key, 'utf-8', errors='replace').translate(xmlTrans) + value = unicode(value, 'utf-8', errors='replace').translate(xmlTrans) new_el.set(key, value) return new_el @@ -211,7 +165,7 @@ def createJournalXML(options): if options.metafile: try: fh = open(options.metafile, 'r+') - except IOError as e: + except IOError, e: sys.stderr.write('Failed to open queue file with' + str(e), 'FAIL') return 1 @@ -244,8 +198,8 @@ def createJournalXML(options): previous_el = new_el elif indent == old_indent: - # TODO refactor # Closing element with updates to it with no elements inside it + # TODO refactor if element == "": # Updating start and end time starttime, endtime = getStartEndTime(previous_el) @@ -253,9 +207,9 @@ def createJournalXML(options): if "timestamp" in attributes: endtime = attributes["timestamp"] # Updating attributes found on closing line - for key, value in attributes.items(): + for key, value in attributes.iteritems(): previous_el.set(key, value) - # Add start/end time and remove timestamp attribute + # add start/end time and remove timestamp attribute addStartEndTime(previous_el, starttime, endtime) # New element is on the same level as previous one else: @@ -270,7 +224,7 @@ def createJournalXML(options): elif indent < old_indent: # Difference between indent levels = how many paired elements will be closed indent_diff = old_indent - indent - for _ in range(indent_diff): + for _ in xrange(indent_diff): el_stack.peek().append(previous_el) previous_el = el_stack.pop() @@ -282,9 +236,9 @@ def createJournalXML(options): if "timestamp" in attributes: endtime = attributes["timestamp"] # Updating attributes found on closing line - for key, value in attributes.items(): + for key, value in attributes.iteritems(): previous_el.set(key, value) - # Add start/end time and remove timestamp attribute + # add start/end time and remove timestamp attribute addStartEndTime(previous_el, starttime, endtime) # Ending paired element and creating new one on the same level as the paired one that just ended @@ -324,9 +278,9 @@ def createJournalXML(options): xslt = etree.parse(options.xslt) transform = etree.XSLT(xslt) journal = transform(journal) - except etree.LxmlError as e: - sys.stderr.write("\nTransformation template file \'" + options.xslt + - "\' could not be parsed.\nError: %s\nAborting journal creation.") % (e) + except etree.LxmlError: + sys.stderr.write("\nTransformation template file " + options.xslt + + " could not be parsed.\nAborting journal creation.") return 1 if options.journal: diff --git a/src/python/rlMemAvg.py b/src/python/rlMemAvg.py index aa1b17f..5f459e0 100755 --- a/src/python/rlMemAvg.py +++ b/src/python/rlMemAvg.py @@ -1,4 +1,4 @@ -#!/usr/libexec/platform-python +#!/usr/bin/python # Authors: Petr Muller # @@ -18,7 +18,6 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -from __future__ import print_function import sys, time, re use_sub = False @@ -32,7 +31,7 @@ except ImportError: use_popen = True if len(sys.argv) < 2: - print('syntax: rlMemAvg ') + print 'syntax: rlMemAvg ' sys.exit(1) proglist = sys.argv[1:] @@ -60,4 +59,4 @@ while True: if (use_sub and finish != None) or (use_popen and finish != -1): break -print("%d" % (memsum/tick)) +print "%d" % (memsum/tick) diff --git a/src/python/rlMemPeak.py b/src/python/rlMemPeak.py index 17ea69d..6228210 100755 --- a/src/python/rlMemPeak.py +++ b/src/python/rlMemPeak.py @@ -1,6 +1,6 @@ -#!/usr/libexec/platform-python +#!/usr/bin/python -# Authors: Petr Muller +# Authors: Petr Muller # # Description: Prints a memory consumption peak of an executed program # @@ -18,7 +18,6 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -from __future__ import print_function import sys, time, re use_sub = False @@ -32,7 +31,7 @@ except ImportError: use_popen = True if len(sys.argv) < 2: - print('syntax: rlMemPeak ') + print 'syntax: rlMemPeak ' sys.exit(1) proglist = sys.argv[1:] @@ -58,4 +57,4 @@ while True: if (use_sub and finish != None) or (use_popen and finish != -1): break -print("%d" % (maxmem)) +print "%d" % (maxmem) diff --git a/src/python/testwatcher.py b/src/python/testwatcher.py index 5182c06..8d716c7 100755 --- a/src/python/testwatcher.py +++ b/src/python/testwatcher.py @@ -1,4 +1,4 @@ -#!/usr/libexec/platform-python +#!/usr/bin/python -u # # Authors: Jiri Jaburek # @@ -54,7 +54,6 @@ # and the test sends the cleanup path to the watcher again -from __future__ import print_function import os import sys import signal @@ -106,12 +105,12 @@ else: ### HELPERS # def debug(msg): - print('TESTWATCHER: '+msg) + print 'TESTWATCHER: '+msg sys.stdout.flush() def fatal(msg): - print('TESTWATCHER fatal: '+msg, file=sys.stderr) + print >> sys.stderr, 'TESTWATCHER fatal: '+msg sys.stderr.flush() sys.exit(1) @@ -154,13 +153,13 @@ def beah_lwd_hook(): debug('hooking beah LWD') try: os.makedirs(os.path.dirname(lwd_guard_file)) - except OSError as e: + except OSError, e: if e.errno == errno.EEXIST: pass f = open(lwd_guard_file, 'w') f.write(watchdog_guard_cont) f.close() - os.chmod(lwd_guard_file, 0o755) + os.chmod(lwd_guard_file, 0755) # called when EWD (external watchdog) is about to expire @@ -235,7 +234,7 @@ def exec_cleanup(): try: os.waitpid(cleanuppid, 0) cleanuppid = 0 - except OSError as e: + except OSError, e: if e.errno == errno.EINTR: pass if e.errno == errno.ECHILD: @@ -292,7 +291,7 @@ def exec_test(): # wait for entire process group os.waitpid(testpid, 0) testpid = 0 - except OSError as e: + except OSError, e: # no traceback if interrupted by a signal if e.errno == errno.EINTR: pass diff --git a/src/rpms.sh b/src/rpms.sh index b21e6f6..e22cecb 100644 --- a/src/rpms.sh +++ b/src/rpms.sh @@ -56,7 +56,6 @@ __INTERNAL_RpmPresent() { local version=$3 local release=$4 local arch=$5 - local IFS local package=$name-$version-$release.$arch [ "$arch" == "" ] && package=$name-$version-$release @@ -625,27 +624,7 @@ __INTERNAL_rpmInitUrl() { } -__INTERNAL_WGET() { - local QUIET - [[ "$1" == "--quiet" ]] && { QUIET=1; shift; } - local URL="$2" - local FILE="$1" - local res=0 - if which wget &> /dev/null; then - rlLogDebug "$FUNCNAME(): using wget for download" - QUIET="${QUIET:+--quiet}" - wget $QUIET -t 3 -T 180 -w 20 --waitretry=30 --no-check-certificate --progress=dot:giga -O $FILE $URL || let res++ - elif which curl &> /dev/null; then - rlLogDebug "$FUNCNAME(): using curl for download" - QUIET="${QUIET:+--silent}" - [[ -t 2 ]] || QUIET="${QUIET:---silent --show-error}" - curl $QUIET --location --retry-connrefused --retry-delay 3 --retry-max-time 3600 --retry 3 --connect-timeout 180 --max-time 1800 --insecure -o $FILE "$URL" || let res++ - else - rlLogError "$FUNCNAME(): no tool for downloading web content is available" - let res++ - fi - return $res -} +__INTERNAL_WGET="wget -t 3 -T 180 -w 20 --waitretry=30 --no-check-certificate --progress=dot:giga" # __INTERNAL_rpmGetNextUrl N V R A | --source N V R __INTERNAL_rpmGetNextUrl() { @@ -686,12 +665,7 @@ __INTERNAL_rpmGetNextUrl() { ;; koji,nvra.rpm) rlLogDebug "$FUNCNAME(): get rpm info" - local rpm_info - if [[ -n "$source" ]]; then - rpm_info=$(__INTERNAL_WGET - "$base_url/search?match=exact&type=rpm&terms=$N-$V-$R.src.rpm") - else - rpm_info=$(__INTERNAL_WGET - "$base_url/search?match=exact&type=rpm&terms=$N-$V-$R.$A.rpm") - fi + local rpm_info=$($__INTERNAL_WGET -O - "$base_url/search?match=exact&type=rpm&terms=$N-$V-$R.$A.rpm") [[ $? -ne 0 || -z "$rpm_info" ]] && { rlLogError "could not download rpm information" let res++ @@ -707,7 +681,7 @@ __INTERNAL_rpmGetNextUrl() { rlLogDebug "$FUNCNAME(): extracted buildurl='$buildurl'" [[ "$buildurl" =~ http ]] || buildurl="$base_url/$buildurl" rlLogDebug "$FUNCNAME(): using buildurl='$buildurl'" - local buildinfo=$(__INTERNAL_WGET - "$buildurl") + local buildinfo=$($__INTERNAL_WGET -O - "$buildurl") [[ $? -ne 0 || -z "$buildinfo" ]] && { rlLogError "could not download build information" let res++ @@ -767,7 +741,7 @@ __INTERNAL_rpmDirectDownload() { url="$__INTERNAL_RETURN_VALUE"; unset __INTERNAL_RETURN_VALUE local pkg=$(basename "$url") rlLog "trying download from '$url'" - if __INTERNAL_WGET $quiet $pkg "$url"; then + if $__INTERNAL_WGET $quiet -O $pkg "$url"; then rlLogDebug "$FUNCNAME(): package '$pkg' was successfully downloaded" echo "$pkg" return 0 diff --git a/src/test/journalTest.sh b/src/test/journalTest.sh index 1c5dc0e..6a3adba 100644 --- a/src/test/journalTest.sh +++ b/src/test/journalTest.sh @@ -26,7 +26,7 @@ test_rlJournalStart(){ assertTrue "journal is well-formed XML" "xmllint $__INTERNAL_BEAKERLIB_JOURNAL >/dev/null" # existing journal is not overwritten - silentIfNotDebug 'DEBUG=1 rlLog "I am"' + silentIfNotDebug 'rlLog "I am"' rlJournalStart assertTrue "existing meta not overwritten" \ "grep 'I\\\ am' $__INTERNAL_BEAKERLIB_METAFILE" diff --git a/src/testing.sh b/src/testing.sh index 451b607..04df9dd 100644 --- a/src/testing.sh +++ b/src/testing.sh @@ -731,12 +731,6 @@ be used to produce unbuffered output). Be aware that there are some variables which can collide with your code executed within rlRun. You should avoid using __INTERNAL_rlRun_* variables. -=item - -When any of C<-t> C<-l>, C<-c>, or C<-s> option is used, special file -descriptors 111 and 112 are used to avoid the issue with incomplete log file, -bz1361246. - =back B using C tool is now disabled because of bug 547686. @@ -755,7 +749,6 @@ rlRun() { local __INTERNAL_rlRun_TAG_OUT='' local __INTERNAL_rlRun_TAG_ERR='' local __INTERNAL_rlRun_LOG_FILE='' - local IFS while true ; do case "$1" in @@ -854,28 +847,9 @@ rlRun() { __INTERNAL_PrintText "$__INTERNAL_rlRun_comment_begin" "BEGIN" if $__INTERNAL_rlRun_DO_LOG || $__INTERNAL_rlRun_DO_TAG || $__INTERNAL_rlRun_DO_KEEP; then - # handle issue with incomplete logs (bz1361246), this could be improved using coproc - # in RHEL-6 and higher - # open file descriptors to parsing processes - exec 111> >(sed -u -e "s/^/$__INTERNAL_rlRun_TAG_OUT/g" | tee -a $__INTERNAL_rlRun_LOG_FILE) - local __INTERNAL_rlRun_OUTpid=$! - exec 112> >(sed -u -e "s/^/$__INTERNAL_rlRun_TAG_ERR/g" | tee -a $__INTERNAL_rlRun_LOG_FILE) - local __INTERNAL_rlRun_ERRpid=$! - eval "$__INTERNAL_rlRun_command" 2>&112 1>&111 + eval "$__INTERNAL_rlRun_command" 2> >(sed -u -e "s/^/$__INTERNAL_rlRun_TAG_ERR/g" | + tee -a $__INTERNAL_rlRun_LOG_FILE) 1> >(sed -u -e "s/^/$__INTERNAL_rlRun_TAG_OUT/g" | tee -a $__INTERNAL_rlRun_LOG_FILE) local __INTERNAL_rlRun_exitcode=$? - # close parsing processes - exec 111>&- - exec 112>&- - # wait for parsing processes to finish their job - local __INTERNAL_rlRun_counter=0 - while kill -0 $__INTERNAL_rlRun_OUTpid 2>/dev/null || kill -0 $__INTERNAL_rlRun_ERRpid 2>/dev/null; do - [[ $((__INTERNAL_rlRun_counter++)) -gt 12000 ]] && { - rlLogError "waiting for flushing the output timed out, there might be some data missing in the output file" - break - } - sleep 0.01; - done - rlLogDebug "waiting for parsing processes took $__INTERNAL_rlRun_counter cycles" else eval "$__INTERNAL_rlRun_command" local __INTERNAL_rlRun_exitcode=$?