The tests create temporary files and fifos in a number of places. Some of them can interfere with later test runs, and are awkward to clean up. Consolidate them in a single per-run directory in /tmp which gets cleaned up automatically. This is based on the earlier userns cleanup series. Changes since v4: * Also moved .pid files from demo into state directory * Moved the .cast video files into $LOGDIR/web instead of plain $LOGDIR * Added a new patch moving the perf.js report into $LOGDIR/web too * Updated hooks/pre-push to take things from their new directories Changes since v3: * Fixed problem with ssh hosts file naming which caused a bunch of non-fatal warnings Changes since v2: * Reinstated patch to move the log pipe accidentally dropped during a rebase Chances since v1: * Fixed a number of straightforward bugs where things were missed * Also removed files we're no longer putting into the source tree from .gitignore * Added an extra patch moving the video processing files David Gibson (14): test: Group tests by mode then protocol, rather than the reverse test: Remove unused variable FFMPEG_PID_FILE test: Actually run cleanup function test: Create common state directories for temporary files test: Move passt_test_log_pipe to state directory test: Move context temporary files to state dir test: Don't redundantly regenerate small test file in pasta/tcp test: Use paths in __STATEDIR__ instead of 'temp' and 'tempdir' directives test: Move pause temporary file to state directory test: Store pcap files in $LOGDIR instead of /tmp test: Move pidfiles and nsholder sockets into state directory demo: Move pidfiles to state directory test: Move video processing files to $STATEBASE test: Move perf.js report file to $LOGDIR/web .gitignore | 1 - hooks/pre-push | 12 +-- test/.gitignore | 5 -- test/build/all | 31 ++++--- test/demo/passt | 14 ++-- test/demo/pasta | 20 ++--- test/demo/podman | 11 ++- test/distro/debian | 2 +- test/distro/fedora | 2 +- test/distro/opensuse | 16 ++-- test/distro/ubuntu | 8 +- test/lib/context | 61 +++++++------- test/lib/layout | 16 ++-- test/lib/perf_report | 3 +- test/lib/setup | 84 ++++++++++--------- test/lib/term | 26 +++--- test/lib/test | 14 +--- test/lib/video | 38 +++++---- test/{dhcp/passt => passt/dhcp} | 2 +- test/{ndp/passt => passt/ndp} | 2 +- test/{shutdown/passt => passt/shutdown} | 4 +- test/{tcp/passt => passt/tcp} | 6 +- test/{udp/passt => passt/udp} | 8 +- test/{icmp/passt_in_ns => passt_in_ns/icmp} | 2 +- .../passt_in_ns => passt_in_ns/shutdown} | 4 +- test/{tcp/passt_in_ns => passt_in_ns/tcp} | 10 +-- test/{udp/passt_in_ns => passt_in_ns/udp} | 8 +- test/{dhcp/pasta => pasta/dhcp} | 2 +- test/{ndp/pasta => pasta/ndp} | 2 +- test/{tcp/pasta => pasta/tcp} | 13 ++- test/{udp/pasta => pasta/udp} | 20 ++--- test/run | 48 +++++------ 32 files changed, 243 insertions(+), 252 deletions(-) rename test/{dhcp/passt => passt/dhcp} (98%) rename test/{ndp/passt => passt/ndp} (95%) rename test/{shutdown/passt => passt/shutdown} (80%) rename test/{tcp/passt => passt/tcp} (96%) rename test/{udp/passt => passt/udp} (88%) rename test/{icmp/passt_in_ns => passt_in_ns/icmp} (94%) rename test/{shutdown/passt_in_ns => passt_in_ns/shutdown} (79%) rename test/{tcp/passt_in_ns => passt_in_ns/tcp} (97%) rename test/{udp/passt_in_ns => passt_in_ns/udp} (97%) rename test/{dhcp/pasta => pasta/dhcp} (96%) rename test/{ndp/pasta => pasta/ndp} (95%) rename test/{tcp/pasta => pasta/tcp} (95%) rename test/{udp/pasta => pasta/udp} (74%) -- 2.37.3
For example, passt/dhcp rather than dhcp/passt. This is more consistent with the two_guests and other test groups, and makes some other cleanups simpler. Signed-off-by: David Gibson <david(a)gibson.dropbear.id.au> --- test/{dhcp/passt => passt/dhcp} | 2 +- test/{ndp/passt => passt/ndp} | 2 +- test/{shutdown/passt => passt/shutdown} | 2 +- test/{tcp/passt => passt/tcp} | 2 +- test/{udp/passt => passt/udp} | 2 +- test/{icmp/passt_in_ns => passt_in_ns/icmp} | 2 +- .../passt_in_ns => passt_in_ns/shutdown} | 2 +- test/{tcp/passt_in_ns => passt_in_ns/tcp} | 2 +- test/{udp/passt_in_ns => passt_in_ns/udp} | 2 +- test/{dhcp/pasta => pasta/dhcp} | 2 +- test/{ndp/pasta => pasta/ndp} | 2 +- test/{tcp/pasta => pasta/tcp} | 2 +- test/{udp/pasta => pasta/udp} | 2 +- test/run | 38 +++++++++---------- 14 files changed, 32 insertions(+), 32 deletions(-) rename test/{dhcp/passt => passt/dhcp} (98%) rename test/{ndp/passt => passt/ndp} (95%) rename test/{shutdown/passt => passt/shutdown} (87%) rename test/{tcp/passt => passt/tcp} (98%) rename test/{udp/passt => passt/udp} (97%) rename test/{icmp/passt_in_ns => passt_in_ns/icmp} (94%) rename test/{shutdown/passt_in_ns => passt_in_ns/shutdown} (87%) rename test/{tcp/passt_in_ns => passt_in_ns/tcp} (99%) rename test/{udp/passt_in_ns => passt_in_ns/udp} (98%) rename test/{dhcp/pasta => pasta/dhcp} (96%) rename test/{ndp/pasta => pasta/ndp} (95%) rename test/{tcp/pasta => pasta/tcp} (98%) rename test/{udp/pasta => pasta/udp} (98%) diff --git a/test/dhcp/passt b/test/passt/dhcp similarity index 98% rename from test/dhcp/passt rename to test/passt/dhcp index 37bf6b5..eef5183 100644 --- a/test/dhcp/passt +++ b/test/passt/dhcp @@ -6,7 +6,7 @@ # PASTA - Pack A Subtle Tap Abstraction # for network namespace/tap device mode # -# test/dhcp/passt - Check DHCP and DHCPv6 functionality in passt mode +# test/passt/dhcp - Check DHCP and DHCPv6 functionality in passt mode # # Copyright (c) 2021 Red Hat GmbH # Author: Stefano Brivio <sbrivio(a)redhat.com> diff --git a/test/ndp/passt b/test/passt/ndp similarity index 95% rename from test/ndp/passt rename to test/passt/ndp index c73fd4d..280b3ae 100644 --- a/test/ndp/passt +++ b/test/passt/ndp @@ -6,7 +6,7 @@ # PASTA - Pack A Subtle Tap Abstraction # for network namespace/tap device mode # -# test/ndp/passt - Check NDP functionality in passt mode +# test/passt/ndp - Check NDP functionality in passt mode # # Copyright (c) 2021 Red Hat GmbH # Author: Stefano Brivio <sbrivio(a)redhat.com> diff --git a/test/shutdown/passt b/test/passt/shutdown similarity index 87% rename from test/shutdown/passt rename to test/passt/shutdown index ac8ff08..ce90ea9 100644 --- a/test/shutdown/passt +++ b/test/passt/shutdown @@ -6,7 +6,7 @@ # PASTA - Pack A Subtle Tap Abstraction # for network namespace/tap device mode # -# test/shutdown/passt - Shut down passt (or pasta) and check exit code (will +# test/passt/shutdown - Shut down passt (or pasta) and check exit code (will # detect valgrind errors amongst others) # # Copyright (c) 2022 Red Hat GmbH diff --git a/test/tcp/passt b/test/passt/tcp similarity index 98% rename from test/tcp/passt rename to test/passt/tcp index 265f270..d5c8164 100644 --- a/test/tcp/passt +++ b/test/passt/tcp @@ -6,7 +6,7 @@ # PASTA - Pack A Subtle Tap Abstraction # for network namespace/tap device mode # -# test/tcp/passt - Check TCP functionality in passt mode +# test/passt/tcp - Check TCP functionality in passt mode # # Copyright (c) 2021 Red Hat GmbH # Author: Stefano Brivio <sbrivio(a)redhat.com> diff --git a/test/udp/passt b/test/passt/udp similarity index 97% rename from test/udp/passt rename to test/passt/udp index a14e6d2..56d01b3 100644 --- a/test/udp/passt +++ b/test/passt/udp @@ -6,7 +6,7 @@ # PASTA - Pack A Subtle Tap Abstraction # for network namespace/tap device mode # -# test/udp/passt - Check UDP functionality in passt mode +# test/passt/udp - Check UDP functionality in passt mode # # Copyright (c) 2021 Red Hat GmbH # Author: Stefano Brivio <sbrivio(a)redhat.com> diff --git a/test/icmp/passt_in_ns b/test/passt_in_ns/icmp similarity index 94% rename from test/icmp/passt_in_ns rename to test/passt_in_ns/icmp index e4ac4ff..f326d4b 100644 --- a/test/icmp/passt_in_ns +++ b/test/passt_in_ns/icmp @@ -6,7 +6,7 @@ # PASTA - Pack A Subtle Tap Abstraction # for network namespace/tap device mode # -# test/icmp/passt_in_ns - Check ICMP/ICMPv6 functionality for passt in ns +# test/passt_in_ns/icmp - Check ICMP/ICMPv6 functionality for passt in ns # # Copyright (c) 2021 Red Hat GmbH # Author: Stefano Brivio <sbrivio(a)redhat.com> diff --git a/test/shutdown/passt_in_ns b/test/passt_in_ns/shutdown similarity index 87% rename from test/shutdown/passt_in_ns rename to test/passt_in_ns/shutdown index 3808adb..abe9d6c 100644 --- a/test/shutdown/passt_in_ns +++ b/test/passt_in_ns/shutdown @@ -6,7 +6,7 @@ # PASTA - Pack A Subtle Tap Abstraction # for network namespace/tap device mode # -# test/shutdown/passt_in_ns - Shut down passt and check exit code (will detect +# test/passt_in_ns/shutdown - Shut down passt and check exit code (will detect # valgrind errors amongst others) # # Copyright (c) 2022 Red Hat GmbH diff --git a/test/tcp/passt_in_ns b/test/passt_in_ns/tcp similarity index 99% rename from test/tcp/passt_in_ns rename to test/passt_in_ns/tcp index a248f00..5ec95e8 100644 --- a/test/tcp/passt_in_ns +++ b/test/passt_in_ns/tcp @@ -6,7 +6,7 @@ # PASTA - Pack A Subtle Tap Abstraction # for network namespace/tap device mode # -# test/tcp/passt_in_ns - Check TCP functionality for passt in ns with pasta +# test/passt_in_ns/tcp - Check TCP functionality for passt in ns with pasta # # Copyright (c) 2021 Red Hat GmbH # Author: Stefano Brivio <sbrivio(a)redhat.com> diff --git a/test/udp/passt_in_ns b/test/passt_in_ns/udp similarity index 98% rename from test/udp/passt_in_ns rename to test/passt_in_ns/udp index d5f08fe..c22a68f 100644 --- a/test/udp/passt_in_ns +++ b/test/passt_in_ns/udp @@ -6,7 +6,7 @@ # PASTA - Pack A Subtle Tap Abstraction # for network namespace/tap device mode # -# test/udp/passt_in_ns - Check UDP functionality for passt in ns and pasta +# test/passt_in_ns/udp - Check UDP functionality for passt in ns and pasta # # Copyright (c) 2021 Red Hat GmbH # Author: Stefano Brivio <sbrivio(a)redhat.com> diff --git a/test/dhcp/pasta b/test/pasta/dhcp similarity index 96% rename from test/dhcp/pasta rename to test/pasta/dhcp index d1e9611..80eabf5 100644 --- a/test/dhcp/pasta +++ b/test/pasta/dhcp @@ -6,7 +6,7 @@ # PASTA - Pack A Subtle Tap Abstraction # for network namespace/tap device mode # -# test/dhcp/pasta - Check DHCP and DHCPv6 functionality in pasta mode +# test/pasta/dhcp - Check DHCP and DHCPv6 functionality in pasta mode # # Copyright (c) 2021 Red Hat GmbH # Author: Stefano Brivio <sbrivio(a)redhat.com> diff --git a/test/ndp/pasta b/test/pasta/ndp similarity index 95% rename from test/ndp/pasta rename to test/pasta/ndp index d776055..d2b2c0b 100644 --- a/test/ndp/pasta +++ b/test/pasta/ndp @@ -6,7 +6,7 @@ # PASTA - Pack A Subtle Tap Abstraction # for network namespace/tap device mode # -# test/ndp/pasta - Check DHCP and DHCPv6 functionality in pasta mode +# test/pasta/ndp - Check DHCP and DHCPv6 functionality in pasta mode # # Copyright (c) 2021 Red Hat GmbH # Author: Stefano Brivio <sbrivio(a)redhat.com> diff --git a/test/tcp/pasta b/test/pasta/tcp similarity index 98% rename from test/tcp/pasta rename to test/pasta/tcp index a13a2ff..7c7de06 100644 --- a/test/tcp/pasta +++ b/test/pasta/tcp @@ -6,7 +6,7 @@ # PASTA - Pack A Subtle Tap Abstraction # for network namespace/tap device mode # -# test/tcp/pasta - Check TCP functionality for pasta +# test/pasta/tcp - Check TCP functionality for pasta # # Copyright (c) 2021 Red Hat GmbH # Author: Stefano Brivio <sbrivio(a)redhat.com> diff --git a/test/udp/pasta b/test/pasta/udp similarity index 98% rename from test/udp/pasta rename to test/pasta/udp index 0767e0b..0e58152 100644 --- a/test/udp/pasta +++ b/test/pasta/udp @@ -6,7 +6,7 @@ # PASTA - Pack A Subtle Tap Abstraction # for network namespace/tap device mode # -# test/udp/pasta - Check UDP functionality for pasta +# test/pasta/udp - Check UDP functionality for pasta # # Copyright (c) 2021 Red Hat GmbH # Author: Stefano Brivio <sbrivio(a)redhat.com> diff --git a/test/run b/test/run index 0ec1334..d8b60bf 100755 --- a/test/run +++ b/test/run @@ -74,40 +74,40 @@ run() { teardown distro setup pasta - test ndp/pasta - test dhcp/pasta - test tcp/pasta - test udp/pasta - test shutdown/passt + test pasta/ndp + test pasta/dhcp + test pasta/tcp + test pasta/udp + test passt/shutdown teardown pasta setup passt - test ndp/passt - test dhcp/passt - test tcp/passt - test udp/passt - test shutdown/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 ndp/passt - test dhcp/passt - test icmp/passt_in_ns - test tcp/passt_in_ns - test udp/passt_in_ns - test shutdown/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 ndp/passt - test dhcp/passt + test passt/ndp + test passt/dhcp test perf/passt_tcp test perf/passt_udp test perf/pasta_tcp test perf/pasta_udp - test shutdown/passt_in_ns + test passt_in_ns/shutdown teardown passt_in_ns setup two_guests -- 2.37.3
FFPMPEG_PID_FILE is set (creating a temporary file), then never used. Signed-off-by: David Gibson <david(a)gibson.dropbear.id.au> --- test/lib/video | 1 - 1 file changed, 1 deletion(-) diff --git a/test/lib/video b/test/lib/video index 22e73bb..f609abf 100755 --- a/test/lib/video +++ b/test/lib/video @@ -13,7 +13,6 @@ # Copyright (c) 2021-2022 Red Hat GmbH # Author: Stefano Brivio <sbrivio(a)redhat.com> -FFMPEG_PID_FILE="$(mktemp)" VIDEO_START_SECONDS= VIDEO_NAME= -- 2.37.3
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(a)gibson.dropbear.id.au> --- test/run | 1 - 1 file changed, 1 deletion(-) diff --git a/test/run b/test/run index d8b60bf..9b0227b 100755 --- a/test/run +++ b/test/run @@ -178,7 +178,6 @@ else :> "${LOGFILE}" trap "cleanup" EXIT run_term - trap "" EXIT fi [ ${DEMO} -eq 1 ] && exit 0 -- 2.37.3
The test scripts create a bunch of temporary files to keep track of internal state. Some are made in /tmp with individual mktemp calls, some go in the passt source directory, and some go in $LOGDIR. This can sometimes make it messy to clean up after failed test runs. Start cleaning this up by creating a single "state" directory ($STATEBASE) in /tmp for all the state or temporary files used by a single test run. Clean it up automatically in cleanup() - except when DEBUG==1, because those files can be useful for debugging test script failures. We create subdirectories under $STATEBASE for each setup function, exposed as $STATESETUP. We also create subdirectories for each test script and expose those to the scripts as __STATEDIR__. Signed-off-by: David Gibson <david(a)gibson.dropbear.id.au> --- test/lib/setup | 2 ++ test/lib/term | 2 +- test/lib/test | 4 ++++ test/run | 2 ++ 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/test/lib/setup b/test/lib/setup index f1e429c..b9c9e81 100755 --- a/test/lib/setup +++ b/test/lib/setup @@ -394,6 +394,8 @@ teardown_demo_podman() { # $*: Suffix list of setup_*() functions to be called setup() { for arg do + STATESETUP="${STATEBASE}/${arg}" + mkdir -p "${STATESETUP}" eval setup_${arg} done } diff --git a/test/lib/term b/test/lib/term index 2355e64..8b8ad56 100755 --- a/test/lib/term +++ b/test/lib/term @@ -639,7 +639,7 @@ pause_continue() { # run_term() - Start tmux session, running entry point, with recording if needed run_term() { - TMUX="tmux new-session -s passt_test -ePCAP=$PCAP -eDEBUG=$DEBUG" + TMUX="tmux new-session -s passt_test -eSTATEBASE=$STATEBASE -ePCAP=$PCAP -eDEBUG=$DEBUG" if [ ${CI} -eq 1 ]; then printf '\e[8;50;240t' diff --git a/test/lib/test b/test/lib/test index 0d06afd..3dbae0b 100755 --- a/test/lib/test +++ b/test/lib/test @@ -351,6 +351,10 @@ test_one() { [ ${CI} -eq 1 ] && video_link "${1}" TEST_ONE_subs="$(list_add_pair "" "__BASEPATH__" "${BASEPATH}")" + TEST_ONE_subs="$(list_add_pair "${TEST_ONE_subs}" "__STATESETUP__" "${STATESETUP}")" + STATEDIR="${STATEBASE}/${1}" + mkdir -p "${STATEDIR}" + TEST_ONE_subs="$(list_add_pair "${TEST_ONE_subs}" "__STATEDIR__" "${STATEDIR}")" TEST_ONE_nok=-1 TEST_ONE_perf_nok=0 TEST_ONE_skip=0 diff --git a/test/run b/test/run index 9b0227b..58d9b49 100755 --- a/test/run +++ b/test/run @@ -48,6 +48,7 @@ COMMIT="$(git log --oneline --no-decorate -1)" # cleanup() - Remove temporary files cleanup() { + [ ${DEBUG} -eq 1 ] || rm -rf "${STATEBASE}" rm -f /tmp/.passt_test_log_pipe } @@ -176,6 +177,7 @@ else rm -rf "${LOGDIR}" mkdir -p "${LOGDIR}" :> "${LOGFILE}" + STATEBASE="$(mktemp -d --tmpdir passt-tests-XXXXXX)" trap "cleanup" EXIT run_term fi -- 2.37.3
We use this fifo to send messages to the information pane. Put it in the state directory so it doesn't need its own cleanup. Signed-off-by: David Gibson <david(a)gibson.dropbear.id.au> --- test/lib/layout | 16 ++++++++-------- test/lib/term | 12 ++++++------ test/run | 7 ++----- 3 files changed, 16 insertions(+), 19 deletions(-) diff --git a/test/lib/layout b/test/lib/layout index cc7c688..cf319bf 100644 --- a/test/lib/layout +++ b/test/lib/layout @@ -27,7 +27,7 @@ layout_host() { get_info_cols - tmux send-keys -l -t ${PANE_INFO} 'while cat /tmp/.passt_test_log_pipe; do :; done' + tmux send-keys -l -t ${PANE_INFO} 'while cat '"$STATEBASE/log_pipe"'; do :; done' tmux send-keys -t ${PANE_INFO} -N 100 C-m tmux select-pane -t ${PANE_INFO} -T "test log" @@ -61,7 +61,7 @@ layout_pasta() { get_info_cols - tmux send-keys -l -t ${PANE_INFO} 'while cat /tmp/.passt_test_log_pipe; do :; done' + tmux send-keys -l -t ${PANE_INFO} 'while cat '"$STATEBASE/log_pipe"'; do :; done' tmux send-keys -t ${PANE_INFO} -N 100 C-m tmux select-pane -t ${PANE_INFO} -T "test log" @@ -92,7 +92,7 @@ layout_passt() { get_info_cols - tmux send-keys -l -t ${PANE_INFO} 'while cat /tmp/.passt_test_log_pipe; do :; done' + tmux send-keys -l -t ${PANE_INFO} 'while cat '"$STATEBASE/log_pipe"'; do :; done' tmux send-keys -t ${PANE_INFO} -N 100 C-m tmux select-pane -t ${PANE_INFO} -T "test log" @@ -128,7 +128,7 @@ layout_passt_in_pasta() { pane_watch_contexts ${PANE_GUEST} "guest" qemu guest pane_watch_contexts ${PANE_NS} "namespace" ns - tmux send-keys -l -t ${PANE_INFO} 'while cat /tmp/.passt_test_log_pipe; do :; done' + tmux send-keys -l -t ${PANE_INFO} 'while cat '"$STATEBASE/log_pipe"'; do :; done' tmux send-keys -t ${PANE_INFO} -N 100 C-m tmux select-pane -t ${PANE_INFO} -T "test log" @@ -171,7 +171,7 @@ layout_two_guests() { pane_watch_contexts ${PANE_GUEST_1} "guest #1 in namespace #1" qemu_1 guest_1 pane_watch_contexts ${PANE_GUEST_2} "guest #2 in namespace #2" qemu_2 guest_2 - tmux send-keys -l -t ${PANE_INFO} 'while cat /tmp/.passt_test_log_pipe; do :; done' + tmux send-keys -l -t ${PANE_INFO} 'while cat '"$STATEBASE/log_pipe"'; do :; done' tmux send-keys -t ${PANE_INFO} -N 100 C-m tmux select-pane -t ${PANE_INFO} -T "test log" @@ -207,7 +207,7 @@ layout_demo_pasta() { tmux pipe-pane -O -t ${PANE_NS} "cat >> ${LOGDIR}/pane_ns.log" tmux select-pane -t ${PANE_NS} -T "namespace" - tmux send-keys -l -t ${PANE_INFO} 'while cat /tmp/.passt_test_log_pipe; do :; done' + tmux send-keys -l -t ${PANE_INFO} 'while cat '"$STATEBASE/log_pipe"'; do :; done' tmux send-keys -t ${PANE_INFO} -N 100 C-m tmux select-pane -t ${PANE_INFO} -T "" @@ -243,7 +243,7 @@ layout_demo_passt() { tmux pipe-pane -O -t ${PANE_GUEST} "cat >> ${LOGDIR}/pane_guest.log" tmux select-pane -t ${PANE_GUEST} -T "guest" - tmux send-keys -l -t ${PANE_INFO} 'while cat /tmp/.passt_test_log_pipe; do :; done' + tmux send-keys -l -t ${PANE_INFO} 'while cat '"$STATEBASE/log_pipe"'; do :; done' tmux send-keys -t ${PANE_INFO} -N 100 C-m tmux select-pane -t ${PANE_INFO} -T "" @@ -282,7 +282,7 @@ layout_demo_podman() { tmux pipe-pane -O -t ${PANE_NS2} "cat >> ${LOGDIR}/pane_ns2.log" tmux select-pane -t ${PANE_NS2} -T "Podman with pasta" - tmux send-keys -l -t ${PANE_INFO} 'while cat /tmp/.passt_test_log_pipe; do :; done' + tmux send-keys -l -t ${PANE_INFO} 'while cat '"$STATEBASE/log_pipe"'; do :; done' tmux send-keys -t ${PANE_INFO} -N 100 C-m tmux select-pane -t ${PANE_INFO} -T "" diff --git a/test/lib/term b/test/lib/term index 8b8ad56..9a3ef7f 100755 --- a/test/lib/term +++ b/test/lib/term @@ -31,7 +31,7 @@ PR_DELAY_INIT=100 # ms # $@: Message to print info() { tmux select-pane -t ${PANE_INFO} - echo "${@}" >> /tmp/.passt_test_log_pipe + echo "${@}" >> $STATEBASE/log_pipe echo "${@}" >> "${LOGFILE}" } @@ -39,7 +39,7 @@ info() { # $@: Message to print info_n() { tmux select-pane -t ${PANE_INFO} - printf "${@}" >> /tmp/.passt_test_log_pipe + printf "${@}" >> $STATEBASE/log_pipe printf "${@}" >> "${LOGFILE}" } @@ -47,7 +47,7 @@ info_n() { # $@: Message to print info_nolog() { tmux select-pane -t ${PANE_INFO} - echo "${@}" >> /tmp/.passt_test_log_pipe + echo "${@}" >> $STATEBASE/log_pipe } # info_nolog() - Print message to log file @@ -365,7 +365,7 @@ status_test_start() { info_check() { switch_pane ${PANE_INFO} - printf "${PR_YELLOW}?${PR_NC} ${@}" >> /tmp/.passt_test_log_pipe + printf "${PR_YELLOW}?${PR_NC} ${@}" >> $STATEBASE/log_pipe printf "? ${@}" >> "${LOGFILE}" } @@ -373,7 +373,7 @@ info_check() { info_check_passed() { switch_pane ${PANE_INFO} - printf "\n" >> /tmp/.passt_test_log_pipe + printf "\n" >> $STATEBASE/log_pipe printf "\n" >> ${LOGFILE} } @@ -381,7 +381,7 @@ info_check_passed() { info_check_failed() { switch_pane ${PANE_INFO} - printf " ${PR_RED}!${PR_NC}\n" >> /tmp/.passt_test_log_pipe + printf " ${PR_RED}!${PR_NC}\n" >> $STATEBASE/log_pipe printf " < failed.\n" >> "${LOGFILE}" } diff --git a/test/run b/test/run index 58d9b49..4bb9cd8 100755 --- a/test/run +++ b/test/run @@ -49,13 +49,11 @@ COMMIT="$(git log --oneline --no-decorate -1)" # cleanup() - Remove temporary files cleanup() { [ ${DEBUG} -eq 1 ] || rm -rf "${STATEBASE}" - 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 + mkfifo $STATEBASE/log_pipe term perf_init @@ -131,8 +129,7 @@ run() { # demo() - Simpler path for demo purposes demo() { - rm -f /tmp/.passt_test_log_pipe - mkfifo /tmp/.passt_test_log_pipe + mkfifo $STATEBASE/log_pipe FAST=0 -- 2.37.3
Currently the context command dispatch subsystem creates a bunch of temporary files in $LOGDIR, which is messy. Store them in $STATEDIR which is for precisely this purpose. The logs from each context still go into $LOGDIR. Signed-off-by: David Gibson <david(a)gibson.dropbear.id.au> --- test/lib/context | 61 +++++++++++++++++++++++++----------------------- 1 file changed, 32 insertions(+), 29 deletions(-) diff --git a/test/lib/context b/test/lib/context index ccb0004..43b00dd 100644 --- a/test/lib/context +++ b/test/lib/context @@ -17,17 +17,17 @@ # $1: Context name context_setup_common() { __name="$1" - __prefix="${LOGDIR}/context_${__name}" - echo -n "${__name}$ " > "${__prefix}.log" + __log="${LOGDIR}/context_${__name}.log" + echo -n "${__name}$ " > "${__log}" } # context_setup_host() - Create a new context for running commands on the host # $1: Context name context_setup_host() { __name="$1" - __prefix="${LOGDIR}/context_${__name}" + __enter="${STATESETUP}/context_${__name}.enter" context_setup_common "${__name}" - echo sh -c > "${__prefix}.enter" + echo sh -c > "${__enter}" } # context_setup_nsenter() - Create a new context for running commands in a namespace @@ -36,9 +36,9 @@ context_setup_host() { context_setup_nsenter() { __name="$1" shift - __prefix="${LOGDIR}/context_${__name}" + __enter="${STATESETUP}/context_${__name}.enter" context_setup_common "${__name}" - echo "nsenter $@ sh -c" > "${__prefix}.enter" + echo "nsenter $@ sh -c" > "${__enter}" } # context_setup_guest() - Create a new context for running commands in a guest @@ -47,22 +47,23 @@ context_setup_nsenter() { context_setup_guest() { __name="$1" __cid="$2" - __prefix="${LOGDIR}/context_${__name}" + __enter="${STATESETUP}/context_${__name}.enter" + __ssh="${STATESETUP}/context_${__name}.ssh" context_setup_common "${__name}" - cat > "${__prefix}.ssh" <<EOF + cat > "${__ssh}" <<EOF Host ${__name} User root - UserKnownHostsFile ${__prefix}.hosts + UserKnownHostsFile ${STATESETUP}/context_${__name}.hosts StrictHostKeyChecking no IdentityFile ${BASEPATH}/guest-key IdentityAgent none ProxyCommand socat - VSOCK-CONNECT:${__cid}:22 EOF - echo "ssh -F ${__prefix}.ssh ${__name}" > "${__prefix}.enter" + echo "ssh -F ${__ssh} ${__name}" > "${__enter}" # Wait for the guest to be booted and accepting connections - while ! ssh -F "${__prefix}.ssh" "${__name}" :; do + while ! ssh -F "${__ssh}" "${__name}" :; do sleep 0.1 done } @@ -71,7 +72,7 @@ EOF # $1: Context name context_teardown() { __name="$1" - __prefix="${LOGDIR}/context_${__name}" + __prefix="${STATESETUP}/context_${__name}" rm -f "${__prefix}.enter" "${__prefix}.ssh" "${__prefix}.hosts" } @@ -79,8 +80,8 @@ context_teardown() { # $1: Context name context_exists() { __name="$1" - __prefix="${LOGDIR}/context_${__name}" - [ -f "${__prefix}.enter" ] + __enter="${STATESETUP}/context_${__name}.enter" + [ -f "${__enter}" ] } # context_run() - Run a shell command in a context, and wait for it to finish @@ -88,18 +89,20 @@ context_exists() { # $*: Command to start context_run() { __name="$1" - __prefix="${LOGDIR}/context_${__name}" - __enter="$(cat "${__prefix}.enter")" + __log="${LOGDIR}/context_${__name}.log" + __enter="${STATESETUP}/context_${__name}.enter" + __stdout="${STATESETUP}/context_${__name}.stdout" + __stderr="${STATESETUP}/context_${__name}.stderr" shift - echo "$*" >> "${__prefix}.log" - mkfifo "${__prefix}.stdout" "${__prefix}.stderr" - tee -a "${__prefix}.log" < "${__prefix}.stdout" & - tee -a "${__prefix}.log" < "${__prefix}.stderr" >&2 & - ${__enter} "$*" >> "${__prefix}.stdout" 2>> "${__prefix}.stderr" + echo "$*" >> "${__log}" + mkfifo "${__stdout}" "${__stderr}" + tee -a "${__log}" < "${__stdout}" & + tee -a "${__log}" < "${__stderr}" >&2 & + $(cat ${__enter}) "$*" >> "${__stdout}" 2>> "${__stderr}" rc=$? - rm "${__prefix}.stdout" "${__prefix}.stderr" - [ ${DEBUG} -eq 1 ] && echo "[Exit code: $rc]" >> "${__prefix}.log" - echo -n "${__name}$ " >> "${__prefix}.log" + rm "${__stdout}" "${__stderr}" + [ ${DEBUG} -eq 1 ] && echo "[Exit code: $rc]" >> "${__log}" + echo -n "${__name}$ " >> "${__log}" return $rc } @@ -108,9 +111,9 @@ context_run() { # $*: Command to start context_run_bg() { __name="$1" - __prefix="${LOGDIR}/context_${__name}" + __pidfile="${STATESETUP}/context_${__name}.pid" context_run "$@" & - echo $! > "${__prefix}.pid" + echo $! > "${__pidfile}" } # context_wait() - Wait for background command in a context to complete @@ -118,8 +121,8 @@ context_run_bg() { # Returns the status of the completed command context_wait() { __name="$1" - __prefix="${LOGDIR}/context_${__name}" - __pid=$(cat "${__prefix}.pid") - rm "${__prefix}.pid" + __pidfile="${STATESETUP}/context_${__name}.pid" + __pid=$(cat "${__pidfile}") + rm "${__pidfile}" wait ${__pid} } -- 2.37.3
In what looks like a copy/paste error, pasta/tcp generates its small test file twice. Signed-off-by: David Gibson <david(a)gibson.dropbear.id.au> --- test/pasta/tcp | 3 --- 1 file changed, 3 deletions(-) diff --git a/test/pasta/tcp b/test/pasta/tcp index 7c7de06..5497f11 100644 --- a/test/pasta/tcp +++ b/test/pasta/tcp @@ -91,10 +91,7 @@ hout HOST_MD5_BIG md5sum __TEMP_BIG__ | cut -d' ' -f1 check [ "__HOST_MD5_BIG__" = "__MD5_BIG__" ] test TCP/IPv6: host to ns: small transfer -temp TEMP_SMALL -temp TEMP_NS_SMALL nsb socat -u TCP6-LISTEN:10002,bind=[::1] OPEN:__TEMP_NS_SMALL__,create,trunc -host dd if=/dev/urandom bs=2k count=1 of=__TEMP_SMALL__ host socat -u OPEN:__TEMP_SMALL__ TCP6:[::1]:10002 nsw hout MD5_SMALL md5sum __TEMP_SMALL__ | cut -d' ' -f1 -- 2.37.3
Instead of using the 'temp' and 'tempdir' DSL directives to create temporary files, use fixed paths relative to __STATEDIR__. This has two advantages: 1) The files are automatically cleaned up if the tests fail (and even if that doesn't work they're easier to clean up manuall) 2) When debugging tests it's easier to figure out which of the temporary files are relevant to whatever's going wrong Signed-off-by: David Gibson <david(a)gibson.dropbear.id.au> --- test/build/all | 31 +++++++++++++++---------------- test/demo/passt | 9 ++++----- test/demo/pasta | 12 +++++------- test/demo/podman | 11 +++++------ test/distro/debian | 2 +- test/distro/fedora | 2 +- test/distro/opensuse | 16 +++++++++------- test/distro/ubuntu | 8 ++++---- test/lib/test | 10 ---------- test/passt/tcp | 4 ++-- test/passt/udp | 6 +++--- test/passt_in_ns/tcp | 8 ++++---- test/passt_in_ns/udp | 6 +++--- test/pasta/tcp | 8 ++++---- test/pasta/udp | 18 +++++++++--------- 15 files changed, 69 insertions(+), 82 deletions(-) diff --git a/test/build/all b/test/build/all index 1a89b77..bacb1d1 100644 --- a/test/build/all +++ b/test/build/all @@ -41,22 +41,21 @@ check [ -f passt ] check [ -h pasta ] check [ -f qrap ] -tempdir TEMP - test Install -host prefix=__TEMP__ make install -check [ -f __TEMP__/bin/passt ] -check [ -h __TEMP__/bin/pasta ] -check [ -f __TEMP__/bin/qrap ] -check man -M __TEMP__/share/man -W passt -check man -M __TEMP__/share/man -W pasta -check man -M __TEMP__/share/man -W qrap +host mkdir __STATEDIR__/prefix +host prefix=__STATEDIR__/prefix make install +check [ -f __STATEDIR__/prefix/bin/passt ] +check [ -h __STATEDIR__/prefix/bin/pasta ] +check [ -f __STATEDIR__/prefix/bin/qrap ] +check man -M __STATEDIR__/prefix/share/man -W passt +check man -M __STATEDIR__/prefix/share/man -W pasta +check man -M __STATEDIR__/prefix/share/man -W qrap test Uninstall -host prefix=__TEMP__ make uninstall -check ! [ -f __TEMP__/bin/passt ] -check ! [ -h __TEMP__/bin/pasta ] -check ! [ -f __TEMP__/bin/qrap ] -check ! man -M __TEMP__/share/man -W passt 2>/dev/null -check ! man -M __TEMP__/share/man -W pasta 2>/dev/null -check ! man -M __TEMP__/share/man -W qrap 2>/dev/null +host prefix=__STATEDIR__/prefix make uninstall +check ! [ -f __STATEDIR__/prefix/bin/passt ] +check ! [ -h __STATEDIR__/prefix/bin/pasta ] +check ! [ -f __STATEDIR__/prefix/bin/qrap ] +check ! man -M __STATEDIR__/prefix/share/man -W passt 2>/dev/null +check ! man -M __STATEDIR__/prefix/share/man -W pasta 2>/dev/null +check ! man -M __STATEDIR__/prefix/share/man -W qrap 2>/dev/null diff --git a/test/demo/passt b/test/demo/passt index 673afd9..dd6a119 100644 --- a/test/demo/passt +++ b/test/demo/passt @@ -20,8 +20,7 @@ sleep 3 say Let's fetch the source sleep 1 -tempdir TEMPDIR -host cd __TEMPDIR__ +host cd __STATEDIR__ host git clone git://passt.top/passt sleep 1 @@ -52,10 +51,10 @@ host q nl nl say Let's create a small initramfs image for the guest. -guest cd __TEMPDIR__ +guest cd __STATEDIR__ guest git clone git://mbuto.sh/mbuto guest cd mbuto -guest ./mbuto -f passt.img -p __TEMPDIR__/passt/test/passt.mbuto -c lz4 +guest ./mbuto -f passt.img -p __STATEDIR__/passt/test/passt.mbuto -c lz4 sleep 2 nl @@ -69,7 +68,7 @@ nl say 'pasta' demo above. sleep 3 -passt cd __TEMPDIR__/passt +passt cd __STATEDIR__/passt passtb ./pasta -P /tmp/pasta.pid sleep 3 passt /sbin/dhclient -4 --no-pid diff --git a/test/demo/pasta b/test/demo/pasta index 393149e..22479f8 100644 --- a/test/demo/pasta +++ b/test/demo/pasta @@ -20,8 +20,7 @@ sleep 3 say Let's fetch the source sleep 1 -tempdir TEMPDIR -host cd __TEMPDIR__ +host cd __STATEDIR__ host git clone git://passt.top/passt sleep 1 @@ -47,7 +46,7 @@ sleep 10 nl say without PID, it will create a namespace. sleep 3 -passt cd __TEMPDIR__/passt +passt cd __STATEDIR__/passt passtb ./pasta -P /tmp/pasta.pid sleep 3 @@ -140,13 +139,12 @@ say can also take packet captures. sleep 3 passt exit sleep 2 -temp TEMP -passtb ./pasta -p __TEMP__.pcap +passtb ./pasta -p __STATEDIR__/demo_pasta.pcap sleep 2 passt passt /sbin/dhclient -4 --no-pid sleep 2 -hostb tshark -r __TEMP__.pcap +hostb tshark -r __STATEDIR__/demo_pasta.pcap sleep 5 nl @@ -257,7 +255,7 @@ sleep 2 killp PASST killp HOST sleep 2 -ns cd __TEMPDIR__/passt +ns cd __STATEDIR__/passt nsb perf report -g --max-stack 3 sleep 10 diff --git a/test/demo/podman b/test/demo/podman index f3411d8..a83a04f 100644 --- a/test/demo/podman +++ b/test/demo/podman @@ -24,14 +24,13 @@ sleep 3 say Let's fetch Podman sleep 1 -tempdir TEMPDIR -host git -C __TEMPDIR__ clone https://github.com/containers/podman.git +host git -C __STATEDIR__ clone https://github.com/containers/podman.git sleep 1 say , patch it sleep 1 -host cp ../contrib/podman/0001-libpod-Add-pasta-networking-mode.patch __TEMPDIR__/podman -host cd __TEMPDIR__/podman +host cp ../contrib/podman/0001-libpod-Add-pasta-networking-mode.patch __STATEDIR__/podman +host cd __STATEDIR__/podman host git am -3 0001-libpod-Add-pasta-networking-mode.patch sleep 1 @@ -54,7 +53,7 @@ nl say Let's start a container with it sleep 1 -ns1 cd __TEMPDIR__/podman +ns1 cd __STATEDIR__/podman ns1b ./bin/podman run --rm -ti alpine sh sleep 2 @@ -64,7 +63,7 @@ say and one with em pasta say instead. -ns2 cd __TEMPDIR__/podman +ns2 cd __STATEDIR__/podman ns2b ./bin/podman run --net=pasta --rm -ti alpine sh sleep 2 diff --git a/test/distro/debian b/test/distro/debian index 83fb32d..4a19f95 100644 --- a/test/distro/debian +++ b/test/distro/debian @@ -11,7 +11,7 @@ # Copyright (c) 2021 Red Hat GmbH # Author: Stefano Brivio <sbrivio(a)redhat.com> -temp PIDFILE +set PIDFILE __STATEDIR__/passt.pid htools cat kill qemu-system-x86_64 qemu-system-aarch64 qemu-system-ppc64 # Quick pasta test: send message from init to ns, and from ns to init diff --git a/test/distro/fedora b/test/distro/fedora index daad6a4..a8d3b51 100644 --- a/test/distro/fedora +++ b/test/distro/fedora @@ -11,7 +11,7 @@ # Copyright (c) 2021 Red Hat GmbH # Author: Stefano Brivio <sbrivio(a)redhat.com> -temp PIDFILE +set PIDFILE __STATEDIR__/passt.pid htools cat kill qemu-system-x86_64 # Quick pasta test: send message from init to ns, and from ns to init diff --git a/test/distro/opensuse b/test/distro/opensuse index d48deb7..314870f 100644 --- a/test/distro/opensuse +++ b/test/distro/opensuse @@ -11,7 +11,7 @@ # Copyright (c) 2021 Red Hat GmbH # Author: Stefano Brivio <sbrivio(a)redhat.com> -temp PIDFILE +set PIDFILE __STATEDIR__/passt.pid htools qemu-img virt-edit guestfish head sed cat kill qemu-system-x86_64 qemu-system-aarch64 xzcat tr # Quick pasta test: send message from init to ns, and from ns to init @@ -44,7 +44,7 @@ hout GUEST_FILES ls -1 *.c *.h *.sh passt.1 qrap.1 Makefile README.md | tr '\n' test OpenSUSE Leap 15.1 -temp IMG +set IMG __STATEDIR__/opensuse-15.1-x86_64.img host qemu-img create -f qcow2 -F qcow2 -b __BASEPATH__/openSUSE-Leap-15.1-JeOS.x86_64-kvm-and-xen.qcow2 __IMG__ host guestfish --rw -a __IMG__ -i rm '/usr/lib/systemd/system/systemd-journald.service' host guestfish --rw -a __IMG__ -i rm /etc/systemd/system/default.target.wants/jeos-firstboot.service @@ -73,6 +73,7 @@ hout PID cat __PIDFILE__ test OpenSUSE Leap 15.2 +set IMG __STATEDIR__/opensuse-15.2-x86_64.img host qemu-img create -f qcow2 -F qcow2 -b __BASEPATH__/openSUSE-Leap-15.2-JeOS.x86_64-kvm-and-xen.qcow2 __IMG__ host guestfish --rw -a __IMG__ -i rm '/usr/lib/systemd/system/systemd-journald.service' host guestfish --rw -a __IMG__ -i rm /etc/systemd/system/default.target.wants/jeos-firstboot.service @@ -98,6 +99,7 @@ sleep 1 test OpenSUSE Leap 15.3 +set IMG __STATEDIR__/opensuse-15.3-x86_64.img host qemu-img create -f qcow2 -F qcow2 -b __BASEPATH__/openSUSE-Leap-15.3-JeOS.x86_64-kvm-and-xen.qcow2 __IMG__ host guestfish --rw -a __IMG__ -i rm '/usr/lib/systemd/system/systemd-journald.service' host guestfish --rw -a __IMG__ -i rm /etc/systemd/system/default.target.wants/jeos-firstboot.service @@ -125,7 +127,7 @@ sleep 1 test OpenSUSE Tumbleweed aarch64 -temp IMG +set IMG __STATEDIR__/opensuse-tumbleweed-aarch64.img host xzcat __BASEPATH__/openSUSE-Tumbleweed-ARM-JeOS-efi.aarch64.raw.xz > __IMG__ host virt-edit -a __IMG__ -m /dev/sda3 /usr/lib/systemd/system/serial-getty@.service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --timeout 5000 --autologin root -i -8 --keep-baud 115200,38400,9600 %I $TERM/g' host guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/ @@ -150,9 +152,9 @@ sleep 1 test OpenSUSE Tumbleweed armv7l -temp IMG -temp ZIMAGE -temp INITRD +set IMG __STATEDIR__/opensuse-tumbleweed-armv7l.img +set ZIMAGE __STATEDIR__/opensuse-tumbleweed-armv7l.zimage +set INITRD __STATEDIR__/opensuse-tumbleweed-armv7l.initrd host xzcat __BASEPATH__/openSUSE-Tumbleweed-ARM-JeOS-efi.armv7l.raw.xz > __IMG__ host guestfish -a __IMG__ -i download /boot/zImage __ZIMAGE__ host guestfish -a __IMG__ -i download /boot/initrd __INITRD__ @@ -178,7 +180,7 @@ sleep 1 test OpenSUSE Tumbleweed -temp IMG +set IMG __STATEDIR__/opensuse-tumbleweed-x86_64.img host qemu-img create -f qcow2 -F qcow2 -b __BASEPATH__/openSUSE-Tumbleweed-JeOS.x86_64-kvm-and-xen.qcow2 __IMG__ host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/systemd-journald.service host guestfish --rw -a __IMG__ -i rm /etc/systemd/system/default.target.wants/jeos-firstboot.service diff --git a/test/distro/ubuntu b/test/distro/ubuntu index 5e67a46..aa42c99 100644 --- a/test/distro/ubuntu +++ b/test/distro/ubuntu @@ -11,7 +11,7 @@ # Copyright (c) 2021 Red Hat GmbH # Author: Stefano Brivio <sbrivio(a)redhat.com> -temp PIDFILE +set PIDFILE __STATEDIR__/passt.pid htools qemu-img virt-edit guestfish cat kill qemu-system-x86_64 qemu-system-ppc64 qemu-system-s390x # Quick pasta test: send message from init to ns, and from ns to init @@ -68,7 +68,7 @@ hout GUEST_FILES ls -1 *.c *.h *.sh passt.1 qrap.1 Makefile README.md | tr '\n' test Ubuntu 14.04.5 LTS (Trusty Tahr), amd64 -temp IMG +set IMG __STATEDIR__/ubuntu-14.04-amd64.img host qemu-img create -f qcow2 -F qcow2 -b __BASEPATH__/trusty-server-cloudimg-amd64-disk1.img __IMG__ host virt-edit -a __IMG__ /etc/init/ttyS0.conf -e 's/\/getty/\/getty --autologin root/' host guestfish --rw -a __IMG__ -i rm /etc/init/cloud-config.conf @@ -101,7 +101,7 @@ hout PID cat __PIDFILE__ test Ubuntu 14.04.5 LTS (Trusty Tahr), i386 -temp IMG +set IMG __STATEDIR__/ubuntu-14.04-i386.img host qemu-img create -f qcow2 -F qcow2 -b __BASEPATH__/trusty-server-cloudimg-i386-disk1.img __IMG__ host virt-edit -a __IMG__ /etc/init/ttyS0.conf -e 's/\/getty/\/getty --autologin root/' host guestfish --rw -a __IMG__ -i rm /etc/init/cloud-config.conf @@ -131,7 +131,7 @@ sleep 1 test Ubuntu 14.04.5 LTS (Trusty Tahr), ppc64le -temp IMG +set IMG __STATEDIR__/ubuntu-14.04-ppc64le.img host qemu-img create -f qcow2 -F qcow2 -b __BASEPATH__/trusty-server-cloudimg-ppc64el-disk1.img __IMG__ host virt-edit -a __IMG__ /etc/init/hvc0.conf -e 's/\/getty/\/getty --autologin root/' host guestfish --rw -a __IMG__ -i rm /etc/init/cloud-config.conf diff --git a/test/lib/test b/test/lib/test index 3dbae0b..3ad178f 100755 --- a/test/lib/test +++ b/test/lib/test @@ -99,16 +99,6 @@ test_one_line() { IFS= eval TEST_ONE_DEF_$TEST_ONE_in_def= IFS="${__ifs}" ;; - "tempdir") - __tmpdir="$(mktemp -d)" - TEST_ONE_subs="$(list_add_pair "${TEST_ONE_subs}" "__${__arg}__" "${__tmpdir}")" - TEST_ONE_dirclean="$(list_add "${TEST_ONE_dirclean}" "${__tmpdir}")" - ;; - "temp") - __tmpfile="$(mktemp)" - TEST_ONE_subs="$(list_add_pair "${TEST_ONE_subs}" "__${__arg}__" "${__tmpfile}")" - TEST_ONE_dirclean="$(list_add "${TEST_ONE_dirclean}" "${__tmpfile}")" - ;; "test") [ ${TEST_ONE_perf_nok} -eq 0 ] || TEST_ONE_nok=1 [ ${TEST_ONE_nok} -eq 1 ] && status_test_fail diff --git a/test/passt/tcp b/test/passt/tcp index d5c8164..7af9c54 100644 --- a/test/passt/tcp +++ b/test/passt/tcp @@ -15,7 +15,7 @@ gtools socat ip jq md5sum cut htools dd socat ip jq md5sum cut test TCP/IPv4: host to guest: big transfer -temp TEMP_BIG +set TEMP_BIG __STATEDIR__/big guestb socat -u TCP4-LISTEN:10001,reuseaddr OPEN:test_big.bin,create,trunc sleep 1 host dd if=/dev/urandom bs=1M count=10 > __TEMP_BIG__ @@ -34,7 +34,7 @@ hout HOST_MD5_BIG md5sum __TEMP_BIG__ | cut -d' ' -f1 check [ "__GUEST_MD5_BIG__" = "__HOST_MD5_BIG__" ] test TCP/IPv4: host to guest: small transfer -temp TEMP_SMALL +set TEMP_SMALL __STATEDIR__/small guestb socat -u TCP4-LISTEN:10001,reuseaddr OPEN:test_small.bin,create,trunc sleep 1 host dd if=/dev/urandom bs=2k count=1 > __TEMP_SMALL__ diff --git a/test/passt/udp b/test/passt/udp index 56d01b3..0253a86 100644 --- a/test/passt/udp +++ b/test/passt/udp @@ -15,9 +15,9 @@ gtools socat tee grep cat ip jq md5sum cut htools printf dd socat tee grep cat ip jq md5sum cut test UDP/IPv4: host to guest -temp TEMP -temp SC_PID -guestb (socat -u UDP4-LISTEN:10001 STDOUT & echo $! > __SC_PID__) | tee test.bin | (grep -qm1 "END_OF_TEST" && kill $(cat __SC_PID__)) +set TEMP __STATEDIR__/data +set SC_PID __STATEDIR__/socat.pid +guestb (socat -u UDP4-LISTEN:10001 STDOUT & echo $! > sc.pid) | tee test.bin | (grep -qm1 "END_OF_TEST" && kill $(cat sc.pid)) sleep 1 host dd if=/dev/urandom bs=1k count=5 > __TEMP__ && printf "\nEND_OF_TEST\n" >> __TEMP__ host socat -u OPEN:__TEMP__ UDP4:127.0.0.1:10001 diff --git a/test/passt_in_ns/tcp b/test/passt_in_ns/tcp index 5ec95e8..a2cb667 100644 --- a/test/passt_in_ns/tcp +++ b/test/passt_in_ns/tcp @@ -16,7 +16,7 @@ htools dd socat ip jq md5sum cut nstools socat ip jq md5sum cut test TCP/IPv4: host to guest: big transfer -temp TEMP_BIG +set TEMP_BIG __STATEDIR__/big.img guestb socat -u TCP4-LISTEN:10001 OPEN:test_big.bin,create,trunc sleep 1 host dd if=/dev/urandom bs=1M count=10 of=__TEMP_BIG__ @@ -27,7 +27,7 @@ gout GUEST_MD5_BIG md5sum test_big.bin | cut -d' ' -f1 check [ "__GUEST_MD5_BIG__" = "__MD5_BIG__" ] test TCP/IPv4: host to ns: big transfer -temp TEMP_NS_BIG +set TEMP_NS_BIG __STATEDIR__/big_ns.img nsb socat -u TCP4-LISTEN:10002 OPEN:__TEMP_NS_BIG__,create,trunc host socat -u OPEN:__TEMP_BIG__ TCP4:127.0.0.1:10002 nsw @@ -82,7 +82,7 @@ gout GUEST_MD5_BIG md5sum test_big.bin | cut -d' ' -f1 check [ "__GUEST_MD5_BIG__" = "__MD5_BIG__" ] test TCP/IPv4: host to guest: small transfer -temp TEMP_SMALL +set TEMP_SMALL __STATEDIR__/small.img guestb socat -u TCP4-LISTEN:10001 OPEN:test_small.bin,create,trunc sleep 1 host dd if=/dev/urandom bs=2k count=100 of=__TEMP_SMALL__ @@ -93,7 +93,7 @@ gout GUEST_MD5_SMALL md5sum test_small.bin | cut -d' ' -f1 check [ "__GUEST_MD5_SMALL__" = "__MD5_SMALL__" ] test TCP/IPv4: host to ns: small transfer -temp TEMP_NS_SMALL +set TEMP_NS_SMALL __STATEDIR__/small_ns.img nsb socat -u TCP4-LISTEN:10002 OPEN:__TEMP_NS_SMALL__,create,trunc host socat -u OPEN:__TEMP_SMALL__ TCP4:127.0.0.1:10002 nsw diff --git a/test/passt_in_ns/udp b/test/passt_in_ns/udp index c22a68f..3b1e521 100644 --- a/test/passt_in_ns/udp +++ b/test/passt_in_ns/udp @@ -16,8 +16,8 @@ nstools socat tee grep cat ip jq md5sum cut htools printf dd socat tee grep cat ip jq md5sum cut test UDP/IPv4: host to guest -temp TEMP -temp SC_PID +set TEMP __STATEDIR__/data +set SC_PID __STATEDIR__/socat.pid guestb (socat -u UDP4-LISTEN:10001 STDOUT & echo $! > sc.pid) | tee test.bin | (grep -qm1 "END_OF_TEST" && kill $(cat sc.pid)) sleep 1 host dd if=/dev/urandom bs=1k count=5 > __TEMP__ && printf "\nEND_OF_TEST\n" >> __TEMP__ @@ -28,7 +28,7 @@ gout GUEST_MD5 md5sum test.bin | cut -d' ' -f1 check [ "__GUEST_MD5__" = "__MD5__" ] test UDP/IPv4: host to ns -temp TEMP_NS +set TEMP_NS __STATEDIR__/data_ns nsb (socat -u UDP4-LISTEN:10002 STDOUT & echo $! > __SC_PID__) | tee __TEMP_NS__ | (grep -qm1 "END_OF_TEST" && kill $(cat __SC_PID__)) host socat -u OPEN:__TEMP__ UDP4:127.0.0.1:10002 nsw diff --git a/test/pasta/tcp b/test/pasta/tcp index 5497f11..d37e21c 100644 --- a/test/pasta/tcp +++ b/test/pasta/tcp @@ -15,8 +15,8 @@ htools dd socat ip jq md5sum cut nstools socat ip jq md5sum cut test TCP/IPv4: host to ns: big transfer -temp TEMP_BIG -temp TEMP_NS_BIG +set TEMP_BIG __STATEDIR__/big +set TEMP_NS_BIG __STATEDIR__/big_ns nsb socat -u TCP4-LISTEN:10002,bind=127.0.0.1 OPEN:__TEMP_NS_BIG__,create,trunc host dd if=/dev/urandom bs=1M count=10 of=__TEMP_BIG__ host socat -u OPEN:__TEMP_BIG__ TCP4:127.0.0.1:10002 @@ -41,8 +41,8 @@ hout HOST_MD5_BIG md5sum __TEMP_BIG__ | cut -d' ' -f1 check [ "__HOST_MD5_BIG__" = "__MD5_BIG__" ] test TCP/IPv4: host to ns: small transfer -temp TEMP_SMALL -temp TEMP_NS_SMALL +set TEMP_SMALL __STATEDIR__/small +set TEMP_NS_SMALL __STATEDIR__/small_ns nsb socat -u TCP4-LISTEN:10002,bind=127.0.0.1 OPEN:__TEMP_NS_SMALL__,create,trunc host dd if=/dev/urandom bs=2k count=1 of=__TEMP_SMALL__ host socat OPEN:__TEMP_SMALL__ TCP4:127.0.0.1:10002 diff --git a/test/pasta/udp b/test/pasta/udp index 0e58152..74148e3 100644 --- a/test/pasta/udp +++ b/test/pasta/udp @@ -15,10 +15,10 @@ nstools socat tee grep cat ip jq md5sum cut htools printf dd socat tee grep cat ip jq md5sum cut test UDP/IPv4: host to ns -temp TEMP -temp TEMP_NS -temp NC_PID -nsb (socat -u UDP4-LISTEN:10002,bind=127.0.0.1 STDOUT & echo $! > __NC_PID__) | tee __TEMP_NS__ | (grep -qm1 "END_OF_TEST" && kill $(cat __NC_PID__)) +set TEMP __STATEDIR__/data +set TEMP_NS __STATEDIR__/data_ns +set SC_PID __STATEDIR__/socat.pid +nsb (socat -u UDP4-LISTEN:10002,bind=127.0.0.1 STDOUT & echo $! > __SC_PID__) | tee __TEMP_NS__ | (grep -qm1 "END_OF_TEST" && kill $(cat __SC_PID__)) host dd if=/dev/urandom bs=1k count=5 > __TEMP__ && printf "\nEND_OF_TEST\n" >> __TEMP__ host socat OPEN:__TEMP__ UDP4:127.0.0.1:10002 @@ -28,7 +28,7 @@ nsout NS_MD5 md5sum __TEMP_NS__ | cut -d' ' -f1 check [ "__NS_MD5__" = "__MD5__" ] test UDP/IPv4: ns to host (recvmmsg/sendmmsg) -hostb (socat -u UDP4-LISTEN:10003,bind=127.0.0.1 STDOUT & echo $! > __NC_PID__) | tee __TEMP__ | (grep -qm1 "END_OF_TEST" && kill $(cat __NC_PID__)) +hostb (socat -u UDP4-LISTEN:10003,bind=127.0.0.1 STDOUT & echo $! > __SC_PID__) | tee __TEMP__ | (grep -qm1 "END_OF_TEST" && kill $(cat __SC_PID__)) sleep 1 ns socat OPEN:__TEMP_NS__ UDP4:127.0.0.1:10003 hostw @@ -36,7 +36,7 @@ hout HOST_MD5 md5sum __TEMP__ | cut -d' ' -f1 check [ "__HOST_MD5__" = "__MD5__" ] test UDP/IPv4: ns to host (via tap) -hostb (socat -u UDP4-LISTEN:10003 STDOUT & echo $! > __NC_PID__) | tee __TEMP__ | (grep -qm1 "END_OF_TEST" && kill $(cat __NC_PID__)) +hostb (socat -u UDP4-LISTEN:10003 STDOUT & echo $! > __SC_PID__) | tee __TEMP__ | (grep -qm1 "END_OF_TEST" && kill $(cat __SC_PID__)) nsout GW ip -j -4 route show|jq -rM '.[] | select(.dst == "default").gateway' ns socat -u OPEN:__TEMP_NS__ UDP4:__GW__:10003 hostw @@ -44,7 +44,7 @@ hout HOST_MD5 md5sum __TEMP__ | cut -d' ' -f1 check [ "__HOST_MD5__" = "__MD5__" ] test UDP/IPv6: host to ns -nsb (socat -u UDP6-LISTEN:10002,bind=[::1] STDOUT & echo $! > __NC_PID__) | tee __TEMP_NS__ | (grep -qm1 "END_OF_TEST" && kill $(cat __NC_PID__)) +nsb (socat -u UDP6-LISTEN:10002,bind=[::1] STDOUT & echo $! > __SC_PID__) | tee __TEMP_NS__ | (grep -qm1 "END_OF_TEST" && kill $(cat __SC_PID__)) host socat -u OPEN:__TEMP__ UDP6:[::1]:10002 nsw hout MD5 md5sum __TEMP__ | cut -d' ' -f1 @@ -52,7 +52,7 @@ nsout NS_MD5 md5sum __TEMP_NS__ | cut -d' ' -f1 check [ "__NS_MD5__" = "__MD5__" ] test UDP/IPv6: ns to host (recvmmsg/sendmmsg) -hostb (socat -u UDP6-LISTEN:10003,bind=[::1] STDOUT & echo $! > __NC_PID__) | tee __TEMP__ | (grep -qm1 "END_OF_TEST" && kill $(cat __NC_PID__)) +hostb (socat -u UDP6-LISTEN:10003,bind=[::1] STDOUT & echo $! > __SC_PID__) | tee __TEMP__ | (grep -qm1 "END_OF_TEST" && kill $(cat __SC_PID__)) sleep 1 ns socat -u OPEN:__TEMP_NS__ UDP6:[::1]:10003 hostw @@ -60,7 +60,7 @@ hout HOST_MD5 md5sum __TEMP__ | cut -d' ' -f1 check [ "__HOST_MD5__" = "__MD5__" ] test UDP/IPv6: ns to host (via tap) -hostb (socat -u UDP6-LISTEN:10003 STDOUT & echo $! > __NC_PID__) | tee __TEMP__ | (grep -qm1 "END_OF_TEST" && kill $(cat __NC_PID__)) +hostb (socat -u UDP6-LISTEN:10003 STDOUT & echo $! > __SC_PID__) | tee __TEMP__ | (grep -qm1 "END_OF_TEST" && kill $(cat __SC_PID__)) nsout GW6 ip -j -6 route show|jq -rM '.[] | select(.dst == "default").gateway' nsout IFNAME ip -j link show | jq -rM '.[] | select(.link_type == "ether").ifname' ns socat -u OPEN:__TEMP_NS__ UDP6:[__GW6__%__IFNAME__]:10003 -- 2.37.3
Signed-off-by: David Gibson <david(a)gibson.dropbear.id.au> --- test/lib/term | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/lib/term b/test/lib/term index 9a3ef7f..c9720be 100755 --- a/test/lib/term +++ b/test/lib/term @@ -599,8 +599,8 @@ pause_continue() { info_nolog "${1}" info_nolog_n "${2}" - __pause_tmp="$(mktemp)" - echo >> "${__pause_tmp}" + __pause_tmp="${STATEBASE}/pause.tmp" + echo > "${__pause_tmp}" tmux pipe-pane -O -t ${PANE_INFO} "cat >> ${__pause_tmp}" __pane_buf= __wait=0 -- 2.37.3
The capture files are more or less a different form of log output from the tests, so place them in $LOGDIR. Signed-off-by: David Gibson <david(a)gibson.dropbear.id.au> --- test/lib/setup | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/test/lib/setup b/test/lib/setup index b9c9e81..ab532b5 100755 --- a/test/lib/setup +++ b/test/lib/setup @@ -47,7 +47,7 @@ setup_passt() { # 10003 | as server __opts= - [ ${PCAP} -eq 1 ] && __opts="${__opts} -p /tmp/passt.pcap" + [ ${PCAP} -eq 1 ] && __opts="${__opts} -p ${LOGDIR}/passt.pcap" [ ${DEBUG} -eq 1 ] && __opts="${__opts} -d" [ ${TRACE} -eq 1 ] && __opts="${__opts} --trace" @@ -94,7 +94,7 @@ setup_pasta() { # 10003 spliced to init | as server __opts= - [ ${PCAP} -eq 1 ] && __opts="${__opts} -p /tmp/pasta.pcap" + [ ${PCAP} -eq 1 ] && __opts="${__opts} -p ${LOGDIR}/pasta.pcap" [ ${DEBUG} -eq 1 ] && __opts="${__opts} -d" [ ${TRACE} -eq 1 ] && __opts="${__opts} --trace" @@ -124,7 +124,7 @@ setup_passt_in_ns() { # 10031 as server | forwarded to guest | __opts= - [ ${PCAP} -eq 1 ] && __opts="${__opts} -p /tmp/pasta_with_passt.pcap" + [ ${PCAP} -eq 1 ] && __opts="${__opts} -p ${LOGDIR}/pasta_with_passt.pcap" [ ${DEBUG} -eq 1 ] && __opts="${__opts} -d" [ ${TRACE} -eq 1 ] && __opts="${__opts} --trace" @@ -142,7 +142,7 @@ setup_passt_in_ns() { context_run ns "/sbin/dhclient -6 --no-pid ${__ifname}" __opts= - [ ${PCAP} -eq 1 ] && __opts="${__opts} -p /tmp/passt_in_pasta.pcap" + [ ${PCAP} -eq 1 ] && __opts="${__opts} -p ${LOGDIR}/passt_in_pasta.pcap" [ ${DEBUG} -eq 1 ] && __opts="${__opts} -d" [ ${TRACE} -eq 1 ] && __opts="${__opts} --trace" @@ -194,7 +194,7 @@ setup_two_guests() { # 10005 | | | as server | to ns #2 __opts= - [ ${PCAP} -eq 1 ] && __opts="${__opts} -p /tmp/pasta_1.pcap" + [ ${PCAP} -eq 1 ] && __opts="${__opts} -p ${LOGDIR}/pasta_1.pcap" [ ${DEBUG} -eq 1 ] && __opts="${__opts} -d" [ ${TRACE} -eq 1 ] && __opts="${__opts} --trace" context_run_bg pasta_1 "./pasta ${__opts} -P pasta_1.pid -t 10001,10002 -T 10003,10004 -u 10001,10002 -U 10003,10004 ${NSHOLDER} ns1.hold hold" @@ -202,7 +202,7 @@ setup_two_guests() { context_setup_nsenter passt_1 -U -n -p --preserve-credentials -t ${__ns1_pid} __opts= - [ ${PCAP} -eq 1 ] && __opts="${__opts} -p /tmp/pasta_2.pcap" + [ ${PCAP} -eq 1 ] && __opts="${__opts} -p ${LOGDIR}/pasta_2.pcap" [ ${DEBUG} -eq 1 ] && __opts="${__opts} -d" [ ${TRACE} -eq 1 ] && __opts="${__opts} --trace" context_run_bg pasta_2 "./pasta ${__opts} -P pasta_2.pid -t 10004,10005 -T 10003,10001 -u 10004,10005 -U 10003,10001 ${NSHOLDER} ns2.hold hold" @@ -220,7 +220,7 @@ setup_two_guests() { context_run qemu_2 "/sbin/dhclient -6 --no-pid ${__ifname}" __opts= - [ ${PCAP} -eq 1 ] && __opts="${__opts} -p /tmp/passt_1.pcap" + [ ${PCAP} -eq 1 ] && __opts="${__opts} -p ${LOGDIR}/passt_1.pcap" [ ${DEBUG} -eq 1 ] && __opts="${__opts} -d" [ ${TRACE} -eq 1 ] && __opts="${__opts} --trace" @@ -228,7 +228,7 @@ setup_two_guests() { sleep 1 __opts= - [ ${PCAP} -eq 1 ] && __opts="${__opts} -p /tmp/passt_2.pcap" + [ ${PCAP} -eq 1 ] && __opts="${__opts} -p ${LOGDIR}/passt_2.pcap" [ ${DEBUG} -eq 1 ] && __opts="${__opts} -d" [ ${TRACE} -eq 1 ] && __opts="${__opts} --trace" -- 2.37.3
Currently they go in the passt source tree with a fixed names, which means their presence can mess with subsequent test runs. Signed-off-by: David Gibson <david(a)gibson.dropbear.id.au> --- .gitignore | 1 - test/lib/setup | 66 +++++++++++++++++++-------------------- test/passt/shutdown | 2 +- test/passt_in_ns/shutdown | 2 +- 4 files changed, 35 insertions(+), 36 deletions(-) diff --git a/.gitignore b/.gitignore index 80967f3..d3d0e2c 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,5 @@ /qrap /pasta.1 /seccomp.h -/*.pid /s*.json README.plain.md diff --git a/test/lib/setup b/test/lib/setup index ab532b5..d7921bf 100755 --- a/test/lib/setup +++ b/test/lib/setup @@ -53,7 +53,7 @@ setup_passt() { context_run passt "make clean" context_run passt "make valgrind" - context_run_bg passt "valgrind --max-stackframe=$((4 * 1024 * 1024)) --trace-children=yes --vgdb=no --error-exitcode=1 --suppressions=test/valgrind.supp ./passt ${__opts} -f -t 10001 -u 10001 -P passt.pid" + context_run_bg passt "valgrind --max-stackframe=$((4 * 1024 * 1024)) --trace-children=yes --vgdb=no --error-exitcode=1 --suppressions=test/valgrind.supp ./passt ${__opts} -f -t 10001 -u 10001 -P ${STATESETUP}/passt.pid" sleep 5 GUEST_CID=94557 @@ -67,7 +67,7 @@ setup_passt() { 'virtio-net.napi_tx=1"' \ " -device virtio-net-pci,netdev=hostnet0,x-txburst=16384" \ " -netdev socket,fd=5,id=hostnet0" \ - " -pidfile passt_qemu.pid" \ + " -pidfile ${STATESETUP}/qemu.pid" \ " -device vhost-vsock-pci,guest-cid=$GUEST_CID" context_setup_guest guest $GUEST_CID @@ -81,8 +81,8 @@ setup_pasta() { layout_pasta - context_run_bg unshare "unshare -rUnpf ${NSHOLDER} ns.hold hold" - __target_pid=$(${NSHOLDER} ns.hold pid) + context_run_bg unshare "unshare -rUnpf ${NSHOLDER} ${STATESETUP}/ns.hold hold" + __target_pid=$(${NSHOLDER} ${STATESETUP}/ns.hold pid) context_setup_nsenter ns -U -n -p --preserve-credentials -t ${__target_pid} @@ -98,7 +98,7 @@ setup_pasta() { [ ${DEBUG} -eq 1 ] && __opts="${__opts} -d" [ ${TRACE} -eq 1 ] && __opts="${__opts} --trace" - context_run_bg passt "./pasta ${__opts} -f -t 10002 -T 10003 -u 10002 -U 10003 -P passt.pid ${__target_pid}" + context_run_bg passt "./pasta ${__opts} -f -t 10002 -T 10003 -u 10002 -U 10003 -P ${STATESETUP}/passt.pid ${__target_pid}" sleep 1 } @@ -128,9 +128,9 @@ setup_passt_in_ns() { [ ${DEBUG} -eq 1 ] && __opts="${__opts} -d" [ ${TRACE} -eq 1 ] && __opts="${__opts} --trace" - context_run_bg pasta "./pasta ${__opts} -t 10001,10002,10011,10012 -T 10003,10013 -u 10001,10002,10011,10012 -U 10003,10013 -P pasta.pid ${NSHOLDER} ns.hold hold" + context_run_bg pasta "./pasta ${__opts} -t 10001,10002,10011,10012 -T 10003,10013 -u 10001,10002,10011,10012 -U 10003,10013 -P ${STATESETUP}/pasta.pid ${NSHOLDER} ${STATESETUP}/ns.hold hold" sleep 1 - __ns_pid=$(${NSHOLDER} ns.hold pid) + __ns_pid=$(${NSHOLDER} ${STATESETUP}/ns.hold pid) context_setup_nsenter qemu "-t ${__ns_pid} -U -n -p --preserve-credentials" context_setup_nsenter ns "-t ${__ns_pid} -U -n -p --preserve-credentials" @@ -149,11 +149,11 @@ setup_passt_in_ns() { if [ ${VALGRIND} -eq 1 ]; then context_run passt "make clean" context_run passt "make valgrind" - context_run_bg passt "valgrind --max-stackframe=$((4 * 1024 * 1024)) --trace-children=yes --vgdb=no --error-exitcode=1 --suppressions=test/valgrind.supp ./passt -f ${__opts} -t 10001,10011,10021,10031 -u 10001,10011,10021,10031 -P passt.pid" + context_run_bg passt "valgrind --max-stackframe=$((4 * 1024 * 1024)) --trace-children=yes --vgdb=no --error-exitcode=1 --suppressions=test/valgrind.supp ./passt -f ${__opts} -t 10001,10011,10021,10031 -u 10001,10011,10021,10031 -P ${STATESETUP}/passt.pid" else context_run passt "make clean" context_run passt "make" - context_run_bg passt "./passt -f ${__opts} -t 10001,10011,10021,10031 -u 10001,10011,10021,10031 -P passt.pid" + context_run_bg passt "./passt -f ${__opts} -t 10001,10011,10021,10031 -u 10001,10011,10021,10031 -P ${STATESETUP}/passt.pid" fi sleep 5 @@ -169,7 +169,7 @@ setup_passt_in_ns() { 'virtio-net.napi_tx=1"' \ " -device virtio-net-pci,netdev=hostnet0,x-txburst=524288" \ " -netdev socket,fd=5,id=hostnet0" \ - ' -pidfile passt_in_ns_qemu.pid' \ + " -pidfile ${STATESETUP}/qemu.pid" \ " -device vhost-vsock-pci,guest-cid=$GUEST_CID" context_setup_guest guest $GUEST_CID @@ -197,16 +197,16 @@ setup_two_guests() { [ ${PCAP} -eq 1 ] && __opts="${__opts} -p ${LOGDIR}/pasta_1.pcap" [ ${DEBUG} -eq 1 ] && __opts="${__opts} -d" [ ${TRACE} -eq 1 ] && __opts="${__opts} --trace" - context_run_bg pasta_1 "./pasta ${__opts} -P pasta_1.pid -t 10001,10002 -T 10003,10004 -u 10001,10002 -U 10003,10004 ${NSHOLDER} ns1.hold hold" - __ns1_pid=$(${NSHOLDER} ns1.hold pid) + context_run_bg pasta_1 "./pasta ${__opts} -P ${STATESETUP}/pasta_1.pid -t 10001,10002 -T 10003,10004 -u 10001,10002 -U 10003,10004 ${NSHOLDER} ${STATESETUP}/ns1.hold hold" + __ns1_pid=$(${NSHOLDER} ${STATESETUP}/ns1.hold pid) context_setup_nsenter passt_1 -U -n -p --preserve-credentials -t ${__ns1_pid} __opts= [ ${PCAP} -eq 1 ] && __opts="${__opts} -p ${LOGDIR}/pasta_2.pcap" [ ${DEBUG} -eq 1 ] && __opts="${__opts} -d" [ ${TRACE} -eq 1 ] && __opts="${__opts} --trace" - context_run_bg pasta_2 "./pasta ${__opts} -P pasta_2.pid -t 10004,10005 -T 10003,10001 -u 10004,10005 -U 10003,10001 ${NSHOLDER} ns2.hold hold" - __ns2_pid=$(${NSHOLDER} ns2.hold pid) + context_run_bg pasta_2 "./pasta ${__opts} -P ${STATESETUP}/pasta_2.pid -t 10004,10005 -T 10003,10001 -u 10004,10005 -U 10003,10001 ${NSHOLDER} ${STATESETUP}/ns2.hold hold" + __ns2_pid=$(${NSHOLDER} ${STATESETUP}/ns2.hold pid) context_setup_nsenter passt_2 -U -n -p --preserve-credentials -t ${__ns2_pid} context_setup_nsenter qemu_1 -U -n -p --preserve-credentials -t ${__ns1_pid} @@ -224,7 +224,7 @@ setup_two_guests() { [ ${DEBUG} -eq 1 ] && __opts="${__opts} -d" [ ${TRACE} -eq 1 ] && __opts="${__opts} --trace" - context_run_bg passt_1 "./passt -P passt_1.pid -f ${__opts} -t 10001 -u 10001" + context_run_bg passt_1 "./passt -P ${STATESETUP}/passt_1.pid -f ${__opts} -t 10001 -u 10001" sleep 1 __opts= @@ -232,7 +232,7 @@ setup_two_guests() { [ ${DEBUG} -eq 1 ] && __opts="${__opts} -d" [ ${TRACE} -eq 1 ] && __opts="${__opts} --trace" - context_run_bg passt_2 "./passt -P passt_2.pid -f ${__opts} -t 10004 -u 10004" + context_run_bg passt_2 "./passt -P ${STATESETUP}/passt_2.pid -f ${__opts} -t 10004 -u 10004" GUEST_1_CID=94557 context_run_bg qemu_1 './qrap 5 qemu-system-$(uname -m)' \ @@ -245,7 +245,7 @@ setup_two_guests() { 'virtio-net.napi_tx=1"' \ " -device virtio-net-pci,netdev=hostnet0,x-txburst=16384" \ " -netdev socket,fd=5,id=hostnet0" \ - ' -pidfile two_guests_qemu_1.pid' \ + " -pidfile ${STATESETUP}/qemu_1.pid" \ " -device vhost-vsock-pci,guest-cid=$GUEST_1_CID" GUEST_2_CID=94558 @@ -259,7 +259,7 @@ setup_two_guests() { 'virtio-net.napi_tx=1"' \ " -device virtio-net-pci,netdev=hostnet0,x-txburst=16384" \ " -netdev socket,fd=5,id=hostnet0" \ - ' -pidfile two_guests_qemu_2.pid' \ + " -pidfile ${STATESETUP}/qemu_2.pid" \ " -device vhost-vsock-pci,guest-cid=$GUEST_2_CID" context_setup_guest guest_1 ${GUEST_1_CID} @@ -290,9 +290,9 @@ teardown_distro() { # teardown_passt() - Kill qemu, remove passt PID file teardown_passt() { - kill $(cat passt_qemu.pid) + kill $(cat "${STATESETUP}/qemu.pid") - rm passt.pid + rm "${STATESETUP}/passt.pid" teardown_context_watch ${PANE_HOST} host teardown_context_watch ${PANE_PASST} passt @@ -301,7 +301,7 @@ teardown_passt() { # teardown_passt() - Exit namespace, kill pasta process teardown_pasta() { - ${NSHOLDER} ns.hold stop + ${NSHOLDER} "${STATESETUP}/ns.hold" stop context_wait unshare teardown_context_watch ${PANE_HOST} host @@ -311,13 +311,13 @@ teardown_pasta() { # teardown_passt_in_ns() - Exit namespace, kill qemu and pasta, remove pid file teardown_passt_in_ns() { - context_run ns kill $(cat passt_in_ns_qemu.pid) + context_run ns kill $(cat "${STATESETUP}/qemu.pid") context_wait qemu - ${NSHOLDER} ns.hold stop + ${NSHOLDER} "${STATESETUP}/ns.hold" stop context_wait pasta - rm passt.pid pasta.pid + rm "${STATESETUP}/passt.pid" "${STATESETUP}/pasta.pid" teardown_context_watch ${PANE_HOST} host teardown_context_watch ${PANE_PASST} pasta passt @@ -327,23 +327,23 @@ teardown_passt_in_ns() { # teardown_two_guests() - Exit namespaces, kill qemu processes, passt and pasta teardown_two_guests() { - __ns1_pid=$(${NSHOLDER} ns1.hold pid) - __ns2_pid=$(${NSHOLDER} ns2.hold pid) - nsenter -U -p --preserve-credentials -t ${__ns1_pid} kill $(cat two_guests_qemu_1.pid) - nsenter -U -p --preserve-credentials -t ${__ns2_pid} kill $(cat two_guests_qemu_2.pid) + __ns1_pid=$(${NSHOLDER} "${STATESETUP}/ns1.hold" pid) + __ns2_pid=$(${NSHOLDER} "${STATESETUP}/ns2.hold" pid) + nsenter -U -p --preserve-credentials -t ${__ns1_pid} kill $(cat "${STATESETUP}/qemu_1.pid") + nsenter -U -p --preserve-credentials -t ${__ns2_pid} kill $(cat "${STATESETUP}/qemu_2.pid") context_wait qemu_1 context_wait qemu_2 - nsenter -U -p --preserve-credentials -t ${__ns1_pid} kill $(cat passt_1.pid) - nsenter -U -p --preserve-credentials -t ${__ns2_pid} kill $(cat passt_2.pid) + nsenter -U -p --preserve-credentials -t ${__ns1_pid} kill $(cat "${STATESETUP}/passt_1.pid") + nsenter -U -p --preserve-credentials -t ${__ns2_pid} kill $(cat "${STATESETUP}/passt_2.pid") context_wait passt_1 context_wait passt_2 - ${NSHOLDER} ns1.hold stop - ${NSHOLDER} ns2.hold stop + ${NSHOLDER} "${STATESETUP}/ns1.hold" stop + ${NSHOLDER} "${STATESETUP}/ns2.hold" stop context_wait pasta_1 context_wait pasta_2 - rm -f passt_[12].pid pasta_[12].pid + rm -f "${STATESETUP}/passt__[12].pid" "${STATESETUP}/pasta_[12].pid" teardown_context_watch ${PANE_HOST} host teardown_context_watch ${PANE_GUEST_1} qemu_1 guest_1 diff --git a/test/passt/shutdown b/test/passt/shutdown index ce90ea9..34ddb64 100644 --- a/test/passt/shutdown +++ b/test/passt/shutdown @@ -14,7 +14,7 @@ test shutdown: exit code -hout PASST_PID cat passt.pid +hout PASST_PID cat __STATESETUP__/passt.pid host kill __PASST_PID__ sleep 1 passtw diff --git a/test/passt_in_ns/shutdown b/test/passt_in_ns/shutdown index abe9d6c..b602ec2 100644 --- a/test/passt_in_ns/shutdown +++ b/test/passt_in_ns/shutdown @@ -14,7 +14,7 @@ test shutdown: exit code -nsout PASST_PID cat passt.pid +nsout PASST_PID cat __STATESETUP__/passt.pid ns kill __PASST_PID__ sleep 1 passtw -- 2.37.3
Avoiding putting them in bare /tmp means they will be automatically cleaned up with everything else. Signed-off-by: David Gibson <david(a)gibson.dropbear.id.au> --- test/demo/passt | 5 +++-- test/demo/pasta | 10 +++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/test/demo/passt b/test/demo/passt index dd6a119..eb9b856 100644 --- a/test/demo/passt +++ b/test/demo/passt @@ -69,7 +69,7 @@ say 'pasta' demo above. sleep 3 passt cd __STATEDIR__/passt -passtb ./pasta -P /tmp/pasta.pid +passtb ./pasta -P pasta.pid sleep 3 passt /sbin/dhclient -4 --no-pid sleep 2 @@ -82,7 +82,8 @@ say Now let's run 'passt' in the new namespace, and nl say enter this namespace from the guest terminal too. sleep 3 -gout TARGET_PID pgrep -P $(cat /tmp/pasta.pid) +guest cd __STATEDIR__/passt +gout TARGET_PID pgrep -P $(cat pasta.pid) sleep 1 passtb ./passt -f -t 5201,5203 diff --git a/test/demo/pasta b/test/demo/pasta index 22479f8..02a2ba2 100644 --- a/test/demo/pasta +++ b/test/demo/pasta @@ -47,7 +47,7 @@ nl say without PID, it will create a namespace. sleep 3 passt cd __STATEDIR__/passt -passtb ./pasta -P /tmp/pasta.pid +passtb ./pasta -P pasta.pid sleep 3 nl @@ -56,7 +56,8 @@ say For convenience, let's enter this namespace nl say from another terminal. sleep 3 -nsout TARGET_PID pgrep -P $(cat /tmp/pasta.pid) +ns cd __STATEDIR__/passt +nsout TARGET_PID pgrep -P $(cat pasta.pid) sleep 1 ns nsenter -t __TARGET_PID__ -U -n --preserve-credentials @@ -168,10 +169,10 @@ passt exit passt make clean passt CFLAGS="-g" make sleep 2 -passtb perf record -g ./pasta -P /tmp/pasta.pid +passtb perf record -g ./pasta -P pasta.pid sleep 2 -nsout TARGET_PID pgrep -P $(cat /tmp/pasta.pid) +nsout TARGET_PID pgrep -P $(cat pasta.pid) sleep 1 ns nsenter -t __TARGET_PID__ -U -n --preserve-credentials sleep 5 @@ -255,7 +256,6 @@ sleep 2 killp PASST killp HOST sleep 2 -ns cd __STATEDIR__/passt nsb perf report -g --max-stack 3 sleep 10 -- 2.37.3
The asciinema video handling creates a number of temporary files (.uncat, .start, .stop) which currently go into the source tree. Put them in the temporary state directory to avoid clutter. The final processed output is now placed into test_logs/web/ along with the corresponding .js file with links, since they're essentially test artefacts. hooks/pre-push is updated to look for those files in the new location when updating the web site. Signed-off-by: David Gibson <david(a)gibson.dropbear.id.au> --- hooks/pre-push | 12 ++++++------ test/.gitignore | 4 ---- test/lib/term | 8 ++++---- test/lib/video | 37 +++++++++++++++++++++---------------- 4 files changed, 31 insertions(+), 30 deletions(-) diff --git a/hooks/pre-push b/hooks/pre-push index 1060802..1c221e7 100755 --- a/hooks/pre-push +++ b/hooks/pre-push @@ -34,15 +34,15 @@ ssh "${USER_HOST}" "mkdir -p ${WEB} ${TEST} ${BIN}" cd test ./ci -gzip -fk9 perf.js ci.js -scp perf.js perf.js.gz ci.js ci.js.gz "${USER_HOST}:${WEB}/" +gzip -fk9 perf.js +scp perf.js perf.js.gz "${USER_HOST}:${WEB}/" scp test_logs/* "${USER_HOST}:${TEST}/" ./run_demo -for cast in ci demo_pasta demo_podman demo_passt; do - gzip -fk9 "${cast}.cast" - scp "${cast}.cast" "${USER_HOST}:${WEB}/" - scp "${cast}.cast.gz" "${USER_HOST}:${WEB}/" +for f in test_logs/web/*.cast test_logs/web/*.js; do + gzip -fk9 "${f}" + scp "${f}" "${USER_HOST}:${WEB}/" + scp "${f}.gz" "${USER_HOST}:${WEB}/" done cd .. diff --git a/test/.gitignore b/test/.gitignore index 0f91c7d..2e75cb5 100644 --- a/test/.gitignore +++ b/test/.gitignore @@ -6,10 +6,6 @@ QEMU_EFI.fd *.qcow2 *.raw *.raw.xz -*.uncut -*.start -*.stop -*.js nsholder guest-key guest-key.pub diff --git a/test/lib/term b/test/lib/term index c9720be..b31deac 100755 --- a/test/lib/term +++ b/test/lib/term @@ -643,12 +643,12 @@ run_term() { if [ ${CI} -eq 1 ]; then printf '\e[8;50;240t' - asciinema rec --overwrite ci.uncut -c "$TMUX /bin/sh -c './ci from_term'" - video_postprocess ci.uncut + asciinema rec --overwrite "${STATEBASE}/ci.uncut" -c "$TMUX /bin/sh -c './ci from_term'" + video_postprocess "${STATEBASE}/ci.uncut" elif [ ${DEMO} -eq 1 ]; then printf '\e[8;40;130t' - asciinema rec --overwrite demo.uncut -c "$TMUX /bin/sh -c './run_demo from_term'" - video_postprocess demo.uncut + asciinema rec --overwrite "${STATEBASE}/demo.uncut" -c "$TMUX /bin/sh -c './run_demo from_term'" + video_postprocess "${STATEBASE}/demo.uncut" else $TMUX /bin/sh -c './run from_term' fi diff --git a/test/lib/video b/test/lib/video index f609abf..0ed6a3e 100755 --- a/test/lib/video +++ b/test/lib/video @@ -60,7 +60,8 @@ VIDEO_LINKS_COUNT=0 # video_append_links() - Append generic string to JavaScript links file video_append_links() { - printf "${@}" >> "${BASEPATH}/${VIDEO_NAME}.js" + __web="${LOGDIR}/web" + printf "${@}" >> "${__web}/${VIDEO_NAME}.js" } # video_append_links() - Append generic string to buffer for links @@ -72,13 +73,14 @@ video_append_links_js() # video_start() - Mark start of a test in capture, record start timestamp video_start() { VIDEO_NAME="${1}" - - echo "${VIDEO_LINKS_TEMPLATE}" > "${BASEPATH}/${VIDEO_NAME}.js" + __web="${LOGDIR}/web" + mkdir -p "${__web}" + echo "${VIDEO_LINKS_TEMPLATE}" > "${__web}/${VIDEO_NAME}.js" VIDEO_START_SECONDS=$(sed -n 's/\([0-9]*\).[0-9]* [0-9]*.[0-9]*/\1/p' /proc/uptime) sync - [ ${DEMO} -eq 1 ] && tail -1 "${BASEPATH}/demo.uncut" > "${BASEPATH}/${VIDEO_NAME}.start" - [ ${CI} -eq 1 ] && tail -1 "${BASEPATH}/ci.uncut" > "${BASEPATH}/${VIDEO_NAME}.start" + [ ${DEMO} -eq 1 ] && tail -1 "${STATEBASE}/demo.uncut" > "${STATEBASE}/${VIDEO_NAME}.start" + [ ${CI} -eq 1 ] && tail -1 "${STATEBASE}/ci.uncut" > "${STATEBASE}/${VIDEO_NAME}.start" sync tmux refresh-client @@ -86,34 +88,37 @@ video_start() { # video_stop() - Mark stop of a test in capture, finalise JavaScript fragments video_stop() { + __web="${LOGDIR}/web" tmux refresh-client sync - [ ${DEMO} -eq 1 ] && tail -1 "${BASEPATH}/demo.uncut" > "${BASEPATH}/${VIDEO_NAME}.stop" - [ ${CI} -eq 1 ] && tail -1 "${BASEPATH}/ci.uncut" > "${BASEPATH}/${VIDEO_NAME}.stop" + [ ${DEMO} -eq 1 ] && tail -1 "${STATEBASE}/demo.uncut" > "${STATEBASE}/${VIDEO_NAME}.stop" + [ ${CI} -eq 1 ] && tail -1 "${STATEBASE}/ci.uncut" > "${STATEBASE}/${VIDEO_NAME}.stop" sync - sed -i 's/^.*$/&\\/g' "${BASEPATH}/${VIDEO_NAME}.js" - echo "${VIDEO_LINKS_TEMPLATE_JS}" | sed "s/__VIDEO_NAME__/${VIDEO_NAME}/g" >> "${BASEPATH}/${VIDEO_NAME}.js" - echo "${VIDEO_LINKS_BUF}" >> "${BASEPATH}/${VIDEO_NAME}.js" - echo "${VIDEO_LINKS_TEMPLATE_POST}" | sed "s/__VIDEO_NAME__/${VIDEO_NAME}/g" >> "${BASEPATH}/${VIDEO_NAME}.js" + sed -i 's/^.*$/&\\/g' "${__web}/${VIDEO_NAME}.js" + echo "${VIDEO_LINKS_TEMPLATE_JS}" | sed "s/__VIDEO_NAME__/${VIDEO_NAME}/g" >> "${__web}/${VIDEO_NAME}.js" + echo "${VIDEO_LINKS_BUF}" >> "${__web}/${VIDEO_NAME}.js" + echo "${VIDEO_LINKS_TEMPLATE_POST}" | sed "s/__VIDEO_NAME__/${VIDEO_NAME}/g" >> "${__web}/${VIDEO_NAME}.js" } # video_postprocess() - Cut terminal recordings based on .start and .stop files video_postprocess() { IFS=' ' + __web="${LOGDIR}/web" __cast_name= for __l in $(cat ${1}); do [ -z "${__header}" ] && __header="${__l}" && continue if [ -z "${__cast_name}" ]; then - for __cast_cut in *.start; do + for __cast_cut in "${STATEBASE}/"*.start; do [ "${__l}" != "$(cat "${__cast_cut}")" ] && continue - __cast_name="${__cast_cut%.start}" + __cast_name="$(basename "${__cast_cut}")" + __cast_name="${__cast_name%.start}" __cast_offset= - __stop_line="$(cat ${__cast_name}.stop)" - echo "${__header}" > "${__cast_name}.cast" + __stop_line="$(cat "${STATEBASE}/${__cast_name}.stop")" + echo "${__header}" > "${__web}/${__cast_name}.cast" break done continue @@ -125,7 +130,7 @@ video_postprocess() { __l_rest="${__l#*.}" [ -z "${__cast_offset}" ] && __cast_offset=${__l_offset} __l_offset=$((__l_offset - __cast_offset)) - printf '[%s.%s\n' "${__l_offset}" "${__l_rest}" >> "${__cast_name}".cast + printf '[%s.%s\n' "${__l_offset}" "${__l_rest}" >> "${__web}/${__cast_name}".cast done unset IFS } -- 2.37.3
The tests generate a performance report in $BASEPATH/perf.js and hooks/pre-push copies it to the website. To avoid cluttering the working directory, instead put perf.js in $LOGDIR/web, since it's a test output artefact. Update hooks/pre-push to copy from its new location. Signed-off-by: David Gibson <david(a)gibson.dropbear.id.au> --- hooks/pre-push | 4 ++-- test/.gitignore | 1 - test/lib/perf_report | 3 ++- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/hooks/pre-push b/hooks/pre-push index 1c221e7..567a3e5 100755 --- a/hooks/pre-push +++ b/hooks/pre-push @@ -34,8 +34,8 @@ ssh "${USER_HOST}" "mkdir -p ${WEB} ${TEST} ${BIN}" cd test ./ci -gzip -fk9 perf.js -scp perf.js perf.js.gz "${USER_HOST}:${WEB}/" +gzip -fk9 test_logs/web/perf.js +scp test_logs/web/perf.js test_logs/web/perf.js.gz "${USER_HOST}:${WEB}/" scp test_logs/* "${USER_HOST}:${TEST}/" ./run_demo diff --git a/test/.gitignore b/test/.gitignore index 2e75cb5..e00b544 100644 --- a/test/.gitignore +++ b/test/.gitignore @@ -1,4 +1,3 @@ -perf.js test_logs/ mbuto/ *.img diff --git a/test/lib/perf_report b/test/lib/perf_report index b4fa685..8fd0588 100755 --- a/test/lib/perf_report +++ b/test/lib/perf_report @@ -14,7 +14,7 @@ # Author: Stefano Brivio <sbrivio(a)redhat.com> PERF_LINK_COUNT=0 -PERF_JS="${BASEPATH}/perf.js" +PERF_JS="${LOGDIR}/web/perf.js" PERF_TEMPLATE_HTML="document.write('"' Throughput in Gbps, latency in µs. Threads are <span style="font-family: monospace;">iperf3</span> processes, <i>passt</i> and <i>pasta</i> are currently single-threaded.<br/> @@ -126,6 +126,7 @@ for (var i = 0; i < perf_links.length; i++) { # perf_init() - Process first part of template perf_init() { + mkdir -p "$(dirname "${PERF_JS}")" echo "${PERF_TEMPLATE_HTML}" > "${PERF_JS}" perf_report_sub commit "$(echo ${COMMIT} | sed "s/'/\\\'/g")" } -- 2.37.3