-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[nix] refactor whole test attribute under emulator
Signed-off-by: Avimitin <[email protected]>
- Loading branch information
Showing
22 changed files
with
602 additions
and
451 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
{ lib, runCommand, zstd, jq }: | ||
emulator: | ||
testCase: | ||
|
||
runCommand "run-${emulator.name}-for-${testCase.pname}" | ||
{ | ||
name = "${testCase.pname}-emu-result" + (lib.optionalString emulator.enable-trace "-trace"); | ||
nativeBuildInputs = [ zstd jq ]; | ||
} '' | ||
mkdir -p "$out" | ||
emuDriverArgsArray=( | ||
"--elf-file" | ||
"${testCase}/bin/${testCase.pname}.elf" | ||
"--log-file" | ||
"$out/emu.log" | ||
"--log-level" | ||
"ERROR" | ||
${lib.optionalString emulator.enable-trace "--wave-path"} | ||
${lib.optionalString emulator.enable-trace "$out/wave.fst"} | ||
) | ||
emuDriverArgs="''${emuDriverArgsArray[@]}" | ||
emuDriver="${emulator}/bin/online_drive" | ||
rtlEventOutPath="$out/${testCase.pname}-rtl-event.jsonl" | ||
echo "[nix] Running test case ${testCase.pname} with args $emuDriverArgs" | ||
export RUST_BACKTRACE=full | ||
if ! "$emuDriver" $emuDriverArgs 2> "$rtlEventOutPath"; then | ||
echo -e "\033[0;31m[nix]\033[0m: online driver run failed" | ||
cat $rtlEventOutPath | ||
echo -e "\033[0;31m[nix]\033[0m: Try rerun with '\033[0;34m$emuDriver $emuDriverArgs\033[0m'" | ||
exit 1 | ||
fi | ||
echo "[nix] online driver run done" | ||
if [ ! -r "$rtlEventOutPath" ]; then | ||
echo -e "[nix] \033[0;31mInternal Error\033[0m: no $rtlEventOutPath found in output" | ||
exit 1 | ||
fi | ||
if ! jq --stream -c -e '.[]' "$rtlEventOutPath" >/dev/null 2>&1; then | ||
echo -e "[nix] \033[0;31mInternal Error\033[0m: invalid JSON file $rtlEventOutPath, showing original file:" | ||
echo "--------------------------------------------" | ||
cat $rtlEventOutPath | ||
echo "--------------------------------------------" | ||
exit 1 | ||
fi | ||
set +e | ||
"${emulator}/bin/offline" \ | ||
--elf-file ${testCase}/bin/${testCase.pname}.elf \ | ||
--log-file $rtlEventOutPath \ | ||
--log-level ERROR &> $out/offline-check-journal | ||
printf "$?" > $out/offline-check-status | ||
if [ "$(cat $out/offline-check-status)" != "0" ]; then | ||
echo "[nix] Offline check FAIL" | ||
else | ||
echo "[nix] Offline check PASS" | ||
fi | ||
set -e | ||
echo "[nix] compressing event log" | ||
zstd $rtlEventOutPath -o $rtlEventOutPath.zstd | ||
rm $rtlEventOutPath | ||
if [ -r perf.txt ]; then | ||
mv perf.txt $out/ | ||
fi | ||
${lib.optionalString emulator.enable-trace '' | ||
if [ ! -r "$out/wave.fst" ]; then | ||
echo -e "[nix] \033[0;31mInternal Error\033[0m: waveform not found in output" | ||
exit 1 | ||
fi | ||
''} | ||
'' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -125,4 +125,5 @@ rec { | |
}; | ||
|
||
t1 = final.callPackage ./t1 { }; | ||
t1-rocket = final.callPackage ../t1rocketemu { }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
{ lib, runCommand, zstd, jq }: | ||
emulator: | ||
testCase: | ||
|
||
runCommand "run-${emulator.name}-for-${testCase.pname}" | ||
{ | ||
name = "${testCase.pname}-vcs-result" + (lib.optionalString emulator.enable-trace "-trace"); | ||
nativeBuildInputs = [ zstd jq ]; | ||
__noChroot = true; | ||
} '' | ||
mkdir -p "$out" | ||
emuDriverArgsArray=( | ||
"--elf-file" | ||
"${testCase}/bin/${testCase.pname}.elf" | ||
${lib.optionalString emulator.enable-trace "--wave-path"} | ||
${lib.optionalString emulator.enable-trace "${testCase.pname}.fsdb"} | ||
) | ||
emuDriverArgs="''${emuDriverArgsArray[@]}" | ||
emuDriver="${emulator}/bin/t1-vcs-simulator" | ||
rtlEventOutPath="$out/${testCase.pname}-rtl-event.jsonl" | ||
echo "[nix] Running VCS ${testCase.pname} with args $emuDriverArgs" | ||
export RUST_BACKTRACE=full | ||
if ! "$emuDriver" $emuDriverArgs >/dev/null 2>"$rtlEventOutPath"; then | ||
echo -e "\033[0;31m[nix]\033[0m: online driver run failed" | ||
cat $rtlEventOutPath | ||
echo -e "\033[0;31m[nix]\033[0m: Try rerun with '\033[0;34m$emuDriver $emuDriverArgs\033[0m'" | ||
exit 1 | ||
fi | ||
echo "[nix] VCS run done" | ||
if [ ! -r "$rtlEventOutPath" ]; then | ||
echo -e "[nix] \033[0;31mInternal Error\033[0m: no $rtlEventOutPath found in output" | ||
exit 1 | ||
fi | ||
if ! jq --stream -c -e '.[]' "$rtlEventOutPath" >/dev/null 2>&1; then | ||
echo -e "[nix] \033[0;31mInternal Error\033[0m: invalid JSON file $rtlEventOutPath, showing original file:" | ||
echo "--------------------------------------------" | ||
cat $rtlEventOutPath | ||
echo "--------------------------------------------" | ||
exit 1 | ||
fi | ||
set +e | ||
"${emulator}/bin/offline" \ | ||
--elf-file ${testCase}/bin/${testCase.pname}.elf \ | ||
--log-file $rtlEventOutPath \ | ||
--log-level ERROR &> $out/offline-check-journal | ||
printf "$?" > $out/offline-check-status | ||
if [ "$(cat $out/offline-check-status)" != "0" ]; then | ||
echo "[nix] Offline check FAIL" | ||
else | ||
echo "[nix] Offline check PASS" | ||
fi | ||
set -e | ||
echo "[nix] compressing event log" | ||
zstd $rtlEventOutPath -o $rtlEventOutPath.zstd | ||
rm $rtlEventOutPath | ||
if [ -r perf.txt ]; then | ||
mv perf.txt $out/ | ||
fi | ||
${lib.optionalString emulator.enable-trace '' | ||
cp -v ${testCase.pname}.fsdb "$out" | ||
cp -vr ${emulator}/lib/t1-vcs-simulator.daidir "$out" | ||
''} | ||
'' |
Oops, something went wrong.