aboutgitcodebugslistschat
path: root/test/lib/context
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2022-09-12 20:56:21 +1000
committerStefano Brivio <sbrivio@redhat.com>2022-09-13 05:32:00 +0200
commita8a437abd6c03161c0d7430f969f6a32d046dc29 (patch)
treef1f8915505a8b73de82d4b3ef69db9ea8fe20e5d /test/lib/context
parenta8c32c85d5f3847a1f9ea0030beb0c338af53cd5 (diff)
downloadpasst-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/context21
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)