2019-04-21 09:34:17 +00:00
|
|
|
#!/usr/bin/env bash
|
2019-05-10 19:44:13 +00:00
|
|
|
#### $$VERSION$$ v0.80-dev2-1-g0b36bc5
|
2019-04-21 09:34:17 +00:00
|
|
|
|
|
|
|
# common variables
|
|
|
|
export TESTME DIRME TESTDIR LOGFILE REFDIR TESTNAME
|
|
|
|
TESTME="$(basename "$0")"
|
|
|
|
DIRME="$(pwd)"
|
|
|
|
TESTDIR="$1"
|
|
|
|
LOGFILE="${TESTDIR}/${TESTME}.log"
|
|
|
|
REFDIR="${TESTME%.sh}"
|
|
|
|
TESTNAME="${REFDIR//-/ }"
|
|
|
|
|
|
|
|
# common filenames
|
2019-05-01 09:46:57 +00:00
|
|
|
export TOKENFILE ACLFILE COUNTFILE ADMINFILE DATADIR
|
2019-04-21 09:34:17 +00:00
|
|
|
TOKENFILE="token"
|
|
|
|
ACLFILE="botacl"
|
|
|
|
COUNTFILE="count"
|
|
|
|
ADMINFILE="botadmin"
|
2019-05-01 09:46:57 +00:00
|
|
|
DATADIR="data-bot-bash"
|
2019-04-21 09:34:17 +00:00
|
|
|
|
|
|
|
# SUCCESS NOSUCCES
|
|
|
|
export SUCCESS NOSUCCESS
|
2019-04-22 08:19:16 +00:00
|
|
|
SUCCESS=" OK"
|
|
|
|
NOSUCCESS=" FAILED!"
|
2019-04-21 09:34:17 +00:00
|
|
|
|
2019-04-21 12:52:55 +00:00
|
|
|
# default input, reference and output files
|
2019-04-22 18:34:43 +00:00
|
|
|
export INPUTFILE REFFILE OUTPUTFILE
|
2019-04-22 08:19:16 +00:00
|
|
|
INPUTFILE="${DIRME}/${REFDIR}/${REFDIR}.input"
|
|
|
|
REFFILE="${DIRME}/${REFDIR}/${REFDIR}.result"
|
|
|
|
OUTPUTFILE="${TESTDIR}/${REFDIR}.out"
|
2019-04-21 12:52:55 +00:00
|
|
|
|
|
|
|
# print arrays in reproducible order
|
|
|
|
print_array() {
|
|
|
|
local idx t
|
|
|
|
local arrays=( "${@}" )
|
|
|
|
for idx in "${arrays[@]}"; do
|
|
|
|
declare -n temp="$idx"
|
|
|
|
for t in "${!temp[@]}"; do
|
2019-04-22 18:34:43 +00:00
|
|
|
printf '%s:\t%s\t%s\n' "$idx" "$t" "${temp[$t]}"
|
2019-04-21 12:52:55 +00:00
|
|
|
done | sort
|
|
|
|
done | grep -v '^USER: 0'
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
######
|
|
|
|
# lets go ...
|
2019-04-21 09:34:17 +00:00
|
|
|
echo "Running ${TESTNAME#? } ..."
|
|
|
|
echo "............................"
|
|
|
|
[ "${TESTDIR}" = "" ] && echo "${NOSUCCESS} not called from testsuite, exit" && exit 1
|
|
|
|
|
|
|
|
# reset env for test
|
|
|
|
unset IFS; set -f
|
|
|
|
export TERM=""
|
|
|
|
|