1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-07-03 15:03:22 +02:00

flashrom_tester: Remove subprocess from elog_sanity_test

Make elog_sanity_test read the elog region itself, instead of calling
out to elogtool. This avoids the need to subprocess and resolves
a deadlock when elogtool attempts to obtain a flash reading lock.

TEST=/usr/bin/flashrom_tester host Coreboot_ELOG_sanity
TEST=flashrom --image RW_ELOG -p host -r /tmp/file.tmp2 # comparison
TEST=hexdump the file and check magic signature == 0x474f4c45

Change-Id: I8ac63e15e063f9c0928e3e185154bb083b367ba9
Signed-off-by: Evan Benn <evanbenn@chromium.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/65119
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Peter Marheine <pmarheine@chromium.org>
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
This commit is contained in:
Evan Benn
2022-06-10 16:43:02 +10:00
committed by Edward O'Callaghan
parent b9e7d20d19
commit 4342cc0f14
4 changed files with 42 additions and 32 deletions

View File

@ -64,6 +64,7 @@ pub struct IOOpt<'a> {
pub write: Option<&'a str>, // -w <file>
pub verify: Option<&'a str>, // -v <file>
pub erase: bool, // -E
pub region: Option<&'a str>, // --image
}
#[derive(PartialEq, Debug)]
@ -264,6 +265,22 @@ impl crate::Flashrom for FlashromCmd {
Ok(())
}
fn read_region(&self, path: &str, region: &str) -> Result<(), FlashromError> {
let opts = FlashromOpt {
io_opt: IOOpt {
read: Some(path),
region: Some(region),
..Default::default()
},
..Default::default()
};
let (stdout, _) = self.dispatch(opts)?;
let output = String::from_utf8_lossy(stdout.as_slice());
debug!("read():\n{}", output);
Ok(())
}
fn write(&self, path: &str) -> Result<(), FlashromError> {
let opts = FlashromOpt {
io_opt: IOOpt {
@ -338,6 +355,10 @@ fn flashrom_decode_opts(opts: FlashromOpt) -> Vec<String> {
}
// io_opt
if let Some(region) = opts.io_opt.region {
params.push("--image".to_string());
params.push(region.to_string());
}
if opts.io_opt.read.is_some() {
params.push("-r".to_string());
params.push(opts.io_opt.read.unwrap().to_string());

View File

@ -114,6 +114,9 @@ pub trait Flashrom {
/// Read the whole flash to the file specified by `path`.
fn read(&self, path: &str) -> Result<(), FlashromError>;
/// Read only a region of the flash.
fn read_region(&self, path: &str, region: &str) -> Result<(), FlashromError>;
/// Write the whole flash to the file specified by `path`.
fn write(&self, path: &str) -> Result<(), FlashromError>;