public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: passt-dev@passt.top
Subject: [PATCH v2 31/32] test: Move pidfiles and nsholder sockets into state directory
Date: Thu, 08 Sep 2022 16:16:20 +1000	[thread overview]
Message-ID: <20220908061621.2430844-32-david@gibson.dropbear.id.au> (raw)
In-Reply-To: <20220908061621.2430844-1-david@gibson.dropbear.id.au>

[-- Attachment #1: Type: text/plain, Size: 11033 bytes --]

Currently they go in the passt source tree with a fixed names, which means
their presence can mess with subsequent test runs.

Signed-off-by: David Gibson <david(a)gibson.dropbear.id.au>
---
 .gitignore                |  1 -
 test/lib/setup            | 66 +++++++++++++++++++--------------------
 test/passt/shutdown       |  2 +-
 test/passt_in_ns/shutdown |  2 +-
 4 files changed, 35 insertions(+), 36 deletions(-)

diff --git a/.gitignore b/.gitignore
index 80967f3..d3d0e2c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,6 +6,5 @@
 /qrap
 /pasta.1
 /seccomp.h
-/*.pid
 /s*.json
 README.plain.md
diff --git a/test/lib/setup b/test/lib/setup
index 87eb05a..bda53f8 100755
--- a/test/lib/setup
+++ b/test/lib/setup
@@ -53,7 +53,7 @@ setup_passt() {
 
 	context_run passt "make clean"
 	context_run passt "make valgrind"
-	context_run_bg passt "valgrind --max-stackframe=$((4 * 1024 * 1024)) --trace-children=yes --vgdb=no --error-exitcode=1 --suppressions=test/valgrind.supp ./passt ${__opts} -f -t 10001 -u 10001 -P passt.pid"
+	context_run_bg passt "valgrind --max-stackframe=$((4 * 1024 * 1024)) --trace-children=yes --vgdb=no --error-exitcode=1 --suppressions=test/valgrind.supp ./passt ${__opts} -f -t 10001 -u 10001 -P ${STATESETUP}/passt.pid"
 	sleep 5
 
 	GUEST_CID=94557
@@ -67,7 +67,7 @@ setup_passt() {
 		'virtio-net.napi_tx=1"'					   \
 		" -device virtio-net-pci,netdev=hostnet0,x-txburst=16384"  \
 		" -netdev socket,fd=5,id=hostnet0"			   \
-		" -pidfile passt_qemu.pid"				   \
+		" -pidfile ${STATESETUP}/qemu.pid"			   \
 		" -device vhost-vsock-pci,guest-cid=$GUEST_CID"
 
 	context_setup_guest guest $GUEST_CID
@@ -81,8 +81,8 @@ setup_pasta() {
 
 	layout_pasta
 
-	context_run_bg unshare "unshare -rUnpf ${NSHOLDER} ns.hold hold"
-	__target_pid=$(${NSHOLDER} ns.hold pid)
+	context_run_bg unshare "unshare -rUnpf ${NSHOLDER} ${STATESETUP}/ns.hold hold"
+	__target_pid=$(${NSHOLDER} ${STATESETUP}/ns.hold pid)
 
 	context_setup_nsenter ns -U -n -p --preserve-credentials -t ${__target_pid}
 
@@ -98,7 +98,7 @@ setup_pasta() {
 	[ ${DEBUG} -eq 1 ] && __opts="${__opts} -d"
 	[ ${TRACE} -eq 1 ] && __opts="${__opts} --trace"
 
-	context_run_bg passt "./pasta ${__opts} -f -t 10002 -T 10003 -u 10002 -U 10003 -P passt.pid ${__target_pid}"
+	context_run_bg passt "./pasta ${__opts} -f -t 10002 -T 10003 -u 10002 -U 10003 -P ${STATESETUP}/passt.pid ${__target_pid}"
 	sleep 1
 }
 
@@ -128,9 +128,9 @@ setup_passt_in_ns() {
 	[ ${DEBUG} -eq 1 ] && __opts="${__opts} -d"
 	[ ${TRACE} -eq 1 ] && __opts="${__opts} --trace"
 
-	context_run_bg pasta "./pasta ${__opts} -t 10001,10002,10011,10012 -T 10003,10013 -u 10001,10002,10011,10012 -U 10003,10013 -P pasta.pid ${NSHOLDER} ns.hold hold"
+	context_run_bg pasta "./pasta ${__opts} -t 10001,10002,10011,10012 -T 10003,10013 -u 10001,10002,10011,10012 -U 10003,10013 -P ${STATESETUP}/pasta.pid ${NSHOLDER} ${STATESETUP}/ns.hold hold"
 	sleep 1
-	__ns_pid=$(${NSHOLDER} ns.hold pid)
+	__ns_pid=$(${NSHOLDER} ${STATESETUP}/ns.hold pid)
 
 	context_setup_nsenter qemu "-t ${__ns_pid} -U -n -p --preserve-credentials"
 	context_setup_nsenter ns "-t ${__ns_pid} -U -n -p --preserve-credentials"
@@ -149,11 +149,11 @@ setup_passt_in_ns() {
 	if [ ${VALGRIND} -eq 1 ]; then
 		context_run passt "make clean"
 		context_run passt "make valgrind"
-		context_run_bg passt "valgrind --max-stackframe=$((4 * 1024 * 1024)) --trace-children=yes --vgdb=no --error-exitcode=1 --suppressions=test/valgrind.supp ./passt -f ${__opts} -t 10001,10011,10021,10031 -u 10001,10011,10021,10031 -P passt.pid"
+		context_run_bg passt "valgrind --max-stackframe=$((4 * 1024 * 1024)) --trace-children=yes --vgdb=no --error-exitcode=1 --suppressions=test/valgrind.supp ./passt -f ${__opts} -t 10001,10011,10021,10031 -u 10001,10011,10021,10031 -P ${STATESETUP}/passt.pid"
 	else
 		context_run passt "make clean"
 		context_run passt "make"
-		context_run_bg passt "./passt -f ${__opts} -t 10001,10011,10021,10031 -u 10001,10011,10021,10031 -P passt.pid"
+		context_run_bg passt "./passt -f ${__opts} -t 10001,10011,10021,10031 -u 10001,10011,10021,10031 -P ${STATESETUP}/passt.pid"
 	fi
 	sleep 5
 
@@ -169,7 +169,7 @@ setup_passt_in_ns() {
 		'virtio-net.napi_tx=1"'					   \
 		" -device virtio-net-pci,netdev=hostnet0,x-txburst=524288" \
 		" -netdev socket,fd=5,id=hostnet0"			   \
-		' -pidfile passt_in_ns_qemu.pid'			   \
+		" -pidfile ${STATESETUP}/qemu.pid"			   \
 		" -device vhost-vsock-pci,guest-cid=$GUEST_CID"
 
 	context_setup_guest guest $GUEST_CID
@@ -197,16 +197,16 @@ setup_two_guests() {
 	[ ${PCAP} -eq 1 ] && __opts="${__opts} -p ${LOGDIR}/pasta_1.pcap"
 	[ ${DEBUG} -eq 1 ] && __opts="${__opts} -d"
 	[ ${TRACE} -eq 1 ] && __opts="${__opts} --trace"
-	context_run_bg pasta_1 "./pasta ${__opts} -P pasta_1.pid -t 10001,10002 -T 10003,10004 -u 10001,10002 -U 10003,10004 ${NSHOLDER} ns1.hold hold"
-	__ns1_pid=$(${NSHOLDER} ns1.hold pid)
+	context_run_bg pasta_1 "./pasta ${__opts} -P ${STATESETUP}/pasta_1.pid -t 10001,10002 -T 10003,10004 -u 10001,10002 -U 10003,10004 ${NSHOLDER} ${STATESETUP}/ns1.hold hold"
+	__ns1_pid=$(${NSHOLDER} ${STATESETUP}/ns1.hold pid)
 	context_setup_nsenter passt_1 -U -n -p --preserve-credentials -t ${__ns1_pid}
 
 	__opts=
 	[ ${PCAP} -eq 1 ] && __opts="${__opts} -p ${LOGDIR}/pasta_2.pcap"
 	[ ${DEBUG} -eq 1 ] && __opts="${__opts} -d"
 	[ ${TRACE} -eq 1 ] && __opts="${__opts} --trace"
-	context_run_bg pasta_2 "./pasta ${__opts} -P pasta_2.pid -t 10004,10005 -T 10003,10001 -u 10004,10005 -U 10003,10001 ${NSHOLDER} ns2.hold hold"
-	__ns2_pid=$(${NSHOLDER} ns2.hold pid)
+	context_run_bg pasta_2 "./pasta ${__opts} -P ${STATESETUP}/pasta_2.pid -t 10004,10005 -T 10003,10001 -u 10004,10005 -U 10003,10001 ${NSHOLDER} ${STATESETUP}/ns2.hold hold"
+	__ns2_pid=$(${NSHOLDER} ${STATESETUP}/ns2.hold pid)
 	context_setup_nsenter passt_2 -U -n -p --preserve-credentials -t ${__ns2_pid}
 
 	context_setup_nsenter qemu_1 -U -n -p --preserve-credentials -t ${__ns1_pid}
@@ -224,7 +224,7 @@ setup_two_guests() {
 	[ ${DEBUG} -eq 1 ] && __opts="${__opts} -d"
 	[ ${TRACE} -eq 1 ] && __opts="${__opts} --trace"
 
-	context_run_bg passt_1 "./passt -P passt_1.pid -f ${__opts} -t 10001 -u 10001"
+	context_run_bg passt_1 "./passt -P ${STATESETUP}/passt_1.pid -f ${__opts} -t 10001 -u 10001"
 	sleep 1
 
 	__opts=
@@ -232,7 +232,7 @@ setup_two_guests() {
 	[ ${DEBUG} -eq 1 ] && __opts="${__opts} -d"
 	[ ${TRACE} -eq 1 ] && __opts="${__opts} --trace"
 
-	context_run_bg passt_2 "./passt -P passt_2.pid -f ${__opts} -t 10004 -u 10004"
+	context_run_bg passt_2 "./passt -P ${STATESETUP}/passt_2.pid -f ${__opts} -t 10004 -u 10004"
 
 	GUEST_1_CID=94557
 	context_run_bg qemu_1 './qrap 5 qemu-system-$(uname -m)'             \
@@ -245,7 +245,7 @@ setup_two_guests() {
 		'virtio-net.napi_tx=1"'					     \
 		" -device virtio-net-pci,netdev=hostnet0,x-txburst=16384"    \
 		" -netdev socket,fd=5,id=hostnet0"			     \
-		' -pidfile two_guests_qemu_1.pid'			     \
+		" -pidfile ${STATESETUP}/qemu_1.pid"			     \
 		" -device vhost-vsock-pci,guest-cid=$GUEST_1_CID"
 
 	GUEST_2_CID=94558
@@ -259,7 +259,7 @@ setup_two_guests() {
 		'virtio-net.napi_tx=1"'					     \
 		" -device virtio-net-pci,netdev=hostnet0,x-txburst=16384"    \
 		" -netdev socket,fd=5,id=hostnet0"			     \
-		' -pidfile two_guests_qemu_2.pid'			     \
+		" -pidfile ${STATESETUP}/qemu_2.pid"			     \
 		" -device vhost-vsock-pci,guest-cid=$GUEST_2_CID"
 
 	context_setup_guest guest_1 ${GUEST_1_CID}
@@ -290,9 +290,9 @@ teardown_distro() {
 
 # teardown_passt() - Kill qemu, remove passt PID file
 teardown_passt() {
-	kill $(cat passt_qemu.pid)
+	kill $(cat "${STATESETUP}/qemu.pid")
 
-	rm passt.pid
+	rm "${STATESETUP}/passt.pid"
 
 	teardown_context_watch ${PANE_HOST} host
 	teardown_context_watch ${PANE_PASST} passt
@@ -301,7 +301,7 @@ teardown_passt() {
 
 # teardown_passt() - Exit namespace, kill pasta process
 teardown_pasta() {
-	${NSHOLDER} ns.hold stop
+	${NSHOLDER} "${STATESETUP}/ns.hold" stop
 	context_wait unshare
 
 	teardown_context_watch ${PANE_HOST} host
@@ -311,13 +311,13 @@ teardown_pasta() {
 
 # teardown_passt_in_ns() - Exit namespace, kill qemu and pasta, remove pid file
 teardown_passt_in_ns() {
-	context_run ns kill $(cat passt_in_ns_qemu.pid)
+	context_run ns kill $(cat "${STATESETUP}/qemu.pid")
 	context_wait qemu
 
-	${NSHOLDER} ns.hold stop
+	${NSHOLDER} "${STATESETUP}/ns.hold" stop
 	context_wait pasta
 
-	rm passt.pid pasta.pid
+	rm "${STATESETUP}/passt.pid" "${STATESETUP}/pasta.pid"
 
 	teardown_context_watch ${PANE_HOST} host
 	teardown_context_watch ${PANE_PASST} pasta passt
@@ -327,23 +327,23 @@ teardown_passt_in_ns() {
 
 # teardown_two_guests() - Exit namespaces, kill qemu processes, passt and pasta
 teardown_two_guests() {
-	__ns1_pid=$(${NSHOLDER} ns1.hold pid)
-	__ns2_pid=$(${NSHOLDER} ns2.hold pid)
-	nsenter -U -p --preserve-credentials -t ${__ns1_pid} kill $(cat two_guests_qemu_1.pid)
-	nsenter -U -p --preserve-credentials -t ${__ns2_pid} kill $(cat two_guests_qemu_2.pid)
+	__ns1_pid=$(${NSHOLDER} "${STATESETUP}/ns1.hold" pid)
+	__ns2_pid=$(${NSHOLDER} "${STATESETUP}/ns2.hold" pid)
+	nsenter -U -p --preserve-credentials -t ${__ns1_pid} kill $(cat "${STATESETUP}/qemu_1.pid")
+	nsenter -U -p --preserve-credentials -t ${__ns2_pid} kill $(cat "${STATESETUP}/qemu_2.pid")
 	context_wait qemu_1
 	context_wait qemu_2
 
-	nsenter -U -p --preserve-credentials -t ${__ns1_pid} kill $(cat passt_1.pid)
-	nsenter -U -p --preserve-credentials -t ${__ns2_pid} kill $(cat passt_2.pid)
+	nsenter -U -p --preserve-credentials -t ${__ns1_pid} kill $(cat "${STATESETUP}/passt_1.pid")
+	nsenter -U -p --preserve-credentials -t ${__ns2_pid} kill $(cat "${STATESETUP}/passt_2.pid")
 	context_wait passt_1
 	context_wait passt_2
-	${NSHOLDER} ns1.hold stop
-	${NSHOLDER} ns2.hold stop
+	${NSHOLDER} "${STATESETUP}/ns1.hold" stop
+	${NSHOLDER} "${STATESETUP}/ns2.hold" stop
 	context_wait pasta_1
 	context_wait pasta_2
 
-	rm -f passt_[12].pid pasta_[12].pid
+	rm -f "${STATESETUP}/passt__[12].pid" "${STATESETUP}/pasta_[12].pid"
 
 	teardown_context_watch ${PANE_HOST} host
 	teardown_context_watch ${PANE_GUEST_1} qemu_1 guest_1
diff --git a/test/passt/shutdown b/test/passt/shutdown
index ce90ea9..34ddb64 100644
--- a/test/passt/shutdown
+++ b/test/passt/shutdown
@@ -14,7 +14,7 @@
 
 test	shutdown: exit code
 
-hout	PASST_PID cat passt.pid
+hout	PASST_PID cat __STATESETUP__/passt.pid
 host	kill __PASST_PID__
 sleep	1
 passtw
diff --git a/test/passt_in_ns/shutdown b/test/passt_in_ns/shutdown
index abe9d6c..b602ec2 100644
--- a/test/passt_in_ns/shutdown
+++ b/test/passt_in_ns/shutdown
@@ -14,7 +14,7 @@
 
 test	shutdown: exit code
 
-nsout	PASST_PID cat passt.pid
+nsout	PASST_PID cat __STATESETUP__/passt.pid
 ns	kill __PASST_PID__
 sleep	1
 passtw
-- 
@@ -14,7 +14,7 @@
 
 test	shutdown: exit code
 
-nsout	PASST_PID cat passt.pid
+nsout	PASST_PID cat __STATESETUP__/passt.pid
 ns	kill __PASST_PID__
 sleep	1
 passtw
-- 
2.37.3


  parent reply	other threads:[~2022-09-08  6:16 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-08  6:15 [PATCH v2 00/32] Improve handling of test temporary files David Gibson
2022-09-08  6:15 ` [PATCH v2 01/32] test: Correctly match "background" with "wait" commands David Gibson
2022-09-08  6:15 ` [PATCH v2 02/32] test: Context execution helpers David Gibson
2022-09-08  6:15 ` [PATCH v2 03/32] test: Allow a tmux pane to watch commands executed in contexts David Gibson
2022-09-08  6:15 ` [PATCH v2 04/32] test: Integration of old-style pane execution and new context execution David Gibson
2022-09-08  6:15 ` [PATCH v2 05/32] test: Issue host commands via context for most tests David Gibson
2022-09-08  6:15 ` [PATCH v2 06/32] test: Use new-style contexts for passt pane in the pasta and passt tests David Gibson
2022-09-08  6:15 ` [PATCH v2 07/32] test: Add nsholder utility David Gibson
2022-09-08  6:15 ` [PATCH v2 08/32] test: Extend context system to run commands in namespace for pasta tests David Gibson
2022-09-08  6:15 ` [PATCH v2 09/32] test: Use context system for guest commands David Gibson
2022-09-08  6:15 ` [PATCH v2 10/32] test: Use context system for two_guests tests David Gibson
2022-09-08  6:16 ` [PATCH v2 11/32] test: Use new-style command issue for passt_in_ns tests David Gibson
2022-09-08  6:16 ` [PATCH v2 12/32] Don't store UID & GID persistently in the context structure David Gibson
2022-09-08  6:16 ` [PATCH v2 13/32] Split checking for root from dropping root privilege David Gibson
2022-09-08  6:16 ` [PATCH v2 14/32] Consolidate determination of UID/GID to run as David Gibson
2022-09-08  6:16 ` [PATCH v2 15/32] Safer handling if we can't open /proc/self/uid_map David Gibson
2022-09-08  6:16 ` [PATCH v2 16/32] Move self-isolation code into a separate file David Gibson
2022-09-08  6:16 ` [PATCH v2 17/32] Consolidate validation of pasta namespace options David Gibson
2022-09-08  6:16 ` [PATCH v2 18/32] Clean up and rename conf_ns_open() David Gibson
2022-09-08  6:16 ` [PATCH v2 19/32] Correctly handle --netns-only in pasta_start_ns() David Gibson
2022-09-08  6:16 ` [PATCH v2 20/32] Handle userns isolation and dropping root at the same time David Gibson
2022-09-08  6:16 ` [PATCH v2 21/32] Allow --userns when pasta spawns a command David Gibson
2022-09-08  6:16 ` [PATCH v2 22/32] test: Group tests by context then protocol, rather than the reverse David Gibson
2022-09-08  6:16 ` [PATCH v2 23/32] test: Remove unused variable FFMPEG_PID_FILE David Gibson
2022-09-08  6:16 ` [PATCH v2 24/32] test: Actually run cleanup function David Gibson
2022-09-08  6:16 ` [PATCH v2 25/32] test: Create common state directories for temporary files David Gibson
2022-09-08  6:16 ` [PATCH v2 26/32] test: Move context temporary files to state dir David Gibson
2022-09-08  6:16 ` [PATCH v2 27/32] test: Dont regnerate small test file in pasta/tcp David Gibson
2022-09-08  6:16 ` [PATCH v2 28/32] test: Use paths in __STATEDIR__ instead of 'temp' and 'tempdir' directives David Gibson
2022-09-08  6:16 ` [PATCH v2 29/32] test: Move pause temporary file to state directory David Gibson
2022-09-08  6:16 ` [PATCH v2 30/32] test: Store pcap files in $LOGDIR instead of /tmp David Gibson
2022-09-08  6:16 ` David Gibson [this message]
2022-09-08  6:16 ` [PATCH v2 32/32] test: Move video processing files to $STATEBASE David Gibson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220908061621.2430844-32-david@gibson.dropbear.id.au \
    --to=david@gibson.dropbear.id.au \
    --cc=passt-dev@passt.top \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).