Skip to content

Commit

Permalink
Added baremetal tests to the nix run scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
HU90m committed Aug 20, 2024
1 parent 48300b0 commit 2e3160a
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 19 deletions.
62 changes: 47 additions & 15 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,35 @@
'';
};

cheriotRtosSource = pkgs.fetchFromGitHub {
owner = "lowRISC";
repo = "CHERIoT-RTOS";
rev = "30148bad7ef45026d4e4b754871bf2b396ce2ca8";
fetchSubmodules = true;
hash = "sha256-3yatAEfZ5eWOfQB7w5I6OOHaG39pRUeyzCGgix3T4PI=";
};

sonata-system-software = pkgs.stdenv.mkDerivation rec {
inherit version;
pname = "sonata-system-software";
src = fileset.toSource {
root = ./sw;
fileset = fileset.unions [
./sw/cheri
./sw/common
];
};
sourceRoot = "${src.name}/cheri";
nativeBuildInputs = cheriotPkgs ++ (with pkgs; [cmake]);
cmakeFlags = [
"-DFETCHCONTENT_SOURCE_DIR_CHERIOT_RTOS=${cheriotRtosSource}"
];
dontFixup = true;
};

cheriot-rtos-test-suite = pkgs.stdenvNoCC.mkDerivation {
name = "cheriot-rtos-test-suite";
src = pkgs.fetchFromGitHub {
owner = "HU90m";
repo = "cheriot-rtos";
rev = "30148bad7ef45026d4e4b754871bf2b396ce2ca8";
fetchSubmodules = true;
hash = "sha256-3yatAEfZ5eWOfQB7w5I6OOHaG39pRUeyzCGgix3T4PI=";
};
src = cheriotRtosSource;
buildInputs = cheriotPkgs ++ [lrPkgs.uf2conv];
dontFixup = true;
buildPhase = ''
Expand All @@ -155,11 +175,17 @@
};
};

tests-runner =
pkgs.writers.writePython3Bin "tests-runner" {
libraries = [pkgs.python3Packages.pyserial];
}
./util/test_runner.py;
tests-runner = pkgs.writeShellApplication {
name = "tests-runner";
runtimeInputs = with pkgs; [
openocd
(python3.withPackages (pyPkg: with pyPkg; [pyserial]))
];
checkPhase = "";
text = ''
python ./util/test_runner.py $@
'';
};

tests-fpga-runner = pkgs.writers.writeBashBin "tests-fpga-runner" ''
set -e
Expand All @@ -168,6 +194,9 @@
"as the first argument."
exit 2
fi
${getExe tests-runner} -t 30 fpga $1 \
--elf-file ${sonata-system-software}/bin/test_runner \
--tcl-file ${./util/sonata-openocd-cfg.tcl}
${getExe tests-runner} -t 30 fpga $1 --uf2-file ${cheriot-rtos-test-suite}/share/test-suite.uf2
'';

Expand All @@ -177,9 +206,12 @@
dontBuild = true;
doCheck = true;
buildInputs = [sonata-simulator];
SONATA_SIM_BOOT_STUB = "${sonata-sim-boot-stub.out}/share/sim_boot_stub";
checkPhase = ''
${getExe tests-runner} -t 600 sim --elf-file ${cheriot-rtos-test-suite}/share/test-suite
${getExe tests-runner} -t 30 sim \
--elf-file ${sonata-system-software}/bin/test_runner
${getExe tests-runner} -t 600 sim \
--sim-boot-stub ${sonata-sim-boot-stub.out}/share/sim_boot_stub \
--elf-file ${cheriot-rtos-test-suite}/share/test-suite
'';
installPhase = "mkdir $out";
};
Expand All @@ -204,7 +236,7 @@
])
++ (with sonata-simulator; buildInputs ++ nativeBuildInputs);
};
packages = {inherit sonata-simulator sonata-sim-boot-stub sonata-documentation cheriot-rtos-test-suite;};
packages = {inherit sonata-simulator sonata-sim-boot-stub sonata-documentation sonata-system-software cheriot-rtos-test-suite;};
checks = {inherit sonata-simulator-lint tests-simulator;};
apps = builtins.listToAttrs (map (program: {
inherit (program) name;
Expand Down
12 changes: 8 additions & 4 deletions sw/cheri/checks/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
set(TESTS
set(CHECKS
cheri_sanity.cc
gpio_check.cc
uart_check.cc
Expand All @@ -7,10 +7,10 @@ set(TESTS
rgbled_test.cc
)

foreach(TEST ${TESTS})
get_filename_component(NAME ${TEST} NAME_WE)
foreach(CHECK ${CHECKS})
get_filename_component(NAME ${CHECK} NAME_WE)

add_executable(${NAME} ${TEST} boot.S)
add_executable(${NAME} ${CHECK} boot.S)
target_include_directories(${NAME} PRIVATE ${CHERIOT_SDK_INCLUDES})

add_custom_command(
Expand All @@ -19,6 +19,8 @@ foreach(TEST ${TESTS})
COMMAND srec_cat "$<TARGET_FILE:${NAME}>.bin" -binary -offset 0x0000 -byte-swap 4 -o "$<TARGET_FILE:${NAME}>.vmem" -vmem
VERBATIM
)

install(TARGETS ${NAME})
endforeach()

set(NAME tag_test)
Expand All @@ -32,6 +34,7 @@ add_custom_command(
COMMAND srec_cat "$<TARGET_FILE:${NAME}>.bin" -binary -offset 0x0000 -byte-swap 4 -o "$<TARGET_FILE:${NAME}>.vmem" -vmem
VERBATIM
)
install(TARGETS ${NAME})

set(NAME hyperram_test)

Expand All @@ -44,3 +47,4 @@ add_custom_command(
COMMAND srec_cat "$<TARGET_FILE:${NAME}>.bin" -binary -offset 0x0000 -byte-swap 4 -o "$<TARGET_FILE:${NAME}>.vmem" -vmem
VERBATIM
)
install(TARGETS ${NAME})
1 change: 1 addition & 0 deletions sw/cheri/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ foreach(TEST ${TESTS})
add_executable(${NAME} ${TEST} boot.S)
target_include_directories(${NAME} PRIVATE ${CHERIOT_SDK_INCLUDES})

install(TARGETS ${NAME})
endforeach()

0 comments on commit 2e3160a

Please sign in to comment.