This series adds tests for a mix of old and new Debian, Fedora, OpenSUSE and Ubuntu versions, on on aarch64, i386, ppc64, ppc64le, s390x, x86_64, plus prerequisites for these tests and some basic documentation about the testing framework itself. Stefano Brivio (4): test/lib/term: Allow for a wider variety of prompt characters in pane_wait() test/lib/test: Introduce 'def' directive for frequently used patterns test: Add distribution tests for several architectures and kernel versions test: Add basic documentation about test suite, and cool-retro-term profile README.md | 4 +- test/README.md | 104 ++++++++ test/distro/debian | 343 ++++++++++++++++++++++++++ test/distro/fedora | 563 +++++++++++++++++++++++++++++++++++++++++++ test/distro/opensuse | 182 ++++++++++++++ test/distro/ubuntu | 208 ++++++++++++++++ test/lib/term | 17 +- test/lib/test | 496 ++++++++++++++++++++------------------ test/run | 1 + 9 files changed, 1680 insertions(+), 238 deletions(-) create mode 100644 test/README.md create mode 100644 test/distro/debian create mode 100644 test/distro/fedora create mode 100644 test/distro/opensuse create mode 100644 test/distro/ubuntu -- 2.33.0
We might have highlighting and slightly different prompts across different distributions, allow a more reasonable set of prompt strings to be accepted as prompts. Signed-off-by: Stefano Brivio <sbrivio(a)redhat.com> --- test/lib/term | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/test/lib/term b/test/lib/term index 78e2bd3..cc6349f 100755 --- a/test/lib/term +++ b/test/lib/term @@ -193,13 +193,16 @@ pane_run() { # pane_wait() - Wait for command to be done in given pane name # $1: Pane name pane_wait() { - __pane_lc="$(echo "${1}" | tr [A-Z] [a-z])" - - while [ "$(tail -n1 ${LOGDIR}/pane_${__pane_lc}.log)" != '$ ' ] && \ - [ "$(tail -n1 ${LOGDIR}/pane_${__pane_lc}.log)" != '# ' ] && \ - [ "$(tail -n1 ${LOGDIR}/pane_${__pane_lc}.log)" != '# # ' ]; do - sleep 0.1 || sleep 1 - done + __lc="$(echo "${1}" | tr [A-Z] [a-z])" + + __done=0 + while + __l="$(tail -1 ${LOGDIR}/pane_${__lc}.log | tr -d [:cntrl:])" + case ${__l} in + '$ ' | '# ' | '# # ' | *"$ " | *"# ") return ;; + *" #[m " | *" #[m [K" | *"]# ["*) return ;; + esac + do sleep 0.1 || sleep 1; done } # pane_parse() - Print last line, @EMPTY@ if command had no output -- 2.33.0
For distribution tests, we'll repeat some tests frequently. Add a 'def' directive that starts a block, ended by 'endef', whose execution can then be triggered by simply giving its name as a directive itself. Signed-off-by: Stefano Brivio <sbrivio(a)redhat.com> --- test/lib/test | 496 +++++++++++++++++++++++++++----------------------- 1 file changed, 267 insertions(+), 229 deletions(-) diff --git a/test/lib/test b/test/lib/test index 682e0c7..9f6f6e4 100755 --- a/test/lib/test +++ b/test/lib/test @@ -86,10 +86,265 @@ test_iperf3() { pane_wait "${__pane}" } +test_one_line() { + __line="${1}" + + # Strip comments + __line="${__line%%#*}" + + if [ -n "${TEST_ONE_in_def}" ]; then + [ "${__line}" = "endef" ] && TEST_ONE_in_def= && return + # Append $__line to variable TEST_ONE_DEF_<definition name> + __ifs="${IFS}" + IFS= + eval TEST_ONE_DEF_$TEST_ONE_in_def=\"\$\(printf \"%s\\n%s\" \"\$TEST_ONE_DEF_$TEST_ONE_in_def\" \"$__line\"\)\" + IFS="${__ifs}" + return + fi + + # tab-split command and arguments, apply variable substitutions + __cmd="${__line%%$(printf '\t')*}" + __arg="${__line#*$(printf '\t')*}" + __arg="$(subs_apply "${TEST_ONE_subs}" "${__arg}")" + + [ ${TEST_ONE_nok} -eq 1 ] && [ "${__cmd}" != "test" ] && continue + case ${__cmd} in + "def") + TEST_ONE_in_def="${__arg}" + # Clear variable TEST_ONE_DEF_<definition name> + __ifs="${IFS}" + 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 + [ ${TEST_ONE_nok} -eq 0 ] && status_test_ok + + status_test_start "${__arg}" + TEST_ONE_nok=0 + TEST_ONE_perf_nok=0 + ;; + "host") + pane_run HOST "${__arg}" + pane_wait HOST + ;; + "hostb") + pane_run HOST "${__arg}" + ;; + "hostw") + pane_wait HOST + ;; + "hint") + tmux send-keys -t ${PANE_HOST} "C-c" + ;; + "htools") + pane_run HOST 'which '"${__arg}"' >/dev/null || echo skip' + pane_wait HOST + [ "$(pane_parse HOST)" = "skip" ] && TEST_ONE_skip=1 + ;; + "passt") + pane_run PASST "${__arg}" + pane_wait PASST + ;; + "passtb") + pane_run PASST "${__arg}" + ;; + "passtw") + pane_wait PASST + ;; + "pout") + __varname="${__arg%% *}" + pane_run PASST "${__arg#* }" + pane_wait PASST + TEST_ONE_subs="$(list_add_pair "${TEST_ONE_subs}" "__${__varname}__" "$(pane_parse PASST)")" + ;; + "guest") + pane_run GUEST "${__arg}" + pane_wait GUEST + ;; + "guestb") + pane_run GUEST "${__arg}" + ;; + "guestw") + pane_wait GUEST + ;; + "guest1") + pane_run GUEST_1 "${__arg}" + pane_wait GUEST_1 + ;; + "guest1b") + pane_run GUEST_1 "${__arg}" + ;; + "guest1w") + pane_wait GUEST_1 + ;; + "gtools") + pane_run GUEST 'which '"${__arg}"' >/dev/null || echo skip' + pane_wait GUEST + [ "$(pane_parse GUEST)" = "skip" ] && TEST_ONE_skip=1 + ;; + "g1tools") + pane_run GUEST_1 'which '"${__arg}"' >/dev/null || echo skip' + pane_wait GUEST_1 + [ "$(pane_parse GUEST_1)" = "skip" ] && TEST_ONE_skip=1 + ;; + "g2tools") + pane_run GUEST_2 'which '"${__arg}"' >/dev/null || echo skip' + pane_wait GUEST_2 + [ "$(pane_parse GUEST_2)" = "skip" ] && TEST_ONE_skip=1 + ;; + "guest2") + pane_run GUEST_2 "${__arg}" + pane_wait GUEST_2 + ;; + "guest2b") + pane_run GUEST_2 "${__arg}" + ;; + "guest2w") + pane_wait GUEST_2 + ;; + "ns") + pane_run NS "${__arg}" + pane_wait NS + ;; + "nsb") + pane_run NS "${__arg}" + ;; + "nsw") + pane_wait NS + ;; + "nstools") + pane_run NS 'which '"${__arg}"' >/dev/null || echo skip' + pane_wait NS + [ "$(pane_parse NS)" = "skip" ] && TEST_ONE_skip=1 + ;; + "gout") + __varname="${__arg%% *}" + pane_run GUEST "${__arg#* }" + pane_wait GUEST + TEST_ONE_subs="$(list_add_pair "${TEST_ONE_subs}" "__${__varname}__" "$(pane_parse GUEST)")" + ;; + "g1out") + __varname="${__arg%% *}" + pane_run GUEST_1 "${__arg#* }" + pane_wait GUEST_1 + TEST_ONE_subs="$(list_add_pair "${TEST_ONE_subs}" "__${__varname}__" "$(pane_parse GUEST_1)")" + ;; + "g2out") + __varname="${__arg%% *}" + pane_run GUEST_2 "${__arg#* }" + pane_wait GUEST_2 + TEST_ONE_subs="$(list_add_pair "${TEST_ONE_subs}" "__${__varname}__" "$(pane_parse GUEST_2)")" + ;; + "hout") + __varname="${__arg%% *}" + pane_run HOST "${__arg#* }" + pane_wait HOST + TEST_ONE_subs="$(list_add_pair "${TEST_ONE_subs}" "__${__varname}__" "$(pane_parse HOST)")" + ;; + "nsout") + __varname="${__arg%% *}" + pane_run NS "${__arg#* }" + pane_wait NS + TEST_ONE_subs="$(list_add_pair "${TEST_ONE_subs}" "__${__varname}__" "$(pane_parse NS)")" + ;; + "check") + info_check "${__arg}" + __nok=0 + eval "${__arg} || __nok=1" + if [ ${__nok} -eq 1 ]; then + TEST_ONE_nok=1 + info_check_failed + else + info_check_passed + fi + ;; + "sleep") + sleep "${__arg}" + ;; + "info") + info "${__arg}" + ;; + "report") + perf_report ${__arg} + ;; + "th") + table_header ${__arg} + ;; + "tr") + table_row "${__arg}" + ;; + "tl") + table_line "${__arg}" + ;; + "te") + table_end + ;; + "bw") + table_value_throughput ${__arg} || TEST_ONE_perf_nok=1 + ;; + "lat") + table_value_latency ${__arg} || TEST_ONE_perf_nok=1 + ;; + "iperf3c") + test_iperf3 client ${__arg} + ;; + "iperf3s") + TEST_ONE_subs="$(list_add_pair "${TEST_ONE_subs}" "__${__arg%% *}__" "$(test_iperf3 server ${__arg#* })" )" + ;; + "set") + TEST_ONE_subs="$(list_add_pair "${TEST_ONE_subs}" "__${__arg%% *}__" "${__arg#* }")" + ;; + + # Demo commands + "say") + text_write "${__arg}" + ;; + "em") + em_write "${__arg}" + ;; + "nl") + info_nolog "" + ;; + "hl") + pane_highlight "${__arg}" + ;; + "bsp") + text_backspace "${__arg}" + ;; + "killp") + pane_kill "${__arg}" + ;; + *) + __def_body="$(eval printf \"\$TEST_ONE_DEF_$__cmd\")" + if [ -n "${__def_body}" ]; then + __ifs="${IFS}" + IFS=' +' + for __def_line in ${__def_body}; do + IFS= test_one_line "${__def_line}" + done + IFS="${__ifs}" + fi + ;; + esac +} + # test_one() - Run a single test file evaluating directives # $1: Name of test file, relative to test/ directory test_one() { - __dirclean= + TEST_ONE_dirclean= __test_file="test/${1}" __type="$(file -b --mime-type ${__test_file})" @@ -104,242 +359,25 @@ test_one() { [ ${CI} -eq 1 ] && video_link "${1}" - __subs= - __nok=-1 - __perf_nok=0 - __skip=0 + TEST_ONE_subs= + TEST_ONE_nok=-1 + TEST_ONE_perf_nok=0 + TEST_ONE_skip=0 + TEST_ONE_in_def= while IFS= read -r __line; do - # Strip comments - __line="${__line%%#*}" - - # tab-split command and arguments, apply variable substitutions - __cmd="${__line%%$(printf '\t')*}" - __arg="${__line#*$(printf '\t')*}" - __arg="$(subs_apply "${__subs}" "${__arg}")" - - [ ${__nok} -eq 1 ] && [ "${__cmd}" != "test" ] && continue - case ${__cmd} in - "tempdir") - __tmpdir="$(mktemp -d)" - __subs="$(list_add_pair "${__subs}" "__${__arg}__" "${__tmpdir}")" - __dirclean="$(list_add "${__dirclean}" "${__tmpdir}")" - ;; - "temp") - __tmpfile="$(mktemp)" - __subs="$(list_add_pair "${__subs}" "__${__arg}__" "${__tmpfile}")" - __dirclean="$(list_add "${__dirclean}" "${__tmpfile}")" - ;; - "test") - [ ${__perf_nok} -eq 0 ] || __nok=1 - [ ${__nok} -eq 1 ] && status_test_fail - [ ${__nok} -eq 0 ] && status_test_ok - - status_test_start "${__arg}" - __nok=0 - __perf_nok=0 - ;; - "host") - pane_run HOST "${__arg}" - pane_wait HOST - ;; - "hostb") - pane_run HOST "${__arg}" - ;; - "hostw") - pane_wait HOST - ;; - "htools") - pane_run HOST 'which '"${__arg}"' >/dev/null || echo skip' - pane_wait HOST - [ "$(pane_parse HOST)" = "skip" ] && { __skip=1; break; } - ;; - "passt") - pane_run PASST "${__arg}" - pane_wait PASST - ;; - "passtb") - pane_run PASST "${__arg}" - ;; - "passtw") - pane_wait PASST - ;; - "pout") - __varname="${__arg%% *}" - pane_run PASST "${__arg#* }" - pane_wait PASST - __subs="$(list_add_pair "${__subs}" "__${__varname}__" "$(pane_parse PASST)")" - ;; - "guest") - pane_run GUEST "${__arg}" - pane_wait GUEST - ;; - "guestb") - pane_run GUEST "${__arg}" - ;; - "guestw") - pane_wait GUEST - ;; - "guest1") - pane_run GUEST_1 "${__arg}" - pane_wait GUEST_1 - ;; - "guest1b") - pane_run GUEST_1 "${__arg}" - ;; - "guest1w") - pane_wait GUEST_1 - ;; - "gtools") - pane_run GUEST 'which '"${__arg}"' >/dev/null || echo skip' - pane_wait GUEST - [ "$(pane_parse GUEST)" = "skip" ] && { __skip=1; break; } - ;; - "g1tools") - pane_run GUEST_1 'which '"${__arg}"' >/dev/null || echo skip' - pane_wait GUEST_1 - [ "$(pane_parse GUEST_1)" = "skip" ] && { __skip=1; break; } - ;; - "g2tools") - pane_run GUEST_2 'which '"${__arg}"' >/dev/null || echo skip' - pane_wait GUEST_2 - [ "$(pane_parse GUEST_2)" = "skip" ] && { __skip=1; break; } - ;; - "guest2") - pane_run GUEST_2 "${__arg}" - pane_wait GUEST_2 - ;; - "guest2b") - pane_run GUEST_2 "${__arg}" - ;; - "guest2w") - pane_wait GUEST_2 - ;; - "ns") - pane_run NS "${__arg}" - pane_wait NS - ;; - "nsb") - pane_run NS "${__arg}" - ;; - "nsw") - pane_wait NS - ;; - "nstools") - pane_run NS 'which '"${__arg}"' >/dev/null || echo skip' - pane_wait NS - [ "$(pane_parse NS)" = "skip" ] && { __skip=1; break; } - ;; - "gout") - __varname="${__arg%% *}" - pane_run GUEST "${__arg#* }" - pane_wait GUEST - __subs="$(list_add_pair "${__subs}" "__${__varname}__" "$(pane_parse GUEST)")" - ;; - "g1out") - __varname="${__arg%% *}" - pane_run GUEST_1 "${__arg#* }" - pane_wait GUEST_1 - __subs="$(list_add_pair "${__subs}" "__${__varname}__" "$(pane_parse GUEST_1)")" - ;; - "g2out") - __varname="${__arg%% *}" - pane_run GUEST_2 "${__arg#* }" - pane_wait GUEST_2 - __subs="$(list_add_pair "${__subs}" "__${__varname}__" "$(pane_parse GUEST_2)")" - ;; - "hout") - __varname="${__arg%% *}" - pane_run HOST "${__arg#* }" - pane_wait HOST - __subs="$(list_add_pair "${__subs}" "__${__varname}__" "$(pane_parse HOST)")" - ;; - "nsout") - __varname="${__arg%% *}" - pane_run NS "${__arg#* }" - pane_wait NS - __subs="$(list_add_pair "${__subs}" "__${__varname}__" "$(pane_parse NS)")" - ;; - "check") - info_check "${__arg}" - eval "${__arg} || __nok=1" - if [ ${__nok} -eq 1 ]; then - info_check_failed - else - info_check_passed - fi - ;; - "sleep") - sleep "${__arg}" - ;; - "info") - info "${__arg}" - ;; - "report") - perf_report ${__arg} - ;; - "th") - table_header ${__arg} - ;; - "tr") - table_row "${__arg}" - ;; - "tl") - table_line "${__arg}" - ;; - "te") - table_end - ;; - "bw") - table_value_throughput ${__arg} || __perf_nok=1 - ;; - "lat") - table_value_latency ${__arg} || __perf_nok=1 - ;; - "iperf3c") - set -x - test_iperf3 client ${__arg} - set +x - ;; - "iperf3s") - set -x - __subs="$(list_add_pair "${__subs}" "__${__arg%% *}__" "$(test_iperf3 server ${__arg#* })" )" - set +x - ;; - "set") - __subs="$(list_add_pair "${__subs}" "__${__arg%% *}__" "${__arg#* }")" - ;; - - # Demo commands - "say") - text_write "${__arg}" - ;; - "em") - em_write "${__arg}" - ;; - "nl") - info_nolog "" - ;; - "hl") - pane_highlight "${__arg}" - ;; - "bsp") - text_backspace "${__arg}" - ;; - "killp") - pane_kill "${__arg}" - ;; - esac + test_one_line "${__line}" + [ ${TEST_ONE_skip} -eq 1 ] && break done < "${__test_file}" - for __d in ${__dirclean}; do + for __d in ${TEST_ONE_dirclean}; do rm -rf ${__d} done [ ${DEMO} -eq 1 ] && return - [ ${__skip} -eq 1 ] && status_test_skip && return - [ ${__perf_nok} -eq 0 ] || __nok=1 - [ ${__nok} -eq 0 ] && status_test_ok || status_test_fail + [ ${TEST_ONE_skip} -eq 1 ] && status_test_skip && return + [ ${TEST_ONE_perf_nok} -eq 0 ] || TEST_ONE_nok=1 + [ ${TEST_ONE_nok} -eq 0 ] && status_test_ok || status_test_fail } # test() - Build list of tests to run, in order, then issue test_one() -- 2.33.0
The new tests check build and a simple case with pasta sending a short message in both directions (namespace to init, init to namespace). Tests cover a mix of Debian, Fedora, OpenSUSE and Ubuntu combinations on aarch64, i386, ppc64, ppc64le, s390x, x86_64. Builds tested starting from approximately glibc 2.19, gcc 4.7, and actual functionality approximately from 4.4 kernels, glibc 2.25, gcc 4.8, all the way up to current glibc/gcc/kernel versions. Signed-off-by: Stefano Brivio <sbrivio(a)redhat.com> --- README.md | 4 +- test/distro/debian | 343 ++++++++++++++++++++++++++ test/distro/fedora | 563 +++++++++++++++++++++++++++++++++++++++++++ test/distro/opensuse | 182 ++++++++++++++ test/distro/ubuntu | 208 ++++++++++++++++ test/run | 1 + 6 files changed, 1299 insertions(+), 2 deletions(-) create mode 100644 test/distro/debian create mode 100644 test/distro/fedora create mode 100644 test/distro/opensuse create mode 100644 test/distro/ubuntu diff --git a/README.md b/README.md index 7f3cd58..d16b705 100644 --- a/README.md +++ b/README.md @@ -217,7 +217,7 @@ speeding up local connections, and usually requiring NAT. _pasta_: ### Portability * Linux * ✅ starting from 4.18 kernel version - * 🛠 starting from 3.8 kernel version + * ✅ starting from 3.13 kernel version * 🛠 build-time selection of AVX2 instructions (as much as possible) * ⌚ [_musl_](https://bugs.passt.top/show_bug.cgi?id=4) and [_uClibc-ng_](https://bugs.passt.top/show_bug.cgi?id=5) @@ -284,9 +284,9 @@ speeding up local connections, and usually requiring NAT. _pasta_: ### Availability * ✅ convenience unofficial packages for Debian, RPM-based distributions on x86_64 (static builds) +* ✅ testing on non-x86 architectures * 🛠 official [OpenSUSE packages](https://build.opensuse.org/package/show/home:mnhauke/passt) -* 🛠 testing on non-x86 architectures * ⌚ packages for Debian, Fedora, etc. ### Services diff --git a/test/distro/debian b/test/distro/debian new file mode 100644 index 0000000..6ba0b10 --- /dev/null +++ b/test/distro/debian @@ -0,0 +1,343 @@ +# SPDX-License-Identifier: AGPL-3.0-or-later +# +# PASST - Plug A Simple Socket Transport +# for qemu/UNIX domain socket mode +# +# PASTA - Pack A Subtle Tap Abstraction +# for network namespace/tap device mode +# +# test/distro/debian - Debian builds, get packages via passt, test pasta +# +# Copyright (c) 2021 Red Hat GmbH +# Author: Stefano Brivio <sbrivio(a)redhat.com> + +temp PIDFILE +htools wget virt-edit guestfish head sed cat kill qemu-system-aarch64 qemu-system-ppc64le + +# Quick pasta test: send message from init to ns, and from ns to init +def distro_quick_pasta_test +host export SHELL="/bin/dash" +host dash +host (nc -w1 -6 -l -p 10000 > /tmp/init_msg; echo "from_init" | nc -q0 ::1 9999) & +hostb ./pasta +sleep 1 +host nc -w1 -6 -l -p 9999 > /tmp/ns_msg & +sleep 2 +host echo "from_ns" | nc -q0 ::1 10000 +sleep 2 +host echo +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 + +# Start passt, set common variables +hostb ./passt -P __PIDFILE__ & +sleep 1 +host echo +hout GUEST_FILES ls -1 *.c *.h *.sh Makefile | tr '\n' ' '; echo + + +test Debian GNU/Linux 8 (jessie), amd64 + +temp IMG +host wget https://cloud.debian.org/images/cloud/OpenStack/archive/8.11.0/debian-8.11.… -O __IMG__ +host virt-edit -a __IMG__ /etc/systemd/system/getty.target.wants/getty(a)tty1.service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --autologin root -8 --keep-baud 115200,38400,9600 ttyS0 $TERM/g' +host guestfish --rw -a __IMG__ -i rm /lib/systemd/system/serial-getty@.service +host guestfish --rw -a __IMG__ -i rm /etc/init.d/cloud-config +host guestfish --rw -a __IMG__ -i rm /etc/init.d/cloud-final +host guestfish --rw -a __IMG__ -i rm /etc/init.d/cloud-init +host guestfish --rw -a __IMG__ -i rm /etc/init.d/cloud-init-local +host guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/ + +host ./qrap 5 kvm -M pc -m 1024 -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none -drive file=__IMG__,if=virtio -net socket,fd=5 -net nic,model=virtio +host PS1='$ ' +sleep 2 +host apt-get update +host apt-get -y install make gcc netcat-openbsd + +host make clean +hout RET CFLAGS="-Wno-missing-field-initializers -Wno-missing-braces -Wno-type-limits" make; echo $? +check [ __RET__ -eq 0 ] + +# TODO: pasta test skipped for the moment: clone() as called by NS_CALL hangs +# with wrapper provided by glibc 2.19, probably wrong argument order. + +hint +sleep 1 + +# PIDFILE is cleaned up when the next test starts, read it now +hout PID cat __PIDFILE__ + + +test Debian GNU/Linux 9 (stretch, oldoldstable), amd64 + +temp IMG +host wget https://cloud.debian.org/images/cloud/stretch/daily/20200210-166/debian-9-n… -O __IMG__ +host virt-edit -a __IMG__ /etc/systemd/system/getty.target.wants/getty(a)tty1.service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --autologin root -8 --keep-baud 115200,38400,9600 ttyS0 $TERM/g' +host guestfish --rw -a __IMG__ -i rm /lib/systemd/system/serial-getty@.service +host guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/ + +host ./qrap 5 kvm -M pc -m 1024 -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none __IMG__ -net socket,fd=5 -net nic,model=virtio +host PS1='$ ' +sleep 2 +host apt-get update +host apt-get -y install make gcc netcat-openbsd + +host make clean +hout RET CFLAGS="-Werror" make; echo $? +check [ __RET__ -eq 0 ] + +distro_quick_pasta_test + +hint +sleep 1 + + +test Debian GNU/Linux 10 (buster, oldstable), amd64 + +temp IMG +host wget https://cloud.debian.org/images/cloud/buster/latest/debian-10-nocloud-amd64… -O __IMG__ +host virt-edit -a __IMG__ /etc/systemd/system/getty.target.wants/getty(a)tty1.service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --autologin root -8 --keep-baud 115200,38400,9600 ttyS0 $TERM/g' +host guestfish --rw -a __IMG__ -i rm /lib/systemd/system/serial-getty@.service +host guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/ + +host ./qrap 5 kvm -M pc -m 1024 -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none __IMG__ -net socket,fd=5 -net nic,model=virtio +host PS1='$ ' +sleep 2 +host apt-get update +host apt-get -y install make gcc netcat-openbsd + +host make clean +hout RET CFLAGS="-Werror" make; echo $? +check [ __RET__ -eq 0 ] + +distro_quick_pasta_test + +hint +sleep 1 + + +test Debian GNU/Linux 10 (buster, oldstable), aarch64 + +temp IMG +host wget https://cloud.debian.org/images/cloud/buster/latest/debian-10-generic-arm64… -O __IMG__ +host virt-edit -a __IMG__ /usr/lib/systemd/system/serial-getty@.service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --autologin root -8 --keep-baud 115200,38400,9600 %I $TERM/g' +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-config.service +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-init.service +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-init-local.service +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-final.service +host guestfish --rw -a __IMG__ -i rm /etc/init.d/cloud-config +host guestfish --rw -a __IMG__ -i rm /etc/init.d/cloud-final +host guestfish --rw -a __IMG__ -i rm /etc/init.d/cloud-init +host guestfish --rw -a __IMG__ -i rm /etc/init.d/cloud-init-local +host guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/ + +host ./qrap 5 qemu-system-aarch64 -m 2048 -cpu cortex-a57 -smp 2 -M virt -bios /usr/share/qemu-efi-aarch64/QEMU_EFI.fd -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none __IMG__ -net socket,fd=5 -net nic,model=virtio +host PS1='$ ' +sleep 2 +host apt-get update +host apt-get -y install make gcc netcat-openbsd + +host make clean +hout RET CFLAGS="-Werror" make; echo $? +check [ __RET__ -eq 0 ] + +distro_quick_pasta_test + +hint +sleep 1 + + +test Debian GNU/Linux 10 (buster, oldstable), ppc64le + +temp IMG +host wget https://cloud.debian.org/images/cloud/buster/latest/debian-10-generic-ppc64… -O __IMG__ +host virt-edit -a __IMG__ /etc/systemd/system/getty.target.wants/getty(a)tty1.service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --autologin root -8 --keep-baud 115200,38400,9600 ttyS0 $TERM/g' +host virt-edit -a __IMG__ /usr/lib/systemd/system/serial-getty@.service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --autologin root -8 --keep-baud 115200,38400,9600 %I $TERM/g' +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-config.service +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-init.service +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-init-local.service +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-final.service +host guestfish --rw -a __IMG__ -i rm /etc/init.d/cloud-config +host guestfish --rw -a __IMG__ -i rm /etc/init.d/cloud-final +host guestfish --rw -a __IMG__ -i rm /etc/init.d/cloud-init +host guestfish --rw -a __IMG__ -i rm /etc/init.d/cloud-init-local +host guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/ + +host ./qrap 5 qemu-system-ppc64le -m 2048 -smp 2 -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none __IMG__ -net socket,fd=5 -net nic,model=virtio +host PS1='$ ' +sleep 2 +host apt-get update +host apt-get -y install make gcc netcat-openbsd + +host make clean +hout RET CFLAGS="-Werror" make; echo $? +check [ __RET__ -eq 0 ] + +distro_quick_pasta_test + +hint +sleep 1 +hostb reset + + +test Debian GNU/Linux 11 (bullseye, stable), amd64 + +temp IMG +host wget https://cloud.debian.org/images/cloud/bullseye/latest/debian-11-nocloud-amd… -O __IMG__ +host virt-edit -a __IMG__ /etc/systemd/system/getty.target.wants/getty(a)tty1.service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --autologin root -8 --keep-baud 115200,38400,9600 ttyS0 $TERM/g' +host guestfish --rw -a __IMG__ -i rm /lib/systemd/system/serial-getty@.service +host guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/ + +host ./qrap 5 kvm -M pc -m 1024 -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none __IMG__ -net socket,fd=5 -net nic,model=virtio +sleep 2 +host apt-get update +host apt-get -y install make gcc netcat-openbsd + +host make clean +hout RET CFLAGS="-Werror" make; echo $? +check [ __RET__ -eq 0 ] + +distro_quick_pasta_test + +hint +sleep 1 + + +test Debian GNU/Linux 11 (bullseye, stable), aarch64 + +temp IMG +host wget https://cloud.debian.org/images/cloud/bullseye/latest/debian-11-generic-arm… -O __IMG__ +host virt-edit -a __IMG__ /usr/lib/systemd/system/serial-getty@.service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --autologin root -8 --keep-baud 115200,38400,9600 %I $TERM/g' +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-config.service +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-init.service +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-init-local.service +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-final.service +host guestfish --rw -a __IMG__ -i rm /etc/init.d/cloud-config +host guestfish --rw -a __IMG__ -i rm /etc/init.d/cloud-final +host guestfish --rw -a __IMG__ -i rm /etc/init.d/cloud-init +host guestfish --rw -a __IMG__ -i rm /etc/init.d/cloud-init-local +host guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/ + +host ./qrap 5 qemu-system-aarch64 -m 2048 -cpu cortex-a57 -smp 2 -M virt -bios /usr/share/qemu-efi-aarch64/QEMU_EFI.fd -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none __IMG__ -net socket,fd=5 -net nic,model=virtio +sleep 2 +host apt-get update +host apt-get -y install make gcc netcat-openbsd + +host make clean +hout RET CFLAGS="-Werror" make; echo $? +check [ __RET__ -eq 0 ] + +distro_quick_pasta_test + +hint +sleep 1 + + +test Debian GNU/Linux 11 (bullseye, stable), ppc64le + +temp IMG +host wget https://cloud.debian.org/images/cloud/bullseye/latest/debian-11-generic-ppc… -O __IMG__ +host virt-edit -a __IMG__ /etc/systemd/system/getty.target.wants/getty(a)tty1.service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --autologin root -8 --keep-baud 115200,38400,9600 ttyS0 $TERM/g' +host virt-edit -a __IMG__ /usr/lib/systemd/system/serial-getty@.service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --autologin root -8 --keep-baud 115200,38400,9600 %I $TERM/g' +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-config.service +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-init.service +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-init-local.service +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-final.service +host guestfish --rw -a __IMG__ -i rm /etc/init.d/cloud-config +host guestfish --rw -a __IMG__ -i rm /etc/init.d/cloud-final +host guestfish --rw -a __IMG__ -i rm /etc/init.d/cloud-init +host guestfish --rw -a __IMG__ -i rm /etc/init.d/cloud-init-local +host guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/ + +host ./qrap 5 qemu-system-ppc64le -m 2048 -smp 2 -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none __IMG__ -net socket,fd=5 -net nic,model=virtio +sleep 2 +host apt-get update +host apt-get -y install make gcc netcat-openbsd + +host make clean +hout RET CFLAGS="-Werror" make; echo $? +check [ __RET__ -eq 0 ] + +distro_quick_pasta_test + +hint +sleep 1 +hostb reset + + +test Debian GNU/Linux sid (experimental), amd64 + +temp IMG +host wget https://cloud.debian.org/images/cloud/sid/daily/latest/debian-sid-nocloud-a… -O __IMG__ +host virt-edit -a __IMG__ /etc/systemd/system/getty.target.wants/getty(a)tty1.service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --autologin root -8 --keep-baud 115200,38400,9600 ttyS0 $TERM/g' +host guestfish --rw -a __IMG__ -i rm /lib/systemd/system/serial-getty@.service +host guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/ + +host ./qrap 5 kvm -M pc -m 1024 -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none __IMG__ -net socket,fd=5 -net nic,model=virtio +sleep 2 +host apt-get update +host apt-get -y install make gcc netcat-openbsd + +host make clean +hout RET CFLAGS="-Werror" make; echo $? +check [ __RET__ -eq 0 ] + +distro_quick_pasta_test + +hint +sleep 1 + + +test Debian GNU/Linux sid (experimental), aarch64 + +temp IMG +host wget https://cloud.debian.org/images/cloud/sid/daily/latest/debian-sid-nocloud-a… -O __IMG__ +host virt-edit -a __IMG__ /usr/lib/systemd/system/serial-getty@.service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --autologin root -8 --keep-baud 115200,38400,9600 %I $TERM/g' +host guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/ + +host ./qrap 5 qemu-system-aarch64 -m 2048 -cpu cortex-a57 -smp 2 -M virt -bios /usr/share/qemu-efi-aarch64/QEMU_EFI.fd -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none __IMG__ -net socket,fd=5 -net nic,model=virtio +sleep 2 +host apt-get update +host apt-get -y install make gcc netcat-openbsd + +host make clean +hout RET CFLAGS="-Werror" make; echo $? +check [ __RET__ -eq 0 ] + +distro_quick_pasta_test + +hint +sleep 1 + + +test Debian GNU/Linux sid (experimental), ppc64le + +temp IMG +host wget https://cloud.debian.org/images/cloud/sid/daily/latest/debian-sid-nocloud-p… -O __IMG__ +host virt-edit -a __IMG__ /etc/systemd/system/getty.target.wants/getty(a)tty1.service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --autologin root -8 --keep-baud 115200,38400,9600 ttyS0 $TERM/g' +host virt-edit -a __IMG__ /usr/lib/systemd/system/serial-getty@.service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --autologin root -8 --keep-baud 115200,38400,9600 %I $TERM/g' +host guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/ + +host ./qrap 5 qemu-system-ppc64le -m 2048 -smp 2 -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none __IMG__ -net socket,fd=5 -net nic,model=virtio +sleep 2 +host apt-get update +host apt-get -y install make gcc netcat-openbsd + +host make clean +hout RET CFLAGS="-Werror" make; echo $? +check [ __RET__ -eq 0 ] + +distro_quick_pasta_test + +hint +sleep 1 +hostb reset + + +sleep 1 +host kill __PID__ diff --git a/test/distro/fedora b/test/distro/fedora new file mode 100644 index 0000000..0a80555 --- /dev/null +++ b/test/distro/fedora @@ -0,0 +1,563 @@ +# SPDX-License-Identifier: AGPL-3.0-or-later +# +# PASST - Plug A Simple Socket Transport +# for qemu/UNIX domain socket mode +# +# PASTA - Pack A Subtle Tap Abstraction +# for network namespace/tap device mode +# +# test/distro/fedora - Fedora builds, get packages via passt, test pasta +# +# Copyright (c) 2021 Red Hat GmbH +# Author: Stefano Brivio <sbrivio(a)redhat.com> + +temp PIDFILE +htools wget virt-edit guestfish head sed cat kill + +# Quick pasta test: send message from init to ns, and from ns to init +def distro_quick_pasta_test +host (nc -6 -l -p 10000 > /tmp/init_msg; echo "from_init" | nc ::1 9999) & +hostb ./pasta +sleep 1 +host PS1='$ ' +host nc -6 -l -p 9999 > /tmp/ns_msg & +sleep 2 +host echo "from_ns" | nc ::1 10000 +sleep 2 +host echo +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 + +# Explicit listening address, bracketed paste mode off, needed from Fedora 34 +def distro_quick_pasta_test_fedora34 +host bind 'set enable-bracketed-paste off' +host (nc -6 -l -p 10000 > /tmp/init_msg; echo "from_init" | nc -6 ::1 9999) & +hostb ./pasta +sleep 1 +host PS1='$ ' +host bind 'set enable-bracketed-paste off' +host nc -6 -l ::1 9999 > /tmp/ns_msg & +sleep 2 +host echo "from_ns" | nc -6 ::1 10000 +sleep 2 +host echo +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 + +# Start passt, set common variables +hostb ./passt -P __PIDFILE__ & +sleep 1 +host echo +hout DNS6 sed -n 's/^nameserver \([^:]*:\)\([^%]*\).*/\1\2/p' /etc/resolv.conf | head -1 +hout GUEST_FILES ls -1 *.c *.h *.sh Makefile | tr '\n' ' '; echo + + +test Fedora 26, x86_64 + +temp IMG +host wget http://archives.fedoraproject.org/pub/archive/fedora/linux/releases/26/Clou… -O __IMG__ +host virt-edit -a __IMG__ /etc/systemd/system/getty.target.wants/getty(a)tty1.service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --autologin root -8 --keep-baud 115200,38400,9600 ttyS0 $TERM/g' +host guestfish --rw -a __IMG__ -i rm /lib/systemd/system/serial-getty@.service +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-config.service +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-init.service +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-init-local.service +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-final.service +host guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/ + +host ./qrap 5 kvm -M pc -m 1024 -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none __IMG__ -net socket,fd=5 -net nic,model=virtio +host PS1='$ ' +sleep 2 +host yum -y install make gcc nmap-ncat + +host make clean +hout RET CFLAGS="-Werror" make; echo $? +check [ __RET__ -eq 0 ] + +distro_quick_pasta_test + +hint +sleep 1 + +# PIDFILE is cleaned up when the next test starts, read it now +hout PID cat __PIDFILE__ + + +test Fedora 27, x86_64 + +temp IMG +host wget http://archives.fedoraproject.org/pub/archive/fedora/linux/releases/27/Clou… -O __IMG__ +host virt-edit -a __IMG__ /etc/systemd/system/getty.target.wants/getty(a)tty1.service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --autologin root -8 --keep-baud 115200,38400,9600 ttyS0 $TERM/g' +host guestfish --rw -a __IMG__ -i rm /lib/systemd/system/serial-getty@.service +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-config.service +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-init.service +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-init-local.service +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-final.service +host guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/ + +host ./qrap 5 kvm -M pc -m 1024 -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none __IMG__ -net socket,fd=5 -net nic,model=virtio +host PS1='$ ' +sleep 2 +host yum -y install make gcc nmap-ncat + +host make clean +hout RET CFLAGS="-Werror" make; echo $? +check [ __RET__ -eq 0 ] + +distro_quick_pasta_test + +hint +sleep 1 + + +test Fedora 28, x86_64 + +temp IMG +host wget http://archives.fedoraproject.org/pub/archive/fedora/linux/releases/28/Clou… -O __IMG__ +host virt-edit -a __IMG__ /etc/systemd/system/getty.target.wants/getty(a)tty1.service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --autologin root -8 --keep-baud 115200,38400,9600 ttyS0 $TERM/g' +host guestfish --rw -a __IMG__ -i rm /lib/systemd/system/serial-getty@.service +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-config.service +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-init.service +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-init-local.service +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-final.service +host guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/ + +host ./qrap 5 kvm -M pc -m 1024 -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none __IMG__ -net socket,fd=5 -net nic,model=virtio +host PS1='$ ' +sleep 2 +host yum -y install make gcc nmap-ncat + +host make clean +hout RET CFLAGS="-Werror" make; echo $? +check [ __RET__ -eq 0 ] + +distro_quick_pasta_test + +hint +sleep 1 + + +test Fedora 28, aarch64 + +temp IMG +host wget http://archives.fedoraproject.org/pub/archive/fedora/linux/releases/28/Clou… -O __IMG__ +host virt-edit -a __IMG__ /usr/lib/systemd/system/serial-getty@.service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --autologin root -8 --keep-baud 115200,38400,9600 %I $TERM/g' +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-config.service +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-init.service +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-init-local.service +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-final.service +host guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/ + +host ./qrap 5 qemu-system-aarch64 -m 2048 -cpu cortex-a57 -smp 2 -M virt -bios /usr/share/qemu-efi-aarch64/QEMU_EFI.fd -nodefaults -nographic -vga none -serial stdio __IMG__ -net socket,fd=5 -net nic,model=virtio -device virtio-rng-pci +host PS1='$ ' +sleep 2 +host yum -y install make gcc nmap-ncat + +host make clean +hout RET CFLAGS="-Werror" make; echo $? +check [ __RET__ -eq 0 ] + +distro_quick_pasta_test + +hint +sleep 1 +hostb reset +sleep 1 +host echo + + +test Fedora 29, x86_64 + +temp IMG +host wget http://archives.fedoraproject.org/pub/archive/fedora/linux/releases/29/Clou… -O __IMG__ +host virt-edit -a __IMG__ /usr/lib/systemd/system/serial-getty@.service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --autologin root -8 --keep-baud 115200,38400,9600 %I $TERM/g' +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-config.service +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-init.service +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-init-local.service +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-final.service +host guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/ + +host ./qrap 5 kvm -M pc -m 1024 -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none __IMG__ -net socket,fd=5 -net nic,model=virtio +host PS1='$ ' +sleep 2 +host yum -y install make gcc nmap-ncat + +host make clean +hout RET CFLAGS="-Werror" make; echo $? +check [ __RET__ -eq 0 ] + +distro_quick_pasta_test + +hint +sleep 1 + + +test Fedora 29, aarch64 + +temp IMG +host wget http://archives.fedoraproject.org/pub/archive/fedora/linux/releases/29/Clou… -O __IMG__ +host virt-edit -a __IMG__ /usr/lib/systemd/system/serial-getty@.service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --autologin root -8 --keep-baud 115200,38400,9600 %I $TERM/g' +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-config.service +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-init.service +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-init-local.service +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-final.service +host guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/ + +host ./qrap 5 qemu-system-aarch64 -m 2048 -cpu cortex-a57 -smp 2 -M virt -bios /usr/share/qemu-efi-aarch64/QEMU_EFI.fd -nodefaults -nographic -vga none -serial stdio __IMG__ -net socket,fd=5 -net nic,model=virtio -device virtio-rng-pci +host PS1='$ ' +sleep 2 +host yum -y install make gcc nmap-ncat + +host make clean +hout RET CFLAGS="-Werror" make; echo $? +check [ __RET__ -eq 0 ] + +distro_quick_pasta_test + +hint +sleep 1 +hostb reset +sleep 1 +host echo + + +test Fedora 30, x86_64 + +temp IMG +host wget http://archives.fedoraproject.org/pub/archive/fedora/linux/releases/30/Clou… -O __IMG__ +host virt-edit -a __IMG__ /usr/lib/systemd/system/serial-getty@.service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --autologin root -8 --keep-baud 115200,38400,9600 %I $TERM/g' +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-config.service +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-init.service +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-init-local.service +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-final.service +host guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/ + +host ./qrap 5 kvm -M pc -m 1024 -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none __IMG__ -net socket,fd=5 -net nic,model=virtio +host PS1='$ ' +sleep 2 +host yum -y install make gcc nmap-ncat + +host make clean +hout RET CFLAGS="-Werror" make; echo $? +check [ __RET__ -eq 0 ] + +distro_quick_pasta_test + +hint +sleep 1 + + +test Fedora 30, aarch64 + +temp IMG +host wget http://archives.fedoraproject.org/pub/archive/fedora/linux/releases/30/Clou… -O __IMG__ +host virt-edit -a __IMG__ /usr/lib/systemd/system/serial-getty@.service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --autologin root -8 --keep-baud 115200,38400,9600 %I $TERM/g' +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-config.service +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-init.service +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-init-local.service +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-final.service +host guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/ + +host ./qrap 5 qemu-system-aarch64 -m 2048 -cpu cortex-a57 -smp 2 -M virt -bios /usr/share/qemu-efi-aarch64/QEMU_EFI.fd -nodefaults -nographic -vga none -serial stdio __IMG__ -net socket,fd=5 -net nic,model=virtio -device virtio-rng-pci +host PS1='$ ' +sleep 2 +host yum -y install make gcc nmap-ncat + +host make clean +hout RET CFLAGS="-Werror" make; echo $? +check [ __RET__ -eq 0 ] + +distro_quick_pasta_test + +hint +sleep 1 +hostb reset +sleep 1 +host echo + + +test Fedora 31, x86_64 + +temp IMG +host wget http://archives.fedoraproject.org/pub/archive/fedora/linux/releases/31/Clou… -O __IMG__ +host virt-edit -a __IMG__ /usr/lib/systemd/system/serial-getty@.service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --autologin root -8 --keep-baud 115200,38400,9600 %I $TERM/g' +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-config.service +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-init.service +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-init-local.service +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-final.service +host guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/ + +host ./qrap 5 kvm -M pc -m 1024 -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none __IMG__ -net socket,fd=5 -net nic,model=virtio +host PS1='$ ' +sleep 2 +host yum -y install make gcc nmap-ncat + +host make clean +hout RET CFLAGS="-Werror" make; echo $? +check [ __RET__ -eq 0 ] + +distro_quick_pasta_test + +hint +sleep 1 + + +test Fedora 31, aarch64 + +temp IMG +host wget http://archives.fedoraproject.org/pub/archive/fedora/linux/releases/31/Clou… -O __IMG__ +host virt-edit -a __IMG__ /usr/lib/systemd/system/serial-getty@.service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --autologin root -8 --keep-baud 115200,38400,9600 %I $TERM/g' +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-config.service +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-init.service +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-init-local.service +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-final.service +host guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/ + +host ./qrap 5 qemu-system-aarch64 -m 2048 -cpu cortex-a57 -smp 2 -M virt -bios /usr/share/qemu-efi-aarch64/QEMU_EFI.fd -nodefaults -nographic -vga none -serial stdio __IMG__ -net socket,fd=5 -net nic,model=virtio -device virtio-rng-pci +host PS1='$ ' +sleep 2 +host yum -y install make gcc nmap-ncat + +host make clean +hout RET CFLAGS="-Werror" make; echo $? +check [ __RET__ -eq 0 ] + +distro_quick_pasta_test + +hint +sleep 1 +hostb reset +sleep 1 +host echo + + +test Fedora 32, x86_64 + +temp IMG +host wget https://download.fedoraproject.org/pub/fedora/linux/releases/32/Cloud/x86_6… -O __IMG__ +host virt-edit -a __IMG__ /usr/lib/systemd/system/serial-getty@.service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --autologin root -8 --keep-baud 115200,38400,9600 %I $TERM/g' +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-config.service +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-init.service +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-init-local.service +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-final.service +host guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/ + +host ./qrap 5 kvm -M pc -m 1024 -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none __IMG__ -net socket,fd=5 -net nic,model=virtio +host PS1='$ ' +sleep 2 +host yum -y install make gcc nmap-ncat + +host make clean +hout RET CFLAGS="-Werror" make; echo $? +check [ __RET__ -eq 0 ] + +distro_quick_pasta_test + +hint +sleep 1 + + +test Fedora 32, aarch64 + +temp IMG +host wget https://download.fedoraproject.org/pub/fedora/linux/releases/32/Cloud/aarch… -O __IMG__ +host virt-edit -a __IMG__ /usr/lib/systemd/system/serial-getty@.service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --autologin root -8 --keep-baud 115200,38400,9600 %I $TERM/g' +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-config.service +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-init.service +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-init-local.service +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-final.service +host guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/ + +host ./qrap 5 qemu-system-aarch64 -m 2048 -cpu cortex-a57 -smp 2 -M virt -bios /usr/share/qemu-efi-aarch64/QEMU_EFI.fd -nodefaults -nographic -vga none -serial stdio __IMG__ -net socket,fd=5 -net nic,model=virtio -device virtio-rng-pci +host PS1='$ ' +sleep 2 +host yum -y install make gcc nmap-ncat + +host make clean +hout RET CFLAGS="-Werror" make; echo $? +check [ __RET__ -eq 0 ] + +distro_quick_pasta_test + +hint +sleep 1 +hostb reset +sleep 1 +host echo + + +test Fedora 33, x86_64 + +temp IMG +host wget https://download.fedoraproject.org/pub/fedora/linux/releases/33/Cloud/x86_6… -O __IMG__ +host virt-edit -a __IMG__ /usr/lib/systemd/system/serial-getty@.service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --autologin root -8 --keep-baud 115200,38400,9600 %I $TERM/g' +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-config.service +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-init.service +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-init-local.service +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-final.service +host guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/ + +host ./qrap 5 kvm -M pc -m 1024 -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none __IMG__ -net socket,fd=5 -net nic,model=virtio +host PS1='$ ' +sleep 2 +host yum -y install make gcc nmap-ncat + +host make clean +hout RET CFLAGS="-Werror" make; echo $? +check [ __RET__ -eq 0 ] + +distro_quick_pasta_test + +hint +sleep 1 + + +test Fedora 33, aarch64 + +temp IMG +host wget https://download.fedoraproject.org/pub/fedora/linux/releases/33/Cloud/aarch… -O __IMG__ +host virt-edit -a __IMG__ /usr/lib/systemd/system/serial-getty@.service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --autologin root -8 --keep-baud 115200,38400,9600 %I $TERM/g' +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-config.service +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-init.service +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-init-local.service +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-final.service +host guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/ + +host ./qrap 5 qemu-system-aarch64 -m 2048 -cpu cortex-a57 -smp 2 -M virt -bios /usr/share/qemu-efi-aarch64/QEMU_EFI.fd -nodefaults -nographic -vga none -serial stdio __IMG__ -net socket,fd=5 -net nic,model=virtio -device virtio-rng-pci +host PS1='$ ' +sleep 2 +host yum -y install make gcc nmap-ncat + +host make clean +hout RET CFLAGS="-Werror" make; echo $? +check [ __RET__ -eq 0 ] + +distro_quick_pasta_test + +hint +sleep 1 +hostb reset +sleep 1 +host echo + + +test Fedora 34, x86_64 + +temp IMG +host wget https://download.fedoraproject.org/pub/fedora/linux//releases/34/Cloud/x86_… -O __IMG__ +host virt-edit -a __IMG__ /usr/lib/systemd/system/serial-getty@.service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --autologin root -8 --keep-baud 115200,38400,9600 %I $TERM/g' +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-config.service +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-init.service +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-init-local.service +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-final.service +host guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/ + +host ./qrap 5 kvm -M pc -m 1024 -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none __IMG__ -net socket,fd=5 -net nic,model=virtio +host PS1='$ ' +sleep 2 +host yum -y install make gcc nmap-ncat + +host make clean +hout RET CFLAGS="-Werror" make; echo $? +check [ __RET__ -eq 0 ] + +distro_quick_pasta_test_fedora34 + +hint +sleep 1 + + +test Fedora 34, aarch64 + +temp IMG +host wget https://download.fedoraproject.org/pub/fedora/linux//releases/34/Cloud/aarc… -O __IMG__ +host virt-edit -a __IMG__ /usr/lib/systemd/system/serial-getty@.service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --autologin root -8 --keep-baud 115200,38400,9600 %I $TERM/g' +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-config.service +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-init.service +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-init-local.service +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-final.service +host guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/ + +host ./qrap 5 qemu-system-aarch64 -m 2048 -cpu cortex-a57 -smp 2 -M virt -bios /usr/share/qemu-efi-aarch64/QEMU_EFI.fd -nodefaults -nographic -vga none -serial stdio __IMG__ -net socket,fd=5 -net nic,model=virtio -device virtio-rng-pci +host PS1='$ ' +sleep 2 +host yum -y install make gcc nmap-ncat + +host make clean +hout RET CFLAGS="-Werror" make; echo $? +check [ __RET__ -eq 0 ] + +distro_quick_pasta_test_fedora34 + +hint +sleep 1 +hostb reset +sleep 1 +host echo + + +test Fedora 35, x86_64 + +temp IMG +host wget https://download.fedoraproject.org/pub/fedora/linux/releases/35/Cloud/x86_6… -O __IMG__ +host virt-edit -a __IMG__ /usr/lib/systemd/system/serial-getty@.service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --autologin root -8 --keep-baud 115200,38400,9600 %I $TERM/g' +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-config.service +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-init.service +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-init-local.service +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-final.service +host guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/ + +host ./qrap 5 kvm -M pc -m 1024 -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none __IMG__ -net socket,fd=5 -net nic,model=virtio +host PS1='$ ' +sleep 2 +host yum -y install make gcc nmap-ncat + +host make clean +hout RET CFLAGS="-Werror" make; echo $? +check [ __RET__ -eq 0 ] + +distro_quick_pasta_test_fedora34 + +hint +sleep 1 + + +test Fedora 35, aarch64 + +temp IMG +host wget https://download.fedoraproject.org/pub/fedora/linux/releases/35/Cloud/aarch… -O __IMG__ +host virt-edit -a __IMG__ /usr/lib/systemd/system/serial-getty@.service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --autologin root -8 --keep-baud 115200,38400,9600 %I $TERM/g' +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-config.service +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-init.service +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-init-local.service +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-final.service +host guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/ + +host ./qrap 5 qemu-system-aarch64 -m 2048 -cpu cortex-a57 -smp 2 -M virt -bios /usr/share/qemu-efi-aarch64/QEMU_EFI.fd -nodefaults -nographic -vga none -serial stdio __IMG__ -net socket,fd=5 -net nic,model=virtio -device virtio-rng-pci +host PS1='$ ' +sleep 2 +host yum -y install make gcc nmap-ncat + +host make clean +hout RET CFLAGS="-Werror" make; echo $? +check [ __RET__ -eq 0 ] + +distro_quick_pasta_test_fedora34 + +hint +sleep 1 +hostb reset +sleep 1 +host echo + + +host kill __PID__ diff --git a/test/distro/opensuse b/test/distro/opensuse new file mode 100644 index 0000000..740108a --- /dev/null +++ b/test/distro/opensuse @@ -0,0 +1,182 @@ +# SPDX-License-Identifier: AGPL-3.0-or-later +# +# PASST - Plug A Simple Socket Transport +# for qemu/UNIX domain socket mode +# +# PASTA - Pack A Subtle Tap Abstraction +# for network namespace/tap device mode +# +# test/distro/opensuse - OpenSUSE builds, get packages via passt, test pasta +# +# Copyright (c) 2021 Red Hat GmbH +# Author: Stefano Brivio <sbrivio(a)redhat.com> + +temp PIDFILE +htools wget virt-edit guestfish head sed cat kill kvm qemu-system-aarch64 xzcat tr + +# Quick pasta test: send message from init to ns, and from ns to init +def distro_quick_pasta_test +host (nc -6 -l -p 10000 > /tmp/init_msg; echo "from_init" | nc -N ::1 9999) & +hostb ./pasta +sleep 1 +host PS1='$ ' +host nc -6 -l -p 9999 > /tmp/ns_msg & +sleep 2 +host echo "from_ns" | nc -N ::1 10000 +sleep 2 +host echo +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 + +# Start passt, set common variables +hostb ./passt -P __PIDFILE__ & +sleep 1 +host echo +hout DNS6 sed -n 's/^nameserver \([^:]*:\)\([^%]*\).*/\1\2/p' /etc/resolv.conf | head -1 +hout GUEST_FILES ls -1 *.c *.h *.sh Makefile | tr '\n' ' '; echo + + +test OpenSUSE Leap 15.1 + +temp IMG +host wget https://download.opensuse.org/distribution/leap/15.1/jeos/openSUSE-Leap-15.… -O __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 +host virt-edit -a __IMG__ /etc/systemd/system/getty.target.wants/getty(a)tty1.service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --timeout 5000 --autologin root -i -8 --keep-baud 115200,38400,9600 ttyS0 $TERM/g' +host guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/ + +host ./qrap 5 kvm -M pc -m 1024 -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none __IMG__ -net socket,fd=5 -net nic,model=virtio +host PS1='$ ' +host ip link set eth0 up +sleep 2 +host echo "DNSSERVERS='__DNS6__'" | netconfig modify -s dns_resolver -i eth0 +# zypper sometimes segfaults, hence the retries +host for i in $(seq 1 10); do zypper install -y gcc make netcat-openbsd && break; done; echo + +host make clean +hout RET CFLAGS="-Werror" make; echo $? +check [ __RET__ -eq 0 ] + +distro_quick_pasta_test + +hint +sleep 1 + +# PIDFILE is cleaned up when the next test starts, read it now +hout PID cat __PIDFILE__ + + +test OpenSUSE Leap 15.2 + +host wget https://download.opensuse.org/distribution/leap/15.2/appliances/openSUSE-Le… -O __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 +host virt-edit -a __IMG__ /etc/systemd/system/getty.target.wants/getty(a)tty1.service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --timeout 5000 --autologin root -i -8 --keep-baud 115200,38400,9600 ttyS0 $TERM/g' +host guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/ + +host ./qrap 5 kvm -M pc -m 1024 -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none __IMG__ -net socket,fd=5 -net nic,model=virtio +host PS1='$ ' +host ip link set eth0 up +sleep 2 +host echo "DNSSERVERS='__DNS6__'" | netconfig modify -s dns_resolver -i eth0 +# zypper sometimes segfaults, hence the retries +host for i in $(seq 1 10); do zypper install -y gcc make netcat-openbsd && break; done; echo + +host make clean +hout RET CFLAGS="-Werror" make; echo $? +check [ __RET__ -eq 0 ] + +distro_quick_pasta_test + +hint +sleep 1 + + +test OpenSUSE Leap 15.3 + +host wget https://download.opensuse.org/distribution/leap/15.3/appliances/openSUSE-Le… -O __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 +host virt-edit -a __IMG__ /etc/systemd/system/getty.target.wants/getty(a)tty1.service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --timeout 5000 --autologin root -i -8 --keep-baud 115200,38400,9600 ttyS0 $TERM/g' +host guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/ + +host ./qrap 5 kvm -M pc -m 1024 -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none __IMG__ -net socket,fd=5 -net nic,model=virtio +# Multiple prompt logins might come up here +sleep 10 +host PS1='$ ' +host ip link set eth0 up +sleep 2 +host echo "DNSSERVERS='__DNS6__'" | netconfig modify -s dns_resolver -i eth0 +# zypper sometimes segfaults, hence the retries +host for i in $(seq 1 10); do zypper install -y gcc make netcat-openbsd && break; done; echo + +host make clean +hout RET CFLAGS="-Werror" make; echo $? +check [ __RET__ -eq 0 ] + +distro_quick_pasta_test + +hint +sleep 1 + + +test OpenSUSE Tumbleweed aarch64 + +temp IMG +host wget http://download.opensuse.org/ports/aarch64/tumbleweed/appliances/openSUSE-T… -O - | xzcat > __IMG__ +host virt-edit -a __IMG__ -m /dev/sda3 /usr/lib/systemd/system/serial-getty@.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/ + +host ./qrap 5 qemu-system-aarch64 -m 2048 -cpu cortex-a57 -smp 2 -M virt -bios /usr/share/qemu-efi-aarch64/QEMU_EFI.fd -nodefaults -nographic -vga none -serial stdio __IMG__ -net socket,fd=5 -net nic,model=virtio +host PS1='$ ' +host ip link set enp0s1 up +sleep 10 +host echo "DNSSERVERS='__DNS6__'" | netconfig modify -s dns_resolver -i enp0s1 +sleep 10 +# No segfaults ever seen with this +host zypper install -y gcc make netcat-openbsd; echo + +host make clean +hout RET CFLAGS="-Werror" make; echo $? +check [ __RET__ -eq 0 ] + +distro_quick_pasta_test + +hint +sleep 1 + + +test OpenSUSE Tumbleweed + +temp IMG +host wget https://download.opensuse.org/tumbleweed/appliances/openSUSE-Tumbleweed-JeO… -O __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 +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/serial-getty@.service +host virt-edit -a __IMG__ /etc/systemd/system/getty.target.wants/getty(a)tty1.service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --timeout 5000 --autologin root -i -8 --keep-baud 115200,38400,9600 ttyS0 $TERM/g' +host guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/ + +host ./qrap 5 kvm -M pc -m 1024 -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none __IMG__ -net socket,fd=5 -net nic,model=virtio +host PS1='$ ' +host ip link set ens2 up +sleep 2 +host echo "DNSSERVERS='__DNS6__'" | netconfig modify -s dns_resolver -i ens2 +# zypper sometimes segfaults, hence the retries +host for i in $(seq 1 10); do zypper install -y gcc make netcat-openbsd && break; done; echo + +host make clean +hout RET CFLAGS="-Werror" make; echo $? +check [ __RET__ -eq 0 ] + +distro_quick_pasta_test + +hint +sleep 1 + + +host kill __PID__ diff --git a/test/distro/ubuntu b/test/distro/ubuntu new file mode 100644 index 0000000..fcd3861 --- /dev/null +++ b/test/distro/ubuntu @@ -0,0 +1,208 @@ +# SPDX-License-Identifier: AGPL-3.0-or-later +# +# PASST - Plug A Simple Socket Transport +# for qemu/UNIX domain socket mode +# +# PASTA - Pack A Subtle Tap Abstraction +# for network namespace/tap device mode +# +# test/distro/ubuntu - Ubuntu builds, get packages via passt, test pasta +# +# Copyright (c) 2021 Red Hat GmbH +# Author: Stefano Brivio <sbrivio(a)redhat.com> + +temp PIDFILE +htools wget virt-edit guestfish head sed cat kill qemu-system-ppc64le qemu-system-s390x + +# Quick pasta test: send message from init to ns, and from ns to init +def distro_quick_pasta_test +host (nc -w1 -6 -l -p 10000 > /tmp/init_msg; echo "from_init" | nc -q0 ::1 9999) & +hostb ./pasta +sleep 1 +host PS1='$ ' +host nc -w1 -6 -l -p 9999 > /tmp/ns_msg & +sleep 2 +host echo "from_ns" | nc -q0 ::1 10000 +sleep 2 +host echo +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 + +# Start passt, set common variables +hostb ./passt -P __PIDFILE__ & +sleep 1 +host echo +hout GUEST_FILES ls -1 *.c *.h *.sh Makefile | tr '\n' ' '; echo + + +test Ubuntu 14.04.5 LTS (Trusty Tahr), amd64 + +temp IMG +host wget https://cloud-images.ubuntu.com/trusty/current/trusty-server-cloudimg-amd64… -O __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 +host guestfish --rw -a __IMG__ -i rm /etc/init/cloud-final.conf +host guestfish --rw -a __IMG__ -i rm /etc/init/cloud-init-container.conf +host guestfish --rw -a __IMG__ -i rm /etc/init/cloud-init-local.conf +host guestfish --rw -a __IMG__ -i rm /etc/init/cloud-init-nonet.conf +host guestfish --rw -a __IMG__ -i rm /etc/init/cloud-init.conf +host guestfish --rw -a __IMG__ -i rm /etc/init/cloud-log-shutdown.conf +host guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/ + +host ./qrap 5 kvm -M pc -m 1024 -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none -drive file=__IMG__,if=virtio -net socket,fd=5 -net nic,model=virtio +host PS1='$ ' +sleep 2 +host apt-get update +host apt-get -y install make gcc netcat-openbsd + +host make clean +hout RET CFLAGS="-Wno-missing-field-initializers -Wno-missing-braces -Wno-type-limits" make; echo $? +check [ __RET__ -eq 0 ] + +# TODO: pasta test skipped for the moment: clone() as called by NS_CALL hangs +# with wrapper provided by glibc 2.19, probably wrong argument order. + +hint +sleep 1 + +# PIDFILE is cleaned up when the next test starts, read it now +hout PID cat __PIDFILE__ + + +test Ubuntu 14.04.5 LTS (Trusty Tahr), i386 + +temp IMG +host wget https://cloud-images.ubuntu.com/trusty/current/trusty-server-cloudimg-i386-… -O __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 +host guestfish --rw -a __IMG__ -i rm /etc/init/cloud-final.conf +host guestfish --rw -a __IMG__ -i rm /etc/init/cloud-init-container.conf +host guestfish --rw -a __IMG__ -i rm /etc/init/cloud-init-local.conf +host guestfish --rw -a __IMG__ -i rm /etc/init/cloud-init-nonet.conf +host guestfish --rw -a __IMG__ -i rm /etc/init/cloud-init.conf +host guestfish --rw -a __IMG__ -i rm /etc/init/cloud-log-shutdown.conf +host guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/ + +host ./qrap 5 kvm -M pc -m 1024 -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none -drive file=__IMG__,if=virtio -net socket,fd=5 -net nic,model=virtio +host PS1='$ ' +sleep 2 +host apt-get update +host apt-get -y install make gcc netcat-openbsd + +host make clean +hout RET CFLAGS="-Wno-missing-field-initializers -Wno-missing-braces -Wno-type-limits -Wno-sign-compare" make; echo $? +check [ __RET__ -eq 0 ] + +# TODO: pasta test skipped for the moment: clone() as called by NS_CALL hangs +# with wrapper provided by glibc 2.19, probably wrong argument order. + +hint +sleep 1 + + +test Ubuntu 14.04.5 LTS (Trusty Tahr), ppc64le + +temp IMG +host wget https://cloud-images.ubuntu.com/trusty/current/trusty-server-cloudimg-ppc64… -O __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 +host guestfish --rw -a __IMG__ -i rm /etc/init/cloud-final.conf +host guestfish --rw -a __IMG__ -i rm /etc/init/cloud-init-container.conf +host guestfish --rw -a __IMG__ -i rm /etc/init/cloud-init-local.conf +host guestfish --rw -a __IMG__ -i rm /etc/init/cloud-init-nonet.conf +host guestfish --rw -a __IMG__ -i rm /etc/init/cloud-init.conf +host guestfish --rw -a __IMG__ -i rm /etc/init/cloud-log-shutdown.conf +host guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/ + +host ./qrap 5 qemu-system-ppc64le -m 2048 -smp 2 -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none __IMG__ -net socket,fd=5 -net nic,model=virtio +host PS1='$ ' +sleep 2 +host apt-get update +host apt-get -y install make gcc netcat-openbsd + +host make clean +hout RET CFLAGS="-Wno-missing-field-initializers -Wno-missing-braces -Wno-type-limits -Wno-sign-compare" make; echo $? +check [ __RET__ -eq 0 ] + +# TODO: pasta test skipped for the moment: clone() as called by NS_CALL hangs +# with wrapper provided by glibc 2.19, probably wrong argument order. + +hint +sleep 1 +hostb reset +sleep 1 +host echo + + +test Ubuntu 16.04 LTS (Xenial Xerus), ppc64 (be) + +temp IMG +host wget https://cloud-images.ubuntu.com/xenial/current/xenial-server-cloudimg-power… -O __IMG__ +host virt-edit -a __IMG__ /lib/systemd/system/serial-getty@.service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --autologin root -8 --keep-baud 115200,38400,9600 %I $TERM/g' +host guestfish --rw -a __IMG__ -i rm /etc/systemd/system/cloud-init.target.wants/cloud-config.service +host guestfish --rw -a __IMG__ -i rm /etc/systemd/system/cloud-init.target.wants/cloud-final.service +host guestfish --rw -a __IMG__ -i rm /etc/systemd/system/cloud-init.target.wants/cloud-init-local.service +host guestfish --rw -a __IMG__ -i rm /etc/systemd/system/cloud-init.target.wants/cloud-init.service +host guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/ + +host ./qrap 5 qemu-system-ppc64 -m 1024 -M pseries -nographic -nodefaults -serial stdio -no-reboot -nographic -vga none -hda __IMG__ -net socket,fd=5 -net nic,model=virtio +host PS1='$ ' +host dhclient +host apt-get update +host apt-get -y install make gcc netcat-openbsd + +host make clean +hout RET CFLAGS="-Werror" make; echo $? +check [ __RET__ -eq 0 ] + +distro_quick_pasta_test + +hint +sleep 1 +hostb reset +sleep 1 +host echo + + +test Ubuntu 22.04 (Jammy Jellyfish), s390x +temp IMG +host wget https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-s390x.i… -O __IMG__ +host virt-edit -a __IMG__ /usr/lib/systemd/system/serial-getty@.service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --autologin root -8 --keep-baud 115200,38400,9600 %I $TERM/g' +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-config.service +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-init.service +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-init-local.service +host guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-final.service +host guestfish --rw -a __IMG__ -i rm /etc/systemd/system/multi-user.target.wants/snapd.service +host guestfish --rw -a __IMG__ -i rm /etc/systemd/system/snap.lxd.activate.service +host guestfish --rw -a __IMG__ -i rm /etc/systemd/system/snap.lxd.daemon.service +host guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/ +host ./qrap 5 qemu-system-s390x -m 2048 -smp 2 -serial stdio -nodefaults -nographic __IMG__ -net socket,fd=5 -net nic,model=virtio -device virtio-rng-ccw + +host service systemd-resolved stop +host apt-get -y remove needrestart snapd +host dhclient +sleep 2 +host apt-get update +host apt-get -y install make gcc netcat-openbsd + +host make clean +hout RET CFLAGS="-Werror" make; echo $? +check [ __RET__ -eq 0 ] + +host export SHELL="/bin/dash" +host dash +distro_quick_pasta_test + +hint +sleep 1 +hostb reset +sleep 1 +host echo + + +host kill __PID__ diff --git a/test/run b/test/run index 2586e85..dadd983 100755 --- a/test/run +++ b/test/run @@ -64,6 +64,7 @@ run() { setup build test build + test distro setup pasta test ndp -- 2.33.0
Signed-off-by: Stefano Brivio <sbrivio(a)redhat.com> --- test/README.md | 104 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 test/README.md diff --git a/test/README.md b/test/README.md new file mode 100644 index 0000000..647100f --- /dev/null +++ b/test/README.md @@ -0,0 +1,104 @@ +<!--- +SPDX-License-Identifier: AGPL-3.0-or-later +Copyright (c) 2021-2022 Red Hat GmbH +Author: Stefano Brivio <sbrivio(a)redhat.com> +--> + +# Scope + +This directory contains test cases for _passt_ and _pasta_ and a simple +POSIX shell-based framework to define them, and run them as a suite. + +These tests can be run as part of a continuous integration workflow, and are +also used to provide short usage demos, with video recording, for _passt_ and +_pasta_ basic use cases. + +# Run + +## Dependencies + +### Packages + +The tests require some package dependencies commonly available in Linux +distributions. If some packages are not available, the test groups that need +them will be selectively skipped. + +This is a non-exhaustive list of packages that might not commonly be installed +on a system, i.e. common utilities such as a shell are not included here. + +Example for Debian, and possibly most Debian-based distributions: + + build-essential git jq strace iperf3 qemu-system-x86 tmux sipcalc bc + clang-tidy cppcheck isc-dhcp-common udhcpc psmisc linux-cpupower + netcat-openbsd fakeroot lz4 lm-sensors qemu-system-arm qemu-system-ppc + qemu-system-misc qemu-system-x86` + +### Other tools + +Test measuring request-response and connect-request-response latencies use +`neper`, which is not commonly packaged by distributions and needs to be built +and installed manually: + + git clone https://github.com/google/neper + cd neper; make + cp tcp_crr tcp_rr udp_rr /usr/local/bin + +Virtual machine images are built during test executions using +[mbuto](https://mbuto.lameexcu.se/), the shell script is sourced via _git_ +as needed, so there's no need to actually install it. + +### Special requirements for continuous integration and demo modes + +Running the test suite as continuous integration or demo modes will record a +video of the steps being executed, and create binary packages. The demo mode +uses _cool-retro-term_ as terminal, whereas the continuous integration mode uses +_MATE Terminal_ by default. + +The following additional packages are commonly needed as well: + + dbus-x11 xdotool x11-utils xvfb ffmpeg mate-terminal cool-retro-term xauth + dconf-cli alien linux-perf tshark sqlite3` + +For convenience, suitable profiles for _MATE Terminal_ and _cool-retro-term_ are +provided under the `env` directory. To source them: + + dconf load /org/mate/terminal/profiles/ < env/mate-terminal.profile + cp env/cool_retro_term.sqlite ~/.local/share/cool-retro-term/QML/OfflineStorage/Databases/*.sqlite + +## Regular test + +Just issue: + + ./run + +from the `test` directory. Elevated privileges are not needed. + +## Continuous integration + +Issuing: + + ./ci + +will run the whole test suite while recording a video of the execution, and it +will also build JavaScript fragments used on http://passt.top/ for performance +data tables and links to specific video offsets. + +## Demo mode + +Issuing: + + ./demo + +will run the demo cases under `demo`, recording videos as well. + +# Framework + +The implementation of the testing framework is under `lib`, and it provides +facilities for terminal and _tmux_ session management, interpretation of test +directives, video recording, and suchlike. Test cases are organised in the +remaining directories. + +Test cases can be implemented as POSIX shell scripts, or as a set of directives, +which are not formally documented here, but should be clear enough from the +existing cases. The entry point for interpretation of test directives is +implemented in `lib/test`. -- 2.33.0