summaryrefslogtreecommitdiffstats
path: root/util/flashrom_tester/src/tester.rs
diff options
context:
space:
mode:
authorPeter Marheine <pmarheine@chromium.org>2020-02-12 15:37:28 +1100
committerEdward O'Callaghan <quasisec@chromium.org>2021-02-11 00:13:04 +0000
commit32aa933b1da48b0730dd79fbb15d864643391072 (patch)
treedb07d4760fa59b59c5a5c0ba9989c24499cdc134 /util/flashrom_tester/src/tester.rs
parent4e31838eb1fabdf22cb1b0b6f4b63f126f8818a5 (diff)
downloadflashrom-32aa933b1da48b0730dd79fbb15d864643391072.tar.gz
flashrom-32aa933b1da48b0730dd79fbb15d864643391072.tar.bz2
flashrom-32aa933b1da48b0730dd79fbb15d864643391072.zip
CHROMIUM: avl_tool: more gracefully handle termination by SIGINT
Since interrupting the test process may be dangerous (leaving the flash in an inconsistent state), we'll catch SIGINT and print a warning the first time, also using it as a signal that we should stop at a convenient time. Any following SIGINT will be handled as normal (killing the process). BUG=b:143251344 TEST=Run tool and verify it exits after a test with a single ^C, exits immediately given two. BRANCH=None Original-Cq-Depend: chromium:2059548 Original-Change-Id: Ib8a7799cba6dbca57dc7f1d3c87521f132c21818 Original-Signed-off-by: Peter Marheine <pmarheine@chromium.org> Original-Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/flashrom/+/2050050 Original-Tested-by: Edward O'Callaghan <quasisec@chromium.org> Original-Reviewed-by: Edward O'Callaghan <quasisec@chromium.org> Change-Id: If43aea0580fcc7e698daad2ffe085a3c9da5bc41 Signed-off-by: Edward O'Callaghan <quasisec@google.com> Reviewed-on: https://review.coreboot.org/c/flashrom/+/49915 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Diffstat (limited to 'util/flashrom_tester/src/tester.rs')
-rw-r--r--util/flashrom_tester/src/tester.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/util/flashrom_tester/src/tester.rs b/util/flashrom_tester/src/tester.rs
index fbef2016e..3150a4354 100644
--- a/util/flashrom_tester/src/tester.rs
+++ b/util/flashrom_tester/src/tester.rs
@@ -39,6 +39,7 @@ use super::utils::{self, LayoutSizes};
use flashrom::{FlashChip, Flashrom, FlashromCmd};
use serde_json::json;
use std::mem::MaybeUninit;
+use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Mutex;
// type-signature comes from the return type of lib.rs workers.
@@ -480,6 +481,7 @@ pub fn run_all_tests<T, TS>(
chip: FlashChip,
cmd: &FlashromCmd,
ts: TS,
+ terminate_flag: Option<&AtomicBool>,
) -> Vec<(String, (TestConclusion, Option<TestError>))>
where
T: TestCase + Copy,
@@ -489,6 +491,13 @@ where
let mut results = Vec::new();
for t in ts {
+ if terminate_flag
+ .map(|b| b.load(Ordering::Acquire))
+ .unwrap_or(false)
+ {
+ break;
+ }
+
let result = decode_test_result(env.run_test(t), t.expected_result());
results.push((t.get_name().into(), result));
}