2022-05-12 04:42:50 +02:00
|
|
|
#!/bin/sh -e
|
2021-09-27 15:10:35 +02:00
|
|
|
#
|
|
|
|
# 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/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
|
2022-02-22 18:29:45 +01:00
|
|
|
[ ${CI} -eq 1 ] && video_start ci
|
2021-09-27 15:10:35 +02:00
|
|
|
|
|
|
|
setup build
|
2022-07-06 09:29:05 +02:00
|
|
|
test $(cd test && echo build/*)
|
|
|
|
test $(cd test && echo distro/*)
|
2021-09-27 15:10:35 +02:00
|
|
|
|
|
|
|
setup pasta
|
2022-07-06 09:29:05 +02:00
|
|
|
test $(cd test && echo ndp/*)
|
|
|
|
test $(cd test && echo dhcp/*)
|
|
|
|
test $(cd test && echo tcp/*)
|
|
|
|
test $(cd test && echo udp/*)
|
2021-09-27 15:10:35 +02:00
|
|
|
teardown pasta
|
|
|
|
|
|
|
|
setup passt
|
2022-07-06 09:29:05 +02:00
|
|
|
test $(cd test && echo ndp/*)
|
|
|
|
test $(cd test && echo dhcp/*)
|
|
|
|
test $(cd test && echo tcp/*)
|
|
|
|
test $(cd test && echo udp/*)
|
|
|
|
test $(cd test && echo valgrind/*)
|
2021-09-27 15:10:35 +02:00
|
|
|
teardown passt
|
|
|
|
|
2022-03-15 20:16:13 +01:00
|
|
|
VALGRIND=1
|
2021-09-27 15:10:35 +02:00
|
|
|
setup passt_in_ns
|
2022-07-06 09:29:05 +02:00
|
|
|
test $(cd test && echo ndp/*)
|
|
|
|
test $(cd test && echo dhcp/*)
|
|
|
|
test $(cd test && echo icmp/*)
|
|
|
|
test $(cd test && echo tcp/*)
|
|
|
|
test $(cd test && echo udp/*)
|
|
|
|
test $(cd test && echo valgrind/*)
|
2022-03-15 20:16:13 +01:00
|
|
|
teardown passt_in_ns
|
|
|
|
|
|
|
|
VALGRIND=0
|
|
|
|
setup passt_in_ns
|
2022-07-06 09:29:05 +02:00
|
|
|
test $(cd test && echo ndp/*)
|
|
|
|
test $(cd test && echo dhcp/*)
|
|
|
|
test $(cd test && echo perf/*)
|
2021-09-27 15:10:35 +02:00
|
|
|
teardown passt_in_ns
|
|
|
|
|
|
|
|
setup two_guests
|
2022-07-06 09:29:05 +02:00
|
|
|
test $(cd test && echo two_guests/*)
|
2021-09-27 15:10:35 +02:00
|
|
|
teardown two_guests
|
|
|
|
|
|
|
|
perf_finish
|
2022-02-22 18:29:45 +01:00
|
|
|
[ ${CI} -eq 1 ] && video_stop
|
2021-09-27 15:10:35 +02:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2022-05-17 14:18:41 +02:00
|
|
|
return 0
|
2021-09-27 15:10:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# 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
|
2022-02-22 18:29:45 +01:00
|
|
|
video_start demo_passt
|
2021-09-27 15:10:35 +02:00
|
|
|
MODE=passt
|
2022-07-06 09:29:05 +02:00
|
|
|
test $(cd test && echo demo/*)
|
2022-02-22 18:29:45 +01:00
|
|
|
video_stop
|
2021-09-29 16:45:26 +02:00
|
|
|
teardown demo_passt
|
2021-09-27 15:10:35 +02:00
|
|
|
|
|
|
|
layout_demo_pasta
|
2022-02-22 18:29:45 +01:00
|
|
|
video_start demo_pasta
|
2021-09-27 15:10:35 +02:00
|
|
|
MODE=pasta
|
2022-07-06 09:29:05 +02:00
|
|
|
test $(cd test && echo demo/*)
|
2022-02-22 18:29:45 +01:00
|
|
|
video_stop
|
2022-02-21 13:35:45 +01:00
|
|
|
teardown demo_pasta
|
|
|
|
|
|
|
|
layout_demo_podman
|
2022-02-22 18:29:45 +01:00
|
|
|
video_start demo_podman
|
2022-02-21 13:35:45 +01:00
|
|
|
MODE=podman
|
2022-07-06 09:29:05 +02:00
|
|
|
test $(cd test && echo demo/*)
|
2022-02-22 18:29:45 +01:00
|
|
|
video_stop
|
2022-02-21 13:35:45 +01:00
|
|
|
teardown_demo_podman
|
2021-09-27 15:10:35 +02:00
|
|
|
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
[ "$(basename "${0}")" = "ci" ] && CI=1
|
|
|
|
[ "$(basename "${0}")" = "run_demo" ] && DEMO=1
|
|
|
|
|
|
|
|
if [ "${1}" = "from_term" ]; then
|
|
|
|
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
|
|
|
|
trap "" EXIT
|
|
|
|
fi
|
|
|
|
|
2021-09-29 16:45:26 +02:00
|
|
|
[ ${DEMO} -eq 1 ] && exit 0
|
|
|
|
|
2021-09-27 15:10:35 +02:00
|
|
|
tail -n1 ${LOGFILE}
|
|
|
|
echo "Log at ${LOGFILE}"
|
|
|
|
exit $(tail -n1 ${LOGFILE} | sed -n 's/.*FAIL: \(.*\)$/\1/p')
|