1
0
Fork 0
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:
David Gibson 2023-04-06 13:28:17 +10:00 committed by Stefano Brivio
parent 3372cd0902
commit 469b69aaa1
3 changed files with 23 additions and 26 deletions
test/lib

View file

@ -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