aboutgitcodebugslistschat
path: root/test/run
diff options
context:
space:
mode:
authorStefano Brivio <sbrivio@redhat.com>2021-09-27 15:10:35 +0200
committerStefano Brivio <sbrivio@redhat.com>2021-09-27 15:10:35 +0200
commit061519b5620f594b5e5711ae6f3372ff152bc14c (patch)
tree6f46a496ddc61b4959c4da9c5b6b3eddfd876cf8 /test/run
parentca325e7583ad7c2f02193813289d1a1cfa17bf7a (diff)
downloadpasst-061519b5620f594b5e5711ae6f3372ff152bc14c.tar
passt-061519b5620f594b5e5711ae6f3372ff152bc14c.tar.gz
passt-061519b5620f594b5e5711ae6f3372ff152bc14c.tar.bz2
passt-061519b5620f594b5e5711ae6f3372ff152bc14c.tar.lz
passt-061519b5620f594b5e5711ae6f3372ff152bc14c.tar.xz
passt-061519b5620f594b5e5711ae6f3372ff152bc14c.tar.zst
passt-061519b5620f594b5e5711ae6f3372ff152bc14c.zip
test: Add CI/demo scripts
Not really quick, definitely dirty. Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'test/run')
-rwxr-xr-xtest/run154
1 files changed, 154 insertions, 0 deletions
diff --git a/test/run b/test/run
new file mode 100755
index 0000000..9d33951
--- /dev/null
+++ b/test/run
@@ -0,0 +1,154 @@
+#!/bin/sh
+#
+# 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
+ [ ${CI} -eq 1 ] && video_grab ci
+
+ setup build
+ test build
+
+ setup pasta
+ test ndp
+ test dhcp
+ test tcp
+ test udp
+ teardown pasta
+
+ setup passt
+ test ndp
+ test dhcp
+ test tcp
+ test udp
+ teardown passt
+
+ setup passt_in_ns
+ test ndp
+ test dhcp
+ test icmp
+ test tcp
+ test udp
+ test perf
+ teardown passt_in_ns
+
+ setup two_guests
+ test two_guests
+ teardown two_guests
+
+ perf_finish
+ [ ${CI} -eq 1 ] && video_stop ${STATUS_FAIL}
+
+ 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 ${STATUS_FAIL}
+}
+
+# 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_grab demo_passt
+ MODE=passt
+ test demo
+ video_stop 0
+ tmux send-keys -t ${PANE_GUEST} "C-c"
+
+ layout_demo_pasta
+ video_grab demo_pasta
+ MODE=pasta
+ test demo
+ video_stop 0
+
+ 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
+
+tail -n1 ${LOGFILE}
+echo "Log at ${LOGFILE}"
+exit $(tail -n1 ${LOGFILE} | sed -n 's/.*FAIL: \(.*\)$/\1/p')