Added sanity test of TIMEFN

This commit adds a sanity check of the test script TIMEFN, which is by
default 'time -p', for the scripts that define it. The scripts are
currently written such that if there is no 'time' executable, such as in
Debian 9, then some of the scripts fail and some don't but should. This
commit fixes that problem.
This commit is contained in:
Jonathan Ben-Avraham 2020-11-14 21:36:32 +02:00
parent 665f540220
commit b37cec53fb
5 changed files with 7 additions and 0 deletions

View file

@ -19,7 +19,9 @@ s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
# -f %e gives elapsed wall clock time but is not available on all systems # -f %e gives elapsed wall clock time but is not available on all systems
# so we use time -p for POSIX compliance and awk to get wall clock time # so we use time -p for POSIX compliance and awk to get wall clock time
# Note sometimes time -p is used and sometimes $TIMEFN, cant get it to work same everywhere # Note sometimes time -p is used and sometimes $TIMEFN, cant get it to work same everywhere
# time function (this is a mess to get right on freebsd/linux)
: ${TIMEFN:=time -p} # portability: 2>&1 | awk '/real/ {print $2}' : ${TIMEFN:=time -p} # portability: 2>&1 | awk '/real/ {print $2}'
if ! $TIMEFN true; then err "A working time function" "'$TIMEFN' does not work"; fi
APPNAME=example APPNAME=example

View file

@ -20,7 +20,9 @@ s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
# -f %e gives elapsed wall clock time but is not available on all systems # -f %e gives elapsed wall clock time but is not available on all systems
# so we use time -p for POSIX compliance and awk to get wall clock time # so we use time -p for POSIX compliance and awk to get wall clock time
# Note sometimes time -p is used and sometimes $TIMEFN, cant get it to work same everywhere # Note sometimes time -p is used and sometimes $TIMEFN, cant get it to work same everywhere
# time function (this is a mess to get right on freebsd/linux)
: ${TIMEFN:=time -p} # portability: 2>&1 | awk '/real/ {print $2}' : ${TIMEFN:=time -p} # portability: 2>&1 | awk '/real/ {print $2}'
if ! $TIMEFN true; then err "A working time function" "'$TIMEFN' does not work"; fi
APPNAME=example APPNAME=example

View file

@ -21,6 +21,7 @@ s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
# so we use time -p for POSIX compliance and awk to get wall clock time # so we use time -p for POSIX compliance and awk to get wall clock time
# Note sometimes time -p is used and sometimes $TIMEFN, cant get it to work same everywhere # Note sometimes time -p is used and sometimes $TIMEFN, cant get it to work same everywhere
: ${TIMEFN:=time -p} # portability: 2>&1 | awk '/real/ {print $2}' : ${TIMEFN:=time -p} # portability: 2>&1 | awk '/real/ {print $2}'
if ! $TIMEFN true; then err "A working time function" "'$TIMEFN' does not work"; fi
APPNAME=example APPNAME=example

View file

@ -20,6 +20,7 @@ fin=$dir/fin
# time function (this is a mess to get right on freebsd/linux) # time function (this is a mess to get right on freebsd/linux)
: ${TIMEFN:=time -p} # portability: 2>&1 | awk '/real/ {print $2}' : ${TIMEFN:=time -p} # portability: 2>&1 | awk '/real/ {print $2}'
if ! $TIMEFN true; then err "A working time function" "'$TIMEFN' does not work"; fi
APPNAME=example APPNAME=example

View file

@ -20,6 +20,7 @@ s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
# time function (this is a mess to get right on freebsd/linux) # time function (this is a mess to get right on freebsd/linux)
: ${TIMEFN:=time -p} # portability: 2>&1 | awk '/real/ {print $2}' : ${TIMEFN:=time -p} # portability: 2>&1 | awk '/real/ {print $2}'
if ! $TIMEFN true; then err "A working time function" "'$TIMEFN' does not work"; fi
APPNAME=example APPNAME=example