diff options
author | David Gibson <david@gibson.dropbear.id.au> | 2023-04-06 13:28:17 +1000 |
---|---|---|
committer | Stefano Brivio <sbrivio@redhat.com> | 2023-04-08 01:12:08 +0200 |
commit | 469b69aaa141a8163a6930e2dd4a25272a85d146 (patch) | |
tree | 7b43761f96732e5d3f9c45954a006747a4b4fcf2 /test/lib/context | |
parent | 3372cd0902f262b591ecb930a12d0049e69ac372 (diff) | |
download | passt-469b69aaa141a8163a6930e2dd4a25272a85d146.tar passt-469b69aaa141a8163a6930e2dd4a25272a85d146.tar.gz passt-469b69aaa141a8163a6930e2dd4a25272a85d146.tar.bz2 passt-469b69aaa141a8163a6930e2dd4a25272a85d146.tar.lz passt-469b69aaa141a8163a6930e2dd4a25272a85d146.tar.xz passt-469b69aaa141a8163a6930e2dd4a25272a85d146.tar.zst passt-469b69aaa141a8163a6930e2dd4a25272a85d146.zip |
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>
Diffstat (limited to 'test/lib/context')
-rw-r--r-- | test/lib/context | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/test/lib/context b/test/lib/context index 624f86b..4741a55 100644 --- a/test/lib/context +++ b/test/lib/context @@ -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 |