remove warnings when benchmarks are on; add log telemetry

this allows us to automate testing using the benchmark code
as a stress test
This commit is contained in:
bunnie 2023-02-26 01:00:45 +08:00
parent f3c28b4e20
commit 62c9f0d0ce
4 changed files with 27 additions and 11 deletions

View file

@ -192,7 +192,9 @@ impl CmdEnv {
) )
.expect("couldn't map event1 CSR range"); .expect("couldn't map event1 CSR range");
let common = CommonEnv { // _ prefix allows us to leave the `mut` here without creating a warning.
// the `mut` option is needed for some features.
let mut _common = CommonEnv {
llio: llio::Llio::new(&xns), llio: llio::Llio::new(&xns),
com: com::Com::new(&xns).expect("could't connect to COM"), com: com::Com::new(&xns).expect("could't connect to COM"),
ticktimer, ticktimer,
@ -209,28 +211,28 @@ impl CmdEnv {
}; };
//let fcc = Fcc::new(&mut common); //let fcc = Fcc::new(&mut common);
#[cfg(feature="benchmarks")] #[cfg(feature="benchmarks")]
let sha = Sha::new(&xns, &mut common); let sha = Sha::new(&xns, &mut _common);
#[cfg(feature="aestests")] #[cfg(feature="aestests")]
let aes = Aes::new(&xns, &mut common); let aes = Aes::new(&xns, &mut _common);
#[cfg(feature="benchmarks")] #[cfg(feature="benchmarks")]
let engine = Engine::new(&xns, &mut common); let engine = Engine::new(&xns, &mut _common);
//let memtest = Memtest::new(&xns, &mut common); //let memtest = Memtest::new(&xns, &mut common);
// print our version info // print our version info
let soc_ver = common.llio.soc_gitrev().unwrap(); let soc_ver = _common.llio.soc_gitrev().unwrap();
log::info!("SoC git rev {}", soc_ver.to_string()); log::info!("SoC git rev {}", soc_ver.to_string());
log::info!("{}PDDB.DNA,{:x},{}", xous::BOOKEND_START, common.llio.soc_dna().unwrap(), xous::BOOKEND_END); log::info!("{}PDDB.DNA,{:x},{}", xous::BOOKEND_START, _common.llio.soc_dna().unwrap(), xous::BOOKEND_END);
let (rev, dirty) = common.com.get_ec_git_rev().unwrap(); let (rev, dirty) = _common.com.get_ec_git_rev().unwrap();
let dirtystr = if dirty { "dirty" } else { "clean" }; let dirtystr = if dirty { "dirty" } else { "clean" };
log::info!("EC gateware git commit: {:x}, {}", rev, dirtystr); log::info!("EC gateware git commit: {:x}, {}", rev, dirtystr);
let ec_ver = common.com.get_ec_sw_tag().unwrap(); let ec_ver = _common.com.get_ec_sw_tag().unwrap();
log::info!("EC sw tag: {}", ec_ver.to_string()); log::info!("EC sw tag: {}", ec_ver.to_string());
let wf_ver = common.com.get_wf200_fw_rev().unwrap(); let wf_ver = _common.com.get_wf200_fw_rev().unwrap();
log::info!("WF200 fw rev {}.{}.{}", wf_ver.maj, wf_ver.min, wf_ver.rev); log::info!("WF200 fw rev {}.{}.{}", wf_ver.maj, wf_ver.min, wf_ver.rev);
CmdEnv { CmdEnv {
common_env: common, common_env: _common,
lastverb: String::<256>::new(), lastverb: String::<256>::new(),
///// 3. initialize your storage, by calling new() ///// 3. initialize your storage, by calling new()
sleep_cmd: Sleep::new(&xns), sleep_cmd: Sleep::new(&xns),

View file

@ -347,9 +347,11 @@ impl<'a> ShellCmdApi<'a> for Aes {
let modestr = if hw_mode != 0 { &"hw" } else { &"sw" }; let modestr = if hw_mode != 0 { &"hw" } else { &"sw" };
if pass != 0 { if pass != 0 {
write!(ret, "[{}] passed: {:.02}µs/block enc+dec AES{}", modestr, elapsed * 1000.0, keybits).unwrap(); write!(ret, "[{}] passed: {:.02}µs/block enc+dec AES{}", modestr, elapsed * 1000.0, keybits).unwrap();
log::info!("{}BENCH,AES,PASS,{}us/block,{}", xous::BOOKEND_START, elapsed * 1000.0, xous::BOOKEND_END);
} else { } else {
// pass was 0, we failed // pass was 0, we failed
write!(ret, "[{}] FAILED: {:.02}µs/block enc+dec AES{}", modestr, elapsed * 1000.0, keybits).unwrap(); write!(ret, "[{}] FAILED: {:.02}µs/block enc+dec AES{}", modestr, elapsed * 1000.0, keybits).unwrap();
log::info!("{}BENCH,AES,FAIL,{}us/block,{}", xous::BOOKEND_START, elapsed * 1000.0, xous::BOOKEND_END);
} }
}); });
Ok(Some(ret)) Ok(Some(ret))

View file

@ -469,7 +469,7 @@ impl<'a> ShellCmdApi<'a> for Engine {
} }
"ed" => { "ed" => {
use ed25519_dalek::*; use ed25519_dalek::*;
use ed25519::signature::Signature as _; // use ed25519::signature::Signature as _;
use hex::FromHex; use hex::FromHex;
let secret_key: &[u8] = b"833fe62409237b9d62ec77587520911e9a759cec1d19755b7da901b96dca3d42"; let secret_key: &[u8] = b"833fe62409237b9d62ec77587520911e9a759cec1d19755b7da901b96dca3d42";
let public_key: &[u8] = b"ec172b93ad5e563bf4932c70e1245034c35467ef2efd4d64ebf819683467e2bf"; let public_key: &[u8] = b"ec172b93ad5e563bf4932c70e1245034c35467ef2efd4d64ebf819683467e2bf";
@ -521,6 +521,7 @@ impl<'a> ShellCmdApi<'a> for Engine {
.filter_map(|test_index| WycheproofTestCase::read(test_index).run()) .filter_map(|test_index| WycheproofTestCase::read(test_index).run())
.collect(); .collect();
write!(ret, "Ran {} tests. {} failures.", WYCHEPROOF_NO_TEST_CASES, failures.len()).unwrap(); write!(ret, "Ran {} tests. {} failures.", WYCHEPROOF_NO_TEST_CASES, failures.len()).unwrap();
let num_failures = failures.len();
if failures.len() > 0 { if failures.len() > 0 {
write!(ret, "\nFailed tests: {:?}", failures.iter().map(|tc| tc.test_id).collect::<Vec<usize>>()).unwrap(); write!(ret, "\nFailed tests: {:?}", failures.iter().map(|tc| tc.test_id).collect::<Vec<usize>>()).unwrap();
for failure in failures { for failure in failures {
@ -528,6 +529,9 @@ impl<'a> ShellCmdApi<'a> for Engine {
log::error!("expected: {}", failure.expected.encode_hex::<std::string::String>()); log::error!("expected: {}", failure.expected.encode_hex::<std::string::String>());
log::error!("actual: {}", failure.actual.encode_hex::<std::string::String>()); log::error!("actual: {}", failure.actual.encode_hex::<std::string::String>());
} }
log::info!("{}BENCH,WYCHEPROOF,FAIL,{},{}", xous::BOOKEND_START, num_failures, xous::BOOKEND_END);
} else {
log::info!("{}BENCH,WYCHEPROOF,PASS,{}", xous::BOOKEND_START, xous::BOOKEND_END);
} }
} }
_ => { _ => {
@ -556,6 +560,11 @@ impl<'a> ShellCmdApi<'a> for Engine {
}, },
Some(BenchResult::DhDone) => { Some(BenchResult::DhDone) => {
write!(ret, "{}ms/DH_iter; Passed {} ops, failed {} ops", elapsed, passes, fails).unwrap(); write!(ret, "{}ms/DH_iter; Passed {} ops, failed {} ops", elapsed, passes, fails).unwrap();
if fails == 0 {
log::info!("{}BENCH,DH,PASS,{}", xous::BOOKEND_START, xous::BOOKEND_END);
} else {
log::info!("{}BENCH,DH,FAIL,{}", xous::BOOKEND_START, xous::BOOKEND_END);
}
}, },
_ => { _ => {
write!(ret, "Engine bench callback with unknown bench type").unwrap(); write!(ret, "Engine bench callback with unknown bench type").unwrap();

View file

@ -258,12 +258,15 @@ impl<'a> ShellCmdApi<'a> for Sha {
let modestr = if hw_mode != 0 { &"hw" } else { &"sw" }; let modestr = if hw_mode != 0 { &"hw" } else { &"sw" };
if first_time != 0 { if first_time != 0 {
write!(ret, "[{}] first pass: {}ms/hash", modestr, elapsed).unwrap(); write!(ret, "[{}] first pass: {}ms/hash", modestr, elapsed).unwrap();
log::info!("{}BENCH,SHA,FIRST,{}ms/hash,{}", xous::BOOKEND_START, elapsed, xous::BOOKEND_END);
} else { } else {
if pass != 0 { if pass != 0 {
write!(ret, "[{}] match to previous pass: {}ms/hash", modestr, elapsed).unwrap(); write!(ret, "[{}] match to previous pass: {}ms/hash", modestr, elapsed).unwrap();
log::info!("{}BENCH,SHA,PASS,{}ms/hash,{}", xous::BOOKEND_START, elapsed, xous::BOOKEND_END);
} else { } else {
// pass was 0, we failed // pass was 0, we failed
write!(ret, "[{}] FAILED match to previous pass: {}ms/hash", modestr, elapsed).unwrap(); write!(ret, "[{}] FAILED match to previous pass: {}ms/hash", modestr, elapsed).unwrap();
log::info!("{}BENCH,SHA,FAIL,{}ms/hash,{}", xous::BOOKEND_START, elapsed, xous::BOOKEND_END);
} }
} }
}); });