aboutgitcodebugslistschat
path: root/test/lib/setup
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/setup
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/setup')
-rwxr-xr-xtest/lib/setup17
1 files changed, 8 insertions, 9 deletions
diff --git a/test/lib/setup b/test/lib/setup
index 6598422..a87bce9 100755
--- a/test/lib/setup
+++ b/test/lib/setup
@@ -17,6 +17,7 @@ INITRAMFS="${BASEPATH}/mbuto.img"
VCPUS="$( [ $(nproc) -ge 8 ] && echo 6 || echo $(( $(nproc) / 2 + 1 )) )"
__mem_kib="$(sed -n 's/MemTotal:[ ]*\([0-9]*\) kB/\1/p' /proc/meminfo)"
VMEM="$((${__mem_kib} / 1024 / 4))"
+NSHOLDER="${BASEPATH}/nsholder"
# setup_build() - Set up pane layout for build tests
setup_build() {
@@ -72,17 +73,14 @@ setup_passt() {
setup_pasta() {
context_setup_host host
context_setup_host passt
+ context_setup_host unshare
layout_pasta
- pane_run NS 'echo $$'
- pane_wait NS
- __tty_pid="$(pane_parse NS)"
-
- pane_run NS "unshare -rUnpf /bin/sh"
- pane_status NS
+ context_run_bg unshare "unshare -rUnpf ${NSHOLDER} ns.hold hold"
+ __target_pid=$(${NSHOLDER} ns.hold pid)
- __target_pid=$(pstree -p ${__tty_pid} | sed -n 's/.*(\([0-9].*\))$/\1/p')
+ context_setup_nsenter ns -U -n -p --preserve-credentials -t ${__target_pid}
# Ports:
#
@@ -318,11 +316,12 @@ teardown_passt() {
# teardown_passt() - Exit namespace, kill pasta process
teardown_pasta() {
- tmux send-keys -t ${PANE_NS} "C-d"
- pane_wait NS
+ ${NSHOLDER} ns.hold stop
+ context_wait unshare
teardown_context_watch ${PANE_HOST} host
teardown_context_watch ${PANE_PASST} passt
+ teardown_context_watch ${PANE_NS} unshare ns
}
# teardown_passt_in_ns() - Exit namespace, kill qemu and pasta, remove pid file