diff --git a/flake.lock b/flake.lock index ecbc5a6..28a99db 100644 --- a/flake.lock +++ b/flake.lock @@ -15,9 +15,27 @@ "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": { "inputs": { - "nixpkgs": "nixpkgs" + "nixpkgs": "nixpkgs", + "riscv-arch-test": "riscv-arch-test" } } }, diff --git a/flake.nix b/flake.nix index 6e2312b..2a78168 100644 --- a/flake.nix +++ b/flake.nix @@ -4,10 +4,14 @@ # Flake inputs inputs = { nixpkgs.url = "github:NixOS/nixpkgs"; # also valid: "nixpkgs"; + riscv-arch-test = { + url = "github:riscv/riscv-arch-test?rev=eb66181dd27ff7847e2c3a010705b13490b0bf75"; + flake = false; + }; }; # Flake outputs - outputs = { self, nixpkgs }: + outputs = { self, nixpkgs, riscv-arch-test }: let # Systems supported allSystems = [ @@ -21,22 +25,16 @@ forAllSystems = f: nixpkgs.lib.genAttrs allSystems (system: f { pkgs = import nixpkgs { inherit system; }; }); - riscv-pkgs = import nixpkgs { - localSystem = "x86_64-linux"; - crossSystem = { - config = "riscv32-unknown-linux-gnu"; - }; - }; in { packages = forAllSystems( {pkgs}: { - lisp = (pkgs.callPackage ./rve.nix {riscv-pkgs=riscv-pkgs;}); - default = (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-arch-test=riscv-arch-test;}); } ); overlays.default = final: prev: { - lisp = (prev.callPackage ./rve.nix {riscv-pkgs=riscv-pkgs;}); + lisp = (prev.callPackage ./rve.nix {riscv-arch-test=riscv-arch-test;}); }; }; } diff --git a/rve.nix b/rve.nix index 13f7dc1..35bfa8a 100644 --- a/rve.nix +++ b/rve.nix @@ -1,4 +1,4 @@ -{ pkgs, stdenv, riscv-pkgs }: +{ pkgs, stdenv, riscv-arch-test }: pkgs.gcc13Stdenv.mkDerivation rec { pname = "rve"; version = "0.1.0"; @@ -38,6 +38,23 @@ pkgs.gcc13Stdenv.mkDerivation rec { 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; src = ./.;