Skip to content

Commit

Permalink
Added nix test runners
Browse files Browse the repository at this point in the history
The `tests-simulator` runs the test suites in a sandbox.
The `tests-fpga-runner` runs the tests suites on the FPGA.
  • Loading branch information
HU90m committed Jul 25, 2024
1 parent 359d2b9 commit 43a321e
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,35 @@
}
// commonSoftwareBuildAttributes);

tests-runner = pkgs.writers.writePython3Bin "tests-runner" {
libraries = [pkgs.python3Packages.pyserial];
} (builtins.readFile ./scripts/test_runner.py);

tests-fpga-runner = pkgs.writers.writeBashBin "tests-fpga-runner" ''
set -e
if [ -z "$1" ]; then
echo "Please provide the tty device location (e.g. /dev/ttyUSB2)" \
"as the first argument."
exit 2
fi
${getExe tests-runner} -t 30 fpga $1 --uf2-file ${sonata-tests}/share/sonata_test_suite.uf2
${getExe tests-runner} -t 30 fpga $1 --uf2-file ${cheriot-rtos-tests}/share/test-suite.uf2
'';

tests-simulator = pkgs.stdenvNoCC.mkDerivation {
name = "tests-simulator";
src = ./.;
dontBuild = true;
doCheck = true;
buildInputs = [sonataSystemPkgs.sonata-simulator];
SONATA_SIM_BOOT_STUB = "${sonataSystemPkgs.sonata-sim-boot-stub.out}/share/sim_boot_stub";
checkPhase = ''
${getExe tests-runner} -t 30 sim --elf-file ${sonata-tests}/share/sonata_test_suite
${getExe tests-runner} -t 960 sim --elf-file ${cheriot-rtos-tests}/share/test-suite
'';
installPhase = "mkdir $out";
};

lint-python = pkgs.writeShellApplication {
name = "lint-python";
runtimeInputs = with pkgs; [
Expand Down Expand Up @@ -148,13 +177,14 @@
};
};
packages = {inherit sonata-examples sonata-tests cheriot-rtos-tests;};
checks = {inherit tests-simulator;};
apps = builtins.listToAttrs (map (program: {
inherit (program) name;
value = {
type = "app";
program = getExe program;
};
}) [lint-all lint-cpp lint-python]);
}) [lint-all lint-cpp lint-python tests-runner tests-fpga-runner]);
};
in
flake-utils.lib.eachDefaultSystem system_outputs;
Expand Down

0 comments on commit 43a321e

Please sign in to comment.