test: Add rudimentary support to run selected tests only
To keep this simple, only support tests that have corresponding setup and teardown functions implied by their path. For example: ./run passt/ndp will trigger the 'passt' setup and teardown functions. This is not really elegant, but it looks robust, and while David is considering proper alternatives, it should be quite useful. Signed-off-by: Stefano Brivio <sbrivio@redhat.com> Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
parent
06aa26fcf3
commit
c4101334e1
3 changed files with 53 additions and 2 deletions
|
@ -85,6 +85,22 @@ variable settings: DEBUG=1 enables debugging messages, TRACE=1 enables tracing
|
||||||
|
|
||||||
PCAP=1 TRACE=1 ./run
|
PCAP=1 TRACE=1 ./run
|
||||||
|
|
||||||
|
## Running selected tests
|
||||||
|
|
||||||
|
Rudimentary support to run a list of selected tests, without support for
|
||||||
|
dependencies, is available. Tests need to have a setup function corresponding to
|
||||||
|
their path. For example:
|
||||||
|
|
||||||
|
./run passt/ndp passt/dhcp pasta/ndp
|
||||||
|
|
||||||
|
will call the 'passt' setup function (from lib/setup), run the two corresponding
|
||||||
|
tests, call the 'passt' teardown function, the 'pasta' setup, run the pasta/ndp
|
||||||
|
test, and finally tear down the 'pasta' setup.
|
||||||
|
|
||||||
|
Note that requirements on steps implemented by related tests are not handled.
|
||||||
|
For example, if the 'passt/tcp' needs guest connectivity set up by the
|
||||||
|
'passt/ndp' and 'passt/dhcp' tests, those need to be listed explicitly.
|
||||||
|
|
||||||
## Continuous integration
|
## Continuous integration
|
||||||
|
|
||||||
Issuing:
|
Issuing:
|
||||||
|
|
|
@ -650,7 +650,7 @@ run_term() {
|
||||||
asciinema rec --overwrite "${STATEBASE}/demo.uncut" -c "$TMUX /bin/sh -c './run_demo from_term'"
|
asciinema rec --overwrite "${STATEBASE}/demo.uncut" -c "$TMUX /bin/sh -c './run_demo from_term'"
|
||||||
video_postprocess "${STATEBASE}/demo.uncut"
|
video_postprocess "${STATEBASE}/demo.uncut"
|
||||||
else
|
else
|
||||||
$TMUX /bin/sh -c './run from_term'
|
$TMUX /bin/sh -c "./run from_term ${*}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
37
test/run
37
test/run
|
@ -127,6 +127,37 @@ run() {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# run_selected() - Run list of tests, with setup/teardown based on test path
|
||||||
|
# $@: List of tests
|
||||||
|
run_selected() {
|
||||||
|
mkfifo $STATEBASE/log_pipe
|
||||||
|
|
||||||
|
term
|
||||||
|
VALGRIND=1
|
||||||
|
|
||||||
|
__setup=
|
||||||
|
for __test; do
|
||||||
|
if [ "${__test%%/*}" != "${__setup}" ]; then
|
||||||
|
[ -n "${__setup}" ] && teardown "${__setup}"
|
||||||
|
__setup="${__test%%/*}"
|
||||||
|
setup "${__setup}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
test "${__test}"
|
||||||
|
done
|
||||||
|
teardown "${__setup}"
|
||||||
|
|
||||||
|
log "PASS: ${STATUS_PASS}, FAIL: ${STATUS_FAIL}"
|
||||||
|
|
||||||
|
pause_continue \
|
||||||
|
"Press any key to keep test session open" \
|
||||||
|
"Closing in " \
|
||||||
|
"Interrupted, press any key to quit" \
|
||||||
|
9
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
# demo() - Simpler path for demo purposes
|
# demo() - Simpler path for demo purposes
|
||||||
demo() {
|
demo() {
|
||||||
mkfifo $STATEBASE/log_pipe
|
mkfifo $STATEBASE/log_pipe
|
||||||
|
@ -160,11 +191,15 @@ demo() {
|
||||||
[ "$(basename "${0}")" = "run_demo" ] && DEMO=1
|
[ "$(basename "${0}")" = "run_demo" ] && DEMO=1
|
||||||
|
|
||||||
if [ "${1}" = "from_term" ]; then
|
if [ "${1}" = "from_term" ]; then
|
||||||
|
shift
|
||||||
|
|
||||||
exec > ${LOGDIR}/script.log 2>&1
|
exec > ${LOGDIR}/script.log 2>&1
|
||||||
[ ${DEBUG} -eq 1 ] && set -x
|
[ ${DEBUG} -eq 1 ] && set -x
|
||||||
cd ..
|
cd ..
|
||||||
if [ ${DEMO} -eq 1 ]; then
|
if [ ${DEMO} -eq 1 ]; then
|
||||||
demo
|
demo
|
||||||
|
elif [ -n "${1}" ]; then
|
||||||
|
run_selected ${*}
|
||||||
else
|
else
|
||||||
run
|
run
|
||||||
fi
|
fi
|
||||||
|
@ -176,7 +211,7 @@ else
|
||||||
:> "${LOGFILE}"
|
:> "${LOGFILE}"
|
||||||
STATEBASE="$(mktemp -d --tmpdir passt-tests-XXXXXX)"
|
STATEBASE="$(mktemp -d --tmpdir passt-tests-XXXXXX)"
|
||||||
trap "cleanup" EXIT
|
trap "cleanup" EXIT
|
||||||
run_term
|
run_term ${*}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[ ${DEMO} -eq 1 ] && exit 0
|
[ ${DEMO} -eq 1 ] && exit 0
|
||||||
|
|
Loading…
Reference in a new issue