From 73ddd6c5e2dec42e99441cf5d34bdcaf65afd149 Mon Sep 17 00:00:00 2001 From: Konstantin Nazarov Date: Mon, 16 Dec 2024 23:20:53 +0000 Subject: [PATCH] Run RISCOF test suite via nix on normal builds --- flake.lock | 20 +++++++++++++++++++- flake.nix | 18 ++++++++---------- rve.nix | 19 ++++++++++++++++++- 3 files changed, 45 insertions(+), 12 deletions(-) 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 = ./.;