From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Gibson To: passt-dev@passt.top Subject: [PATCH v5 11/14] test: Move pidfiles and nsholder sockets into state directory Date: Tue, 13 Sep 2022 14:35:26 +1000 Message-ID: <20220913043529.3079003-12-david@gibson.dropbear.id.au> In-Reply-To: <20220913043529.3079003-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============9121491648011318043==" --===============9121491648011318043== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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 --- .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 ab532b5..d7921bf 100755 --- a/test/lib/setup +++ b/test/lib/setup @@ -53,7 +53,7 @@ setup_passt() { =20 context_run passt "make clean" context_run passt "make valgrind" - context_run_bg passt "valgrind --max-stackframe=3D$((4 * 1024 * 1024)) --tr= ace-children=3Dyes --vgdb=3Dno --error-exitcode=3D1 --suppressions=3Dtest/val= grind.supp ./passt ${__opts} -f -t 10001 -u 10001 -P passt.pid" + context_run_bg passt "valgrind --max-stackframe=3D$((4 * 1024 * 1024)) --tr= ace-children=3Dyes --vgdb=3Dno --error-exitcode=3D1 --suppressions=3Dtest/val= grind.supp ./passt ${__opts} -f -t 10001 -u 10001 -P ${STATESETUP}/passt.pid" sleep 5 =20 GUEST_CID=3D94557 @@ -67,7 +67,7 @@ setup_passt() { 'virtio-net.napi_tx=3D1"' \ " -device virtio-net-pci,netdev=3Dhostnet0,x-txburst=3D16384" \ " -netdev socket,fd=3D5,id=3Dhostnet0" \ - " -pidfile passt_qemu.pid" \ + " -pidfile ${STATESETUP}/qemu.pid" \ " -device vhost-vsock-pci,guest-cid=3D$GUEST_CID" =20 context_setup_guest guest $GUEST_CID @@ -81,8 +81,8 @@ setup_pasta() { =20 layout_pasta =20 - context_run_bg unshare "unshare -rUnpf ${NSHOLDER} ns.hold hold" - __target_pid=3D$(${NSHOLDER} ns.hold pid) + context_run_bg unshare "unshare -rUnpf ${NSHOLDER} ${STATESETUP}/ns.hold ho= ld" + __target_pid=3D$(${NSHOLDER} ${STATESETUP}/ns.hold pid) =20 context_setup_nsenter ns -U -n -p --preserve-credentials -t ${__target_pid} =20 @@ -98,7 +98,7 @@ setup_pasta() { [ ${DEBUG} -eq 1 ] && __opts=3D"${__opts} -d" [ ${TRACE} -eq 1 ] && __opts=3D"${__opts} --trace" =20 - context_run_bg passt "./pasta ${__opts} -f -t 10002 -T 10003 -u 10002 -U 10= 003 -P passt.pid ${__target_pid}" + context_run_bg passt "./pasta ${__opts} -f -t 10002 -T 10003 -u 10002 -U 10= 003 -P ${STATESETUP}/passt.pid ${__target_pid}" sleep 1 } =20 @@ -128,9 +128,9 @@ setup_passt_in_ns() { [ ${DEBUG} -eq 1 ] && __opts=3D"${__opts} -d" [ ${TRACE} -eq 1 ] && __opts=3D"${__opts} --trace" =20 - 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=3D$(${NSHOLDER} ns.hold pid) + __ns_pid=3D$(${NSHOLDER} ${STATESETUP}/ns.hold pid) =20 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=3D$((4 * 1024 * 1024)) --t= race-children=3Dyes --vgdb=3Dno --error-exitcode=3D1 --suppressions=3Dtest/va= lgrind.supp ./passt -f ${__opts} -t 10001,10011,10021,10031 -u 10001,10011,10= 021,10031 -P passt.pid" + context_run_bg passt "valgrind --max-stackframe=3D$((4 * 1024 * 1024)) --t= race-children=3Dyes --vgdb=3Dno --error-exitcode=3D1 --suppressions=3Dtest/va= lgrind.supp ./passt -f ${__opts} -t 10001,10011,10021,10031 -u 10001,10011,10= 021,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 1= 0001,10011,10021,10031 -P passt.pid" + context_run_bg passt "./passt -f ${__opts} -t 10001,10011,10021,10031 -u 1= 0001,10011,10021,10031 -P ${STATESETUP}/passt.pid" fi sleep 5 =20 @@ -169,7 +169,7 @@ setup_passt_in_ns() { 'virtio-net.napi_tx=3D1"' \ " -device virtio-net-pci,netdev=3Dhostnet0,x-txburst=3D524288" \ " -netdev socket,fd=3D5,id=3Dhostnet0" \ - ' -pidfile passt_in_ns_qemu.pid' \ + " -pidfile ${STATESETUP}/qemu.pid" \ " -device vhost-vsock-pci,guest-cid=3D$GUEST_CID" =20 context_setup_guest guest $GUEST_CID @@ -197,16 +197,16 @@ setup_two_guests() { [ ${PCAP} -eq 1 ] && __opts=3D"${__opts} -p ${LOGDIR}/pasta_1.pcap" [ ${DEBUG} -eq 1 ] && __opts=3D"${__opts} -d" [ ${TRACE} -eq 1 ] && __opts=3D"${__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=3D$(${NSHOLDER} ns1.hold pid) + context_run_bg pasta_1 "./pasta ${__opts} -P ${STATESETUP}/pasta_1.pid -t 1= 0001,10002 -T 10003,10004 -u 10001,10002 -U 10003,10004 ${NSHOLDER} ${STATESE= TUP}/ns1.hold hold" + __ns1_pid=3D$(${NSHOLDER} ${STATESETUP}/ns1.hold pid) context_setup_nsenter passt_1 -U -n -p --preserve-credentials -t ${__ns1_pi= d} =20 __opts=3D [ ${PCAP} -eq 1 ] && __opts=3D"${__opts} -p ${LOGDIR}/pasta_2.pcap" [ ${DEBUG} -eq 1 ] && __opts=3D"${__opts} -d" [ ${TRACE} -eq 1 ] && __opts=3D"${__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=3D$(${NSHOLDER} ns2.hold pid) + context_run_bg pasta_2 "./pasta ${__opts} -P ${STATESETUP}/pasta_2.pid -t 1= 0004,10005 -T 10003,10001 -u 10004,10005 -U 10003,10001 ${NSHOLDER} ${STATESE= TUP}/ns2.hold hold" + __ns2_pid=3D$(${NSHOLDER} ${STATESETUP}/ns2.hold pid) context_setup_nsenter passt_2 -U -n -p --preserve-credentials -t ${__ns2_pi= d} =20 context_setup_nsenter qemu_1 -U -n -p --preserve-credentials -t ${__ns1_pid} @@ -224,7 +224,7 @@ setup_two_guests() { [ ${DEBUG} -eq 1 ] && __opts=3D"${__opts} -d" [ ${TRACE} -eq 1 ] && __opts=3D"${__opts} --trace" =20 - context_run_bg passt_1 "./passt -P passt_1.pid -f ${__opts} -t 10001 -u 100= 01" + context_run_bg passt_1 "./passt -P ${STATESETUP}/passt_1.pid -f ${__opts} -= t 10001 -u 10001" sleep 1 =20 __opts=3D @@ -232,7 +232,7 @@ setup_two_guests() { [ ${DEBUG} -eq 1 ] && __opts=3D"${__opts} -d" [ ${TRACE} -eq 1 ] && __opts=3D"${__opts} --trace" =20 - context_run_bg passt_2 "./passt -P passt_2.pid -f ${__opts} -t 10004 -u 100= 04" + context_run_bg passt_2 "./passt -P ${STATESETUP}/passt_2.pid -f ${__opts} -= t 10004 -u 10004" =20 GUEST_1_CID=3D94557 context_run_bg qemu_1 './qrap 5 qemu-system-$(uname -m)' \ @@ -245,7 +245,7 @@ setup_two_guests() { 'virtio-net.napi_tx=3D1"' \ " -device virtio-net-pci,netdev=3Dhostnet0,x-txburst=3D16384" \ " -netdev socket,fd=3D5,id=3Dhostnet0" \ - ' -pidfile two_guests_qemu_1.pid' \ + " -pidfile ${STATESETUP}/qemu_1.pid" \ " -device vhost-vsock-pci,guest-cid=3D$GUEST_1_CID" =20 GUEST_2_CID=3D94558 @@ -259,7 +259,7 @@ setup_two_guests() { 'virtio-net.napi_tx=3D1"' \ " -device virtio-net-pci,netdev=3Dhostnet0,x-txburst=3D16384" \ " -netdev socket,fd=3D5,id=3Dhostnet0" \ - ' -pidfile two_guests_qemu_2.pid' \ + " -pidfile ${STATESETUP}/qemu_2.pid" \ " -device vhost-vsock-pci,guest-cid=3D$GUEST_2_CID" =20 context_setup_guest guest_1 ${GUEST_1_CID} @@ -290,9 +290,9 @@ teardown_distro() { =20 # teardown_passt() - Kill qemu, remove passt PID file teardown_passt() { - kill $(cat passt_qemu.pid) + kill $(cat "${STATESETUP}/qemu.pid") =20 - rm passt.pid + rm "${STATESETUP}/passt.pid" =20 teardown_context_watch ${PANE_HOST} host teardown_context_watch ${PANE_PASST} passt @@ -301,7 +301,7 @@ teardown_passt() { =20 # teardown_passt() - Exit namespace, kill pasta process teardown_pasta() { - ${NSHOLDER} ns.hold stop + ${NSHOLDER} "${STATESETUP}/ns.hold" stop context_wait unshare =20 teardown_context_watch ${PANE_HOST} host @@ -311,13 +311,13 @@ teardown_pasta() { =20 # teardown_passt_in_ns() - Exit namespace, kill qemu and pasta, remove pid f= ile 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 =20 - ${NSHOLDER} ns.hold stop + ${NSHOLDER} "${STATESETUP}/ns.hold" stop context_wait pasta =20 - rm passt.pid pasta.pid + rm "${STATESETUP}/passt.pid" "${STATESETUP}/pasta.pid" =20 teardown_context_watch ${PANE_HOST} host teardown_context_watch ${PANE_PASST} pasta passt @@ -327,23 +327,23 @@ teardown_passt_in_ns() { =20 # teardown_two_guests() - Exit namespaces, kill qemu processes, passt and pa= sta teardown_two_guests() { - __ns1_pid=3D$(${NSHOLDER} ns1.hold pid) - __ns2_pid=3D$(${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=3D$(${NSHOLDER} "${STATESETUP}/ns1.hold" pid) + __ns2_pid=3D$(${NSHOLDER} "${STATESETUP}/ns2.hold" pid) + nsenter -U -p --preserve-credentials -t ${__ns1_pid} kill $(cat "${STATESET= UP}/qemu_1.pid") + nsenter -U -p --preserve-credentials -t ${__ns2_pid} kill $(cat "${STATESET= UP}/qemu_2.pid") context_wait qemu_1 context_wait qemu_2 =20 - 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 "${STATESET= UP}/passt_1.pid") + nsenter -U -p --preserve-credentials -t ${__ns2_pid} kill $(cat "${STATESET= UP}/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 =20 - rm -f passt_[12].pid pasta_[12].pid + rm -f "${STATESETUP}/passt__[12].pid" "${STATESETUP}/pasta_[12].pid" =20 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 @@ =20 test shutdown: exit code =20 -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 @@ =20 test shutdown: exit code =20 -nsout PASST_PID cat passt.pid +nsout PASST_PID cat __STATESETUP__/passt.pid ns kill __PASST_PID__ sleep 1 passtw --=20 2.37.3 --===============9121491648011318043==--