mirror of
https://review.coreboot.org/flashrom.git
synced 2025-04-28 15:33:42 +02:00
flashrom_tester: Add _into_file to function names
Rename Flashrom trait function names to reflect that the data is read to/from a file provided as an argument. BUG=None BRANCH=None TEST=cargo test; cargo check Change-Id: I0015c9bf64349a5512dbdb0ef6f3dad38aa2fd8e Signed-off-by: Evan Benn <evanbenn@chromium.org> Reviewed-on: https://review.coreboot.org/c/flashrom/+/66956 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
This commit is contained in:
parent
1acef16895
commit
b41bb5622c
@ -227,7 +227,7 @@ impl crate::Flashrom for FlashromCmd {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read(&self, path: &str) -> Result<(), FlashromError> {
|
fn read_into_file(&self, path: &str) -> Result<(), FlashromError> {
|
||||||
let opts = FlashromOpt {
|
let opts = FlashromOpt {
|
||||||
io_opt: IOOpt {
|
io_opt: IOOpt {
|
||||||
read: Some(path),
|
read: Some(path),
|
||||||
@ -236,11 +236,11 @@ impl crate::Flashrom for FlashromCmd {
|
|||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
self.dispatch(opts, "read")?;
|
self.dispatch(opts, "read_into_file")?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read_region(&self, path: &str, region: &str) -> Result<(), FlashromError> {
|
fn read_region_into_file(&self, path: &str, region: &str) -> Result<(), FlashromError> {
|
||||||
let opts = FlashromOpt {
|
let opts = FlashromOpt {
|
||||||
io_opt: IOOpt {
|
io_opt: IOOpt {
|
||||||
region: Some((region, path)),
|
region: Some((region, path)),
|
||||||
@ -249,11 +249,11 @@ impl crate::Flashrom for FlashromCmd {
|
|||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
let (stdout, _) = self.dispatch(opts, "read_region")?;
|
let (stdout, _) = self.dispatch(opts, "read_region_into_file")?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn write(&self, path: &str) -> Result<(), FlashromError> {
|
fn write_from_file(&self, path: &str) -> Result<(), FlashromError> {
|
||||||
let opts = FlashromOpt {
|
let opts = FlashromOpt {
|
||||||
io_opt: IOOpt {
|
io_opt: IOOpt {
|
||||||
write: Some(path),
|
write: Some(path),
|
||||||
@ -262,11 +262,11 @@ impl crate::Flashrom for FlashromCmd {
|
|||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
self.dispatch(opts, "write")?;
|
self.dispatch(opts, "write_from_file")?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn verify(&self, path: &str) -> Result<(), FlashromError> {
|
fn verify_from_file(&self, path: &str) -> Result<(), FlashromError> {
|
||||||
let opts = FlashromOpt {
|
let opts = FlashromOpt {
|
||||||
io_opt: IOOpt {
|
io_opt: IOOpt {
|
||||||
verify: Some(path),
|
verify: Some(path),
|
||||||
@ -275,7 +275,7 @@ impl crate::Flashrom for FlashromCmd {
|
|||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
self.dispatch(opts, "verify")?;
|
self.dispatch(opts, "verify_from_file")?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,16 +134,16 @@ pub trait Flashrom {
|
|||||||
fn wp_toggle(&self, en: bool) -> Result<bool, FlashromError>;
|
fn wp_toggle(&self, en: bool) -> Result<bool, FlashromError>;
|
||||||
|
|
||||||
/// Read the whole flash to the file specified by `path`.
|
/// Read the whole flash to the file specified by `path`.
|
||||||
fn read(&self, path: &str) -> Result<(), FlashromError>;
|
fn read_into_file(&self, path: &str) -> Result<(), FlashromError>;
|
||||||
|
|
||||||
/// Read only a region of the flash.
|
/// Read only a region of the flash.
|
||||||
fn read_region(&self, path: &str, region: &str) -> Result<(), FlashromError>;
|
fn read_region_into_file(&self, path: &str, region: &str) -> Result<(), FlashromError>;
|
||||||
|
|
||||||
/// Write the whole flash to the file specified by `path`.
|
/// Write the whole flash to the file specified by `path`.
|
||||||
fn write(&self, path: &str) -> Result<(), FlashromError>;
|
fn write_from_file(&self, path: &str) -> Result<(), FlashromError>;
|
||||||
|
|
||||||
/// Verify the whole flash against the file specified by `path`.
|
/// Verify the whole flash against the file specified by `path`.
|
||||||
fn verify(&self, path: &str) -> Result<(), FlashromError>;
|
fn verify_from_file(&self, path: &str) -> Result<(), FlashromError>;
|
||||||
|
|
||||||
/// Erase the whole flash.
|
/// Erase the whole flash.
|
||||||
fn erase(&self) -> Result<(), FlashromError>;
|
fn erase(&self) -> Result<(), FlashromError>;
|
||||||
|
@ -78,8 +78,8 @@ impl<'a> TestEnv<'a> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
info!("Stashing golden image for verification/recovery on completion");
|
info!("Stashing golden image for verification/recovery on completion");
|
||||||
out.cmd.read(&out.original_flash_contents)?;
|
out.cmd.read_into_file(&out.original_flash_contents)?;
|
||||||
out.cmd.verify(&out.original_flash_contents)?;
|
out.cmd.verify_from_file(&out.original_flash_contents)?;
|
||||||
|
|
||||||
info!("Generating random flash-sized data");
|
info!("Generating random flash-sized data");
|
||||||
rand_util::gen_rand_testdata(&out.random_data, rom_sz as usize)
|
rand_util::gen_rand_testdata(&out.random_data, rom_sz as usize)
|
||||||
@ -124,14 +124,16 @@ impl<'a> TestEnv<'a> {
|
|||||||
/// Return true if the current Flash contents are the same as the golden image
|
/// Return true if the current Flash contents are the same as the golden image
|
||||||
/// that was present at the start of testing.
|
/// that was present at the start of testing.
|
||||||
pub fn is_golden(&self) -> bool {
|
pub fn is_golden(&self) -> bool {
|
||||||
self.cmd.verify(&self.original_flash_contents).is_ok()
|
self.cmd
|
||||||
|
.verify_from_file(&self.original_flash_contents)
|
||||||
|
.is_ok()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Do whatever is necessary to make the current Flash contents the same as they
|
/// Do whatever is necessary to make the current Flash contents the same as they
|
||||||
/// were at the start of testing.
|
/// were at the start of testing.
|
||||||
pub fn ensure_golden(&mut self) -> Result<(), FlashromError> {
|
pub fn ensure_golden(&mut self) -> Result<(), FlashromError> {
|
||||||
self.wp.set_hw(false)?.set_sw(false)?;
|
self.wp.set_hw(false)?.set_sw(false)?;
|
||||||
self.cmd.write(&self.original_flash_contents)?;
|
self.cmd.write_from_file(&self.original_flash_contents)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,7 +148,7 @@ impl<'a> TestEnv<'a> {
|
|||||||
///
|
///
|
||||||
/// Returns Err if they are not the same.
|
/// Returns Err if they are not the same.
|
||||||
pub fn verify(&self, contents_path: &str) -> Result<(), FlashromError> {
|
pub fn verify(&self, contents_path: &str) -> Result<(), FlashromError> {
|
||||||
self.cmd.verify(contents_path)?;
|
self.cmd.verify_from_file(contents_path)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -243,7 +243,8 @@ fn elog_sanity_test(env: &mut TestEnv) -> TestResult {
|
|||||||
env.ensure_golden()?;
|
env.ensure_golden()?;
|
||||||
|
|
||||||
const ELOG_RW_REGION_NAME: &str = "RW_ELOG";
|
const ELOG_RW_REGION_NAME: &str = "RW_ELOG";
|
||||||
env.cmd.read_region(ELOG_FILE, ELOG_RW_REGION_NAME)?;
|
env.cmd
|
||||||
|
.read_region_into_file(ELOG_FILE, ELOG_RW_REGION_NAME)?;
|
||||||
|
|
||||||
// Just checking for the magic numer
|
// Just checking for the magic numer
|
||||||
// TODO: improve this test to read the events
|
// TODO: improve this test to read the events
|
||||||
|
Loading…
x
Reference in New Issue
Block a user