test: Issue host commands via context for most tests

Convert most of the tests to use the new-style system for issuing commands
for all host commands.  We leave the distro tests for now: they use
the same pane for both host and guest commands which we'll need some more
things to deal with.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
David Gibson 2022-09-12 20:56:18 +10:00 committed by Stefano Brivio
parent c2f248588b
commit d9b9c252cd
2 changed files with 42 additions and 25 deletions

View file

@ -31,8 +31,12 @@ layout_host() {
tmux send-keys -t ${PANE_INFO} -N 100 C-m tmux send-keys -t ${PANE_INFO} -N 100 C-m
tmux select-pane -t ${PANE_INFO} -T "test log" tmux select-pane -t ${PANE_INFO} -T "test log"
if context_exists host; then
pane_watch_contexts 0 host host
else
tmux pipe-pane -O -t ${PANE_HOST} "cat >> ${LOGDIR}/pane_host.log" tmux pipe-pane -O -t ${PANE_HOST} "cat >> ${LOGDIR}/pane_host.log"
tmux select-pane -t ${PANE_HOST} -T "host" tmux select-pane -t ${PANE_HOST} -T "host"
fi
info_layout "host commands only" info_layout "host commands only"
@ -64,8 +68,7 @@ layout_pasta() {
tmux send-keys -t ${PANE_INFO} -N 100 C-m tmux send-keys -t ${PANE_INFO} -N 100 C-m
tmux select-pane -t ${PANE_INFO} -T "test log" tmux select-pane -t ${PANE_INFO} -T "test log"
tmux pipe-pane -O -t ${PANE_HOST} "cat >> ${LOGDIR}/pane_host.log" pane_watch_contexts ${PANE_HOST} host host
tmux select-pane -t ${PANE_HOST} -T "host"
tmux pipe-pane -O -t ${PANE_PASST} "cat >> ${LOGDIR}/pane_passt.log" tmux pipe-pane -O -t ${PANE_PASST} "cat >> ${LOGDIR}/pane_passt.log"
tmux select-pane -t ${PANE_PASST} -T "pasta" tmux select-pane -t ${PANE_PASST} -T "pasta"
@ -100,8 +103,7 @@ layout_passt() {
tmux send-keys -t ${PANE_INFO} -N 100 C-m tmux send-keys -t ${PANE_INFO} -N 100 C-m
tmux select-pane -t ${PANE_INFO} -T "test log" tmux select-pane -t ${PANE_INFO} -T "test log"
tmux pipe-pane -O -t ${PANE_HOST} "cat >> ${LOGDIR}/pane_host.log" pane_watch_contexts ${PANE_HOST} host host
tmux select-pane -t ${PANE_HOST} -T "host"
tmux pipe-pane -O -t ${PANE_PASST} "cat >> ${LOGDIR}/pane_passt.log" tmux pipe-pane -O -t ${PANE_PASST} "cat >> ${LOGDIR}/pane_passt.log"
tmux select-pane -t ${PANE_PASST} -T "passt" tmux select-pane -t ${PANE_PASST} -T "passt"
@ -141,8 +143,7 @@ layout_passt_in_pasta() {
tmux send-keys -t ${PANE_INFO} -N 100 C-m tmux send-keys -t ${PANE_INFO} -N 100 C-m
tmux select-pane -t ${PANE_INFO} -T "test log" tmux select-pane -t ${PANE_INFO} -T "test log"
tmux pipe-pane -O -t ${PANE_HOST} "cat >> ${LOGDIR}/pane_host.log" pane_watch_contexts ${PANE_HOST} host host
tmux select-pane -t ${PANE_HOST} -T "host"
tmux pipe-pane -O -t ${PANE_PASST} "cat >> ${LOGDIR}/pane_passt.log" tmux pipe-pane -O -t ${PANE_PASST} "cat >> ${LOGDIR}/pane_passt.log"
tmux select-pane -t ${PANE_PASST} -T "passt in pasta (namespace)" tmux select-pane -t ${PANE_PASST} -T "passt in pasta (namespace)"
@ -189,8 +190,7 @@ layout_two_guests() {
tmux send-keys -t ${PANE_INFO} -N 100 C-m tmux send-keys -t ${PANE_INFO} -N 100 C-m
tmux select-pane -t ${PANE_INFO} -T "test log" tmux select-pane -t ${PANE_INFO} -T "test log"
tmux pipe-pane -O -t ${PANE_HOST} "cat >> ${LOGDIR}/pane_host.log" pane_watch_contexts ${PANE_HOST} host host
tmux select-pane -t ${PANE_HOST} -T "host"
tmux pipe-pane -O -t ${PANE_PASST_1} "cat >> ${LOGDIR}/pane_passt_1.log" tmux pipe-pane -O -t ${PANE_PASST_1} "cat >> ${LOGDIR}/pane_passt_1.log"
tmux select-pane -t ${PANE_PASST_1} -T "passt #1 in namespace #1" tmux select-pane -t ${PANE_PASST_1} -T "passt #1 in namespace #1"

View file

@ -20,6 +20,8 @@ VMEM="$((${__mem_kib} / 1024 / 4))"
# setup_build() - Set up pane layout for build tests # setup_build() - Set up pane layout for build tests
setup_build() { setup_build() {
context_setup_host host
layout_host layout_host
} }
@ -30,6 +32,8 @@ setup_distro() {
# setup_passt() - Start qemu and passt # setup_passt() - Start qemu and passt
setup_passt() { setup_passt() {
context_setup_host host
layout_passt layout_passt
# Ports: # Ports:
@ -63,17 +67,12 @@ setup_passt() {
" -netdev socket,fd=5,id=hostnet0" \ " -netdev socket,fd=5,id=hostnet0" \
' -pidfile passt_qemu.pid' ' -pidfile passt_qemu.pid'
pane_status GUEST pane_status GUEST
# Set things up to reduce problems parsing host command output
pane_run HOST "PS1='$ '"
pane_wait HOST
# Non-bash shells will fail this, but also don't need it, so ignore errors
pane_run HOST "bind 'set enable-bracketed-paste off'"
pane_wait HOST
} }
# setup_pasta() - Create a network and user namespace, connect pasta to it # setup_pasta() - Create a network and user namespace, connect pasta to it
setup_pasta() { setup_pasta() {
context_setup_host host
layout_pasta layout_pasta
pane_run NS 'echo $$' pane_run NS 'echo $$'
@ -105,6 +104,8 @@ setup_pasta() {
# setup_passt_in_ns() - Set up namespace (with pasta), run qemu and passt into it # setup_passt_in_ns() - Set up namespace (with pasta), run qemu and passt into it
setup_passt_in_ns() { setup_passt_in_ns() {
context_setup_host host
layout_passt_in_pasta layout_passt_in_pasta
# Ports: # Ports:
@ -182,17 +183,12 @@ setup_passt_in_ns() {
" -netdev socket,fd=5,id=hostnet0" \ " -netdev socket,fd=5,id=hostnet0" \
' -pidfile passt_in_ns_qemu.pid' ' -pidfile passt_in_ns_qemu.pid'
pane_status GUEST pane_status GUEST
# Set things up to reduce problems parsing host command output
pane_run HOST "PS1='$ '"
pane_wait HOST
# Non-bash shells will fail this, but also don't need it, so ignore errors
pane_run HOST "bind 'set enable-bracketed-paste off'"
pane_wait HOST
} }
# setup_two_guests() - Set up two namespace, run qemu and passt in both of them # setup_two_guests() - Set up two namespace, run qemu and passt in both of them
setup_two_guests() { setup_two_guests() {
context_setup_host host
layout_two_guests layout_two_guests
# Ports: # Ports:
@ -290,9 +286,21 @@ setup_two_guests() {
pane_status GUEST_2 pane_status GUEST_2
} }
# teardown_context_watch() - Remove contexts and stop panes watching them
# $1: Pane number watching
# $@: Context names
teardown_context_watch() {
__pane="$1"
shift
for __c; do
context_teardown "${__c}"
done
tmux send-keys -t ${__pane} "C-c"
}
# teardown_build() - Nothing to do, yet # teardown_build() - Nothing to do, yet
teardown_build() { teardown_build() {
: teardown_context_watch ${PANE_HOST} host
} }
# teardown_distro() - Nothing to do, yet # teardown_distro() - Nothing to do, yet
@ -303,14 +311,19 @@ teardown_distro() {
# teardown_passt() - Kill qemu, remove passt PID file # teardown_passt() - Kill qemu, remove passt PID file
teardown_passt() { teardown_passt() {
kill $(cat passt_qemu.pid) kill $(cat passt_qemu.pid)
pane_wait GUEST pane_wait GUEST
rm passt.pid rm passt.pid
teardown_context_watch ${PANE_HOST} host
} }
# teardown_passt() - Exit namespace, kill pasta process # teardown_passt() - Exit namespace, kill pasta process
teardown_pasta() { teardown_pasta() {
tmux send-keys -t ${PANE_NS} "C-d" tmux send-keys -t ${PANE_NS} "C-d"
pane_wait NS pane_wait NS
teardown_context_watch ${PANE_HOST} host
} }
# teardown_passt_in_ns() - Exit namespace, kill qemu and pasta, remove pid file # teardown_passt_in_ns() - Exit namespace, kill qemu and pasta, remove pid file
@ -326,6 +339,8 @@ teardown_passt_in_ns() {
pane_wait PASST pane_wait PASST
rm passt.pid rm passt.pid
teardown_context_watch ${PANE_HOST} host
} }
# teardown_two_guests() - Exit namespaces, kill qemu processes, passt and pasta # teardown_two_guests() - Exit namespaces, kill qemu processes, passt and pasta
@ -350,6 +365,8 @@ teardown_two_guests() {
pane_wait GUEST_2 pane_wait GUEST_2
pane_wait PASST_1 pane_wait PASST_1
pane_wait PASST_2 pane_wait PASST_2
teardown_context_watch ${PANE_HOST} host
} }
# teardown_demo_passt() - Exit namespace, kill qemu, passt and pasta # teardown_demo_passt() - Exit namespace, kill qemu, passt and pasta