add shellchat test routines for bulk read

This commit is contained in:
bunnie 2022-10-26 05:29:56 +08:00
parent bffe92cab9
commit 4c1e416244
2 changed files with 14 additions and 9 deletions

View file

@ -107,7 +107,7 @@ features = ["u32_backend", "rand"]
[features] [features]
precursor = ["utralib/precursor"] precursor = ["utralib/precursor"]
hosted = ["utralib/hosted"] hosted = ["utralib/hosted", "random-pick"]
renode = ["utralib/renode"] renode = ["utralib/renode"]
debugprint = [] debugprint = []
spinortest = [] # for spinor testing. contra-indicated with PDDB, as it steals memory from the PDDB. spinortest = [] # for spinor testing. contra-indicated with PDDB, as it steals memory from the PDDB.

View file

@ -6,11 +6,11 @@ use xous_ipc::String;
use std::io::{Write, Read, Seek, SeekFrom}; use std::io::{Write, Read, Seek, SeekFrom};
use core::fmt::Write as FmtWrite; use core::fmt::Write as FmtWrite;
#[cfg(feature="shellperf")] #[cfg(any(feature="shellperf", not(target_os = "xous")))]
const TEST_DICT: &'static str = "perftest"; const TEST_DICT: &'static str = "perftest";
#[cfg(feature="shellperf")] #[cfg(feature="shellperf")]
use perflib::*; use perflib::*;
#[cfg(feature="shellperf")] #[cfg(any(feature="shellperf", not(target_os = "xous")))]
use sha2::Digest; use sha2::Digest;
#[cfg(feature="shellperf")] #[cfg(feature="shellperf")]
const FILE_ID_SERVICES_SHELLCHAT_SRC_CMDS_PDDB_CMD: u32 = 2; const FILE_ID_SERVICES_SHELLCHAT_SRC_CMDS_PDDB_CMD: u32 = 2;
@ -927,17 +927,14 @@ impl<'a> ShellCmdApi<'a> for PddbCmd {
} }
} }
} }
#[cfg(feature="hosted")] #[cfg(not(target_os = "xous"))]
"rkyvtest" => { "rkyvtest" => {
use rkyv::{ use rkyv::{
archived_value, archived_value,
de::deserializers::AllocDeserializer, de::deserializers::AllocDeserializer,
ser::{Serializer, serializers::WriteSerializer}, ser::{Serializer, serializers::WriteSerializer},
AlignedVec, AlignedVec,
Archive,
Archived,
Deserialize, Deserialize,
Serialize,
}; };
let test = pddb::PddbKeyRecord { let test = pddb::PddbKeyRecord {
name: "test".to_string(), name: "test".to_string(),
@ -975,6 +972,14 @@ impl<'a> ShellCmdApi<'a> for PddbCmd {
let deserialized = archived.deserialize(&mut AllocDeserializer).unwrap(); let deserialized = archived.deserialize(&mut AllocDeserializer).unwrap();
log::info!("deserialized: {:?}", deserialized); log::info!("deserialized: {:?}", deserialized);
} }
#[cfg(not(target_os = "xous"))]
"bulktest" => {
let bulk_read = self.pddb.read_dict(TEST_DICT, None, None).unwrap();
log::info!("read {} records", bulk_read.len());
for record in bulk_read {
log::info!("{:?}", record);
}
}
#[cfg(feature="shellperf")] #[cfg(feature="shellperf")]
"v2p" => { "v2p" => {
// don't generate a new object since it clears the data, just do a raw dump // don't generate a new object since it clears the data, just do a raw dump
@ -1029,7 +1034,7 @@ impl<'a> ShellCmdApi<'a> for PddbCmd {
} }
} }
} }
#[cfg(feature="shellperf")] #[cfg(any(feature="shellperf", not(target_os = "xous")))]
"perfprep" => { "perfprep" => {
log::info!("Preparing test set for performance profiling"); log::info!("Preparing test set for performance profiling");
let words = [ let words = [
@ -1164,7 +1169,7 @@ fn join_tokens<'a>(buf: &mut String<1024>, tokens: impl Iterator<Item = &'a str>
} }
} }
#[cfg(feature="perflib")] #[cfg(any(feature="shellperf", not(target_os = "xous")))]
fn hex(data: Vec<u8>) -> std::string::String { fn hex(data: Vec<u8>) -> std::string::String {
use std::fmt::Write; use std::fmt::Write;
let mut s = std::string::String::with_capacity(2 * data.len()); let mut s = std::string::String::with_capacity(2 * data.len());