diff --git a/difftest/run-emulator.nix b/difftest/run-emulator.nix index baee3ec7a2..0c8924c2db 100644 --- a/difftest/run-emulator.nix +++ b/difftest/run-emulator.nix @@ -2,6 +2,9 @@ emulator: testCase: +let + impureEnvs = import (../../nix/impure.nix); +in runCommand "run-${emulator.name}-for-${testCase.pname}" { name = "${testCase.pname}-emu-result" + (lib.optionalString emulator.enable-trace "-trace"); @@ -50,10 +53,19 @@ runCommand "run-${emulator.name}-for-${testCase.pname}" fi set +e - "${emulator}/bin/offline" \ - --elf-file ${testCase}/bin/${testCase.pname}.elf \ - --log-file $rtlEventOutPath \ - --log-level ERROR &> $out/offline-check-journal + offlineCheckArgsArray=( + "--elf-file" + "${testCase}/bin/${testCase.pname}.elf" + "--log-file" + "$rtlEventOutPath" + "--log-level" + "${impureEnvs.t1OfflineLogLevel}" + ) + offlineCheckArgs="''${offlineCheckArgsArray[@]}" + + echo "[nix] running ${emulator}/bin/offline $offlineCheckArgs" + "${emulator}/bin/offline" $offlineCheckArgs &> $out/offline-check-journal + printf "$?" > $out/offline-check-status if [ "$(cat $out/offline-check-status)" != "0" ]; then echo "[nix] Offline check FAIL" diff --git a/nix/impure.nix b/nix/impure.nix new file mode 100644 index 0000000000..019528e1a6 --- /dev/null +++ b/nix/impure.nix @@ -0,0 +1,4 @@ +rec { + t1OfflineLogLevelEnv = builtins.getEnv "T1_OFFLINE_LOG_LEVEL"; + t1OfflineLogLevel = if t1OfflineLogLevelEnv != "" then t1OfflineLogLevelEnv else "ERROR"; +} diff --git a/nix/t1/run-vcs-emulation.nix b/nix/t1/run-vcs-emulation.nix index 8c4f9f3c7e..78307194f4 100644 --- a/nix/t1/run-vcs-emulation.nix +++ b/nix/t1/run-vcs-emulation.nix @@ -3,6 +3,9 @@ emulator: testCase: +let + impureEnvs = import (../../nix/impure.nix); +in runCommand "run-${emulator.name}-for-${testCase.pname}" { name = "${testCase.pname}-vcs-result" + (lib.optionalString emulator.enable-trace "-trace"); @@ -48,10 +51,19 @@ runCommand "run-${emulator.name}-for-${testCase.pname}" fi set +e - "${verilator-emu}/bin/offline" \ - --elf-file ${testCase}/bin/${testCase.pname}.elf \ - --log-file $rtlEventOutPath \ - --log-level ERROR &> $out/offline-check-journal + offlineCheckArgsArray=( + "--elf-file" + "${testCase}/bin/${testCase.pname}.elf" + "--log-file" + "$rtlEventOutPath" + "--log-level" + "${impureEnvs.t1OfflineLogLevel}" + ) + offlineCheckArgs="''${offlineCheckArgsArray[@]}" + + echo "[nix] running ${emulator}/bin/offline $offlineCheckArgs" + "${emulator}/bin/offline" $offlineCheckArgs &> $out/offline-check-journal + printf "$?" > $out/offline-check-status if [ "$(cat $out/offline-check-status)" != "0" ]; then echo "[nix] Offline check FAIL" diff --git a/t1rocketemu/nix/run-emulator.nix b/t1rocketemu/nix/run-emulator.nix index cd2fdfc3ac..ce0ce73fee 100644 --- a/t1rocketemu/nix/run-emulator.nix +++ b/t1rocketemu/nix/run-emulator.nix @@ -2,6 +2,9 @@ emulator: testCase: +let + impureEnvs = import (../../nix/impure.nix); +in runCommand ("${emulator.name}-${testCase.pname}-emu-result" + lib.optionalString emulator.enable-trace "-trace") { nativeBuildInputs = [ zstd jq ]; @@ -49,10 +52,19 @@ runCommand ("${emulator.name}-${testCase.pname}-emu-result" + lib.optionalString fi set +e - "${emulator}/bin/offline" \ - --elf-file ${testCase}/bin/${testCase.pname}.elf \ - --log-file $rtlEventOutPath \ - --log-level ERROR &> $out/offline-check-journal + offlineCheckArgsArray=( + "--elf-file" + "${testCase}/bin/${testCase.pname}.elf" + "--log-file" + "$rtlEventOutPath" + "--log-level" + "${impureEnvs.t1OfflineLogLevel}" + ) + offlineCheckArgs="''${offlineCheckArgsArray[@]}" + + echo "[nix] running ${emulator}/bin/offline $offlineCheckArgs" + "${emulator}/bin/offline" $offlineCheckArgs &> $out/offline-check-journal + printf "$?" > $out/offline-check-status if [ "$(cat $out/offline-check-status)" != "0" ]; then echo "[nix] Offline check FAIL" diff --git a/t1rocketemu/nix/run-vcs-emulation.nix b/t1rocketemu/nix/run-vcs-emulation.nix index d4df55cb08..7b7f2a106b 100644 --- a/t1rocketemu/nix/run-vcs-emulation.nix +++ b/t1rocketemu/nix/run-vcs-emulation.nix @@ -3,6 +3,9 @@ emulator: testCase: +let + impureEnvs = import (../../nix/impure.nix); +in runCommand "run-${emulator.name}-for-${testCase.pname}" { name = "${testCase.pname}-vcs-result" + (lib.optionalString emulator.enable-trace "-trace"); @@ -48,10 +51,18 @@ runCommand "run-${emulator.name}-for-${testCase.pname}" fi set +e - "${verilator-emu}/bin/offline" \ - --elf-file ${testCase}/bin/${testCase.pname}.elf \ - --log-file $rtlEventOutPath \ - --log-level ERROR &> $out/offline-check-journal + offlineCheckArgsArray=( + "--elf-file" + "${testCase}/bin/${testCase.pname}.elf" + "--log-file" + "$rtlEventOutPath" + "--log-level" + "${impureEnvs.t1OfflineLogLevel}" + ) + offlineCheckArgs="''${offlineCheckArgsArray[@]}" + + echo "[nix] running ${emulator}/bin/offline $offlineCheckArgs" + "${emulator}/bin/offline" $offlineCheckArgs &> $out/offline-check-journal printf "$?" > $out/offline-check-status if [ "$(cat $out/offline-check-status)" != "0" ]; then echo "[nix] Offline check FAIL"