diff options
author | David Gibson <david@gibson.dropbear.id.au> | 2022-09-12 20:56:21 +1000 |
---|---|---|
committer | Stefano Brivio <sbrivio@redhat.com> | 2022-09-13 05:32:00 +0200 |
commit | a8a437abd6c03161c0d7430f969f6a32d046dc29 (patch) | |
tree | f1f8915505a8b73de82d4b3ef69db9ea8fe20e5d /test/lib/context | |
parent | a8c32c85d5f3847a1f9ea0030beb0c338af53cd5 (diff) | |
download | passt-a8a437abd6c03161c0d7430f969f6a32d046dc29.tar passt-a8a437abd6c03161c0d7430f969f6a32d046dc29.tar.gz passt-a8a437abd6c03161c0d7430f969f6a32d046dc29.tar.bz2 passt-a8a437abd6c03161c0d7430f969f6a32d046dc29.tar.lz passt-a8a437abd6c03161c0d7430f969f6a32d046dc29.tar.xz passt-a8a437abd6c03161c0d7430f969f6a32d046dc29.tar.zst passt-a8a437abd6c03161c0d7430f969f6a32d046dc29.zip |
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>
Diffstat (limited to 'test/lib/context')
-rw-r--r-- | test/lib/context | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/test/lib/context b/test/lib/context index babf59a..0d92d8f 100644 --- a/test/lib/context +++ b/test/lib/context @@ -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) |