mirror of
https://passt.top/passt
synced 2025-05-30 04:45:34 +02:00
test: Extend context system to run commands in namespace for pasta tests
Extend the context system to allow commands to be run in a namespace created with unshare, and use it for the namespace used in the pasta tests. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
parent
a8c32c85d5
commit
a8a437abd6
3 changed files with 29 additions and 13 deletions
test/lib
|
@ -13,13 +13,32 @@
|
|||
# Copyright Red Hat
|
||||
# Author: David Gibson <david@gibson.dropbear.id.au>
|
||||
|
||||
# context_setup_common() - Create outline of a new context
|
||||
# $1: Context name
|
||||
context_setup_common() {
|
||||
__name="$1"
|
||||
__prefix="${LOGDIR}/context_${__name}"
|
||||
echo -n "${__name}$ " > "${__prefix}.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}"
|
||||
context_setup_common "${__name}"
|
||||
echo sh -c > "${__prefix}.enter"
|
||||
echo -n "${__name}$ " > "${__prefix}.log"
|
||||
}
|
||||
|
||||
# context_setup_nsenter() - Create a new context for running commands in a namespace
|
||||
# $1: Context name
|
||||
# $2: Namespace PID
|
||||
context_setup_nsenter() {
|
||||
__name="$1"
|
||||
shift
|
||||
__prefix="${LOGDIR}/context_${__name}"
|
||||
context_setup_common "${__name}"
|
||||
echo "nsenter $@ sh -c" > "${__prefix}.enter"
|
||||
}
|
||||
|
||||
# context_teardown() - Remove a context (leave log files intact)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue