mirror of
https://passt.top/passt
synced 2025-05-25 02:25:34 +02:00
test: Use "nstool exec" to slightly simplify tests
Using this, rather than using "nstool info" to get the pid then manually connecting with nsenter makes things a little simpler. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:
parent
3372cd0902
commit
469b69aaa1
3 changed files with 23 additions and 26 deletions
test/lib
|
@ -13,6 +13,8 @@
|
|||
# Copyright Red Hat
|
||||
# Author: David Gibson <david@gibson.dropbear.id.au>
|
||||
|
||||
NSTOOL="${BASEPATH}/nstool"
|
||||
|
||||
# context_setup_common() - Create outline of a new context
|
||||
# $1: Context name
|
||||
context_setup_common() {
|
||||
|
@ -30,15 +32,17 @@ context_setup_host() {
|
|||
echo sh -c > "${__enter}"
|
||||
}
|
||||
|
||||
# context_setup_nsenter() - Create a new context for running commands in a namespace
|
||||
# context_setup_nstool() - Create a new context for running commands with nstool exec
|
||||
# $1: Context name
|
||||
# $2: Namespace PID
|
||||
context_setup_nsenter() {
|
||||
# $2: nstool control socket
|
||||
context_setup_nstool() {
|
||||
__name="$1"
|
||||
shift
|
||||
__sock="$2"
|
||||
__enter="${STATESETUP}/context_${__name}.enter"
|
||||
# Wait for the ns to be ready
|
||||
${NSTOOL} info -w "${__sock}" > /dev/null
|
||||
context_setup_common "${__name}"
|
||||
echo "nsenter $@ sh -c" > "${__enter}"
|
||||
echo "${NSTOOL} exec ${__sock} -- sh -c" > "${__enter}"
|
||||
}
|
||||
|
||||
# context_setup_guest() - Create a new context for running commands in a guest
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue