sim: Create cargo tests for each testcase
Now that the test infrastructure has changed so that the tests can be run independently, create a series of cargo tests that run them. This allows the tests to simply be run as: cargo test or possibly with feature flags cargo test --features overwrite-only It is also possible to run individual tests by giving their name after the "cargo test" command. Signed-off-by: David Brown <david.brown@linaro.org>
This commit is contained in:
parent
c49811e855
commit
a4167efc8e
|
@ -377,12 +377,12 @@ impl Images {
|
|||
}
|
||||
|
||||
#[cfg(feature = "overwrite-only")]
|
||||
fn run_basic_revert(&self) -> bool {
|
||||
pub fn run_basic_revert(&self) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "overwrite-only"))]
|
||||
fn run_basic_revert(&self) -> bool {
|
||||
pub fn run_basic_revert(&self) -> bool {
|
||||
let mut fails = 0;
|
||||
|
||||
// FIXME: this test would also pass if no swap is ever performed???
|
||||
|
@ -400,7 +400,7 @@ impl Images {
|
|||
fails > 0
|
||||
}
|
||||
|
||||
fn run_perm_with_fails(&self) -> bool {
|
||||
pub fn run_perm_with_fails(&self) -> bool {
|
||||
let mut fails = 0;
|
||||
let total_flash_ops = self.total_count.unwrap();
|
||||
|
||||
|
@ -442,6 +442,10 @@ impl Images {
|
|||
fails > 0
|
||||
}
|
||||
|
||||
pub fn run_perm_with_random_fails_5(&self) -> bool {
|
||||
self.run_perm_with_random_fails(5)
|
||||
}
|
||||
|
||||
fn run_perm_with_random_fails(&self, total_fails: usize) -> bool {
|
||||
let mut fails = 0;
|
||||
let total_flash_ops = self.total_count.unwrap();
|
||||
|
@ -480,13 +484,12 @@ impl Images {
|
|||
}
|
||||
|
||||
#[cfg(feature = "overwrite-only")]
|
||||
#[allow(unused_variables)]
|
||||
fn run_revert_with_fails(&self) -> bool {
|
||||
pub fn run_revert_with_fails(&self) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "overwrite-only"))]
|
||||
fn run_revert_with_fails(&self) -> bool {
|
||||
pub fn run_revert_with_fails(&self) -> bool {
|
||||
let mut fails = 0;
|
||||
|
||||
if Caps::SwapUpgrade.present() {
|
||||
|
@ -503,12 +506,12 @@ impl Images {
|
|||
}
|
||||
|
||||
#[cfg(feature = "overwrite-only")]
|
||||
fn run_norevert(&self) -> bool {
|
||||
pub fn run_norevert(&self) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "overwrite-only"))]
|
||||
fn run_norevert(&self) -> bool {
|
||||
pub fn run_norevert(&self) -> bool {
|
||||
let mut fl = self.flash.clone();
|
||||
let mut fails = 0;
|
||||
|
||||
|
|
|
@ -4,20 +4,26 @@
|
|||
|
||||
extern crate bootsim;
|
||||
|
||||
use bootsim::{ALL_DEVICES, RunStatus};
|
||||
use bootsim::testlog;
|
||||
use bootsim::{Run, testlog};
|
||||
|
||||
#[test]
|
||||
fn core_tests() {
|
||||
testlog::setup();
|
||||
macro_rules! sim_test {
|
||||
($name:ident, $maker:ident, $test:ident) => {
|
||||
#[test]
|
||||
fn $name() {
|
||||
testlog::setup();
|
||||
|
||||
let mut status = RunStatus::new();
|
||||
|
||||
for &dev in ALL_DEVICES {
|
||||
for &align in &[1, 2, 4, 8] {
|
||||
status.run_single(dev, align);
|
||||
Run::each_device(|r| {
|
||||
let image = r.$maker();
|
||||
assert!(!image.$test());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
assert!(status.failures() == 0);
|
||||
};
|
||||
}
|
||||
|
||||
sim_test!(bad_slot1, make_bad_slot1_image, run_signfail_upgrade);
|
||||
sim_test!(norevert_newimage, make_no_upgrade_image, run_norevert_newimage);
|
||||
sim_test!(basic_revert, make_image, run_basic_revert);
|
||||
sim_test!(revert_with_fails, make_image, run_revert_with_fails);
|
||||
sim_test!(perm_with_fails, make_image, run_perm_with_fails);
|
||||
sim_test!(perm_with_random_fails, make_image, run_perm_with_random_fails_5);
|
||||
sim_test!(norevert, make_image, run_norevert);
|
||||
|
|
Loading…
Reference in New Issue