From 68102d9c3df602d2d12656c98a7d105a22bd5cf9 Mon Sep 17 00:00:00 2001 From: Alfred Bratterud Date: Sat, 7 Sep 2024 19:57:10 +0200 Subject: [PATCH 1/3] test: Enable ccache by default for test runs --- test.sh | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/test.sh b/test.sh index 4e2821c9f..5968ba0ef 100755 --- a/test.sh +++ b/test.sh @@ -7,6 +7,7 @@ : "${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:=--arg withCcache true}" # Undefine to dosable ccache. steps=0 fails=0 @@ -62,18 +63,18 @@ unittests(){ } build_chainloader(){ - nix-build chainloader.nix + nix-build $CCACHE_FLAG chainloader.nix } build_example(){ - nix-build example.nix + nix-build $CCACHE_FLAG example.nix } smoke_tests(){ - nix-shell --pure --argstr unikernel ./test/net/integration/udp --run ./test.py - nix-shell --pure --argstr unikernel ./test/net/integration/tcp --run ./test.py - nix-shell --pure --argstr unikernel ./test/kernel/integration/paging --run ./test.py - nix-shell --pure --argstr unikernel ./test/kernel/integration/smp --run ./test.py + 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" @@ -139,7 +140,7 @@ run_testsuite() { # The command to run, as string to be able to print the fully expanded command - cmd="nix-shell --pure --argstr unikernel $subfolder --run ./test.py" + cmd="nix-shell --pure $CCACHE_FLAG --argstr unikernel $subfolder --run ./test.py" echo "" echo "🚧 Step $steps.$substeps" From 7729cea03a7469c6ce13973d1ba52ae8ec776945 Mon Sep 17 00:00:00 2001 From: Alfred Bratterud Date: Sat, 7 Sep 2024 22:07:34 +0200 Subject: [PATCH 2/3] Enable SMP for selected tests, add SMP option to nix - Add smp parameter to nix default, shell, and overlay. Enable with --arg smp true. - Added multiple cores to paging, UDP and exceptions tests, add them to an SMP test set. - Enable boot logger to tests make it easier toverify that multiple cores come up. - Disable SMP for chainloader. It would be nice to test 32 bit multicore, but not in there. --- chainloader.nix | 1 + default.nix | 4 ++-- overlay.nix | 5 ++++- shell.nix | 5 ++++- test.sh | 13 ++++++++++++- test/kernel/integration/paging/vm.json | 3 ++- test/net/integration/udp/CMakeLists.txt | 2 +- test/net/integration/udp/vm.json | 3 ++- test/stl/integration/exceptions/CMakeLists.txt | 1 + test/stl/integration/exceptions/vm.json | 3 +++ 10 files changed, 32 insertions(+), 8 deletions(-) create mode 100644 test/stl/integration/exceptions/vm.json diff --git a/chainloader.nix b/chainloader.nix index 7a887b78a..7076fcefc 100644 --- a/chainloader.nix +++ b/chainloader.nix @@ -5,6 +5,7 @@ overlays ? [ (import ./overlay.nix { inherit withCcache; + smp = false; # No SMP for chainloader }) ], pkgs ? import nixpkgs { diff --git a/default.nix b/default.nix index 134bfb81b..0e7b270fe 100644 --- a/default.nix +++ b/default.nix @@ -1,8 +1,8 @@ { withCcache ? false, # Enable ccache. Requires correct permissions, see overlay.nix. - + smp ? false, # Enable multcore support (SMP) nixpkgs ? ./pinned.nix, overlays ? [ - (import ./overlay.nix { inherit withCcache; } ) + (import ./overlay.nix { inherit withCcache; inherit smp; } ) ], pkgs ? import nixpkgs { config = {}; inherit overlays; } }: diff --git a/overlay.nix b/overlay.nix index 361002a48..c77c41dab 100644 --- a/overlay.nix +++ b/overlay.nix @@ -1,5 +1,6 @@ { withCcache, # Enable ccache. Requires correct permissions, see below. + smp, # Enable multicore support (SMP) } : final: prev: { @@ -154,7 +155,9 @@ final: prev: { else [ "-DARCH=x86_64"]; - cmakeFlags = archFlags; + smpFlags = if smp then [ "-DSMP=ON" ] else []; + + cmakeFlags = archFlags ++ smpFlags; # Add some pasthroughs, for easily building the depdencies (for debugging): # $ nix-build -A NAME diff --git a/shell.nix b/shell.nix index 7e22cbdda..d0fb1e16d 100644 --- a/shell.nix +++ b/shell.nix @@ -12,8 +12,11 @@ # Enable ccache support. See overlay.nix for details. withCcache ? false, + # Enable multicore suport. + smp ? false, + nixpkgs ? ./pinned.nix, - overlays ? [ (import ./overlay.nix { inherit withCcache; }) ], + overlays ? [ (import ./overlay.nix { inherit withCcache; inherit smp; }) ], chainloader ? (import ./chainloader.nix { inherit withCcache; }), pkgs ? import nixpkgs { config = {}; diff --git a/test.sh b/test.sh index 5968ba0ef..ec7524d46 100755 --- a/test.sh +++ b/test.sh @@ -33,6 +33,7 @@ fail(){ } run(){ + steps=$((steps + 1)) echo "" echo "🚧 Step $steps) $2" echo "⚙️ Running this command:" @@ -42,7 +43,6 @@ run(){ declare -f $1 | sed '1d;2d;$d' | sed 's/^[[:space:]]*//' # Print the function body echo "-------------------------------------- 💣 --------------------------------------" - steps=$((steps + 1)) if [ ! $DRY_RUN ] then @@ -70,6 +70,15 @@ 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 + + # 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 +} + 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 @@ -83,6 +92,8 @@ 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" diff --git a/test/kernel/integration/paging/vm.json b/test/kernel/integration/paging/vm.json index 80667d137..d956b1da9 100644 --- a/test/kernel/integration/paging/vm.json +++ b/test/kernel/integration/paging/vm.json @@ -1,5 +1,6 @@ { "description" : "Page protection test", "mem" : 3584, - "time_sensitive": "True" + "time_sensitive": "True", + "smp" : 16 } diff --git a/test/net/integration/udp/CMakeLists.txt b/test/net/integration/udp/CMakeLists.txt index 979455d1c..d6ba0eb32 100644 --- a/test/net/integration/udp/CMakeLists.txt +++ b/test/net/integration/udp/CMakeLists.txt @@ -6,7 +6,7 @@ include(os) os_add_executable(net_udp "UDP test" service.cpp) -os_add_drivers(net_udp virtionet ip4_reassembly) +os_add_drivers(net_udp virtionet ip4_reassembly boot_logger) os_add_stdout(net_udp default_stdout) configure_file(test.py ${CMAKE_CURRENT_BINARY_DIR}) diff --git a/test/net/integration/udp/vm.json b/test/net/integration/udp/vm.json index 5c09682f7..c0a3555b1 100644 --- a/test/net/integration/udp/vm.json +++ b/test/net/integration/udp/vm.json @@ -1,5 +1,6 @@ { "net" : [{"device" : "virtio", "mac" : "c0:01:0a:00:00:2a"}], "mem" : 400, - "time_sensitive": "True" + "time_sensitive": "True", + "smp" : 16 } diff --git a/test/stl/integration/exceptions/CMakeLists.txt b/test/stl/integration/exceptions/CMakeLists.txt index affe1ebc8..cc068f10f 100644 --- a/test/stl/integration/exceptions/CMakeLists.txt +++ b/test/stl/integration/exceptions/CMakeLists.txt @@ -10,4 +10,5 @@ set(SOURCES os_add_executable(stl_exceptions "C++ exceptions test" ${SOURCES}) os_add_stdout(stl_exceptions default_stdout) +os_add_drivers(stl_exceptions boot_logger) configure_file (test.py ${CMAKE_CURRENT_BINARY_DIR}) diff --git a/test/stl/integration/exceptions/vm.json b/test/stl/integration/exceptions/vm.json new file mode 100644 index 000000000..c9dc3adc0 --- /dev/null +++ b/test/stl/integration/exceptions/vm.json @@ -0,0 +1,3 @@ +{ + "smp" : 16 +} From 32d7bb75497a3cce303a4aed14ff6b45c7e4037d Mon Sep 17 00:00:00 2001 From: Alfred Bratterud Date: Sun, 8 Sep 2024 10:01:43 +0200 Subject: [PATCH 3/3] test.sh: set ccache default to off --- test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test.sh b/test.sh index ec7524d46..52e8275c0 100755 --- a/test.sh +++ b/test.sh @@ -7,7 +7,7 @@ : "${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:=--arg withCcache true}" # Undefine to dosable ccache. +: "${CCACHE_FLAG:=}" # Define as "--arg withCcache true" to enable ccache. steps=0 fails=0