From 6d2b0d46fc6a7b90f37a3c316a3b041a8017cda2 Mon Sep 17 00:00:00 2001 From: Shupei Fan Date: Thu, 5 Sep 2024 14:07:47 +0000 Subject: [PATCH] [difftest] unsuccessful simulation will panic in final block can be suppressed by setting 'T1_SUPPRESS_PANIC_IN_FINAL=1' --- difftest/dpi_common/src/util.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/difftest/dpi_common/src/util.rs b/difftest/dpi_common/src/util.rs index c1302c241..7fe7f1c39 100644 --- a/difftest/dpi_common/src/util.rs +++ b/difftest/dpi_common/src/util.rs @@ -1,6 +1,12 @@ //! utility functions pub fn write_perf_json(cycle: u64, success: bool) { + // unsuccessful simulation will panic by default. + // However, it could be suppressed by setting env T1_SUPPRESS_PANIC_IN_FINAL=1 + if !success && !suppress_panic_in_final() { + panic!("simulation ends unsuccessfully [T={cycle}]"); + } + let mut content = String::new(); content += "{\n"; content += &format!(" \"total_cycles\": {cycle},\n"); @@ -14,3 +20,7 @@ pub fn write_perf_json(cycle: u64, success: bool) { } } } + +fn suppress_panic_in_final() -> bool { + std::env::var("T1_SUPPRESS_PANIC_IN_FINAL").as_deref() == Ok("1") +}