1
0
Fork 0
mirror of https://passt.top/passt synced 2025-05-22 17:25:35 +02:00

test: Use context system for guest commands

Extends the context system in the test scripts to allow executing commands
within a guest.  Do this without requiring an existing network in the guest
by using socat to run ssh via a vsock connection.

We do need some additional "sleep"s in the tests, because the new
faster dispatch means that sometimes we attempt to connect before
socat has managed to listen.

For now, only use this for the plain "passt" tests.  The "passt_in_ns" and
other tests have additional complications we still need 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:22 +10:00 committed by Stefano Brivio
parent a8a437abd6
commit 56e755ba11
10 changed files with 90 additions and 16 deletions
test/lib

View file

@ -266,7 +266,8 @@ pane_or_context_run() {
__name="${1}"
shift
if context_exists "${__name}"; then
context_run "${__name}" "$@" >/dev/null 2>&1
# Redirect stdin to stop ssh from eating the test instructions file we have on stdin
context_run "${__name}" "$@" >/dev/null 2>&1 < /dev/null
else
__uc="$(echo "${__name}" | tr [a-z] [A-Z])"
pane_run "${__uc}" "$@"
@ -281,7 +282,8 @@ pane_or_context_run_bg() {
__name="${1}"
shift
if context_exists "${__name}"; then
context_run_bg "${__name}" "$@" >/dev/null 2>&1
# Redirect stdin to stop ssh from eating the test instructions file we have on stdin
context_run_bg "${__name}" "$@" >/dev/null 2>&1 < /dev/null
else
__uc="$(echo "${__name}" | tr [a-z] [A-Z])"
pane_run "${__uc}" "$@"
@ -295,7 +297,8 @@ pane_or_context_output() {
__name="${1}"
shift
if context_exists "${__name}"; then
__output=$(context_run "${__name}" "$@" 2>/dev/null)
# Redirect stdin to stop ssh from eating the test instructions file we have on stdin
__output=$(context_run "${__name}" "$@" 2>/dev/null </dev/null)
if [ -z "${__output}" ]; then
echo "@EMPTY@"
else