1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-04-26 22:52:34 +02:00

flashrom_tester: Fix cmd read_region to read only the region

read_region for the CLI implementation was writing a file the size of
the whole flash, with only the region filled with real data. Now write
only the region to the file. This fixes the Coreboot_ELOG_sanity test
which regressed in 4342cc0f14e2945d7642e75e44346c13ca23089b.

BUG=b:241486407
BRANCH=None
TEST=flashrom_tester /usr/sbin/flashrom host Coreboot_ELOG_sanity

Change-Id: I97ff8c71861f1d0282a7d6173e196e3d0b41d746
Signed-off-by: Evan Benn <evanbenn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/flashrom/+/3812722
Tested-by: Edward O'Callaghan <quasisec@chromium.org>
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/66588
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
This commit is contained in:
Evan Benn 2022-08-05 14:17:00 +10:00 committed by Edward O'Callaghan
parent 41d0de0ad8
commit 6c1b0acc4c

View File

@ -60,11 +60,11 @@ pub struct WPOpt {
#[derive(Default)]
pub struct IOOpt<'a> {
pub read: Option<&'a str>, // -r <file>
pub write: Option<&'a str>, // -w <file>
pub verify: Option<&'a str>, // -v <file>
pub erase: bool, // -E
pub region: Option<&'a str>, // --image
pub read: Option<&'a str>, // -r <file>
pub write: Option<&'a str>, // -w <file>
pub verify: Option<&'a str>, // -v <file>
pub erase: bool, // -E
pub region: Option<(&'a str, &'a str)>, // --image
}
#[derive(PartialEq, Debug)]
@ -243,8 +243,7 @@ impl crate::Flashrom for FlashromCmd {
fn read_region(&self, path: &str, region: &str) -> Result<(), FlashromError> {
let opts = FlashromOpt {
io_opt: IOOpt {
read: Some(path),
region: Some(region),
region: Some((region, path)),
..Default::default()
},
..Default::default()
@ -322,11 +321,11 @@ fn flashrom_decode_opts(opts: FlashromOpt) -> Vec<String> {
}
// io_opt
if let Some(region) = opts.io_opt.region {
if let Some((region, path)) = opts.io_opt.region {
params.push("--image".to_string());
params.push(region.to_string());
}
if opts.io_opt.read.is_some() {
params.push(format!("{}:{}", region, path));
params.push("-r".to_string());
} else if opts.io_opt.read.is_some() {
params.push("-r".to_string());
params.push(opts.io_opt.read.unwrap().to_string());
} else if opts.io_opt.write.is_some() {