Attention is currently required from: Sam McNally, Angel Pons, Peter Marheine.
Edward O'Callaghan has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/49915 )
Change subject: CHROMIUM: avl_tool: more gracefully handle termination by SIGINT
......................................................................
Patch Set 1:
(1 comment)
Commit Message:
https://review.coreboot.org/c/flashrom/+/49915/comment/d38e7eb2_c8c4daa2
PS1, Line 7: CHROMIUM:
> Is the CHROMIUM: prefix commonly used here?
Since it is a new thing for Chromium Flashrom and upstream Flashrom to be collaborating now there is no prior art to a convention specifically for Flashrom obviously. However, this is a convention for Coreboot which is the closest thing to draw upon and so sensible to use that here.
--
To view, visit https://review.coreboot.org/c/flashrom/+/49915
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: If43aea0580fcc7e698daad2ffe085a3c9da5bc41
Gerrit-Change-Number: 49915
Gerrit-PatchSet: 1
Gerrit-Owner: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Reviewer: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: Peter Marheine <pmarheine(a)chromium.org>
Gerrit-Reviewer: Sam McNally <sammc(a)google.com>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-Attention: Sam McNally <sammc(a)google.com>
Gerrit-Attention: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Attention: Peter Marheine <pmarheine(a)chromium.org>
Gerrit-Comment-Date: Wed, 27 Jan 2021 05:51:55 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Sam McNally <sammc(a)google.com>
Gerrit-MessageType: comment
Attention is currently required from: Edward O'Callaghan, Peter Marheine.
Sam McNally has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/49915 )
Change subject: CHROMIUM: avl_tool: more gracefully handle termination by SIGINT
......................................................................
Patch Set 1:
(1 comment)
Commit Message:
https://review.coreboot.org/c/flashrom/+/49915/comment/6b3e5bd4_233dd758
PS1, Line 7: CHROMIUM:
Is the CHROMIUM: prefix commonly used here?
--
To view, visit https://review.coreboot.org/c/flashrom/+/49915
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: If43aea0580fcc7e698daad2ffe085a3c9da5bc41
Gerrit-Change-Number: 49915
Gerrit-PatchSet: 1
Gerrit-Owner: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Reviewer: Peter Marheine <pmarheine(a)chromium.org>
Gerrit-Reviewer: Sam McNally <sammc(a)google.com>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-Attention: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Attention: Peter Marheine <pmarheine(a)chromium.org>
Gerrit-Comment-Date: Tue, 26 Jan 2021 23:43:58 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment
Attention is currently required from: Edward O'Callaghan, Angel Pons.
Sam McNally has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/49924 )
Change subject: meson.build: Require at least meson 0.50.0
......................................................................
Patch Set 1: Code-Review+2
--
To view, visit https://review.coreboot.org/c/flashrom/+/49924
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: Iadcffb7f8c720ffa8aa5f0ad62638d7b37f39934
Gerrit-Change-Number: 49924
Gerrit-PatchSet: 1
Gerrit-Owner: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: Edward O'Callaghan <edward.ocallaghan(a)koparo.com>
Gerrit-Reviewer: Sam McNally <sammc(a)google.com>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-Attention: Edward O'Callaghan <edward.ocallaghan(a)koparo.com>
Gerrit-Attention: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Comment-Date: Tue, 26 Jan 2021 23:22:31 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
Attention is currently required from: Edward O'Callaghan.
Sam McNally has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/49914 )
Change subject: meson: Rename 'config_raiden' to 'config_raiden_debug_spi'
......................................................................
Patch Set 1: Code-Review+2
--
To view, visit https://review.coreboot.org/c/flashrom/+/49914
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: Icb6c73ab3d4369fcffb96eb117fc376da75dfb84
Gerrit-Change-Number: 49914
Gerrit-PatchSet: 1
Gerrit-Owner: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Reviewer: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: Sam McNally <sammc(a)google.com>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-Attention: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Comment-Date: Tue, 26 Jan 2021 23:21:28 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
Attention is currently required from: Alan Green.
Simon Buhrow has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/40477 )
Change subject: ft2232_spi.c: Pack WREN and op in one ftdi_write_data() call
......................................................................
Patch Set 21:
(1 comment)
Patchset:
PS21:
@Alan: Hi. As you uploaded other ft2232_spi.c changes I assume you are using it. Maybe you can check this commit?
--
To view, visit https://review.coreboot.org/c/flashrom/+/40477
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: Ie4a07499ec5ef0af23818593f45dc427285a9e8a
Gerrit-Change-Number: 40477
Gerrit-PatchSet: 21
Gerrit-Owner: Simon Buhrow
Gerrit-Reviewer: Alan Green <avg(a)google.com>
Gerrit-Reviewer: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-CC: Nico Huber <nico.h(a)gmx.de>
Gerrit-CC: Patrick Georgi <pgeorgi(a)google.com>
Gerrit-CC: Paul Menzel <paulepanter(a)users.sourceforge.net>
Gerrit-Attention: Alan Green <avg(a)google.com>
Gerrit-Comment-Date: Tue, 26 Jan 2021 10:48:56 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment
Attention is currently required from: Sam McNally, Edward O'Callaghan.
Angel Pons has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/49914 )
Change subject: meson: Rename 'config_raiden' to 'config_raiden_debug_spi'
......................................................................
Patch Set 1: Code-Review+2
--
To view, visit https://review.coreboot.org/c/flashrom/+/49914
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: Icb6c73ab3d4369fcffb96eb117fc376da75dfb84
Gerrit-Change-Number: 49914
Gerrit-PatchSet: 1
Gerrit-Owner: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Reviewer: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: Sam McNally <sammc(a)google.com>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-Attention: Sam McNally <sammc(a)google.com>
Gerrit-Attention: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Comment-Date: Tue, 26 Jan 2021 09:15:26 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
Edward O'Callaghan has uploaded this change for review. ( https://review.coreboot.org/c/flashrom/+/49916 )
Change subject: CHROMIUM: flashrom_tester: Drop nix dependency
......................................................................
CHROMIUM: flashrom_tester: Drop nix dependency
We can just use the libc functions directly. This is exactly what nix
does anyway.
BUG=none
TEST=unit tests
BRANCH=none
Original-Change-Id: I45c02f0c71d164bd8f504fe2b8d3acd54e0d5704
Original-Signed-off-by: Chirantan Ekbote <chirantan(a)chromium.org>
Original-Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/flashrom/…
Original-Reviewed-by: Edward O'Callaghan <quasisec(a)chromium.org>
Original-Reviewed-by: Allen Webb <allenwebb(a)google.com>
Original-Commit-Queue: Allen Webb <allenwebb(a)google.com>
Change-Id: If7d1c7c7b5663a32c0a338866f7f7f9bee604cc0
Signed-off-by: Edward O'Callaghan <quasisec(a)google.com>
---
M util/flashrom_tester/Cargo.toml
M util/flashrom_tester/src/main.rs
2 files changed, 13 insertions(+), 7 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/16/49916/1
diff --git a/util/flashrom_tester/Cargo.toml b/util/flashrom_tester/Cargo.toml
index 0898d3c..e7a5820 100644
--- a/util/flashrom_tester/Cargo.toml
+++ b/util/flashrom_tester/Cargo.toml
@@ -18,8 +18,8 @@
chrono = { version = "0.4", optional = true }
clap = { version = "2.33", default-features = false, optional = true }
flashrom = { path = "flashrom/" }
+libc = "0.2"
log = { version = "0.4", features = ["std"] }
-nix = "0.14.1"
rand = "0.6.4"
serde_json = "1"
sys-info = "0.5.7"
diff --git a/util/flashrom_tester/src/main.rs b/util/flashrom_tester/src/main.rs
index e589ee1..80484d2 100644
--- a/util/flashrom_tester/src/main.rs
+++ b/util/flashrom_tester/src/main.rs
@@ -152,12 +152,11 @@
/// Once a signal is trapped, the default behavior is restored (terminating
/// the process) for future signals.
fn handle_sigint() -> &'static AtomicBool {
- use nix::libc::c_int;
- use nix::sys::signal::{self, SigHandler, Signal};
+ use libc::c_int;
use std::sync::atomic::Ordering;
unsafe {
- let _ = signal::signal(Signal::SIGINT, SigHandler::Handler(sigint_handler));
+ let _ = libc::signal(libc::SIGINT, sigint_handler as libc::sighandler_t);
}
static TERMINATE_FLAG: AtomicBool = AtomicBool::new(false);
@@ -169,10 +168,17 @@
test, or press ^C again to exit immediately (possibly bricking your machine).
";
- // Use raw write() because signal-safety is a very hard problem
- let _ = nix::unistd::write(STDERR_FILENO, MESSAGE);
+ // Use raw write() because signal-safety is a very hard problem. Safe because this doesn't
+ // modify any memory.
+ let _ = unsafe {
+ libc::write(
+ STDERR_FILENO,
+ MESSAGE.as_ptr() as *const libc::c_void,
+ MESSAGE.len() as libc::size_t,
+ )
+ };
unsafe {
- let _ = signal::signal(Signal::SIGINT, SigHandler::SigDfl);
+ let _ = libc::signal(libc::SIGINT, libc::SIG_DFL);
}
TERMINATE_FLAG.store(true, Ordering::Release);
}
--
To view, visit https://review.coreboot.org/c/flashrom/+/49916
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: If7d1c7c7b5663a32c0a338866f7f7f9bee604cc0
Gerrit-Change-Number: 49916
Gerrit-PatchSet: 1
Gerrit-Owner: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-MessageType: newchange
Attention is currently required from: Peter Marheine.
Hello Peter Marheine,
I'd like you to do a code review. Please visit
https://review.coreboot.org/c/flashrom/+/49915
to review the following change.
Change subject: CHROMIUM: avl_tool: more gracefully handle termination by SIGINT
......................................................................
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(a)chromium.org>
Original-Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/flashrom/…
Original-Tested-by: Edward O'Callaghan <quasisec(a)chromium.org>
Original-Reviewed-by: Edward O'Callaghan <quasisec(a)chromium.org>
Change-Id: If43aea0580fcc7e698daad2ffe085a3c9da5bc41
Signed-off-by: Edward O'Callaghan <quasisec(a)google.com>
---
M util/flashrom_tester/Cargo.toml
M util/flashrom_tester/src/main.rs
M util/flashrom_tester/src/tester.rs
M util/flashrom_tester/src/tests.rs
4 files changed, 51 insertions(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/15/49915/1
diff --git a/util/flashrom_tester/Cargo.toml b/util/flashrom_tester/Cargo.toml
index 50f2c4a..0898d3c 100644
--- a/util/flashrom_tester/Cargo.toml
+++ b/util/flashrom_tester/Cargo.toml
@@ -19,6 +19,7 @@
clap = { version = "2.33", default-features = false, optional = true }
flashrom = { path = "flashrom/" }
log = { version = "0.4", features = ["std"] }
+nix = "0.14.1"
rand = "0.6.4"
serde_json = "1"
sys-info = "0.5.7"
diff --git a/util/flashrom_tester/src/main.rs b/util/flashrom_tester/src/main.rs
index 1cc525e..e589ee1 100644
--- a/util/flashrom_tester/src/main.rs
+++ b/util/flashrom_tester/src/main.rs
@@ -42,6 +42,7 @@
use flashrom::FlashChip;
use flashrom_tester::{tester, tests};
use std::path::PathBuf;
+use std::sync::atomic::AtomicBool;
pub mod built_info {
include!(concat!(env!("OUT_DIR"), "/built.rs"));
@@ -136,8 +137,45 @@
print_layout,
output_format,
test_names,
+ Some(handle_sigint()),
) {
eprintln!("Failed to run tests: {:?}", e);
std::process::exit(1);
}
}
+
+/// Catch exactly one SIGINT, printing a message in response and setting a flag.
+///
+/// The returned value is false by default, becoming true after a SIGINT is
+/// trapped.
+///
+/// Once a signal is trapped, the default behavior is restored (terminating
+/// the process) for future signals.
+fn handle_sigint() -> &'static AtomicBool {
+ use nix::libc::c_int;
+ use nix::sys::signal::{self, SigHandler, Signal};
+ use std::sync::atomic::Ordering;
+
+ unsafe {
+ let _ = signal::signal(Signal::SIGINT, SigHandler::Handler(sigint_handler));
+ }
+ static TERMINATE_FLAG: AtomicBool = AtomicBool::new(false);
+
+ extern "C" fn sigint_handler(_: c_int) {
+ const STDERR_FILENO: c_int = 2;
+ static MESSAGE: &[u8] = b"
+WARNING: terminating tests prematurely may leave Flash in an inconsistent state,
+rendering your machine unbootable. Testing will end on completion of the current
+test, or press ^C again to exit immediately (possibly bricking your machine).
+";
+
+ // Use raw write() because signal-safety is a very hard problem
+ let _ = nix::unistd::write(STDERR_FILENO, MESSAGE);
+ unsafe {
+ let _ = signal::signal(Signal::SIGINT, SigHandler::SigDfl);
+ }
+ TERMINATE_FLAG.store(true, Ordering::Release);
+ }
+
+ &TERMINATE_FLAG
+}
diff --git a/util/flashrom_tester/src/tester.rs b/util/flashrom_tester/src/tester.rs
index fbef201..3150a43 100644
--- a/util/flashrom_tester/src/tester.rs
+++ b/util/flashrom_tester/src/tester.rs
@@ -39,6 +39,7 @@
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 @@
chip: FlashChip,
cmd: &FlashromCmd,
ts: TS,
+ terminate_flag: Option<&AtomicBool>,
) -> Vec<(String, (TestConclusion, Option<TestError>))>
where
T: TestCase + Copy,
@@ -489,6 +491,13 @@
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));
}
diff --git a/util/flashrom_tester/src/tests.rs b/util/flashrom_tester/src/tests.rs
index dd75689..9ef98e5 100644
--- a/util/flashrom_tester/src/tests.rs
+++ b/util/flashrom_tester/src/tests.rs
@@ -40,6 +40,7 @@
use std::collections::{HashMap, HashSet};
use std::fs::File;
use std::io::{BufRead, Write};
+use std::sync::atomic::AtomicBool;
const LAYOUT_FILE: &'static str = "/tmp/layout.file";
@@ -82,6 +83,7 @@
print_layout: bool,
output_format: OutputFormat,
test_names: Option<TN>,
+ terminate_flag: Option<&AtomicBool>,
) -> Result<(), Box<dyn std::error::Error>> {
let p = path.to_string();
let cmd = FlashromCmd { path: p, fc };
@@ -142,7 +144,7 @@
// ------------------------.
// Run all the tests and collate the findings:
- let results = tester::run_all_tests(fc, &cmd, tests);
+ let results = tester::run_all_tests(fc, &cmd, tests, terminate_flag);
// Any leftover filtered names were specified to be run but don't exist
for leftover in filter_names.iter().flatten() {
--
To view, visit https://review.coreboot.org/c/flashrom/+/49915
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: If43aea0580fcc7e698daad2ffe085a3c9da5bc41
Gerrit-Change-Number: 49915
Gerrit-PatchSet: 1
Gerrit-Owner: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Reviewer: Peter Marheine <pmarheine(a)chromium.org>
Gerrit-Attention: Peter Marheine <pmarheine(a)chromium.org>
Gerrit-MessageType: newchange