mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
start of testing code for the PDDB
This commit is contained in:
parent
874a5ac20e
commit
18c202dcee
5 changed files with 35 additions and 1 deletions
|
|
@ -118,6 +118,9 @@ pub(crate) enum Opcode {
|
||||||
SuspendResume,
|
SuspendResume,
|
||||||
/// quit the server
|
/// quit the server
|
||||||
Quit,
|
Quit,
|
||||||
|
/// Write debug dump (only available in hosted mode)
|
||||||
|
#[cfg(not(any(target_os = "none", target_os = "xous")))]
|
||||||
|
DbgDump,
|
||||||
}
|
}
|
||||||
#[derive(num_derive::FromPrimitive, num_derive::ToPrimitive, Debug)]
|
#[derive(num_derive::FromPrimitive, num_derive::ToPrimitive, Debug)]
|
||||||
pub(crate) enum PollOp {
|
pub(crate) enum PollOp {
|
||||||
|
|
|
||||||
|
|
@ -583,6 +583,12 @@ impl Pddb {
|
||||||
}
|
}
|
||||||
Ok(dict_list)
|
Ok(dict_list)
|
||||||
}
|
}
|
||||||
|
#[cfg(not(any(target_os = "none", target_os = "xous")))]
|
||||||
|
pub fn dbg_dump(&self, name: &str) -> Result<()> {
|
||||||
|
let ipc_str = xous_ipc::String::<128>::from_str(name);
|
||||||
|
ipc_str.send(self.conn).expect("couldn't initiate debug dump");
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Drop for Pddb {
|
impl Drop for Pddb {
|
||||||
|
|
|
||||||
|
|
@ -1088,6 +1088,12 @@ fn xmain() -> ! {
|
||||||
}
|
}
|
||||||
modals.show_notification(¬e).expect("couldn't show basis list");
|
modals.show_notification(¬e).expect("couldn't show basis list");
|
||||||
},
|
},
|
||||||
|
#[cfg(not(any(target_os = "none", target_os = "xous")))]
|
||||||
|
Some(Opcode::DbgDump) => {
|
||||||
|
let dumpname = xous_ipc::String::<128>::from_message(msg.body.memory_message().unwrap()).unwrap();
|
||||||
|
log::info!("dumping {}", dumpname);
|
||||||
|
pddb_os.dbg_dump(Some(dumpname.as_str().unwrap().to_string()), None);
|
||||||
|
}
|
||||||
Some(Opcode::Quit) => {
|
Some(Opcode::Quit) => {
|
||||||
log::warn!("quitting the PDDB server");
|
log::warn!("quitting the PDDB server");
|
||||||
send_message(
|
send_message(
|
||||||
|
|
|
||||||
|
|
@ -83,7 +83,8 @@ 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.
|
||||||
benchmarks = [] # adds the benchmark routines. Left off normally to free up code and memory space.
|
benchmarks = [] # adds the benchmark routines. Left off normally to free up code and memory space.
|
||||||
tts = [] # adds text to speech plugin
|
tts = [] # adds text to speech plugin
|
||||||
default = [] # "debugprint"
|
pddbtest = []
|
||||||
|
default = ["pddbtest"] # "debugprint"
|
||||||
|
|
||||||
[target.'cfg(any(windows,unix))'.dependencies]
|
[target.'cfg(any(windows,unix))'.dependencies]
|
||||||
debug-here = "*"
|
debug-here = "*"
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,10 @@ impl<'a> ShellCmdApi<'a> for PddbCmd {
|
||||||
fn process(&mut self, args: String::<1024>, _env: &mut CommonEnv) -> Result<Option<String::<1024>>, xous::Error> {
|
fn process(&mut self, args: String::<1024>, _env: &mut CommonEnv) -> Result<Option<String::<1024>>, xous::Error> {
|
||||||
use core::fmt::Write;
|
use core::fmt::Write;
|
||||||
let mut ret = String::<1024>::new();
|
let mut ret = String::<1024>::new();
|
||||||
|
#[cfg(not(feature="pddbtest"))]
|
||||||
let helpstring = "pddb [basislist] [dictlist] [keylist] [query] [dictdelete] [keydelete]";
|
let helpstring = "pddb [basislist] [dictlist] [keylist] [query] [dictdelete] [keydelete]";
|
||||||
|
#[cfg(feature="pddbtest")]
|
||||||
|
let helpstring = "pddb [basislist] [dictlist] [keylist] [query] [dictdelete] [keydelete] [test]";
|
||||||
|
|
||||||
let mut tokens = args.as_str().unwrap().split(' ');
|
let mut tokens = args.as_str().unwrap().split(' ');
|
||||||
if let Some(sub_cmd) = tokens.next() {
|
if let Some(sub_cmd) = tokens.next() {
|
||||||
|
|
@ -164,6 +167,21 @@ impl<'a> ShellCmdApi<'a> for PddbCmd {
|
||||||
Err(_) => write!(ret, "Error encountered listing dictionaries").ok().unwrap_or(()),
|
Err(_) => write!(ret, "Error encountered listing dictionaries").ok().unwrap_or(()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// note that this feature only works in hosted mode
|
||||||
|
#[cfg(feature="pddbtest")]
|
||||||
|
"test" => {
|
||||||
|
let mut test_handle = pddb::Pddb::new();
|
||||||
|
let test_key = test_handle.get(
|
||||||
|
"test",
|
||||||
|
"zerolength",
|
||||||
|
None, true, true,
|
||||||
|
Some(8),
|
||||||
|
None::<fn()>
|
||||||
|
).expect("couldn't build empty key");
|
||||||
|
// test_handle.sync().expect("couldn't sync");
|
||||||
|
self.pddb.dbg_dump("std_test1").unwrap();
|
||||||
|
write!(ret, "dumped std_test1").unwrap();
|
||||||
|
}
|
||||||
_ => {
|
_ => {
|
||||||
write!(ret, "{}", helpstring).unwrap();
|
write!(ret, "{}", helpstring).unwrap();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue