From: David Gibson <david@gibson.dropbear.id.au>
To: passt-dev@passt.top
Subject: [PATCH 09/12] test: Use paths in __STATEDIR__ instead of 'temp' and 'tempdir' directives
Date: Wed, 07 Sep 2022 23:03:04 +1000 [thread overview]
Message-ID: <20220907130307.1166467-10-david@gibson.dropbear.id.au> (raw)
In-Reply-To: <20220907130307.1166467-1-david@gibson.dropbear.id.au>
[-- Attachment #1: Type: text/plain, Size: 21183 bytes --]
Instead of using the 'temp' and 'tempdir' DSL directives to create
temporary files, use fixed paths relative to __STATEDIR__. This has two
advantages:
1) The files are automatically cleaned up if the tests fail (and even if
that doesn't work they're easier to clean up manuall)
2) When debugging tests it's easier to figure out which of the temporary
files are relevant to whatever's going wrong
Signed-off-by: David Gibson <david(a)gibson.dropbear.id.au>
---
test/build/all | 31 +++++++++++++++----------------
test/demo/passt | 9 ++++-----
test/demo/pasta | 12 +++++-------
test/demo/podman | 11 +++++------
test/distro/debian | 2 +-
test/distro/fedora | 2 +-
test/distro/opensuse | 16 +++++++++-------
test/distro/ubuntu | 8 ++++----
test/lib/test | 10 ----------
test/passt/tcp | 4 ++--
test/passt/udp | 6 +++---
test/passt_in_ns/tcp | 8 ++++----
test/passt_in_ns/udp | 6 +++---
test/pasta/tcp | 8 ++++----
test/pasta/udp | 18 +++++++++---------
15 files changed, 69 insertions(+), 82 deletions(-)
diff --git a/test/build/all b/test/build/all
index 1a89b77..bacb1d1 100644
--- a/test/build/all
+++ b/test/build/all
@@ -41,22 +41,21 @@ check [ -f passt ]
check [ -h pasta ]
check [ -f qrap ]
-tempdir TEMP
-
test Install
-host prefix=__TEMP__ make install
-check [ -f __TEMP__/bin/passt ]
-check [ -h __TEMP__/bin/pasta ]
-check [ -f __TEMP__/bin/qrap ]
-check man -M __TEMP__/share/man -W passt
-check man -M __TEMP__/share/man -W pasta
-check man -M __TEMP__/share/man -W qrap
+host mkdir __STATEDIR__/prefix
+host prefix=__STATEDIR__/prefix make install
+check [ -f __STATEDIR__/prefix/bin/passt ]
+check [ -h __STATEDIR__/prefix/bin/pasta ]
+check [ -f __STATEDIR__/prefix/bin/qrap ]
+check man -M __STATEDIR__/prefix/share/man -W passt
+check man -M __STATEDIR__/prefix/share/man -W pasta
+check man -M __STATEDIR__/prefix/share/man -W qrap
test Uninstall
-host prefix=__TEMP__ make uninstall
-check ! [ -f __TEMP__/bin/passt ]
-check ! [ -h __TEMP__/bin/pasta ]
-check ! [ -f __TEMP__/bin/qrap ]
-check ! man -M __TEMP__/share/man -W passt 2>/dev/null
-check ! man -M __TEMP__/share/man -W pasta 2>/dev/null
-check ! man -M __TEMP__/share/man -W qrap 2>/dev/null
+host prefix=__STATEDIR__/prefix make uninstall
+check ! [ -f __STATEDIR__/prefix/bin/passt ]
+check ! [ -h __STATEDIR__/prefix/bin/pasta ]
+check ! [ -f __STATEDIR__/prefix/bin/qrap ]
+check ! man -M __STATEDIR__/prefix/share/man -W passt 2>/dev/null
+check ! man -M __STATEDIR__/prefix/share/man -W pasta 2>/dev/null
+check ! man -M __STATEDIR__/prefix/share/man -W qrap 2>/dev/null
diff --git a/test/demo/passt b/test/demo/passt
index 673afd9..dd6a119 100644
--- a/test/demo/passt
+++ b/test/demo/passt
@@ -20,8 +20,7 @@ sleep 3
say Let's fetch the source
sleep 1
-tempdir TEMPDIR
-host cd __TEMPDIR__
+host cd __STATEDIR__
host git clone git://passt.top/passt
sleep 1
@@ -52,10 +51,10 @@ host q
nl
nl
say Let's create a small initramfs image for the guest.
-guest cd __TEMPDIR__
+guest cd __STATEDIR__
guest git clone git://mbuto.sh/mbuto
guest cd mbuto
-guest ./mbuto -f passt.img -p __TEMPDIR__/passt/test/passt.mbuto -c lz4
+guest ./mbuto -f passt.img -p __STATEDIR__/passt/test/passt.mbuto -c lz4
sleep 2
nl
@@ -69,7 +68,7 @@ nl
say 'pasta' demo above.
sleep 3
-passt cd __TEMPDIR__/passt
+passt cd __STATEDIR__/passt
passtb ./pasta -P /tmp/pasta.pid
sleep 3
passt /sbin/dhclient -4 --no-pid
diff --git a/test/demo/pasta b/test/demo/pasta
index 393149e..22479f8 100644
--- a/test/demo/pasta
+++ b/test/demo/pasta
@@ -20,8 +20,7 @@ sleep 3
say Let's fetch the source
sleep 1
-tempdir TEMPDIR
-host cd __TEMPDIR__
+host cd __STATEDIR__
host git clone git://passt.top/passt
sleep 1
@@ -47,7 +46,7 @@ sleep 10
nl
say without PID, it will create a namespace.
sleep 3
-passt cd __TEMPDIR__/passt
+passt cd __STATEDIR__/passt
passtb ./pasta -P /tmp/pasta.pid
sleep 3
@@ -140,13 +139,12 @@ say can also take packet captures.
sleep 3
passt exit
sleep 2
-temp TEMP
-passtb ./pasta -p __TEMP__.pcap
+passtb ./pasta -p __STATEDIR__/demo_pasta.pcap
sleep 2
passt
passt /sbin/dhclient -4 --no-pid
sleep 2
-hostb tshark -r __TEMP__.pcap
+hostb tshark -r __STATEDIR__/demo_pasta.pcap
sleep 5
nl
@@ -257,7 +255,7 @@ sleep 2
killp PASST
killp HOST
sleep 2
-ns cd __TEMPDIR__/passt
+ns cd __STATEDIR__/passt
nsb perf report -g --max-stack 3
sleep 10
diff --git a/test/demo/podman b/test/demo/podman
index f3411d8..a83a04f 100644
--- a/test/demo/podman
+++ b/test/demo/podman
@@ -24,14 +24,13 @@ sleep 3
say Let's fetch Podman
sleep 1
-tempdir TEMPDIR
-host git -C __TEMPDIR__ clone https://github.com/containers/podman.git
+host git -C __STATEDIR__ clone https://github.com/containers/podman.git
sleep 1
say , patch it
sleep 1
-host cp ../contrib/podman/0001-libpod-Add-pasta-networking-mode.patch __TEMPDIR__/podman
-host cd __TEMPDIR__/podman
+host cp ../contrib/podman/0001-libpod-Add-pasta-networking-mode.patch __STATEDIR__/podman
+host cd __STATEDIR__/podman
host git am -3 0001-libpod-Add-pasta-networking-mode.patch
sleep 1
@@ -54,7 +53,7 @@ nl
say Let's start a container with it
sleep 1
-ns1 cd __TEMPDIR__/podman
+ns1 cd __STATEDIR__/podman
ns1b ./bin/podman run --rm -ti alpine sh
sleep 2
@@ -64,7 +63,7 @@ say and one with
em pasta
say instead.
-ns2 cd __TEMPDIR__/podman
+ns2 cd __STATEDIR__/podman
ns2b ./bin/podman run --net=pasta --rm -ti alpine sh
sleep 2
diff --git a/test/distro/debian b/test/distro/debian
index 83fb32d..4a19f95 100644
--- a/test/distro/debian
+++ b/test/distro/debian
@@ -11,7 +11,7 @@
# Copyright (c) 2021 Red Hat GmbH
# Author: Stefano Brivio <sbrivio(a)redhat.com>
-temp PIDFILE
+set PIDFILE __STATEDIR__/passt.pid
htools cat kill qemu-system-x86_64 qemu-system-aarch64 qemu-system-ppc64
# Quick pasta test: send message from init to ns, and from ns to init
diff --git a/test/distro/fedora b/test/distro/fedora
index daad6a4..a8d3b51 100644
--- a/test/distro/fedora
+++ b/test/distro/fedora
@@ -11,7 +11,7 @@
# Copyright (c) 2021 Red Hat GmbH
# Author: Stefano Brivio <sbrivio(a)redhat.com>
-temp PIDFILE
+set PIDFILE __STATEDIR__/passt.pid
htools cat kill qemu-system-x86_64
# Quick pasta test: send message from init to ns, and from ns to init
diff --git a/test/distro/opensuse b/test/distro/opensuse
index d48deb7..314870f 100644
--- a/test/distro/opensuse
+++ b/test/distro/opensuse
@@ -11,7 +11,7 @@
# Copyright (c) 2021 Red Hat GmbH
# Author: Stefano Brivio <sbrivio(a)redhat.com>
-temp PIDFILE
+set PIDFILE __STATEDIR__/passt.pid
htools qemu-img virt-edit guestfish head sed cat kill qemu-system-x86_64 qemu-system-aarch64 xzcat tr
# Quick pasta test: send message from init to ns, and from ns to init
@@ -44,7 +44,7 @@ hout GUEST_FILES ls -1 *.c *.h *.sh passt.1 qrap.1 Makefile README.md | tr '\n'
test OpenSUSE Leap 15.1
-temp IMG
+set IMG __STATEDIR__/opensuse-15.1-x86_64.img
host qemu-img create -f qcow2 -F qcow2 -b __BASEPATH__/openSUSE-Leap-15.1-JeOS.x86_64-kvm-and-xen.qcow2 __IMG__
host guestfish --rw -a __IMG__ -i rm '/usr/lib/systemd/system/systemd-journald.service'
host guestfish --rw -a __IMG__ -i rm /etc/systemd/system/default.target.wants/jeos-firstboot.service
@@ -73,6 +73,7 @@ hout PID cat __PIDFILE__
test OpenSUSE Leap 15.2
+set IMG __STATEDIR__/opensuse-15.2-x86_64.img
host qemu-img create -f qcow2 -F qcow2 -b __BASEPATH__/openSUSE-Leap-15.2-JeOS.x86_64-kvm-and-xen.qcow2 __IMG__
host guestfish --rw -a __IMG__ -i rm '/usr/lib/systemd/system/systemd-journald.service'
host guestfish --rw -a __IMG__ -i rm /etc/systemd/system/default.target.wants/jeos-firstboot.service
@@ -98,6 +99,7 @@ sleep 1
test OpenSUSE Leap 15.3
+set IMG __STATEDIR__/opensuse-15.3-x86_64.img
host qemu-img create -f qcow2 -F qcow2 -b __BASEPATH__/openSUSE-Leap-15.3-JeOS.x86_64-kvm-and-xen.qcow2 __IMG__
host guestfish --rw -a __IMG__ -i rm '/usr/lib/systemd/system/systemd-journald.service'
host guestfish --rw -a __IMG__ -i rm /etc/systemd/system/default.target.wants/jeos-firstboot.service
@@ -125,7 +127,7 @@ sleep 1
test OpenSUSE Tumbleweed aarch64
-temp IMG
+set IMG __STATEDIR__/opensuse-tumbleweed-aarch64.img
host xzcat __BASEPATH__/openSUSE-Tumbleweed-ARM-JeOS-efi.aarch64.raw.xz > __IMG__
host virt-edit -a __IMG__ -m /dev/sda3 /usr/lib/systemd/system/serial-getty(a).service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --timeout 5000 --autologin root -i -8 --keep-baud 115200,38400,9600 %I $TERM/g'
host guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/
@@ -150,9 +152,9 @@ sleep 1
test OpenSUSE Tumbleweed armv7l
-temp IMG
-temp ZIMAGE
-temp INITRD
+set IMG __STATEDIR__/opensuse-tumbleweed-armv7l.img
+set ZIMAGE __STATEDIR__/opensuse-tumbleweed-armv7l.zimage
+set INITRD __STATEDIR__/opensuse-tumbleweed-armv7l.initrd
host xzcat __BASEPATH__/openSUSE-Tumbleweed-ARM-JeOS-efi.armv7l.raw.xz > __IMG__
host guestfish -a __IMG__ -i download /boot/zImage __ZIMAGE__
host guestfish -a __IMG__ -i download /boot/initrd __INITRD__
@@ -178,7 +180,7 @@ sleep 1
test OpenSUSE Tumbleweed
-temp IMG
+set IMG __STATEDIR__/opensuse-tumbleweed-x86_64.img
host qemu-img create -f qcow2 -F qcow2 -b __BASEPATH__/openSUSE-Tumbleweed-JeOS.x86_64-kvm-and-xen.qcow2 __IMG__
host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/systemd-journald.service
host guestfish --rw -a __IMG__ -i rm /etc/systemd/system/default.target.wants/jeos-firstboot.service
diff --git a/test/distro/ubuntu b/test/distro/ubuntu
index 6666f38..72d2bea 100644
--- a/test/distro/ubuntu
+++ b/test/distro/ubuntu
@@ -11,7 +11,7 @@
# Copyright (c) 2021 Red Hat GmbH
# Author: Stefano Brivio <sbrivio(a)redhat.com>
-temp PIDFILE
+set PIDFILE __STATEDIR__/passt.pid
htools qemu-img virt-edit guestfish cat kill qemu-system-x86_64 qemu-system-ppc64 qemu-system-s390x
# Quick pasta test: send message from init to ns, and from ns to init
@@ -63,7 +63,7 @@ hout GUEST_FILES ls -1 *.c *.h *.sh passt.1 qrap.1 Makefile README.md | tr '\n'
test Ubuntu 14.04.5 LTS (Trusty Tahr), amd64
-temp IMG
+set IMG __STATEDIR__/ubuntu-14.04-amd64.img
host qemu-img create -f qcow2 -F qcow2 -b __BASEPATH__/trusty-server-cloudimg-amd64-disk1.img __IMG__
host virt-edit -a __IMG__ /etc/init/ttyS0.conf -e 's/\/getty/\/getty --autologin root/'
host guestfish --rw -a __IMG__ -i rm /etc/init/cloud-config.conf
@@ -96,7 +96,7 @@ hout PID cat __PIDFILE__
test Ubuntu 14.04.5 LTS (Trusty Tahr), i386
-temp IMG
+set IMG __STATEDIR__/ubuntu-14.04-i386.img
host qemu-img create -f qcow2 -F qcow2 -b __BASEPATH__/trusty-server-cloudimg-i386-disk1.img __IMG__
host virt-edit -a __IMG__ /etc/init/ttyS0.conf -e 's/\/getty/\/getty --autologin root/'
host guestfish --rw -a __IMG__ -i rm /etc/init/cloud-config.conf
@@ -126,7 +126,7 @@ sleep 1
test Ubuntu 14.04.5 LTS (Trusty Tahr), ppc64le
-temp IMG
+set IMG __STATEDIR__/ubuntu-14.04-ppc64le.img
host qemu-img create -f qcow2 -F qcow2 -b __BASEPATH__/trusty-server-cloudimg-ppc64el-disk1.img __IMG__
host virt-edit -a __IMG__ /etc/init/hvc0.conf -e 's/\/getty/\/getty --autologin root/'
host guestfish --rw -a __IMG__ -i rm /etc/init/cloud-config.conf
diff --git a/test/lib/test b/test/lib/test
index 052ebf0..6db1b35 100755
--- a/test/lib/test
+++ b/test/lib/test
@@ -98,16 +98,6 @@ test_one_line() {
IFS= eval TEST_ONE_DEF_$TEST_ONE_in_def=
IFS="${__ifs}"
;;
- "tempdir")
- __tmpdir="$(mktemp -d)"
- TEST_ONE_subs="$(list_add_pair "${TEST_ONE_subs}" "__${__arg}__" "${__tmpdir}")"
- TEST_ONE_dirclean="$(list_add "${TEST_ONE_dirclean}" "${__tmpdir}")"
- ;;
- "temp")
- __tmpfile="$(mktemp)"
- TEST_ONE_subs="$(list_add_pair "${TEST_ONE_subs}" "__${__arg}__" "${__tmpfile}")"
- TEST_ONE_dirclean="$(list_add "${TEST_ONE_dirclean}" "${__tmpfile}")"
- ;;
"test")
[ ${TEST_ONE_perf_nok} -eq 0 ] || TEST_ONE_nok=1
[ ${TEST_ONE_nok} -eq 1 ] && status_test_fail
diff --git a/test/passt/tcp b/test/passt/tcp
index d5c8164..7af9c54 100644
--- a/test/passt/tcp
+++ b/test/passt/tcp
@@ -15,7 +15,7 @@ gtools socat ip jq md5sum cut
htools dd socat ip jq md5sum cut
test TCP/IPv4: host to guest: big transfer
-temp TEMP_BIG
+set TEMP_BIG __STATEDIR__/big
guestb socat -u TCP4-LISTEN:10001,reuseaddr OPEN:test_big.bin,create,trunc
sleep 1
host dd if=/dev/urandom bs=1M count=10 > __TEMP_BIG__
@@ -34,7 +34,7 @@ hout HOST_MD5_BIG md5sum __TEMP_BIG__ | cut -d' ' -f1
check [ "__GUEST_MD5_BIG__" = "__HOST_MD5_BIG__" ]
test TCP/IPv4: host to guest: small transfer
-temp TEMP_SMALL
+set TEMP_SMALL __STATEDIR__/small
guestb socat -u TCP4-LISTEN:10001,reuseaddr OPEN:test_small.bin,create,trunc
sleep 1
host dd if=/dev/urandom bs=2k count=1 > __TEMP_SMALL__
diff --git a/test/passt/udp b/test/passt/udp
index 56d01b3..0253a86 100644
--- a/test/passt/udp
+++ b/test/passt/udp
@@ -15,9 +15,9 @@ gtools socat tee grep cat ip jq md5sum cut
htools printf dd socat tee grep cat ip jq md5sum cut
test UDP/IPv4: host to guest
-temp TEMP
-temp SC_PID
-guestb (socat -u UDP4-LISTEN:10001 STDOUT & echo $! > __SC_PID__) | tee test.bin | (grep -qm1 "END_OF_TEST" && kill $(cat __SC_PID__))
+set TEMP __STATEDIR__/data
+set SC_PID __STATEDIR__/socat.pid
+guestb (socat -u UDP4-LISTEN:10001 STDOUT & echo $! > sc.pid) | tee test.bin | (grep -qm1 "END_OF_TEST" && kill $(cat sc.pid))
sleep 1
host dd if=/dev/urandom bs=1k count=5 > __TEMP__ && printf "\nEND_OF_TEST\n" >> __TEMP__
host socat -u OPEN:__TEMP__ UDP4:127.0.0.1:10001
diff --git a/test/passt_in_ns/tcp b/test/passt_in_ns/tcp
index 5ec95e8..a2cb667 100644
--- a/test/passt_in_ns/tcp
+++ b/test/passt_in_ns/tcp
@@ -16,7 +16,7 @@ htools dd socat ip jq md5sum cut
nstools socat ip jq md5sum cut
test TCP/IPv4: host to guest: big transfer
-temp TEMP_BIG
+set TEMP_BIG __STATEDIR__/big.img
guestb socat -u TCP4-LISTEN:10001 OPEN:test_big.bin,create,trunc
sleep 1
host dd if=/dev/urandom bs=1M count=10 of=__TEMP_BIG__
@@ -27,7 +27,7 @@ gout GUEST_MD5_BIG md5sum test_big.bin | cut -d' ' -f1
check [ "__GUEST_MD5_BIG__" = "__MD5_BIG__" ]
test TCP/IPv4: host to ns: big transfer
-temp TEMP_NS_BIG
+set TEMP_NS_BIG __STATEDIR__/big_ns.img
nsb socat -u TCP4-LISTEN:10002 OPEN:__TEMP_NS_BIG__,create,trunc
host socat -u OPEN:__TEMP_BIG__ TCP4:127.0.0.1:10002
nsw
@@ -82,7 +82,7 @@ gout GUEST_MD5_BIG md5sum test_big.bin | cut -d' ' -f1
check [ "__GUEST_MD5_BIG__" = "__MD5_BIG__" ]
test TCP/IPv4: host to guest: small transfer
-temp TEMP_SMALL
+set TEMP_SMALL __STATEDIR__/small.img
guestb socat -u TCP4-LISTEN:10001 OPEN:test_small.bin,create,trunc
sleep 1
host dd if=/dev/urandom bs=2k count=100 of=__TEMP_SMALL__
@@ -93,7 +93,7 @@ gout GUEST_MD5_SMALL md5sum test_small.bin | cut -d' ' -f1
check [ "__GUEST_MD5_SMALL__" = "__MD5_SMALL__" ]
test TCP/IPv4: host to ns: small transfer
-temp TEMP_NS_SMALL
+set TEMP_NS_SMALL __STATEDIR__/small_ns.img
nsb socat -u TCP4-LISTEN:10002 OPEN:__TEMP_NS_SMALL__,create,trunc
host socat -u OPEN:__TEMP_SMALL__ TCP4:127.0.0.1:10002
nsw
diff --git a/test/passt_in_ns/udp b/test/passt_in_ns/udp
index c22a68f..3b1e521 100644
--- a/test/passt_in_ns/udp
+++ b/test/passt_in_ns/udp
@@ -16,8 +16,8 @@ nstools socat tee grep cat ip jq md5sum cut
htools printf dd socat tee grep cat ip jq md5sum cut
test UDP/IPv4: host to guest
-temp TEMP
-temp SC_PID
+set TEMP __STATEDIR__/data
+set SC_PID __STATEDIR__/socat.pid
guestb (socat -u UDP4-LISTEN:10001 STDOUT & echo $! > sc.pid) | tee test.bin | (grep -qm1 "END_OF_TEST" && kill $(cat sc.pid))
sleep 1
host dd if=/dev/urandom bs=1k count=5 > __TEMP__ && printf "\nEND_OF_TEST\n" >> __TEMP__
@@ -28,7 +28,7 @@ gout GUEST_MD5 md5sum test.bin | cut -d' ' -f1
check [ "__GUEST_MD5__" = "__MD5__" ]
test UDP/IPv4: host to ns
-temp TEMP_NS
+set TEMP_NS __STATEDIR__/data_ns
nsb (socat -u UDP4-LISTEN:10002 STDOUT & echo $! > __SC_PID__) | tee __TEMP_NS__ | (grep -qm1 "END_OF_TEST" && kill $(cat __SC_PID__))
host socat -u OPEN:__TEMP__ UDP4:127.0.0.1:10002
nsw
diff --git a/test/pasta/tcp b/test/pasta/tcp
index 5497f11..d37e21c 100644
--- a/test/pasta/tcp
+++ b/test/pasta/tcp
@@ -15,8 +15,8 @@ htools dd socat ip jq md5sum cut
nstools socat ip jq md5sum cut
test TCP/IPv4: host to ns: big transfer
-temp TEMP_BIG
-temp TEMP_NS_BIG
+set TEMP_BIG __STATEDIR__/big
+set TEMP_NS_BIG __STATEDIR__/big_ns
nsb socat -u TCP4-LISTEN:10002,bind=127.0.0.1 OPEN:__TEMP_NS_BIG__,create,trunc
host dd if=/dev/urandom bs=1M count=10 of=__TEMP_BIG__
host socat -u OPEN:__TEMP_BIG__ TCP4:127.0.0.1:10002
@@ -41,8 +41,8 @@ hout HOST_MD5_BIG md5sum __TEMP_BIG__ | cut -d' ' -f1
check [ "__HOST_MD5_BIG__" = "__MD5_BIG__" ]
test TCP/IPv4: host to ns: small transfer
-temp TEMP_SMALL
-temp TEMP_NS_SMALL
+set TEMP_SMALL __STATEDIR__/small
+set TEMP_NS_SMALL __STATEDIR__/small_ns
nsb socat -u TCP4-LISTEN:10002,bind=127.0.0.1 OPEN:__TEMP_NS_SMALL__,create,trunc
host dd if=/dev/urandom bs=2k count=1 of=__TEMP_SMALL__
host socat OPEN:__TEMP_SMALL__ TCP4:127.0.0.1:10002
diff --git a/test/pasta/udp b/test/pasta/udp
index 0e58152..74148e3 100644
--- a/test/pasta/udp
+++ b/test/pasta/udp
@@ -15,10 +15,10 @@ nstools socat tee grep cat ip jq md5sum cut
htools printf dd socat tee grep cat ip jq md5sum cut
test UDP/IPv4: host to ns
-temp TEMP
-temp TEMP_NS
-temp NC_PID
-nsb (socat -u UDP4-LISTEN:10002,bind=127.0.0.1 STDOUT & echo $! > __NC_PID__) | tee __TEMP_NS__ | (grep -qm1 "END_OF_TEST" && kill $(cat __NC_PID__))
+set TEMP __STATEDIR__/data
+set TEMP_NS __STATEDIR__/data_ns
+set SC_PID __STATEDIR__/socat.pid
+nsb (socat -u UDP4-LISTEN:10002,bind=127.0.0.1 STDOUT & echo $! > __SC_PID__) | tee __TEMP_NS__ | (grep -qm1 "END_OF_TEST" && kill $(cat __SC_PID__))
host dd if=/dev/urandom bs=1k count=5 > __TEMP__ && printf "\nEND_OF_TEST\n" >> __TEMP__
host socat OPEN:__TEMP__ UDP4:127.0.0.1:10002
@@ -28,7 +28,7 @@ nsout NS_MD5 md5sum __TEMP_NS__ | cut -d' ' -f1
check [ "__NS_MD5__" = "__MD5__" ]
test UDP/IPv4: ns to host (recvmmsg/sendmmsg)
-hostb (socat -u UDP4-LISTEN:10003,bind=127.0.0.1 STDOUT & echo $! > __NC_PID__) | tee __TEMP__ | (grep -qm1 "END_OF_TEST" && kill $(cat __NC_PID__))
+hostb (socat -u UDP4-LISTEN:10003,bind=127.0.0.1 STDOUT & echo $! > __SC_PID__) | tee __TEMP__ | (grep -qm1 "END_OF_TEST" && kill $(cat __SC_PID__))
sleep 1
ns socat OPEN:__TEMP_NS__ UDP4:127.0.0.1:10003
hostw
@@ -36,7 +36,7 @@ hout HOST_MD5 md5sum __TEMP__ | cut -d' ' -f1
check [ "__HOST_MD5__" = "__MD5__" ]
test UDP/IPv4: ns to host (via tap)
-hostb (socat -u UDP4-LISTEN:10003 STDOUT & echo $! > __NC_PID__) | tee __TEMP__ | (grep -qm1 "END_OF_TEST" && kill $(cat __NC_PID__))
+hostb (socat -u UDP4-LISTEN:10003 STDOUT & echo $! > __SC_PID__) | tee __TEMP__ | (grep -qm1 "END_OF_TEST" && kill $(cat __SC_PID__))
nsout GW ip -j -4 route show|jq -rM '.[] | select(.dst == "default").gateway'
ns socat -u OPEN:__TEMP_NS__ UDP4:__GW__:10003
hostw
@@ -44,7 +44,7 @@ hout HOST_MD5 md5sum __TEMP__ | cut -d' ' -f1
check [ "__HOST_MD5__" = "__MD5__" ]
test UDP/IPv6: host to ns
-nsb (socat -u UDP6-LISTEN:10002,bind=[::1] STDOUT & echo $! > __NC_PID__) | tee __TEMP_NS__ | (grep -qm1 "END_OF_TEST" && kill $(cat __NC_PID__))
+nsb (socat -u UDP6-LISTEN:10002,bind=[::1] STDOUT & echo $! > __SC_PID__) | tee __TEMP_NS__ | (grep -qm1 "END_OF_TEST" && kill $(cat __SC_PID__))
host socat -u OPEN:__TEMP__ UDP6:[::1]:10002
nsw
hout MD5 md5sum __TEMP__ | cut -d' ' -f1
@@ -52,7 +52,7 @@ nsout NS_MD5 md5sum __TEMP_NS__ | cut -d' ' -f1
check [ "__NS_MD5__" = "__MD5__" ]
test UDP/IPv6: ns to host (recvmmsg/sendmmsg)
-hostb (socat -u UDP6-LISTEN:10003,bind=[::1] STDOUT & echo $! > __NC_PID__) | tee __TEMP__ | (grep -qm1 "END_OF_TEST" && kill $(cat __NC_PID__))
+hostb (socat -u UDP6-LISTEN:10003,bind=[::1] STDOUT & echo $! > __SC_PID__) | tee __TEMP__ | (grep -qm1 "END_OF_TEST" && kill $(cat __SC_PID__))
sleep 1
ns socat -u OPEN:__TEMP_NS__ UDP6:[::1]:10003
hostw
@@ -60,7 +60,7 @@ hout HOST_MD5 md5sum __TEMP__ | cut -d' ' -f1
check [ "__HOST_MD5__" = "__MD5__" ]
test UDP/IPv6: ns to host (via tap)
-hostb (socat -u UDP6-LISTEN:10003 STDOUT & echo $! > __NC_PID__) | tee __TEMP__ | (grep -qm1 "END_OF_TEST" && kill $(cat __NC_PID__))
+hostb (socat -u UDP6-LISTEN:10003 STDOUT & echo $! > __SC_PID__) | tee __TEMP__ | (grep -qm1 "END_OF_TEST" && kill $(cat __SC_PID__))
nsout GW6 ip -j -6 route show|jq -rM '.[] | select(.dst == "default").gateway'
nsout IFNAME ip -j link show | jq -rM '.[] | select(.link_type == "ether").ifname'
ns socat -u OPEN:__TEMP_NS__ UDP6:[__GW6__%__IFNAME__]:10003
--
@@ -15,10 +15,10 @@ nstools socat tee grep cat ip jq md5sum cut
htools printf dd socat tee grep cat ip jq md5sum cut
test UDP/IPv4: host to ns
-temp TEMP
-temp TEMP_NS
-temp NC_PID
-nsb (socat -u UDP4-LISTEN:10002,bind=127.0.0.1 STDOUT & echo $! > __NC_PID__) | tee __TEMP_NS__ | (grep -qm1 "END_OF_TEST" && kill $(cat __NC_PID__))
+set TEMP __STATEDIR__/data
+set TEMP_NS __STATEDIR__/data_ns
+set SC_PID __STATEDIR__/socat.pid
+nsb (socat -u UDP4-LISTEN:10002,bind=127.0.0.1 STDOUT & echo $! > __SC_PID__) | tee __TEMP_NS__ | (grep -qm1 "END_OF_TEST" && kill $(cat __SC_PID__))
host dd if=/dev/urandom bs=1k count=5 > __TEMP__ && printf "\nEND_OF_TEST\n" >> __TEMP__
host socat OPEN:__TEMP__ UDP4:127.0.0.1:10002
@@ -28,7 +28,7 @@ nsout NS_MD5 md5sum __TEMP_NS__ | cut -d' ' -f1
check [ "__NS_MD5__" = "__MD5__" ]
test UDP/IPv4: ns to host (recvmmsg/sendmmsg)
-hostb (socat -u UDP4-LISTEN:10003,bind=127.0.0.1 STDOUT & echo $! > __NC_PID__) | tee __TEMP__ | (grep -qm1 "END_OF_TEST" && kill $(cat __NC_PID__))
+hostb (socat -u UDP4-LISTEN:10003,bind=127.0.0.1 STDOUT & echo $! > __SC_PID__) | tee __TEMP__ | (grep -qm1 "END_OF_TEST" && kill $(cat __SC_PID__))
sleep 1
ns socat OPEN:__TEMP_NS__ UDP4:127.0.0.1:10003
hostw
@@ -36,7 +36,7 @@ hout HOST_MD5 md5sum __TEMP__ | cut -d' ' -f1
check [ "__HOST_MD5__" = "__MD5__" ]
test UDP/IPv4: ns to host (via tap)
-hostb (socat -u UDP4-LISTEN:10003 STDOUT & echo $! > __NC_PID__) | tee __TEMP__ | (grep -qm1 "END_OF_TEST" && kill $(cat __NC_PID__))
+hostb (socat -u UDP4-LISTEN:10003 STDOUT & echo $! > __SC_PID__) | tee __TEMP__ | (grep -qm1 "END_OF_TEST" && kill $(cat __SC_PID__))
nsout GW ip -j -4 route show|jq -rM '.[] | select(.dst == "default").gateway'
ns socat -u OPEN:__TEMP_NS__ UDP4:__GW__:10003
hostw
@@ -44,7 +44,7 @@ hout HOST_MD5 md5sum __TEMP__ | cut -d' ' -f1
check [ "__HOST_MD5__" = "__MD5__" ]
test UDP/IPv6: host to ns
-nsb (socat -u UDP6-LISTEN:10002,bind=[::1] STDOUT & echo $! > __NC_PID__) | tee __TEMP_NS__ | (grep -qm1 "END_OF_TEST" && kill $(cat __NC_PID__))
+nsb (socat -u UDP6-LISTEN:10002,bind=[::1] STDOUT & echo $! > __SC_PID__) | tee __TEMP_NS__ | (grep -qm1 "END_OF_TEST" && kill $(cat __SC_PID__))
host socat -u OPEN:__TEMP__ UDP6:[::1]:10002
nsw
hout MD5 md5sum __TEMP__ | cut -d' ' -f1
@@ -52,7 +52,7 @@ nsout NS_MD5 md5sum __TEMP_NS__ | cut -d' ' -f1
check [ "__NS_MD5__" = "__MD5__" ]
test UDP/IPv6: ns to host (recvmmsg/sendmmsg)
-hostb (socat -u UDP6-LISTEN:10003,bind=[::1] STDOUT & echo $! > __NC_PID__) | tee __TEMP__ | (grep -qm1 "END_OF_TEST" && kill $(cat __NC_PID__))
+hostb (socat -u UDP6-LISTEN:10003,bind=[::1] STDOUT & echo $! > __SC_PID__) | tee __TEMP__ | (grep -qm1 "END_OF_TEST" && kill $(cat __SC_PID__))
sleep 1
ns socat -u OPEN:__TEMP_NS__ UDP6:[::1]:10003
hostw
@@ -60,7 +60,7 @@ hout HOST_MD5 md5sum __TEMP__ | cut -d' ' -f1
check [ "__HOST_MD5__" = "__MD5__" ]
test UDP/IPv6: ns to host (via tap)
-hostb (socat -u UDP6-LISTEN:10003 STDOUT & echo $! > __NC_PID__) | tee __TEMP__ | (grep -qm1 "END_OF_TEST" && kill $(cat __NC_PID__))
+hostb (socat -u UDP6-LISTEN:10003 STDOUT & echo $! > __SC_PID__) | tee __TEMP__ | (grep -qm1 "END_OF_TEST" && kill $(cat __SC_PID__))
nsout GW6 ip -j -6 route show|jq -rM '.[] | select(.dst == "default").gateway'
nsout IFNAME ip -j link show | jq -rM '.[] | select(.link_type == "ether").ifname'
ns socat -u OPEN:__TEMP_NS__ UDP6:[__GW6__%__IFNAME__]:10003
--
2.37.3
next prev parent reply other threads:[~2022-09-07 13:03 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-07 13:02 [PATCH 00/12] Improve handling of test temporary files David Gibson
2022-09-07 13:02 ` [PATCH 01/12] test: Group tests by context then protocol, rather than the reverse David Gibson
2022-09-07 13:02 ` [PATCH 02/12] test: Remove stale comments from context_setup_guest() David Gibson
2022-09-07 13:02 ` [PATCH 03/12] test: Remove unused variable FFMPEG_PID_FILE David Gibson
2022-09-07 13:02 ` [PATCH 04/12] test: Actually run cleanup function David Gibson
2022-09-07 13:03 ` [PATCH 05/12] test: Create common state directories for temporary files David Gibson
2022-09-07 13:03 ` [PATCH 06/12] test: Move passt_test_log_pipe to state directory David Gibson
2022-09-07 13:03 ` [PATCH 07/12] test: Move context temporary files to state dir David Gibson
2022-09-07 13:03 ` [PATCH 08/12] test: Dont regnerate small test file in pasta/tcp David Gibson
2022-09-07 13:03 ` David Gibson [this message]
2022-09-07 13:03 ` [PATCH 10/12] test: Move pause temporary file to state directory David Gibson
2022-09-07 13:03 ` [PATCH 11/12] test: Store pcap files in $LOGDIR instead of /tmp David Gibson
2022-09-07 13:03 ` [PATCH 12/12] test: Move pidfiles and nsholder sockets into state directory David Gibson
2022-09-08 2:59 ` [PATCH 00/12] Improve handling of test temporary files 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=20220907130307.1166467-10-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).