From 6f954b9b27a974c0746bcc1faa02559347a00e4d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B8rn=20Forsman?= <bjorn.forsman@gmail.com>
Date: Sat, 30 Dec 2023 20:07:21 +0100
Subject: [PATCH] quartus-prime-lite: add a test

Test that the wrapped quartus can build a SOF file.
---
 .../editors/quartus-prime/default.nix         | 31 +++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/pkgs/applications/editors/quartus-prime/default.nix b/pkgs/applications/editors/quartus-prime/default.nix
index 538d3fb134ca..8275be235b43 100644
--- a/pkgs/applications/editors/quartus-prime/default.nix
+++ b/pkgs/applications/editors/quartus-prime/default.nix
@@ -117,6 +117,37 @@ in buildFHSEnv rec {
   passthru = {
     inherit unwrapped;
     tests = {
+      buildSof = runCommand "quartus-prime-lite-test-build-sof"
+        { nativeBuildInputs = [ quartus-prime-lite ];
+        }
+        ''
+          cat >mydesign.vhd <<EOF
+          library ieee;
+          use ieee.std_logic_1164.all;
+
+          entity mydesign is
+          port (
+              in_0: in std_logic;
+              in_1: in std_logic;
+              out_1: out std_logic
+          );
+          end mydesign;
+
+          architecture dataflow of mydesign is
+          begin
+              out_1 <= in_0 and in_1;
+          end dataflow;
+          EOF
+
+          quartus_sh --flow compile mydesign
+
+          if ! [ -f mydesign.sof ]; then
+              echo "error: failed to produce mydesign.sof" >&2
+              exit 1
+          fi
+
+          touch "$out"
+        '';
       questaEncryptedModel = runCommand "quartus-prime-lite-test-questa-encrypted-model" {} ''
         "${quartus-prime-lite}/bin/vlog" "${quartus-prime-lite.unwrapped}/questa_fse/intel/verilog/src/arriav_atoms_ncrypt.v"
         touch "$out"