This closes #4.

Merge remote-tracking branch 'd3zd3z/sim' into mcuboot-master

* d3zd3z/sim:
  sim: Fix build paths for new directory layout
  sim: Test multiple reverts
  sim: Add dependency output
This commit is contained in:
Christopher Collins 2017-01-10 17:29:29 -08:00
commit 4c3ce3f70e
2 changed files with 35 additions and 7 deletions

View File

@ -2,6 +2,10 @@
extern crate gcc;
use std::fs;
use std::io;
use std::path::Path;
fn main() {
let mut conf = gcc::Config::new();
@ -9,7 +13,28 @@ fn main() {
conf.file("../boot/bootutil/src/bootutil_misc.c");
conf.file("csupport/run.c");
conf.include("../boot/bootutil/include");
conf.include("../zephyr/include");
conf.include("../boot/zephyr/include");
conf.debug(true);
conf.compile("libbootutil.a");
walk_dir("../boot").unwrap();
walk_dir("csupport").unwrap();
}
// Output the names of all files within a directory so that Cargo knows when to rebuild.
fn walk_dir<P: AsRef<Path>>(path: P) -> io::Result<()> {
for ent in fs::read_dir(path.as_ref())? {
let ent = ent?;
let p = ent.path();
if p.is_dir() {
walk_dir(p)?;
} else {
// Note that non-utf8 names will fail.
let name = p.to_str().unwrap();
if name.ends_with(".c") || name.ends_with(".h") {
println!("cargo:rerun-if-changed={}", name);
}
}
}
Ok(())
}

View File

@ -143,9 +143,11 @@ fn main() {
bad, total_count,
bad as f32 * 100.0 / total_count as f32);
info!("Try revert");
let fl2 = try_revert(&flash, &areadesc);
for count in 2 .. 5 {
info!("Try revert: {}", count);
let fl2 = try_revert(&flash, &areadesc, count);
assert!(verify_image(&fl2, 0x020000, &primary));
}
info!("Try norevert");
let fl2 = try_norevert(&flash, &areadesc);
@ -194,12 +196,13 @@ fn try_upgrade(flash: &Flash, areadesc: &AreaDesc, stop: Option<i32>) -> (Flash,
(fl, cnt2)
}
fn try_revert(flash: &Flash, areadesc: &AreaDesc) -> Flash {
fn try_revert(flash: &Flash, areadesc: &AreaDesc, count: usize) -> Flash {
let mut fl = flash.clone();
c::set_flash_counter(0);
for _ in 0 .. count {
assert_eq!(c::boot_go(&mut fl, &areadesc), 0);
assert_eq!(c::boot_go(&mut fl, &areadesc), 0);
}
fl
}