mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-17 08:40:52 +00:00
add more test features to the console; absorb board:: api for sizes
This commit is contained in:
parent
645846e32e
commit
5417c2bd87
2 changed files with 59 additions and 4 deletions
|
|
@ -23,6 +23,10 @@ modals = { path = "../modals", default-features = false }
|
|||
ux-api = { path = "../../libs/ux-api", optional = true }
|
||||
pddb = { path = "../pddb", features = ["gen2"] }
|
||||
|
||||
# pddb testing
|
||||
rand = { version = "0.8.5", features = ["getrandom"], optional = true }
|
||||
rand_chacha = { version = "0.3.1", optional = true }
|
||||
|
||||
[features]
|
||||
cramium-soc = [
|
||||
"utralib/cramium-soc",
|
||||
|
|
@ -41,11 +45,12 @@ hosted-baosec = [
|
|||
"usb-cramium/hosted-baosec",
|
||||
"cramium-emu",
|
||||
"pddb/hosted-baosec",
|
||||
"cramium-hal/hosted-baosec",
|
||||
]
|
||||
usb = []
|
||||
pddbtest = []
|
||||
test-rekey = []
|
||||
autobasis = []
|
||||
autobasis = ["rand_chacha", "rand"]
|
||||
modal-testing = ["ux-api", "modals/modal-testing"]
|
||||
test-scrollbars = []
|
||||
default = []
|
||||
default = ["pddbtest"]
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use std::path::PathBuf;
|
|||
|
||||
use String;
|
||||
#[cfg(all(feature = "pddbtest", feature = "autobasis"))]
|
||||
const PDDB_A_LEN: usize = cramium_emu::PDDB_LEN as usize;
|
||||
const PDDB_A_LEN: usize = cramium_hal::board::PDDB_LEN as usize;
|
||||
|
||||
use crate::{CommonEnv, ShellCmdApi};
|
||||
|
||||
|
|
@ -1184,7 +1184,7 @@ impl<'a> ShellCmdApi<'a> for PddbCmd {
|
|||
for i in 0..20 {
|
||||
let mut testkey = self
|
||||
.pddb
|
||||
.get("wlan.networks", "testkey", None, false, true, None, None::<fn()>)
|
||||
.get("wlan.networks", "testkey", None, true, true, None, None::<fn()>)
|
||||
.expect("couldn't make test key");
|
||||
testdata.push_str(&i.to_string());
|
||||
// testkey.seek(SeekFrom::Start(0)).ok();
|
||||
|
|
@ -1249,3 +1249,53 @@ fn join_tokens<'a>(buf: &mut String, tokens: impl Iterator<Item = &'a str>) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(all(feature = "pddbtest", feature = "autobasis"))]
|
||||
enum VectorType {
|
||||
Small(usize),
|
||||
Large(usize),
|
||||
Junk,
|
||||
}
|
||||
#[cfg(all(feature = "pddbtest", feature = "autobasis"))]
|
||||
const SMALL_SIZE: usize = 2011;
|
||||
#[cfg(all(feature = "pddbtest", feature = "autobasis"))]
|
||||
const LARGE_SIZE: usize = 28813;
|
||||
#[cfg(all(feature = "pddbtest", feature = "autobasis"))]
|
||||
const JUNK_SIZE: usize = 128 * 1024 - 2;
|
||||
#[cfg(all(feature = "pddbtest", feature = "autobasis"))]
|
||||
fn make_vector(basis_number: usize, vtype: VectorType) -> Vec<u8> {
|
||||
use rand::prelude::*;
|
||||
use rand_chacha::ChaCha8Rng;
|
||||
|
||||
let mut vector = Vec::<u8>::new();
|
||||
// seed format:
|
||||
// bottom 0xFFFF is reserved for the basis_number
|
||||
// next 0xFFF is resrved for the vector number
|
||||
// 0x8000_0000 when set means small, not set means large
|
||||
let typemod = match vtype {
|
||||
VectorType::Small(n) => 0x1_0000 * (n as u64) + 0x8000_0000,
|
||||
VectorType::Large(n) => 0x1_0000 * (n as u64) + 0x0000_0000,
|
||||
VectorType::Junk => 0x1_0000_000,
|
||||
};
|
||||
let mut rng = ChaCha8Rng::seed_from_u64(basis_number as u64 + typemod);
|
||||
match vtype {
|
||||
VectorType::Small(n) => {
|
||||
// multiply the vector number by some odd value so the vectors are not same-sized
|
||||
for _ in 0..SMALL_SIZE + 7 * n + basis_number {
|
||||
vector.push(rng.gen());
|
||||
}
|
||||
}
|
||||
VectorType::Large(n) => {
|
||||
// multiply the vector number by some odd value so the vectors are not same-sized
|
||||
for _ in 0..LARGE_SIZE + 1117 * n + basis_number {
|
||||
vector.push(rng.gen());
|
||||
}
|
||||
}
|
||||
VectorType::Junk => {
|
||||
for _ in 0..JUNK_SIZE + basis_number {
|
||||
vector.push(rng.gen());
|
||||
}
|
||||
}
|
||||
}
|
||||
vector
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue