From 2e758e85a1dddb6e735383ac811659e652991343 Mon Sep 17 00:00:00 2001 From: "Matthieu Baerts (NGI0)" Date: Fri, 22 Mar 2024 15:40:03 +0100 Subject: [PATCH 1/5] kunit: catch errors with core module The assignation of KUNIT_CORE_LOADED=1 was ignoring errors from the insmod. Signed-off-by: Matthieu Baerts (NGI0) --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index b4def74..3524057 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -788,9 +788,9 @@ _kunit_result() { run_kunit_core() { [ "\${KUNIT_CORE_LOADED}" = 1 ] && return 0 + KUNIT_CORE_LOADED=1 _tap "${RESULTS_DIR}/kunit" insmod ${VIRTME_BUILD_DIR}/lib/kunit/kunit.ko - KUNIT_CORE_LOADED=1 } # \$1: .ko path From 0e1f26ca30f4aa69ee2fc624358d352925278493 Mon Sep 17 00:00:00 2001 From: "Matthieu Baerts (NGI0)" Date: Fri, 22 Mar 2024 16:13:55 +0100 Subject: [PATCH 2/5] packetdrill: always limit to nproc in debug mode Not only for the CI, when the debug mode is used (or QEmu is used without KVM support). Signed-off-by: Matthieu Baerts (NGI0) --- entrypoint.sh | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 3524057..7ba0f2c 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -622,9 +622,6 @@ prepare() { local mode no_tap=1 if is_ci; then no_tap=0 # we want subtests - if [ "${mode}" == "debug" ]; then - INPUT_MAX_THREADS=${INPUT_CPUS} ## avoid too many concurrent work - fi fi cat < "${VIRTME_SCRIPT}" @@ -646,8 +643,9 @@ export SELFTESTS_MPTCP_LIB_NO_TAP="${no_tap}" set_max_threads() { # if QEmu without KVM support - if [ "\$(cat /sys/devices/virtual/dmi/id/sys_vendor)" = "QEMU" ] && - [ "\$(cat /sys/devices/system/clocksource/clocksource0/current_clocksource)" != "kvm-clock" ]; then + if [ "${mode}" == "debug" ] || + { [ "\$(cat /sys/devices/virtual/dmi/id/sys_vendor)" = "QEMU" ] && + [ "\$(cat /sys/devices/system/clocksource/clocksource0/current_clocksource)" != "kvm-clock" ]; }; then MAX_THREADS=$((MAX_THREADS / 2)) # avoid too many concurrent work fi } From 522683f70cdc63d26f708426ba89369efea87555 Mon Sep 17 00:00:00 2001 From: "Matthieu Baerts (NGI0)" Date: Fri, 22 Mar 2024 16:18:16 +0100 Subject: [PATCH 3/5] kunit: keep the same title in case of error So it is known as the same test. Signed-off-by: Matthieu Baerts (NGI0) --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index 7ba0f2c..5c2cffd 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -779,7 +779,7 @@ _kunit_result() { fi if ! cat "\${1}"; then - echo "not ok 1 test: no kunit result \${2} # exit=1" + echo "not ok 1 test: \${2} # no kunit result" return 1 fi } From 911044346ad0337343c78f43a6ab8e791f0335d0 Mon Sep 17 00:00:00 2001 From: "Matthieu Baerts (NGI0)" Date: Fri, 22 Mar 2024 16:39:12 +0100 Subject: [PATCH 4/5] summary: add missing kunit tests Only kunit (core) was listed, because the others doesn't use '_tap()'. Signed-off-by: Matthieu Baerts (NGI0) --- entrypoint.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index 5c2cffd..0513607 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1289,9 +1289,20 @@ _has_failed_tests() { grep -q "^not ok " "${1:-${TESTS_SUMMARY}}" } +# $1: prefix +_print_tests_results_subtests() { local tap + for tap in "${RESULTS_DIR}/${1}"*.tap; do + [[ "${tap}" = *"_*.tap" ]] && continue + if ! grep -q "^not ok " "${tap}"; then + echo "ok 1 test: $(basename "${tap}" ".tap")" + fi + done +} + _print_tests_result() { echo "All tests:" - grep --no-filename -e "^ok [0-9]\+ test:" -e "^not ok " "${RESULTS_DIR}"/*.tap + grep --no-filename -e "^ok 1 test: " -e "^not ok " "${RESULTS_DIR}"/*.tap + _print_tests_results_subtests "kunit_" } _print_failed_tests() { local t From b27adb3c9fd28a13a341a0a0f7e9e4a9a34c2706 Mon Sep 17 00:00:00 2001 From: "Matthieu Baerts (NGI0)" Date: Fri, 22 Mar 2024 19:19:00 +0100 Subject: [PATCH 5/5] packetdrill: track the subtests This use a new --tap option from 'run_all'. It will generate a .tap file with the subtests. The script now has to check that a .tap file has been generated. If not, a file is created because there was a critical error. Signed-off-by: Matthieu Baerts (NGI0) --- entrypoint.sh | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 0513607..17f8a3c 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -874,11 +874,27 @@ run_mptcp_connect_mmap() { _run_mptcp_connect_opt mmap -m mmap } +# \$1: packetdrill TAP file, \$2: TAP prefix +_packetdrill_result() { + if grep -q "^TAP version 13" "\${1}" 2>/dev/null; then + sed -i "s#\${PWD}/##g" "\${1}" # remove long path + return 0 + fi + + { + echo "TAP version 13" + echo "1..1" + echo "not ok 1 test: \${2} # no result" + } > "\${1}" + + return 1 +} + # \$1: pktd_dir (e.g. mptcp/dss) run_packetdrill_one() { local pktd_dir pktd tap rc=0 pktd_dir="\${1}" - pktd="\${pktd_dir#*/}" - tap="packetdrill_\${pktd//\//_}" + pktd="\$(basename "\${pktd_dir}" ".pkt")" # remove ext just in case + tap="packetdrill_\${pktd}" if [ "\${pktd}" = "common" ]; then return 0 @@ -888,8 +904,9 @@ run_packetdrill_one() { local pktd_dir pktd tap rc=0 log_section_start "Packetdrill Test: \${pktd}" cd /opt/packetdrill/gtests/net/ - PYTHONUNBUFFERED=1 _tap "${RESULTS_DIR}/\${tap}" \ - ./packetdrill/run_all.py -l -v -P \${MAX_THREADS} \${pktd_dir} || rc=\${?} + PYTHONUNBUFFERED=1 ./packetdrill/run_all.py -t "${RESULTS_DIR}" \ + -l -v -P \${MAX_THREADS} \${pktd_dir} || rc=\${?} + _packetdrill_result "${RESULTS_DIR}/\${tap}.tap" "\${tap}" || rc=\${?} log_section_end return \${rc} @@ -1303,6 +1320,7 @@ _print_tests_result() { echo "All tests:" grep --no-filename -e "^ok 1 test: " -e "^not ok " "${RESULTS_DIR}"/*.tap _print_tests_results_subtests "kunit_" + _print_tests_results_subtests "packetdrill_" } _print_failed_tests() { local t