From 900dc36af66c33f8c0ce4f0c0d1d3f5bda119580 Mon Sep 17 00:00:00 2001 From: Mazunki Hoksaas Date: Tue, 14 Oct 2025 14:46:04 +0200 Subject: [PATCH 01/10] use sane shebang path for bash --- test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test.sh b/test.sh index 52e8275c0..79018d896 100755 --- a/test.sh +++ b/test.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Run all known IncludeOS tests. # From 222a15bde884ce9e4282b599d338c04fd259d208 Mon Sep 17 00:00:00 2001 From: Mazunki Hoksaas Date: Tue, 14 Oct 2025 14:46:38 +0200 Subject: [PATCH 02/10] nit: formatting --- test.sh | 60 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/test.sh b/test.sh index 79018d896..0128b42b8 100755 --- a/test.sh +++ b/test.sh @@ -13,7 +13,7 @@ steps=0 fails=0 failed_tests=() -success(){ +success() { echo "" if [[ $1 =~ ^[0-9]+$ ]]; then echo -n "👷💬 Step $1 succeeded " @@ -26,13 +26,13 @@ success(){ echo "" } -fail(){ +fail() { echo "" echo "👷⛔ Step $1 failed ($2)" failed_tests+=("step $1: $2") } -run(){ +run() { steps=$((steps + 1)) echo "" echo "🚧 Step $steps) $2" @@ -40,50 +40,51 @@ run(){ # This will print the body of a bash function, but won't expand variables # inside. It works well for bundling simple commands together and allows us to # print them without wrapping them in qotes. - declare -f $1 | sed '1d;2d;$d' | sed 's/^[[:space:]]*//' # Print the function body + declare -f "$1" | sed '1d;2d;$d' | sed 's/^[[:space:]]*//' # Print the function body echo "-------------------------------------- 💣 --------------------------------------" - if [ ! $DRY_RUN ] + if [ ! "$DRY_RUN" ] then $1 fi - if [ $? -eq 0 ]; then + errno=$? + if [ $errno -eq 0 ]; then success $steps else - echo "‼️ Error: Command failed with exit status $?" + echo "‼️ Error: Command failed with exit status $errno" fail $steps "$1" fails=$((fails + 1)) return $? fi } -unittests(){ +unittests() { nix-build unittests.nix } -build_chainloader(){ - nix-build $CCACHE_FLAG chainloader.nix +build_chainloader() { + nix-build "${CCACHE_FLAG[@]}" chainloader.nix } -build_example(){ - nix-build $CCACHE_FLAG example.nix +build_example() { + nix-build "${CCACHE_FLAG[@]}" example.nix } -multicore_subset(){ - nix-shell --pure --arg smp true $CCACHE_FLAG --argstr unikernel ./test/kernel/integration/smp --run ./test.py +multicore_subset() { + nix-shell --pure --arg smp true "${CCACHE_FLAG[@]}" --argstr unikernel ./test/kernel/integration/smp --run ./test.py # The following tests are not using multiple CPU's, but have been equippedd with some anyway # to make sure core functionality is not broken by missing locks etc. when waking up more cores. - nix-shell --pure --arg smp true $CCACHE_FLAG --argstr unikernel ./test/net/integration/udp --run ./test.py - nix-shell --pure --arg smp true $CCACHE_FLAG --argstr unikernel ./test/kernel/integration/paging --run ./test.py + nix-shell --pure --arg smp true "${CCACHE_FLAG[@]}" --argstr unikernel ./test/net/integration/udp --run ./test.py + nix-shell --pure --arg smp true "${CCACHE_FLAG[@]}" --argstr unikernel ./test/kernel/integration/paging --run ./test.py } -smoke_tests(){ - nix-shell --pure $CCACHE_FLAG --argstr unikernel ./test/net/integration/udp --run ./test.py - nix-shell --pure $CCACHE_FLAG --argstr unikernel ./test/net/integration/tcp --run ./test.py - nix-shell --pure $CCACHE_FLAG --argstr unikernel ./test/kernel/integration/paging --run ./test.py - nix-shell --pure $CCACHE_FLAG --argstr unikernel ./test/kernel/integration/smp --run ./test.py +smoke_tests() { + nix-shell --pure "${CCACHE_FLAG[@]}" --argstr unikernel ./test/net/integration/udp --run ./test.py + nix-shell --pure "${CCACHE_FLAG[@]}" --argstr unikernel ./test/net/integration/tcp --run ./test.py + nix-shell --pure "${CCACHE_FLAG[@]}" --argstr unikernel ./test/kernel/integration/paging --run ./test.py + nix-shell --pure "${CCACHE_FLAG[@]}" --argstr unikernel ./test/kernel/integration/smp --run ./test.py } run unittests "Build and run unit tests" @@ -157,19 +158,18 @@ run_testsuite() { echo "🚧 Step $steps.$substeps" echo "📂 $subfolder" echo "⚙️ Running this command:" - echo $cmd + printf '%s\n' "$cmd" echo "-------------------------------------- 💣 --------------------------------------" - if [ ! $DRY_RUN ] + if [ ! "$DRY_RUN" ] then - $cmd - fi - if [ $? -eq 0 ]; then - success "$steps.$substeps" - else - fail "$steps.$substeps" "$cmd" - subfails=$((subfails + 1)) + if $cmd; then + success "$steps.$substeps" + else + fail "$steps.$substeps" "$cmd" + subfails=$((subfails + 1)) + fi fi substeps=$((substeps + 1)) From b45141cc44e3c117d692f69bf8c1d4abde483463 Mon Sep 17 00:00:00 2001 From: Mazunki Hoksaas Date: Tue, 14 Oct 2025 15:39:50 +0200 Subject: [PATCH 03/10] replace variables with booleans --- test.sh | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/test.sh b/test.sh index 0128b42b8..af82c3f77 100755 --- a/test.sh +++ b/test.sh @@ -5,9 +5,9 @@ # A lot of these tests require vmrunner and a network bridge. # See https://github.com/includeos/vmrunner/pull/31 -: "${QUICK_SMOKE:=}" # Define this to only do a ~1-5 min. smoke test. -: "${DRY_RUN:=}" # Define this to expand all steps without running any -: "${CCACHE_FLAG:=}" # Define as "--arg withCcache true" to enable ccache. +: "${QUICK_SMOKE:=false}" # Set to "true" for a ~1–5 min smoke test. +: "${DRY_RUN:=false}" # Set to "true" to print steps without running them. +: "${USE_CCACHE:=false}" # Set to "true" to enable ccache. steps=0 fails=0 @@ -44,7 +44,7 @@ run() { echo "-------------------------------------- 💣 --------------------------------------" - if [ ! "$DRY_RUN" ] + if [ "$DRY_RUN" != true ] then $1 fi @@ -64,27 +64,27 @@ unittests() { } build_chainloader() { - nix-build "${CCACHE_FLAG[@]}" chainloader.nix + nix-build --arg withCcache "${USE_CCACHE}" chainloader.nix } build_example() { - nix-build "${CCACHE_FLAG[@]}" example.nix + nix-build --arg withCcache "${USE_CCACHE}" example.nix } multicore_subset() { - nix-shell --pure --arg smp true "${CCACHE_FLAG[@]}" --argstr unikernel ./test/kernel/integration/smp --run ./test.py + nix-shell --pure --arg smp true --arg withCcache "${USE_CCACHE}" --argstr unikernel ./test/kernel/integration/smp --run ./test.py # The following tests are not using multiple CPU's, but have been equippedd with some anyway # to make sure core functionality is not broken by missing locks etc. when waking up more cores. - nix-shell --pure --arg smp true "${CCACHE_FLAG[@]}" --argstr unikernel ./test/net/integration/udp --run ./test.py - nix-shell --pure --arg smp true "${CCACHE_FLAG[@]}" --argstr unikernel ./test/kernel/integration/paging --run ./test.py + nix-shell --pure --arg smp true --arg withCcache "${USE_CCACHE}" --argstr unikernel ./test/net/integration/udp --run ./test.py + nix-shell --pure --arg smp true --arg withCcache "${USE_CCACHE}" --argstr unikernel ./test/kernel/integration/paging --run ./test.py } smoke_tests() { - nix-shell --pure "${CCACHE_FLAG[@]}" --argstr unikernel ./test/net/integration/udp --run ./test.py - nix-shell --pure "${CCACHE_FLAG[@]}" --argstr unikernel ./test/net/integration/tcp --run ./test.py - nix-shell --pure "${CCACHE_FLAG[@]}" --argstr unikernel ./test/kernel/integration/paging --run ./test.py - nix-shell --pure "${CCACHE_FLAG[@]}" --argstr unikernel ./test/kernel/integration/smp --run ./test.py + nix-shell --pure --arg withCcache "${USE_CCACHE}" --argstr unikernel ./test/net/integration/udp --run ./test.py + nix-shell --pure --arg withCcache "${USE_CCACHE}" --argstr unikernel ./test/net/integration/tcp --run ./test.py + nix-shell --pure --arg withCcache "${USE_CCACHE}" --argstr unikernel ./test/kernel/integration/paging --run ./test.py + nix-shell --pure --arg withCcache "${USE_CCACHE}" --argstr unikernel ./test/kernel/integration/smp --run ./test.py } run unittests "Build and run unit tests" @@ -152,7 +152,7 @@ run_testsuite() { # The command to run, as string to be able to print the fully expanded command - cmd="nix-shell --pure $CCACHE_FLAG --argstr unikernel $subfolder --run ./test.py" + cmd="nix-shell --pure --arg withCcache ${USE_CCACHE} --argstr unikernel $subfolder --run ./test.py" echo "" echo "🚧 Step $steps.$substeps" From 32408171c2683caec31e77b09cdb345d673300a9 Mon Sep 17 00:00:00 2001 From: Mazunki Hoksaas Date: Tue, 14 Oct 2025 14:55:07 +0200 Subject: [PATCH 04/10] convert test sections into functions --- test.sh | 127 ++++++++++++++++++++++++++++++-------------------------- 1 file changed, 67 insertions(+), 60 deletions(-) diff --git a/test.sh b/test.sh index af82c3f77..df59bf307 100755 --- a/test.sh +++ b/test.sh @@ -87,32 +87,6 @@ smoke_tests() { nix-shell --pure --arg withCcache "${USE_CCACHE}" --argstr unikernel ./test/kernel/integration/smp --run ./test.py } -run unittests "Build and run unit tests" - -run build_chainloader "Build the 32-bit chainloader" - -run build_example "Build the basic example" - -run multicore_subset "Run selected tests with multicore enabled" - -if [ "$QUICK_SMOKE" ]; then - - run smoke_tests "Build and run a few key smoke tests" - - if [ $fails -eq 0 ]; then - echo "" - echo "👷💬 A lot of things are working! 💪" - else - echo "" - echo "👷🧰 $fails / $steps steps failed. There's some work left to do. 🛠 " - echo "" - exit 1 - fi - exit 0 -fi - -# Continuing from here will run all integration tests. - run_testsuite() { local base_folder="$1" shift @@ -184,46 +158,79 @@ run_testsuite() { fi } -# -# Kernel tests -# -exclusions=( - "LiveUpdate" # Missing includes - "context" # Outdated - references nonexisting OS::heap_end() - "fiber" # Crashes - "modules" # Requires 32-bit build, which our shell.nix is not set up for -) +kernel_tests() { + local exclusions=( + "LiveUpdate" # Missing includes + "context" # Outdated - references nonexisting OS::heap_end() + "fiber" # Crashes + "modules" # Requires 32-bit build, which our shell.nix is not set up for + ) -run_testsuite "./test/kernel/integration" "${exclusions[@]}" + run_testsuite "./test/kernel/integration" "${exclusions[@]}" +} -# -# C++ STL runtime tests -# -exclusions=( +stl_tests() { + local exclusions=() -) + run_testsuite "./test/stl/integration" "${exclusions[@]}" +} -run_testsuite "./test/stl/integration" "${exclusions[@]}" +net_tests() { + local exclusions=( + "dhclient" # Times out because it requires DHCP server on the bridge. + "dhcpd" # Times out, requires certain routes to be set up. Seems easy. + "dhcpd_dhclient_linux" # We can't run userspace tests with this setup yet. + "gateway" # Requires NaCl which is currently not integrated + "http" # Linking fails, undefined ref to http_parser_parse_url, http_parser_execute + "microLB" # Missing dependencies: microLB, diskbuilder, os_add_os_library + "nat" # Times out after 3 / 6 tests seem to pass. Might be a legit bug here. + "router" # Times out, requies sudo and has complex network setup. + "router6" # Times out: iperf3: error - unable to connect to server + "vlan" # Times out. Looks similar to the nat test - maybe similar cause? + "websocket" # Linking fails, undefined ref to http_parser_parse_url, http_parser_execute + ) + + run_testsuite "./test/net/integration" "${exclusions[@]}" +} -# -# Networking tests -# -exclusions=( - "dhclient" # Times out because it requires DHCP server on the bridge. - "dhcpd" # Times out, requires certain routes to be set up. Seems easy. - "dhcpd_dhclient_linux" # We can't run userspace tests with this setup yet. - "gateway" # Requires NaCl which is currently not integrated - "http" # Linking fails, undefined ref to http_parser_parse_url, http_parser_execute - "microLB" # Missing dependencies: microLB, diskbuilder, os_add_os_library - "nat" # Times out after 3 / 6 tests seem to pass. Might be a legit bug here. - "router" # Times out, requies sudo and has complex network setup. - "router6" # Times out: iperf3: error - unable to connect to server - "vlan" # Times out. Looks similar to the nat test - maybe similar cause? - "websocket" # Linking fails, undefined ref to http_parser_parse_url, http_parser_execute -) - -run_testsuite "./test/net/integration" "${exclusions[@]}" + +run_all() { + run unittests "Build and run unit tests" + + run build_chainloader "Build the 32-bit chainloader" + + run build_example "Build the basic example" + + run multicore_subset "Run selected tests with multicore enabled" + + if [ "$QUICK_SMOKE" ]; then + + run smoke_tests "Build and run a few key smoke tests" + + if [ $fails -eq 0 ]; then + echo "" + echo "👷💬 A lot of things are working! 💪" + else + echo "" + echo "👷🧰 $fails / $steps steps failed. There's some work left to do. 🛠 " + echo "" + exit 1 + fi + exit 0 + fi + + # Continuing from here will run all integration tests. + + run kernel_tests "Run kernel integration tests" + + run stl_tests "Run C++ STL integration tests" + + run net_tests "Run networking integration tests" + +} + +run_all echo -e "\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" From 9f49d7f9b309d2d90edf254474a4c8eb5e22c0bf Mon Sep 17 00:00:00 2001 From: Mazunki Hoksaas Date: Tue, 14 Oct 2025 14:56:12 +0200 Subject: [PATCH 05/10] entry point --- test.sh | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/test.sh b/test.sh index df59bf307..a86555e3b 100755 --- a/test.sh +++ b/test.sh @@ -230,7 +230,41 @@ run_all() { } -run_all +list_targets(){ + cat < Date: Tue, 14 Oct 2025 15:17:21 +0200 Subject: [PATCH 06/10] separate single test from testsuite --- test.sh | 45 ++++++++++++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 15 deletions(-) diff --git a/test.sh b/test.sh index a86555e3b..6aa402a88 100755 --- a/test.sh +++ b/test.sh @@ -87,6 +87,34 @@ smoke_tests() { nix-shell --pure --arg withCcache "${USE_CCACHE}" --argstr unikernel ./test/kernel/integration/smp --run ./test.py } +run_test() { + if [ "$DRY_RUN" ]; then return; fi + subfolder="$1"; shift + + # The command to run, as string to be able to print the fully expanded command + cmd=( + nix-shell + --pure + --arg withCcache "$CCACHE_FLAG" + --argstr unikernel "$subfolder" + --run "./test.py" + ) + + echo "⚙️ Running this command:" + printf '%s\n' "${cmd[*]}" + echo "-------------------------------------- 💣 --------------------------------------" + + "${cmd[@]}" + errno=$? + if $? -eq 0; then + success "$steps.$substeps" + else + fail "$steps.$substeps" "${cmd[*]}" + fi + + return $errno +} + run_testsuite() { local base_folder="$1" shift @@ -125,25 +153,12 @@ run_testsuite() { fi - # The command to run, as string to be able to print the fully expanded command - cmd="nix-shell --pure --arg withCcache ${USE_CCACHE} --argstr unikernel $subfolder --run ./test.py" - echo "" echo "🚧 Step $steps.$substeps" echo "📂 $subfolder" - echo "⚙️ Running this command:" - printf '%s\n' "$cmd" - echo "-------------------------------------- 💣 --------------------------------------" - - if [ ! "$DRY_RUN" ] - then - if $cmd; then - success "$steps.$substeps" - else - fail "$steps.$substeps" "$cmd" - subfails=$((subfails + 1)) - fi + if ! run_test "$subfolder"; then + subfails=$((subfails + 1)) fi substeps=$((substeps + 1)) From c01c815020fc75ea36634874dc9122905d524139 Mon Sep 17 00:00:00 2001 From: Mazunki Hoksaas Date: Tue, 14 Oct 2025 15:22:49 +0200 Subject: [PATCH 07/10] facilitate custom tests --- test.sh | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/test.sh b/test.sh index 6aa402a88..26d51578a 100755 --- a/test.sh +++ b/test.sh @@ -209,6 +209,17 @@ net_tests() { run_testsuite "./test/net/integration" "${exclusions[@]}" } +custom_tests() { + # write your custom tests here + local exclusions=() + + # for testing all subdirectories in path + : run_testsuite "./test/path/to/custom/tests*" "${exclusions[@]}" + + # for testing a single test + : run_test "./test/path/to/single_test*" +} + run_all() { run unittests "Build and run unit tests" @@ -250,7 +261,7 @@ list_targets(){ Available targets: unittests build_chainloader build_example multicore_subset smoke_tests kernel_tests - stl_tests net_tests all + stl_tests net_tests custom_tests EOF } @@ -260,7 +271,7 @@ main() { else for t in "$@"; do case "$t" in - unittests|build_chainloader|build_example|multicore_subset|smoke_tests|kernel_tests|stl_tests|net_tests) + unittests|build_chainloader|build_example|multicore_subset|smoke_tests|kernel_tests|stl_tests|net_tests|custom_tests) run "$t" "Run target: $t" ;; all) From fc0c2e52d819ee19c86b2506a1a3d14ccaebd32c Mon Sep 17 00:00:00 2001 From: Mazunki Hoksaas Date: Tue, 14 Oct 2025 17:22:30 +0200 Subject: [PATCH 08/10] consolidate testsuite and function runner --- test.sh | 120 ++++++++++++++++++++++++++------------------------------ 1 file changed, 56 insertions(+), 64 deletions(-) diff --git a/test.sh b/test.sh index 26d51578a..ac2f50e82 100755 --- a/test.sh +++ b/test.sh @@ -14,16 +14,14 @@ fails=0 failed_tests=() success() { - echo "" if [[ $1 =~ ^[0-9]+$ ]]; then echo -n "👷💬 Step $1 succeeded " for ((i=1; i<=$1; i++)); do echo -n "👏" done else - echo "👷💬 Step $1 succeeded ✅" + echo -n "👷💬 Step $1 succeeded ✅" fi - echo "" } fail() { @@ -32,33 +30,6 @@ fail() { failed_tests+=("step $1: $2") } -run() { - steps=$((steps + 1)) - echo "" - echo "🚧 Step $steps) $2" - echo "⚙️ Running this command:" - # This will print the body of a bash function, but won't expand variables - # inside. It works well for bundling simple commands together and allows us to - # print them without wrapping them in qotes. - declare -f "$1" | sed '1d;2d;$d' | sed 's/^[[:space:]]*//' # Print the function body - echo "-------------------------------------- 💣 --------------------------------------" - - - if [ "$DRY_RUN" != true ] - then - $1 - fi - errno=$? - if [ $errno -eq 0 ]; then - success $steps - else - echo "‼️ Error: Command failed with exit status $errno" - fail $steps "$1" - fails=$((fails + 1)) - return $? - fi -} - unittests() { nix-build unittests.nix } @@ -87,32 +58,55 @@ smoke_tests() { nix-shell --pure --arg withCcache "${USE_CCACHE}" --argstr unikernel ./test/kernel/integration/smp --run ./test.py } -run_test() { - if [ "$DRY_RUN" ]; then return; fi +run() { + if [ "$DRY_RUN" = true ]; then + echo "-------------------------------------- 💣 --------------------------------------" + return; + fi + + echo "-------------------------------------- 🗲 --------------------------------------" + "${@}" + errno=$? + echo "-------------------------------------- 󱦟 --------------------------------------" + + if [ $errno -eq 0 ]; then + success "$steps.$substeps" + else + fail "$steps.$substeps" "${cmd[*]}" + fi + printf "\n\n\n" +} + +run_single_test() { subfolder="$1"; shift - # The command to run, as string to be able to print the fully expanded command cmd=( nix-shell --pure - --arg withCcache "$CCACHE_FLAG" + --arg withCcache "$USE_CCACHE" --argstr unikernel "$subfolder" --run "./test.py" ) echo "⚙️ Running this command:" - printf '%s\n' "${cmd[*]}" - echo "-------------------------------------- 💣 --------------------------------------" + printf '%q ' "${cmd[@]}" + printf '\n' - "${cmd[@]}" - errno=$? - if $? -eq 0; then - success "$steps.$substeps" - else - fail "$steps.$substeps" "${cmd[*]}" - fi + run "${cmd[@]}" + return $? +} - return $errno +run_function() { + steps=$((steps + 1)) + echo "🚧 Step ${steps}: $2" + echo "⚙️ Running this command:" + # This will print the body of a bash function, but won't expand variables + # inside. It works well for bundling simple commands together and allows us to + # print them without wrapping them in qotes. + declare -f "$1" | sed '1d;2d;$d' | sed 's/^[[:space:]]*//' # Print the function body + + run "$1" + return $? } run_testsuite() { @@ -120,11 +114,9 @@ run_testsuite() { shift local exclusion_list=("$@") - steps=$((steps + 1)) - substeps=1 + substeps=0 subfails=0 - echo "" echo "====================================== 🚜 ======================================" echo "" echo "🚧 $steps) Running integration tests in $base_folder" @@ -152,17 +144,14 @@ run_testsuite() { continue fi - - echo "" + substeps=$((substeps + 1)) echo "🚧 Step $steps.$substeps" echo "📂 $subfolder" - if ! run_test "$subfolder"; then + if ! run_single_test "$subfolder"; then subfails=$((subfails + 1)) fi - substeps=$((substeps + 1)) - done if [ $subfails -eq 0 ]; then @@ -171,6 +160,9 @@ run_testsuite() { fail $steps fails=$((fails + 1)) fi + + echo "Test suite finished (ran ${substeps} tests)" + echo "--------------------------------------------------------------------------------" } kernel_tests() { @@ -210,7 +202,7 @@ net_tests() { } custom_tests() { - # write your custom tests here + # add your custom tests here local exclusions=() # for testing all subdirectories in path @@ -222,17 +214,17 @@ custom_tests() { run_all() { - run unittests "Build and run unit tests" + run_function unittests "Build and run unit tests" - run build_chainloader "Build the 32-bit chainloader" + run_function build_chainloader "Build the 32-bit chainloader" - run build_example "Build the basic example" + run_function build_example "Build the basic example" - run multicore_subset "Run selected tests with multicore enabled" + run_function multicore_subset "Run selected tests with multicore enabled" - if [ "$QUICK_SMOKE" ]; then + if [ "$QUICK_SMOKE" = true ]; then - run smoke_tests "Build and run a few key smoke tests" + run_function smoke_tests "Build and run a few key smoke tests" if [ $fails -eq 0 ]; then echo "" @@ -248,11 +240,11 @@ run_all() { # Continuing from here will run all integration tests. - run kernel_tests "Run kernel integration tests" + run_function kernel_tests "Run kernel integration tests" - run stl_tests "Run C++ STL integration tests" + run_function stl_tests "Run C++ STL integration tests" - run net_tests "Run networking integration tests" + run_function net_tests "Run networking integration tests" } @@ -272,7 +264,7 @@ main() { for t in "$@"; do case "$t" in unittests|build_chainloader|build_example|multicore_subset|smoke_tests|kernel_tests|stl_tests|net_tests|custom_tests) - run "$t" "Run target: $t" + run_function "$t" "Run target: $t" ;; all) run_all @@ -304,7 +296,7 @@ else echo "" echo "Failed tests:" for t in "${failed_tests[@]}"; do - echo "$t" + printf '%s\n' "$t" done exit 1 From 6679c45e80ec3cc88551799592aba8e63b43b6ea Mon Sep 17 00:00:00 2001 From: Mazunki Hoksaas Date: Tue, 14 Oct 2025 17:23:42 +0200 Subject: [PATCH 09/10] permit silencing test output --- test.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/test.sh b/test.sh index ac2f50e82..1202f524f 100755 --- a/test.sh +++ b/test.sh @@ -5,9 +5,11 @@ # A lot of these tests require vmrunner and a network bridge. # See https://github.com/includeos/vmrunner/pull/31 -: "${QUICK_SMOKE:=false}" # Set to "true" for a ~1–5 min smoke test. -: "${DRY_RUN:=false}" # Set to "true" to print steps without running them. -: "${USE_CCACHE:=false}" # Set to "true" to enable ccache. +: "${QUICK_SMOKE:=false}" # Set to "true" for a ~1–5 min smoke test. +: "${DRY_RUN:=false}" # Set to "true" to print steps without running them. +: "${USE_CCACHE:=false}" # Set to "true" to enable ccache. +: "${TESTS_STDOUT:=/dev/stdout}" # Set to /dev/null (or a file) to silence stdout of tests +: "${TESTS_STDERR:=/dev/stderr}" # Set to /dev/null (or a file) to silence stderr of tests steps=0 fails=0 @@ -65,7 +67,7 @@ run() { fi echo "-------------------------------------- 🗲 --------------------------------------" - "${@}" + "${@}" >"${TESTS_STDOUT}" 2>"${TESTS_STDERR}" errno=$? echo "-------------------------------------- 󱦟 --------------------------------------" From 441ac73cea6b19a71db3815474fd44381095ebf2 Mon Sep 17 00:00:00 2001 From: Mazunki Hoksaas Date: Tue, 14 Oct 2025 17:44:59 +0200 Subject: [PATCH 10/10] reordering and documenting --- test.sh | 94 +++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 61 insertions(+), 33 deletions(-) diff --git a/test.sh b/test.sh index 1202f524f..135acf088 100755 --- a/test.sh +++ b/test.sh @@ -11,10 +11,16 @@ : "${TESTS_STDOUT:=/dev/stdout}" # Set to /dev/null (or a file) to silence stdout of tests : "${TESTS_STDERR:=/dev/stderr}" # Set to /dev/null (or a file) to silence stderr of tests +# +# counters +# steps=0 fails=0 failed_tests=() +# +# helpers +# success() { if [[ $1 =~ ^[0-9]+$ ]]; then echo -n "👷💬 Step $1 succeeded " @@ -32,34 +38,9 @@ fail() { failed_tests+=("step $1: $2") } -unittests() { - nix-build unittests.nix -} - -build_chainloader() { - nix-build --arg withCcache "${USE_CCACHE}" chainloader.nix -} - -build_example() { - nix-build --arg withCcache "${USE_CCACHE}" example.nix -} - -multicore_subset() { - nix-shell --pure --arg smp true --arg withCcache "${USE_CCACHE}" --argstr unikernel ./test/kernel/integration/smp --run ./test.py - - # The following tests are not using multiple CPU's, but have been equippedd with some anyway - # to make sure core functionality is not broken by missing locks etc. when waking up more cores. - nix-shell --pure --arg smp true --arg withCcache "${USE_CCACHE}" --argstr unikernel ./test/net/integration/udp --run ./test.py - nix-shell --pure --arg smp true --arg withCcache "${USE_CCACHE}" --argstr unikernel ./test/kernel/integration/paging --run ./test.py -} - -smoke_tests() { - nix-shell --pure --arg withCcache "${USE_CCACHE}" --argstr unikernel ./test/net/integration/udp --run ./test.py - nix-shell --pure --arg withCcache "${USE_CCACHE}" --argstr unikernel ./test/net/integration/tcp --run ./test.py - nix-shell --pure --arg withCcache "${USE_CCACHE}" --argstr unikernel ./test/kernel/integration/paging --run ./test.py - nix-shell --pure --arg withCcache "${USE_CCACHE}" --argstr unikernel ./test/kernel/integration/smp --run ./test.py -} - +# +# runners +# run() { if [ "$DRY_RUN" = true ]; then echo "-------------------------------------- 💣 --------------------------------------" @@ -167,6 +148,42 @@ run_testsuite() { echo "--------------------------------------------------------------------------------" } +# +# function suites +# used as targets for `./test.sh ...` +# +unittests() { + nix-build unittests.nix +} + +build_chainloader() { + nix-build --arg withCcache "${USE_CCACHE}" chainloader.nix +} + +build_example() { + nix-build --arg withCcache "${USE_CCACHE}" example.nix +} + +multicore_subset() { + nix-shell --pure --arg smp true --arg withCcache "${USE_CCACHE}" --argstr unikernel ./test/kernel/integration/smp --run ./test.py + + # The following tests are not using multiple CPU's, but have been equippedd with some anyway + # to make sure core functionality is not broken by missing locks etc. when waking up more cores. + nix-shell --pure --arg smp true --arg withCcache "${USE_CCACHE}" --argstr unikernel ./test/net/integration/udp --run ./test.py + nix-shell --pure --arg smp true --arg withCcache "${USE_CCACHE}" --argstr unikernel ./test/kernel/integration/paging --run ./test.py +} + +smoke_tests() { + nix-shell --pure --arg withCcache "${USE_CCACHE}" --argstr unikernel ./test/net/integration/udp --run ./test.py + nix-shell --pure --arg withCcache "${USE_CCACHE}" --argstr unikernel ./test/net/integration/tcp --run ./test.py + nix-shell --pure --arg withCcache "${USE_CCACHE}" --argstr unikernel ./test/kernel/integration/paging --run ./test.py + nix-shell --pure --arg withCcache "${USE_CCACHE}" --argstr unikernel ./test/kernel/integration/smp --run ./test.py +} + +# +# wrappers for testsuites +# also acts as wrappers for `./test.sh ...` +# kernel_tests() { local exclusions=( "LiveUpdate" # Missing includes @@ -184,7 +201,6 @@ stl_tests() { run_testsuite "./test/stl/integration" "${exclusions[@]}" } - net_tests() { local exclusions=( "dhclient" # Times out because it requires DHCP server on the bridge. @@ -214,10 +230,19 @@ custom_tests() { : run_test "./test/path/to/single_test*" } +# +# entry points +# run_all() { + # + # unit tests + # run_function unittests "Build and run unit tests" + # + # build tests + # run_function build_chainloader "Build the 32-bit chainloader" run_function build_example "Build the basic example" @@ -240,7 +265,7 @@ run_all() { exit 0 fi - # Continuing from here will run all integration tests. + # all integration tests should go here run_function kernel_tests "Run kernel integration tests" @@ -250,7 +275,7 @@ run_all() { } -list_targets(){ +list_targets() { cat <