1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-08-20 05:21:43 +02:00

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>
This commit is contained in:
Evan Benn
2022-05-25 16:38:17 +10:00
committed by Edward O'Callaghan
parent 96fb37cb0f
commit b9e7d20d19
5 changed files with 364 additions and 327 deletions

View File

@@ -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,