Skip to content

Commit

Permalink
[nix] allow user pass offline log from outside
Browse files Browse the repository at this point in the history
Signed-off-by: Avimitin <[email protected]>
  • Loading branch information
Avimitin committed Aug 19, 2024
1 parent b146b34 commit 8f47b7a
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 16 deletions.
20 changes: 16 additions & 4 deletions difftest/run-emulator.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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"
Expand Down
4 changes: 4 additions & 0 deletions nix/impure.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
rec {
t1OfflineLogLevelEnv = builtins.getEnv "T1_OFFLINE_LOG_LEVEL";
t1OfflineLogLevel = if t1OfflineLogLevelEnv != "" then t1OfflineLogLevelEnv else "ERROR";
}
20 changes: 16 additions & 4 deletions nix/t1/run-vcs-emulation.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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"
Expand Down
20 changes: 16 additions & 4 deletions t1rocketemu/nix/run-emulator.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 ];
Expand Down Expand Up @@ -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"
Expand Down
19 changes: 15 additions & 4 deletions t1rocketemu/nix/run-vcs-emulation.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 8f47b7a

Please sign in to comment.