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
This commit is contained in:
Ian Wienand 2016-10-24 11:17:28 +11:00
parent 2e0f812efa
commit 6fb658a5f1

View File

@ -27,16 +27,26 @@ DEFAULT_SKIP_TESTS=(
function log_with_prefix { function log_with_prefix {
local pr=$1 local pr=$1
local log
while read a; do 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 done
} }
# Log job control messages # Log job control messages
function log_jc { function log_jc {
local msg="$1" 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 { function job_cnt {
@ -156,15 +166,23 @@ for e in $DIB_ELEMENTS/*/test-elements/*; do
TESTS+=("$element/$test_element") TESTS+=("$element/$test_element")
done done
#
# Default values
#
JOB_MAX_CNT=1 JOB_MAX_CNT=1
LOG_DATESTAMP=0
while getopts ":hlpj:" opt; do #
# Parse args
#
while getopts ":hlj:t" opt; do
case $opt in case $opt in
h) h)
echo "run_functests.sh [-h] [-l] <test> <test> ..." echo "run_functests.sh [-h] [-l] <test> <test> ..."
echo " -h : show this help" echo " -h : show this help"
echo " -l : list available tests" 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 " <test> : functional test to run" echo " <test> : functional test to run"
echo " Special test 'all' will run all tests" echo " Special test 'all' will run all tests"
exit 0 exit 0
@ -182,6 +200,9 @@ while getopts ":hlpj:" opt; do
JOB_MAX_CNT=${OPTARG} JOB_MAX_CNT=${OPTARG}
echo "Running parallel - using [${JOB_MAX_CNT}] jobs" echo "Running parallel - using [${JOB_MAX_CNT}] jobs"
;; ;;
t)
LOG_DATESTAMP=1
;;
\?) \?)
echo "Invalid option: -$OPTARG" echo "Invalid option: -$OPTARG"
exit 1 exit 1