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>
diff --git a/sim/src/lib.rs b/sim/src/lib.rs
index 03bb2cb..1314c42 100644
--- a/sim/src/lib.rs
+++ b/sim/src/lib.rs
@@ -377,12 +377,12 @@
}
#[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 @@
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 @@
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 @@
}
#[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 @@
}
#[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;