From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Gibson 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 Message-ID: <20220907130307.1166467-10-david@gibson.dropbear.id.au> In-Reply-To: <20220907130307.1166467-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============5874127377116768371==" --===============5874127377116768371== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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 --- 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 ] =20 -tempdir TEMP - test Install -host prefix=3D__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=3D__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 =20 test Uninstall -host prefix=3D__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=3D__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 =20 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 =20 @@ -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 =20 nl @@ -69,7 +68,7 @@ nl say 'pasta' demo above. sleep 3 =20 -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 =20 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 =20 @@ -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 =20 @@ -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=09 passt /sbin/dhclient -4 --no-pid sleep 2 -hostb tshark -r __TEMP__.pcap +hostb tshark -r __STATEDIR__/demo_pasta.pcap sleep 5 =20 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 =20 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 =20 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 =20 say , patch it sleep 1 -host cp ../contrib/podman/0001-libpod-Add-pasta-networking-mode.patch __TEMP= DIR__/podman -host cd __TEMPDIR__/podman +host cp ../contrib/podman/0001-libpod-Add-pasta-networking-mode.patch __STAT= EDIR__/podman +host cd __STATEDIR__/podman host git am -3 0001-libpod-Add-pasta-networking-mode.patch sleep 1 =20 @@ -54,7 +53,7 @@ nl say Let's start a container with it sleep 1 =20 -ns1 cd __TEMPDIR__/podman +ns1 cd __STATEDIR__/podman ns1b ./bin/podman run --rm -ti alpine sh sleep 2 =20 @@ -64,7 +63,7 @@ say and one with em pasta say instead. =20 -ns2 cd __TEMPDIR__/podman +ns2 cd __STATEDIR__/podman ns2b ./bin/podman run --net=3Dpasta --rm -ti alpine sh sleep 2 =20 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 =20 -temp PIDFILE +set PIDFILE __STATEDIR__/passt.pid htools cat kill qemu-system-x86_64 qemu-system-aarch64 qemu-system-ppc64 =20 # 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 =20 -temp PIDFILE +set PIDFILE __STATEDIR__/passt.pid htools cat kill qemu-system-x86_64 =20 # 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 =20 -temp PIDFILE +set PIDFILE __STATEDIR__/passt.pid htools qemu-img virt-edit guestfish head sed cat kill qemu-system-x86_64 qem= u-system-aarch64 xzcat tr =20 # 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' =20 test OpenSUSE Leap 15.1 =20 -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-Je= OS.x86_64-kvm-and-xen.qcow2 __IMG__ host guestfish --rw -a __IMG__ -i rm '/usr/lib/systemd/system/systemd-journa= ld.service' host guestfish --rw -a __IMG__ -i rm /etc/systemd/system/default.target.want= s/jeos-firstboot.service @@ -73,6 +73,7 @@ hout PID cat __PIDFILE__ =20 test OpenSUSE Leap 15.2 =20 +set IMG __STATEDIR__/opensuse-15.2-x86_64.img host qemu-img create -f qcow2 -F qcow2 -b __BASEPATH__/openSUSE-Leap-15.2-Je= OS.x86_64-kvm-and-xen.qcow2 __IMG__ host guestfish --rw -a __IMG__ -i rm '/usr/lib/systemd/system/systemd-journa= ld.service' host guestfish --rw -a __IMG__ -i rm /etc/systemd/system/default.target.want= s/jeos-firstboot.service @@ -98,6 +99,7 @@ sleep 1 =20 test OpenSUSE Leap 15.3 =20 +set IMG __STATEDIR__/opensuse-15.3-x86_64.img host qemu-img create -f qcow2 -F qcow2 -b __BASEPATH__/openSUSE-Leap-15.3-Je= OS.x86_64-kvm-and-xen.qcow2 __IMG__ host guestfish --rw -a __IMG__ -i rm '/usr/lib/systemd/system/systemd-journa= ld.service' host guestfish --rw -a __IMG__ -i rm /etc/systemd/system/default.target.want= s/jeos-firstboot.service @@ -125,7 +127,7 @@ sleep 1 =20 test OpenSUSE Tumbleweed aarch64 =20 -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=3D.*/ExecStart=3D\/sbin\/agetty --timeout 5000 --a= utologin 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 =20 test OpenSUSE Tumbleweed armv7l =20 -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 > __I= MG__ host guestfish -a __IMG__ -i download /boot/zImage __ZIMAGE__ host guestfish -a __IMG__ -i download /boot/initrd __INITRD__ @@ -178,7 +180,7 @@ sleep 1 =20 test OpenSUSE Tumbleweed =20 -temp IMG +set IMG __STATEDIR__/opensuse-tumbleweed-x86_64.img host qemu-img create -f qcow2 -F qcow2 -b __BASEPATH__/openSUSE-Tumbleweed-J= eOS.x86_64-kvm-and-xen.qcow2 __IMG__ host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/systemd-journal= d.service host guestfish --rw -a __IMG__ -i rm /etc/systemd/system/default.target.want= s/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 =20 -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 =20 # 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' =20 test Ubuntu 14.04.5 LTS (Trusty Tahr), amd64 =20 -temp IMG +set IMG __STATEDIR__/ubuntu-14.04-amd64.img host qemu-img create -f qcow2 -F qcow2 -b __BASEPATH__/trusty-server-cloudim= g-amd64-disk1.img __IMG__ host virt-edit -a __IMG__ /etc/init/ttyS0.conf -e 's/\/getty/\/getty --autol= ogin root/' host guestfish --rw -a __IMG__ -i rm /etc/init/cloud-config.conf @@ -96,7 +96,7 @@ hout PID cat __PIDFILE__ =20 test Ubuntu 14.04.5 LTS (Trusty Tahr), i386 =20 -temp IMG +set IMG __STATEDIR__/ubuntu-14.04-i386.img host qemu-img create -f qcow2 -F qcow2 -b __BASEPATH__/trusty-server-cloudim= g-i386-disk1.img __IMG__ host virt-edit -a __IMG__ /etc/init/ttyS0.conf -e 's/\/getty/\/getty --autol= ogin root/' host guestfish --rw -a __IMG__ -i rm /etc/init/cloud-config.conf @@ -126,7 +126,7 @@ sleep 1 =20 test Ubuntu 14.04.5 LTS (Trusty Tahr), ppc64le =20 -temp IMG +set IMG __STATEDIR__/ubuntu-14.04-ppc64le.img host qemu-img create -f qcow2 -F qcow2 -b __BASEPATH__/trusty-server-cloudim= g-ppc64el-disk1.img __IMG__ host virt-edit -a __IMG__ /etc/init/hvc0.conf -e 's/\/getty/\/getty --autolo= gin 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=3D eval TEST_ONE_DEF_$TEST_ONE_in_def=3D IFS=3D"${__ifs}" ;; - "tempdir") - __tmpdir=3D"$(mktemp -d)" - TEST_ONE_subs=3D"$(list_add_pair "${TEST_ONE_subs}" "__${__arg}__" "${__tm= pdir}")" - TEST_ONE_dirclean=3D"$(list_add "${TEST_ONE_dirclean}" "${__tmpdir}")" - ;; - "temp") - __tmpfile=3D"$(mktemp)" - TEST_ONE_subs=3D"$(list_add_pair "${TEST_ONE_subs}" "__${__arg}__" "${__tm= pfile}")" - TEST_ONE_dirclean=3D"$(list_add "${TEST_ONE_dirclean}" "${__tmpfile}")" - ;; "test") [ ${TEST_ONE_perf_nok} -eq 0 ] || TEST_ONE_nok=3D1 [ ${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 =20 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=3D/dev/urandom bs=3D1M count=3D10 > __TEMP_BIG__ @@ -34,7 +34,7 @@ hout HOST_MD5_BIG md5sum __TEMP_BIG__ | cut -d' ' -f1 check [ "__GUEST_MD5_BIG__" =3D "__HOST_MD5_BIG__" ] =20 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=3D/dev/urandom bs=3D2k count=3D1 > __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 =20 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=3D/dev/urandom bs=3D1k count=3D5 > __TEMP__ && printf "\nEND_OF_T= EST\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 =20 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=3D/dev/urandom bs=3D1M count=3D10 of=3D__TEMP_BIG__ @@ -27,7 +27,7 @@ gout GUEST_MD5_BIG md5sum test_big.bin | cut -d' ' -f1 check [ "__GUEST_MD5_BIG__" =3D "__MD5_BIG__" ] =20 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__" =3D "__MD5_BIG__" ] =20 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=3D/dev/urandom bs=3D2k count=3D100 of=3D__TEMP_SMALL__ @@ -93,7 +93,7 @@ gout GUEST_MD5_SMALL md5sum test_small.bin | cut -d' ' -f1 check [ "__GUEST_MD5_SMALL__" =3D "__MD5_SMALL__" ] =20 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 =20 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=3D/dev/urandom bs=3D1k count=3D5 > __TEMP__ && printf "\nEND_OF_T= EST\n" >> __TEMP__ @@ -28,7 +28,7 @@ gout GUEST_MD5 md5sum test.bin | cut -d' ' -f1 check [ "__GUEST_MD5__" =3D "__MD5__" ] =20 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 =20 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=3D127.0.0.1 OPEN:__TEMP_NS_BIG__,create,= trunc host dd if=3D/dev/urandom bs=3D1M count=3D10 of=3D__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__" =3D "__MD5_BIG__" ] =20 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=3D127.0.0.1 OPEN:__TEMP_NS_SMALL__,creat= e,trunc host dd if=3D/dev/urandom bs=3D2k count=3D1 of=3D__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 =20 test UDP/IPv4: host to ns -temp TEMP -temp TEMP_NS -temp NC_PID -nsb (socat -u UDP4-LISTEN:10002,bind=3D127.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=3D127.0.0.1 STDOUT & echo $! > __SC_PID= __) | tee __TEMP_NS__ | (grep -qm1 "END_OF_TEST" && kill $(cat __SC_PID__)) host dd if=3D/dev/urandom bs=3D1k count=3D5 > __TEMP__ && printf "\nEND_OF_T= EST\n" >> __TEMP__ =20 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__" =3D "__MD5__" ] =20 test UDP/IPv4: ns to host (recvmmsg/sendmmsg) -hostb (socat -u UDP4-LISTEN:10003,bind=3D127.0.0.1 STDOUT & echo $! > __NC_P= ID__) | tee __TEMP__ | (grep -qm1 "END_OF_TEST" && kill $(cat __NC_PID__)) +hostb (socat -u UDP4-LISTEN:10003,bind=3D127.0.0.1 STDOUT & echo $! > __SC_P= ID__) | 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__" =3D "__MD5__" ] =20 test UDP/IPv4: ns to host (via tap) -hostb (socat -u UDP4-LISTEN:10003 STDOUT & echo $! > __NC_PID__) | tee __TEM= P__ | (grep -qm1 "END_OF_TEST" && kill $(cat __NC_PID__)) +hostb (socat -u UDP4-LISTEN:10003 STDOUT & echo $! > __SC_PID__) | tee __TEM= P__ | (grep -qm1 "END_OF_TEST" && kill $(cat __SC_PID__)) nsout GW ip -j -4 route show|jq -rM '.[] | select(.dst =3D=3D "default").gat= eway' 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__" =3D "__MD5__" ] =20 test UDP/IPv6: host to ns -nsb (socat -u UDP6-LISTEN:10002,bind=3D[::1] STDOUT & echo $! > __NC_PID__) = | tee __TEMP_NS__ | (grep -qm1 "END_OF_TEST" && kill $(cat __NC_PID__)) +nsb (socat -u UDP6-LISTEN:10002,bind=3D[::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__" =3D "__MD5__" ] =20 test UDP/IPv6: ns to host (recvmmsg/sendmmsg) -hostb (socat -u UDP6-LISTEN:10003,bind=3D[::1] STDOUT & echo $! > __NC_PID__= ) | tee __TEMP__ | (grep -qm1 "END_OF_TEST" && kill $(cat __NC_PID__)) +hostb (socat -u UDP6-LISTEN:10003,bind=3D[::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__" =3D "__MD5__" ] =20 test UDP/IPv6: ns to host (via tap) -hostb (socat -u UDP6-LISTEN:10003 STDOUT & echo $! > __NC_PID__) | tee __TEM= P__ | (grep -qm1 "END_OF_TEST" && kill $(cat __NC_PID__)) +hostb (socat -u UDP6-LISTEN:10003 STDOUT & echo $! > __SC_PID__) | tee __TEM= P__ | (grep -qm1 "END_OF_TEST" && kill $(cat __SC_PID__)) nsout GW6 ip -j -6 route show|jq -rM '.[] | select(.dst =3D=3D "default").ga= teway' nsout IFNAME ip -j link show | jq -rM '.[] | select(.link_type =3D=3D "ether= ").ifname' ns socat -u OPEN:__TEMP_NS__ UDP6:[__GW6__%__IFNAME__]:10003 --=20 2.37.3 --===============5874127377116768371==--