aboutgitcodebugslistschat
path: root/test/distro/ubuntu
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2022-08-18 16:13:49 +1000
committerStefano Brivio <sbrivio@redhat.com>2022-08-20 19:07:12 +0200
commita8598c7e70df60e1193993ac6b7c4c729518c7aa (patch)
treeea7bc8ae3176d6edb5cb479d6ab355f39ef0f513 /test/distro/ubuntu
parent662407de0fae6335bbaff935a5d7969853e547a0 (diff)
downloadpasst-a8598c7e70df60e1193993ac6b7c4c729518c7aa.tar
passt-a8598c7e70df60e1193993ac6b7c4c729518c7aa.tar.gz
passt-a8598c7e70df60e1193993ac6b7c4c729518c7aa.tar.bz2
passt-a8598c7e70df60e1193993ac6b7c4c729518c7aa.tar.lz
passt-a8598c7e70df60e1193993ac6b7c4c729518c7aa.tar.xz
passt-a8598c7e70df60e1193993ac6b7c4c729518c7aa.tar.zst
passt-a8598c7e70df60e1193993ac6b7c4c729518c7aa.zip
test: Convert distro tests to use socat instead of nc/ncat
We've recently converted most of our tests to use socat instead of nc/netcat/ncat, because socat is more powerful and we don't need to deal with the several possible variants of netcat. We still use nc or ncat for the distro tests. Because there we control the guest environment and can pick our tools, there isn't the same reason to switch to socat. However, using socat here as well makes the tests a bit easier to read, and doesn't require people reading or modifying them to become familiar with an additional tool. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> [sbrivio: keep using netcat-openbsd in Ubuntu 16.04 ppc64 test, as socat is unavailable there] Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'test/distro/ubuntu')
-rw-r--r--test/distro/ubuntu32
1 files changed, 27 insertions, 5 deletions
diff --git a/test/distro/ubuntu b/test/distro/ubuntu
index ec6c819..6666f38 100644
--- a/test/distro/ubuntu
+++ b/test/distro/ubuntu
@@ -16,6 +16,26 @@ htools qemu-img virt-edit guestfish cat kill qemu-system-x86_64 qemu-system-ppc6
# Quick pasta test: send message from init to ns, and from ns to init
def distro_quick_pasta_test
+host (socat -u TCP6-LISTEN:10000 OPEN:/tmp/init_msg,create,trunc; echo "from_init" | socat -u STDIN TCP6:[::1]:9999) &
+hostb ./pasta
+sleep 1
+host PS1='$ '
+host socat -u TCP6-LISTEN:9999 OPEN:/tmp/ns_msg,create,trunc &
+sleep 2
+host echo "from_ns" | socat -u STDIN TCP6:[::1]:10000
+sleep 2
+host echo
+sleep 1
+hout NS_MSG cat /tmp/ns_msg
+check [ __NS_MSG__ = "from_init" ]
+hostb exit
+host echo
+hout INIT_MSG cat /tmp/init_msg
+check [ __INIT_MSG__ = "from_ns" ]
+endef
+
+# Quick pasta test: netcat-openbsd version for Ubuntu 16.04 ppc64
+def distro_quick_pasta_test_netcat
host (nc -w1 -6 -l -p 10000 > /tmp/init_msg; echo "from_init" | nc -q0 ::1 9999) &
hostb ./pasta
sleep 1
@@ -59,7 +79,7 @@ host ./qrap 5 qemu-system-x86_64 -M pc,accel=kvm:tcg -m 1024 -nographic -serial
host PS1='$ '
sleep 2
host apt-get update
-host apt-get -y install make gcc netcat-openbsd
+host apt-get -y install make gcc socat
host make clean
host CFLAGS="-Wno-missing-field-initializers -Wno-missing-braces -Wno-type-limits" make
@@ -92,7 +112,7 @@ host ./qrap 5 qemu-system-x86_64 -M pc,accel=kvm:tcg -m 1024 -nographic -serial
host PS1='$ '
sleep 2
host apt-get update
-host apt-get -y install make gcc netcat-openbsd
+host apt-get -y install make gcc socat
host make clean
host CFLAGS="-Wno-missing-field-initializers -Wno-missing-braces -Wno-type-limits -Wno-sign-compare" make
@@ -122,7 +142,7 @@ host ./qrap 5 qemu-system-ppc64 -m 2048 -smp 2 -nographic -serial stdio -nodefau
host PS1='$ '
sleep 2
host apt-get update
-host apt-get -y install make gcc netcat-openbsd
+host apt-get -y install make gcc socat
host make clean
host CFLAGS="-Wno-missing-field-initializers -Wno-missing-braces -Wno-type-limits -Wno-sign-compare" make
@@ -145,12 +165,14 @@ host dhclient -4
# Skip apt-get update here: some updates to xenial-updates around 2022-01-30
# broke dependencies for libc6 and gcc-5 -- note that powerpc is not officially
# supported on this version
+
+# socat not available: install netcat-openbsd and run the test with it
host apt-get -y install make gcc netcat-openbsd
host make clean
host CFLAGS="-Werror" make
-distro_quick_pasta_test
+distro_quick_pasta_test_netcat
hint
sleep 1
@@ -169,7 +191,7 @@ host apt-get -y remove needrestart snapd
host dhclient -4
sleep 2
host apt-get update
-host apt-get -y install make gcc netcat-openbsd
+host apt-get -y install make gcc socat
host make clean
host CFLAGS="-Werror" make