diff options
author | Stefano Brivio <sbrivio@redhat.com> | 2022-07-21 13:53:21 +0200 |
---|---|---|
committer | Stefano Brivio <sbrivio@redhat.com> | 2022-07-22 19:41:18 +0200 |
commit | a4778b3b8194d8ac9443661c5d150a739b8e7eca (patch) | |
tree | 32f9ae4a36d6ae49a41ac311654b0f2f604d3d9b /test/demo | |
parent | 95f7b4ec3fb9cf6f080067fa25300eb22b00181b (diff) | |
download | passt-a4778b3b8194d8ac9443661c5d150a739b8e7eca.tar passt-a4778b3b8194d8ac9443661c5d150a739b8e7eca.tar.gz passt-a4778b3b8194d8ac9443661c5d150a739b8e7eca.tar.bz2 passt-a4778b3b8194d8ac9443661c5d150a739b8e7eca.tar.lz passt-a4778b3b8194d8ac9443661c5d150a739b8e7eca.tar.xz passt-a4778b3b8194d8ac9443661c5d150a739b8e7eca.tar.zst passt-a4778b3b8194d8ac9443661c5d150a739b8e7eca.zip |
test: In demos, use pgrep instead of pstree to find namespace PID
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@redhat.com>
Diffstat (limited to 'test/demo')
-rw-r--r-- | test/demo/passt | 5 | ||||
-rw-r--r-- | test/demo/pasta | 9 |
2 files changed, 6 insertions, 8 deletions
diff --git a/test/demo/passt b/test/demo/passt index 16dcea3..c6c3bcc 100644 --- a/test/demo/passt +++ b/test/demo/passt @@ -70,7 +70,7 @@ say 'pasta' demo above. sleep 3 passt cd __TEMPDIR__/passt -passtb ./pasta +passtb ./pasta -P /tmp/pasta.pid sleep 3 passt /sbin/dhclient -4 --no-pid sleep 2 @@ -83,8 +83,7 @@ say Now let's run 'passt' in the new namespace, and nl say enter this namespace from the guest terminal too. sleep 3 -guest pstree -p | grep pasta -gout TARGET_PID pstree -p | grep pasta | sed -n 's/.*(\([0-9].*\))$/\1/p' +gout TARGET_PID pgrep -P $(cat /tmp/pasta.pid) sleep 1 passtb ./passt -f -t 5201,5203 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 |