mirror of
https://passt.top/passt
synced 2025-05-30 21:05:34 +02:00
test: Integration of old-style pane execution and new context execution
We're creating a system for tests to more reliably execute commands in various contexts (e.g. host, guest, namespace). That transition is going to happen over a number of steps though, so in the meantime we need to deal with both the old-style issuing of commands via typing into and screen scraping tmux panels, and the new-style system for executing commands in context. Introduce some transitional helpers which will issue a command via context if the requested context is initialized, but will otherwise fall back to the old style tmux panel based method. Re-implement the various test DSL commands in terms of these new helpers. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
parent
a32df9b6f4
commit
c2f248588b
3 changed files with 121 additions and 81 deletions
test/lib
|
@ -259,6 +259,69 @@ pane_watch_contexts() {
|
|||
cmd_write ${__pane_number} "${__cmd}"
|
||||
}
|
||||
|
||||
# pane_or_context_run() - Issue a command in given context or pane
|
||||
# $1: Context or lower-case pane name
|
||||
# $@: Command to issue
|
||||
pane_or_context_run() {
|
||||
__name="${1}"
|
||||
shift
|
||||
if context_exists "${__name}"; then
|
||||
context_run "${__name}" "$@" >/dev/null 2>&1
|
||||
else
|
||||
__uc="$(echo "${__name}" | tr [a-z] [A-Z])"
|
||||
pane_run "${__uc}" "$@"
|
||||
pane_status "${__uc}"
|
||||
fi
|
||||
}
|
||||
|
||||
# pane_or_context_run_bg() - Issue a background command in given context or pane
|
||||
# $1: Context or lower-case pane name
|
||||
# $@: Command to issue
|
||||
pane_or_context_run_bg() {
|
||||
__name="${1}"
|
||||
shift
|
||||
if context_exists "${__name}"; then
|
||||
context_run_bg "${__name}" "$@" >/dev/null 2>&1
|
||||
else
|
||||
__uc="$(echo "${__name}" | tr [a-z] [A-Z])"
|
||||
pane_run "${__uc}" "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
# pane_or_context_output() - Get output from a command in a context or pane
|
||||
# $1: Context or lower-case pane name
|
||||
# $@: Command to issue
|
||||
pane_or_context_output() {
|
||||
__name="${1}"
|
||||
shift
|
||||
if context_exists "${__name}"; then
|
||||
__output=$(context_run "${__name}" "$@" 2>/dev/null)
|
||||
if [ -z "${__output}" ]; then
|
||||
echo "@EMPTY@"
|
||||
else
|
||||
echo "${__output}"
|
||||
fi
|
||||
else
|
||||
__uc="$(echo "${__name}" | tr [a-z] [A-Z])"
|
||||
pane_run "${__uc}" "$@"
|
||||
pane_wait "${__uc}"
|
||||
pane_parse "${__uc}"
|
||||
fi
|
||||
}
|
||||
|
||||
# pane_or_context_wait() - Wait for a command to be done in a context or pane
|
||||
# $1: Context or lower-case pane name
|
||||
pane_or_context_wait() {
|
||||
__name="${1}"
|
||||
shift
|
||||
if context_exists "${__name}"; then
|
||||
context_wait "${__name}"
|
||||
else
|
||||
__uc="$(echo "${__name}" | tr [a-z] [A-Z])"
|
||||
pane_wait "${__uc}"
|
||||
fi
|
||||
}
|
||||
|
||||
# status_file_end() - Display and log messages when tests from one file are done
|
||||
status_file_end() {
|
||||
[ -z "${STATUS_FILE}" ] && return
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue