1e4a15398f
We install a cleanup() function with 'trap' in order to clean up temporary files we generate during the tests. However, we deinstall it after run_term, which means it won't run in most of the cases where it would be useful. Even if "run from_term" exits with an error, that error will be hidden from the run_term wrapper because it's within a tmux session, so we will return from run_term normally, uninstall the trap and never clean up. In fact there's no reason to uninstall the trap at all, it works just as well on the success exit path as an error exit path. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
187 lines
3.4 KiB
Bash
Executable file
187 lines
3.4 KiB
Bash
Executable file
#!/bin/sh -e
|
|
#
|
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
#
|
|
# PASST - Plug A Simple Socket Transport
|
|
# for qemu/UNIX domain socket mode
|
|
#
|
|
# PASTA - Pack A Subtle Tap Abstraction
|
|
# for network namespace/tap device mode
|
|
#
|
|
# test/run - Entry point to run test cases and demo
|
|
#
|
|
# Copyright (c) 2021 Red Hat GmbH
|
|
# Author: Stefano Brivio <sbrivio@redhat.com>
|
|
|
|
# Start an X terminal and capture a video of the test run (also set for ./ci)
|
|
CI=${CI:-0}
|
|
|
|
# Start an X terminal and show the demo (also set for ./demo)
|
|
DEMO=${DEMO:-0}
|
|
|
|
# Base path for output files
|
|
BASEPATH=${BASEPATH:-"$(pwd)"}
|
|
|
|
# Location of log files for test run
|
|
LOGDIR=${LOGDIR:-"${BASEPATH}/test_logs"}
|
|
LOGFILE=${LOGFILE:-"${LOGDIR}/test.log"}
|
|
|
|
# If set, skip typing delays while issuing commands in panes
|
|
FAST=${FAST:-1}
|
|
|
|
# If set, run passt and pasta with debug options
|
|
DEBUG=${DEBUG:-0}
|
|
|
|
# If set, tell passt and pasta to take packet captures
|
|
PCAP=${PCAP:-0}
|
|
|
|
COMMIT="$(git log --oneline --no-decorate -1)"
|
|
|
|
. lib/util
|
|
. lib/setup
|
|
. lib/context
|
|
. lib/term
|
|
. lib/perf_report
|
|
. lib/layout
|
|
. lib/test
|
|
. lib/video
|
|
|
|
# cleanup() - Remove temporary files
|
|
cleanup() {
|
|
rm -f /tmp/.passt_test_log_pipe
|
|
}
|
|
|
|
# run() - Call setup functions, run tests, handle exit from test session
|
|
run() {
|
|
rm -f /tmp/.passt_test_log_pipe
|
|
mkfifo /tmp/.passt_test_log_pipe
|
|
|
|
term
|
|
perf_init
|
|
[ ${CI} -eq 1 ] && video_start ci
|
|
|
|
setup build
|
|
test build/all
|
|
test build/cppcheck
|
|
test build/clang_tidy
|
|
teardown build
|
|
|
|
setup distro
|
|
test distro/debian
|
|
test distro/fedora
|
|
test distro/opensuse
|
|
test distro/ubuntu
|
|
teardown distro
|
|
|
|
setup pasta
|
|
test pasta/ndp
|
|
test pasta/dhcp
|
|
test pasta/tcp
|
|
test pasta/udp
|
|
test passt/shutdown
|
|
teardown pasta
|
|
|
|
setup passt
|
|
test passt/ndp
|
|
test passt/dhcp
|
|
test passt/tcp
|
|
test passt/udp
|
|
test passt/shutdown
|
|
teardown passt
|
|
|
|
VALGRIND=1
|
|
setup passt_in_ns
|
|
test passt/ndp
|
|
test passt/dhcp
|
|
test passt_in_ns/icmp
|
|
test passt_in_ns/tcp
|
|
test passt_in_ns/udp
|
|
test passt_in_ns/shutdown
|
|
teardown passt_in_ns
|
|
|
|
VALGRIND=0
|
|
setup passt_in_ns
|
|
test passt/ndp
|
|
test passt/dhcp
|
|
test perf/passt_tcp
|
|
test perf/passt_udp
|
|
test perf/pasta_tcp
|
|
test perf/pasta_udp
|
|
test passt_in_ns/shutdown
|
|
teardown passt_in_ns
|
|
|
|
setup two_guests
|
|
test two_guests/basic
|
|
teardown two_guests
|
|
|
|
perf_finish
|
|
[ ${CI} -eq 1 ] && video_stop
|
|
|
|
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() {
|
|
rm -f /tmp/.passt_test_log_pipe
|
|
mkfifo /tmp/.passt_test_log_pipe
|
|
|
|
FAST=0
|
|
|
|
term_demo
|
|
|
|
layout_demo_passt
|
|
video_start demo_passt
|
|
test demo/passt
|
|
video_stop
|
|
teardown demo_passt
|
|
|
|
layout_demo_pasta
|
|
video_start demo_pasta
|
|
test demo/pasta
|
|
video_stop
|
|
teardown demo_pasta
|
|
|
|
layout_demo_podman
|
|
video_start demo_podman
|
|
test demo/podman
|
|
video_stop
|
|
teardown_demo_podman
|
|
|
|
return 0
|
|
}
|
|
|
|
[ "$(basename "${0}")" = "ci" ] && CI=1
|
|
[ "$(basename "${0}")" = "run_demo" ] && DEMO=1
|
|
|
|
if [ "${1}" = "from_term" ]; then
|
|
exec > ${LOGDIR}/script.log 2>&1
|
|
[ ${DEBUG} -eq 1 ] && set -x
|
|
cd ..
|
|
if [ ${DEMO} -eq 1 ]; then
|
|
demo
|
|
else
|
|
run
|
|
fi
|
|
tmux kill-session -t passt_test
|
|
exit
|
|
else
|
|
rm -rf "${LOGDIR}"
|
|
mkdir -p "${LOGDIR}"
|
|
:> "${LOGFILE}"
|
|
trap "cleanup" EXIT
|
|
run_term
|
|
fi
|
|
|
|
[ ${DEMO} -eq 1 ] && exit 0
|
|
|
|
tail -n1 ${LOGFILE}
|
|
echo "Log at ${LOGFILE}"
|
|
exit $(tail -n1 ${LOGFILE} | sed -n 's/.*FAIL: \(.*\)$/\1/p')
|