diff options
author | Evan Benn <evanbenn@chromium.org> | 2022-05-25 16:38:17 +1000 |
---|---|---|
committer | Edward O'Callaghan <quasisec@chromium.org> | 2022-07-21 23:28:30 +0000 |
commit | b9e7d20d192ca15c704b2e59dca24d7bc654680b (patch) | |
tree | 3720ab506d109f9674bf796bff64936a03db6a48 /util/flashrom_tester/src/main.rs | |
parent | 96fb37cb0f3475ec3c996888b1e2eaae4bbb42cb (diff) | |
download | flashrom-b9e7d20d192ca15c704b2e59dca24d7bc654680b.tar.gz flashrom-b9e7d20d192ca15c704b2e59dca24d7bc654680b.tar.bz2 flashrom-b9e7d20d192ca15c704b2e59dca24d7bc654680b.zip |
flashrom_tester: Use Flashrom trait instead of struct FlashromCmd
To allow FlashromCmd to be reimplemented with libflashrom move all
concrete cmd functions into the FlashromCmd type that implements the
Flashrom trait. This allows users to be generalised upon the Flashrom
trait as the contract rather than the concrete FlashromCmd type.
Change-Id: Ie2b4e7e91d69043fd50d1c57f6585fc9946fab10
Signed-off-by: Evan Benn <evanbenn@chromium.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/64849
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Peter Marheine <pmarheine@chromium.org>
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
Diffstat (limited to 'util/flashrom_tester/src/main.rs')
-rw-r--r-- | util/flashrom_tester/src/main.rs | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/util/flashrom_tester/src/main.rs b/util/flashrom_tester/src/main.rs index 80484d20..69bb92db 100644 --- a/util/flashrom_tester/src/main.rs +++ b/util/flashrom_tester/src/main.rs @@ -39,7 +39,7 @@ extern crate log; mod logger; use clap::{App, Arg}; -use flashrom::FlashChip; +use flashrom::{FlashChip, Flashrom, FlashromCmd}; use flashrom_tester::{tester, tests}; use std::path::PathBuf; use std::sync::atomic::AtomicBool; @@ -123,6 +123,11 @@ fn main() { ) .expect("ccd_target_type should admit only known types"); + let cmd: Box<dyn Flashrom> = Box::new(FlashromCmd { + path: flashrom_path.to_string(), + fc: ccd_type, + }); + let print_layout = matches.is_present("print-layout"); let output_format = matches .value_of("output-format") @@ -132,7 +137,7 @@ fn main() { let test_names = matches.values_of("test_name"); if let Err(e) = tests::generic( - flashrom_path, + cmd.as_ref(), ccd_type, print_layout, output_format, |