From 6fb658a5f1bbc38baa07bb2f51acc6528b8c017a Mon Sep 17 00:00:00 2001 From: Ian Wienand Date: Mon, 24 Oct 2016 11:17:28 +1100 Subject: [PATCH] Don't log datestamp by default in functional tests We're getting double time-stamps in the console log of upstream jobs. Move the logging of a prefix datestamp into a "-t" option to retain the status quo prior to Id9ea5131f0026c292ca6453ba2c80fe12c47f808 (we could, of course, do it the other way and turn if off in the jobs, but since we didn't have it before...) While poking, make the time-stamp consistent and always prefixed if -t is turned on. Also, it seems the parallel options got a bit of sync with what got merged. Add "-j" documentation and remove unused "p" option. Change-Id: Ic7c2ebeca3f9d5784cac59505b6e6181151f5805 --- tests/run_functests.sh | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/tests/run_functests.sh b/tests/run_functests.sh index 2bbd8c57f..84b6d38e8 100755 --- a/tests/run_functests.sh +++ b/tests/run_functests.sh @@ -27,16 +27,26 @@ DEFAULT_SKIP_TESTS=( function log_with_prefix { local pr=$1 + local log while read a; do - echo $(date +"%Y%m%d-%H%M%S.%N") "[$pr] $a" + log="[$pr] $a" + if [[ ${LOG_DATESTAMP} -ne 0 ]]; then + log="$(date +"%Y%m%d-%H%M%S.%N") ${log}" + fi + echo "${log}" done } # Log job control messages function log_jc { local msg="$1" - printf "[JOB-CONTROL] %s %s\n" "$(date)" "${msg}" + local log="[JOB-CONTROL] ${msg}" + + if [[ ${LOG_DATESTAMP} -ne 0 ]]; then + log="$(date +"%Y%m%d-%H%M%S.%N") ${log}" + fi + echo "${log}" } function job_cnt { @@ -156,15 +166,23 @@ for e in $DIB_ELEMENTS/*/test-elements/*; do TESTS+=("$element/$test_element") done +# +# Default values +# JOB_MAX_CNT=1 +LOG_DATESTAMP=0 -while getopts ":hlpj:" opt; do +# +# Parse args +# +while getopts ":hlj:t" opt; do case $opt in h) echo "run_functests.sh [-h] [-l] ..." echo " -h : show this help" echo " -l : list available tests" - echo " -p : run all tests in parallel" + echo " -j : parallel job count (default to 1)" + echo " -t : prefix log messages with timestamp" echo " : functional test to run" echo " Special test 'all' will run all tests" exit 0 @@ -182,6 +200,9 @@ while getopts ":hlpj:" opt; do JOB_MAX_CNT=${OPTARG} echo "Running parallel - using [${JOB_MAX_CNT}] jobs" ;; + t) + LOG_DATESTAMP=1 + ;; \?) echo "Invalid option: -$OPTARG" exit 1