add susres testing feature to the ticktimer-test-client

This commit is contained in:
bunnie 2024-01-06 15:45:20 +08:00
parent 10154b8372
commit 385e15084a
3 changed files with 20 additions and 0 deletions

2
Cargo.lock generated
View file

@ -4908,6 +4908,8 @@ dependencies = [
"log",
"xous 0.9.56 (registry+https://github.com/rust-lang/crates.io-index)",
"xous-api-log",
"xous-api-names",
"xous-api-susres",
]
[[package]]

View file

@ -10,6 +10,9 @@ version = "0.1.0"
xous = "0.9.56"
log = "0.4.14"
log-server = {package = "xous-api-log", version = "0.1.52"}
susres = {package = "xous-api-susres", version = "0.9.52", optional = true}
xous-names = {package = "xous-api-names", version = "0.9.54", optional = true}
[features]
susres-testing = ["susres", "xous-names"]
default = []

View file

@ -10,11 +10,26 @@ fn main() -> ! {
log::set_max_level(log::LevelFilter::Trace);
info!("my PID is {}", xous::process::id());
#[cfg(feature="susres-testing")]
const DELAY_MS: u64 = 2000;
#[cfg(not(feature="susres-testing"))]
const DELAY_MS: u64 = 5000;
#[cfg(feature="susres-testing")]
let xns = xous_names::XousNames::new().unwrap();
#[cfg(feature="susres-testing")]
let susres = susres::Susres::new_without_hook(&xns).unwrap();
for i in 0.. {
info!("Loop #{}, waiting {} ms", i, DELAY_MS);
sleep(Duration::from_millis(DELAY_MS));
#[cfg(feature="susres-testing")]
{
info!("initiate suspend");
susres.initiate_suspend().unwrap();
info!("after suspend, sleeping");
sleep(Duration::from_millis(DELAY_MS));
}
}
panic!("Finished endless loop");