From: Stefano Brivio <sbrivio@redhat.com>
To: passt-dev@passt.top
Subject: [PATCH 3/7] test: In pasta demo, use pgrep instead of pstree to find namespace PID
Date: Thu, 21 Jul 2022 14:06:33 +0200 [thread overview]
Message-ID: <20220721120637.232914-4-sbrivio@redhat.com> (raw)
In-Reply-To: <20220721120637.232914-1-sbrivio@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 1508 bytes --]
Parsing pstree's output is somewhat unreliable: there might be
multiple pasta instances running on the same host, and depending on
the overall output width pstree might truncate some branches.
Ask pasta to save its PID to file, and use that as parameter for
pgrep to find the PID of the interactive shell whose user and network
namespaces we want to join.
Signed-off-by: Stefano Brivio <sbrivio(a)redhat.com>
---
test/demo/pasta | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/test/demo/pasta b/test/demo/pasta
index f4b7da2..be117b3 100644
--- a/test/demo/pasta
+++ b/test/demo/pasta
@@ -48,7 +48,7 @@ nl
say without PID, it will create a namespace.
sleep 3
passt cd __TEMPDIR__/passt
-passtb ./pasta
+passtb ./pasta -P /tmp/pasta.pid
sleep 3
nl
@@ -57,8 +57,7 @@ say For convenience, let's enter this namespace
nl
say from another terminal.
sleep 3
-ns pstree -p | grep pasta
-nsout TARGET_PID pstree -p | grep pasta | sed -n 's/.*(\([0-9].*\))$/\1/p'
+nsout TARGET_PID pgrep -P $(cat /tmp/pasta.pid)
sleep 1
ns nsenter -t __TARGET_PID__ -U -n --preserve-credentials
@@ -171,10 +170,10 @@ passt exit
passt make clean
passt CFLAGS="-g" make
sleep 2
-passtb perf record -g ./pasta
+passtb perf record -g ./pasta -P /tmp/pasta.pid
sleep 2
-nsout TARGET_PID pstree -p | grep pasta | sed -n 's/.*(\([0-9].*\))$/\1/p'
+nsout TARGET_PID pgrep -P $(cat /tmp/pasta.pid)
sleep 1
ns nsenter -t __TARGET_PID__ -U -n --preserve-credentials
sleep 5
--
@@ -48,7 +48,7 @@ nl
say without PID, it will create a namespace.
sleep 3
passt cd __TEMPDIR__/passt
-passtb ./pasta
+passtb ./pasta -P /tmp/pasta.pid
sleep 3
nl
@@ -57,8 +57,7 @@ say For convenience, let's enter this namespace
nl
say from another terminal.
sleep 3
-ns pstree -p | grep pasta
-nsout TARGET_PID pstree -p | grep pasta | sed -n 's/.*(\([0-9].*\))$/\1/p'
+nsout TARGET_PID pgrep -P $(cat /tmp/pasta.pid)
sleep 1
ns nsenter -t __TARGET_PID__ -U -n --preserve-credentials
@@ -171,10 +170,10 @@ passt exit
passt make clean
passt CFLAGS="-g" make
sleep 2
-passtb perf record -g ./pasta
+passtb perf record -g ./pasta -P /tmp/pasta.pid
sleep 2
-nsout TARGET_PID pstree -p | grep pasta | sed -n 's/.*(\([0-9].*\))$/\1/p'
+nsout TARGET_PID pgrep -P $(cat /tmp/pasta.pid)
sleep 1
ns nsenter -t __TARGET_PID__ -U -n --preserve-credentials
sleep 5
--
2.35.1
next prev parent reply other threads:[~2022-07-21 12:06 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-21 12:06 [PATCH 0/7] Demo fixes and Podman patch rebase Stefano Brivio
2022-07-21 12:06 ` [PATCH 1/7] contrib: Rebase Podman patch to latest upstream Stefano Brivio
2022-07-21 12:06 ` [PATCH 2/7] test: In passt demo, bring up eth0 in guest, not in namespace pane Stefano Brivio
2022-07-21 12:06 ` Stefano Brivio [this message]
2022-07-21 12:06 ` [PATCH 4/7] test: In pasta demo, issue /sbin/dhclient instead of dhclient Stefano Brivio
2022-07-21 12:06 ` [PATCH 5/7] test: Fix Podman build in Podman demo Stefano Brivio
2022-07-21 12:06 ` [PATCH 6/7] test: Actually use pasta in Podman demo step with HTTP service Stefano Brivio
2022-07-21 12:06 ` [PATCH 7/7] test: Drop further ^D in passt demo teardown Stefano Brivio
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=20220721120637.232914-4-sbrivio@redhat.com \
--to=sbrivio@redhat.com \
--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).