Run RISCOF test suite via nix on normal builds

This commit is contained in:
Konstantin Nazarov 2024-12-16 23:20:53 +00:00
parent 3888a0d65a
commit 73ddd6c5e2
Signed by: knazarov
GPG key ID: 4CFE0A42FA409C22
3 changed files with 45 additions and 12 deletions

View file

@ -15,9 +15,27 @@
"type": "github" "type": "github"
} }
}, },
"riscv-arch-test": {
"flake": false,
"locked": {
"lastModified": 1719853882,
"narHash": "sha256-SSsRbutbJb5c9dn3cL5ocOtx/fYn9Ygjp5w4sBwP50U=",
"owner": "riscv",
"repo": "riscv-arch-test",
"rev": "eb66181dd27ff7847e2c3a010705b13490b0bf75",
"type": "github"
},
"original": {
"owner": "riscv",
"repo": "riscv-arch-test",
"rev": "eb66181dd27ff7847e2c3a010705b13490b0bf75",
"type": "github"
}
},
"root": { "root": {
"inputs": { "inputs": {
"nixpkgs": "nixpkgs" "nixpkgs": "nixpkgs",
"riscv-arch-test": "riscv-arch-test"
} }
} }
}, },

View file

@ -4,10 +4,14 @@
# Flake inputs # Flake inputs
inputs = { inputs = {
nixpkgs.url = "github:NixOS/nixpkgs"; # also valid: "nixpkgs"; nixpkgs.url = "github:NixOS/nixpkgs"; # also valid: "nixpkgs";
riscv-arch-test = {
url = "github:riscv/riscv-arch-test?rev=eb66181dd27ff7847e2c3a010705b13490b0bf75";
flake = false;
};
}; };
# Flake outputs # Flake outputs
outputs = { self, nixpkgs }: outputs = { self, nixpkgs, riscv-arch-test }:
let let
# Systems supported # Systems supported
allSystems = [ allSystems = [
@ -21,22 +25,16 @@
forAllSystems = f: nixpkgs.lib.genAttrs allSystems (system: f { forAllSystems = f: nixpkgs.lib.genAttrs allSystems (system: f {
pkgs = import nixpkgs { inherit system; }; pkgs = import nixpkgs { inherit system; };
}); });
riscv-pkgs = import nixpkgs {
localSystem = "x86_64-linux";
crossSystem = {
config = "riscv32-unknown-linux-gnu";
};
};
in in
{ {
packages = forAllSystems( {pkgs}: packages = forAllSystems( {pkgs}:
{ {
lisp = (pkgs.callPackage ./rve.nix {riscv-pkgs=riscv-pkgs;}); lisp = (pkgs.callPackage ./rve.nix {riscv-arch-test=riscv-arch-test;});
default = (pkgs.callPackage ./rve.nix {riscv-pkgs=riscv-pkgs;}); default = (pkgs.callPackage ./rve.nix {riscv-arch-test=riscv-arch-test;});
} }
); );
overlays.default = final: prev: { overlays.default = final: prev: {
lisp = (prev.callPackage ./rve.nix {riscv-pkgs=riscv-pkgs;}); lisp = (prev.callPackage ./rve.nix {riscv-arch-test=riscv-arch-test;});
}; };
}; };
} }

19
rve.nix
View file

@ -1,4 +1,4 @@
{ pkgs, stdenv, riscv-pkgs }: { pkgs, stdenv, riscv-arch-test }:
pkgs.gcc13Stdenv.mkDerivation rec { pkgs.gcc13Stdenv.mkDerivation rec {
pname = "rve"; pname = "rve";
version = "0.1.0"; version = "0.1.0";
@ -38,6 +38,23 @@ pkgs.gcc13Stdenv.mkDerivation rec {
ln -s build/compile_commands.json compile_commands.json ln -s build/compile_commands.json compile_commands.json
''; '';
checkPhase = ''
export PATH=`pwd`:$PATH
cd ../test
riscof run --config=config.ini \
--suite=${riscv-arch-test}/riscv-test-suite \
--env=${riscv-arch-test}/riscv-test-suite/env \
--no-browser 2>report.txt
# This is needed because `riscof` doesn't return
# error code on failed tests
if [ ! -z "$(grep ERROR report.txt)" ]; then
cat report.txt
echo "Some of the RISCOF tests failed"
exit 1
fi
cd -
'';
doCheck = true; doCheck = true;
src = ./.; src = ./.;