2021-12-25 07:58:27 +00:00
use rand ::prelude ::* ;
use rand_chacha ::ChaCha8Rng ;
2021-11-22 08:04:50 +00:00
use crate ::* ;
2021-12-25 07:58:27 +00:00
use core ::sync ::atomic ::{ AtomicU64 , Ordering } ;
2021-12-25 17:42:36 +00:00
use std ::collections ::BTreeSet ;
2021-12-28 21:49:07 +00:00
use std ::io ::{ Result , Error , ErrorKind } ;
2021-11-22 08:04:50 +00:00
2021-11-23 15:33:06 +00:00
const UPPER_BOUND : usize = 9000 ;
small keys had their data missing because i deleted it :-/
it's one of those bugs where you're like oh...right. it's doing
exactly what i told it to. I just told it to do the wrong thing.
Right. If you're updating data at the end of a file, you kind of
don't want to delete the file entirely then do the update.
Fix the code so that in the case of a file extension of a small
key, you're re-inserting the key in its entirety (not just the
updated portion) on the extension case.
Also handled an issue with large files where key extension
should not lead to overwrite of the neighboring data, and put
a cap of the large file limit of 32GiB. See comments for thoughts
on the trade-off of the large file limit versus the allocation
limit of the number of files and the physically realistic
outcomes for the PDDB. Basically as written the PDDB can handle
32GiB files (big enough to hold a blu-ray movie, but not a 4k/8k
movie, uncompressed movies, and/or large virtual machine images),
and can handle creation of files at an average rate of one per
second for 10 years without stop before running out of virtual
memory space.
This isn't "Web scale" as large servers will
definitely require files bigger than 32GiB these days, and
can easily create files at a rate of thousands per second. But,
the PDDB isn't performant enough nor targeted toward large
scale server applications. It should, however, be adequate for
pretty much any user data on a mobile phone if it were recompiled
for a 64-bit target. And, if you needed to scale up to bigger
files and/or more write cycles, the problem can be solved
with some simple memory allocation tricks on the large pool,
but because Precursor only has 16MiB of its own RAM to play
with, we don't implement that as the RAM overhead is both
detrimental and unnecessary at our scale of operation.
2021-11-25 09:56:39 +00:00
const LOWER_BOUND : usize = 12 ; // needs to be big enough to compute murmur3 hash + hold checksum
2021-11-23 15:33:06 +00:00
2021-12-26 18:49:08 +00:00
static RNG_LOCAL_STATE : AtomicU64 = AtomicU64 ::new ( 3 ) ;
2021-12-25 07:58:27 +00:00
2021-11-22 18:57:13 +00:00
fn gen_key ( dictname : & str , keynum : usize , lower_size_bound : usize , upper_size_bound : usize ) -> ( String , Vec ::< u8 > ) {
2021-12-26 18:49:08 +00:00
let mut rng = ChaCha8Rng ::seed_from_u64 ( RNG_LOCAL_STATE . load ( Ordering ::SeqCst ) + xous ::TESTING_RNG_SEED . load ( core ::sync ::atomic ::Ordering ::SeqCst ) ) ;
2021-11-22 18:57:13 +00:00
// we want roughly half our keys to be in the small bin, and half in the large bin
let keylen = if rng . gen_bool ( 0.5 ) {
rng . gen_range ( lower_size_bound .. VPAGE_SIZE )
} else {
rng . gen_range ( VPAGE_SIZE .. upper_size_bound )
} ;
// record the owning dictionary name & length with the key. This isn't mandatory for a key name,
// but it helps the test checking program check things.
let keyname = format! ( " sanitycheck| {} |key {} |len {} " , dictname , keynum , keylen ) ;
let mut keydata = Vec ::< u8 > ::new ( ) ;
for i in 0 .. keylen - 4 {
// the data starts with a number equal to the key number, and increments from there
keydata . push ( ( keynum + i ) as u8 ) ;
}
// a checksum is appended to each run of data
// copy the stored data, and pad it out to a multiple of word lengths with 0's so we can compute the checksum
let mut checkdata = Vec ::< u8 > ::new ( ) ;
for & b in & keydata {
checkdata . push ( b ) ;
}
while checkdata . len ( ) % 4 ! = 0 {
checkdata . push ( 0 ) ;
}
let checksum = murmur3_32 ( & checkdata , 0 ) ;
keydata . append ( & mut checksum . to_le_bytes ( ) . to_vec ( ) ) ;
2021-12-25 07:58:27 +00:00
RNG_LOCAL_STATE . store ( rng . next_u64 ( ) , Ordering ::SeqCst ) ;
2021-11-22 18:57:13 +00:00
( keyname , keydata )
}
pub ( crate ) fn create_basis_testcase ( hw : & mut PddbOs , basis_cache : & mut BasisCache ,
2021-11-23 19:57:50 +00:00
maybe_num_dicts : Option < usize > , maybe_num_keys : Option < usize > , maybe_key_sizes : Option < ( usize , usize ) > ,
maybe_extra_reserved : Option < usize > ,
2021-12-28 21:49:07 +00:00
) -> Result < ( ) > {
2021-11-22 08:04:50 +00:00
2021-11-22 20:36:58 +00:00
hw . pddb_format ( false ) . unwrap ( ) ;
2021-11-22 08:04:50 +00:00
let sys_basis = hw . pddb_mount ( ) . expect ( " couldn't mount system basis " ) ;
2021-11-28 15:54:58 +00:00
basis_cache . basis_add ( sys_basis ) ;
2021-11-22 08:04:50 +00:00
let num_dicts = maybe_num_dicts . unwrap_or ( 4 ) ;
let num_keys = maybe_num_keys . unwrap_or ( 34 ) ;
small keys had their data missing because i deleted it :-/
it's one of those bugs where you're like oh...right. it's doing
exactly what i told it to. I just told it to do the wrong thing.
Right. If you're updating data at the end of a file, you kind of
don't want to delete the file entirely then do the update.
Fix the code so that in the case of a file extension of a small
key, you're re-inserting the key in its entirety (not just the
updated portion) on the extension case.
Also handled an issue with large files where key extension
should not lead to overwrite of the neighboring data, and put
a cap of the large file limit of 32GiB. See comments for thoughts
on the trade-off of the large file limit versus the allocation
limit of the number of files and the physically realistic
outcomes for the PDDB. Basically as written the PDDB can handle
32GiB files (big enough to hold a blu-ray movie, but not a 4k/8k
movie, uncompressed movies, and/or large virtual machine images),
and can handle creation of files at an average rate of one per
second for 10 years without stop before running out of virtual
memory space.
This isn't "Web scale" as large servers will
definitely require files bigger than 32GiB these days, and
can easily create files at a rate of thousands per second. But,
the PDDB isn't performant enough nor targeted toward large
scale server applications. It should, however, be adequate for
pretty much any user data on a mobile phone if it were recompiled
for a 64-bit target. And, if you needed to scale up to bigger
files and/or more write cycles, the problem can be solved
with some simple memory allocation tricks on the large pool,
but because Precursor only has 16MiB of its own RAM to play
with, we don't implement that as the RAM overhead is both
detrimental and unnecessary at our scale of operation.
2021-11-25 09:56:39 +00:00
let ( key_lower_bound , key_upper_bound ) = maybe_key_sizes . unwrap_or ( ( LOWER_BOUND , UPPER_BOUND - 4 ) ) ; // 4 bytes for the CI checksum
2021-11-23 19:57:50 +00:00
let extra_reserved = maybe_extra_reserved . unwrap_or ( 0 ) ;
2021-11-22 08:04:50 +00:00
// make all the directories first
for dictnum in 1 ..= num_dicts {
let dictname = format! ( " dict {} " , dictnum ) ;
basis_cache . dict_add ( hw , & dictname , None ) . unwrap ( ) ;
}
// now add keys of various sizes, striping through each dictionary. Adding the keys cross-dictionary
// exercises the large pool allocator, as it is shared across multiple dictionaries.
for keynum in 1 ..= num_keys {
for dictnum in 1 ..= num_dicts {
let dictname = format! ( " dict {} " , dictnum ) ;
2021-11-22 18:57:13 +00:00
let ( keyname , keydata ) = gen_key ( & dictname , keynum , key_lower_bound , key_upper_bound ) ;
// now we're ready to write it out
2021-11-23 19:57:50 +00:00
if maybe_extra_reserved . is_none ( ) {
// we do this slightly funky way instead of just passing Some(0) because we want to test the "None" path explicitly
basis_cache . key_update ( hw , & dictname , & keyname , & keydata , None ,
None ,
2021-12-28 21:49:07 +00:00
None , false ) ? ;
2021-11-23 19:57:50 +00:00
} else {
basis_cache . key_update ( hw , & dictname , & keyname , & keydata , None ,
Some ( keydata . len ( ) + extra_reserved ) ,
2021-12-28 21:49:07 +00:00
None , false ) ? ;
2021-11-23 19:57:50 +00:00
}
2021-11-22 18:57:13 +00:00
}
}
2021-12-28 21:49:07 +00:00
Ok ( ( ) )
2021-11-22 18:57:13 +00:00
}
/// Delete & add dictionary consistency check
pub ( crate ) fn delete_add_dict_consistency ( hw : & mut PddbOs , basis_cache : & mut BasisCache ,
small keys had their data missing because i deleted it :-/
it's one of those bugs where you're like oh...right. it's doing
exactly what i told it to. I just told it to do the wrong thing.
Right. If you're updating data at the end of a file, you kind of
don't want to delete the file entirely then do the update.
Fix the code so that in the case of a file extension of a small
key, you're re-inserting the key in its entirety (not just the
updated portion) on the extension case.
Also handled an issue with large files where key extension
should not lead to overwrite of the neighboring data, and put
a cap of the large file limit of 32GiB. See comments for thoughts
on the trade-off of the large file limit versus the allocation
limit of the number of files and the physically realistic
outcomes for the PDDB. Basically as written the PDDB can handle
32GiB files (big enough to hold a blu-ray movie, but not a 4k/8k
movie, uncompressed movies, and/or large virtual machine images),
and can handle creation of files at an average rate of one per
second for 10 years without stop before running out of virtual
memory space.
This isn't "Web scale" as large servers will
definitely require files bigger than 32GiB these days, and
can easily create files at a rate of thousands per second. But,
the PDDB isn't performant enough nor targeted toward large
scale server applications. It should, however, be adequate for
pretty much any user data on a mobile phone if it were recompiled
for a 64-bit target. And, if you needed to scale up to bigger
files and/or more write cycles, the problem can be solved
with some simple memory allocation tricks on the large pool,
but because Precursor only has 16MiB of its own RAM to play
with, we don't implement that as the RAM overhead is both
detrimental and unnecessary at our scale of operation.
2021-11-25 09:56:39 +00:00
maybe_num_dicts : Option < usize > , maybe_num_keys : Option < usize > , maybe_key_sizes : Option < ( usize , usize ) > ,
2021-11-28 15:54:58 +00:00
maybe_extra_reserved : Option < usize > , basis_name : Option < & str >
2021-12-28 21:49:07 +00:00
) -> Result < ( ) > {
2021-11-22 18:57:13 +00:00
let evict_count = maybe_num_dicts . unwrap_or ( 1 ) ;
let num_keys = maybe_num_keys . unwrap_or ( 36 ) ;
small keys had their data missing because i deleted it :-/
it's one of those bugs where you're like oh...right. it's doing
exactly what i told it to. I just told it to do the wrong thing.
Right. If you're updating data at the end of a file, you kind of
don't want to delete the file entirely then do the update.
Fix the code so that in the case of a file extension of a small
key, you're re-inserting the key in its entirety (not just the
updated portion) on the extension case.
Also handled an issue with large files where key extension
should not lead to overwrite of the neighboring data, and put
a cap of the large file limit of 32GiB. See comments for thoughts
on the trade-off of the large file limit versus the allocation
limit of the number of files and the physically realistic
outcomes for the PDDB. Basically as written the PDDB can handle
32GiB files (big enough to hold a blu-ray movie, but not a 4k/8k
movie, uncompressed movies, and/or large virtual machine images),
and can handle creation of files at an average rate of one per
second for 10 years without stop before running out of virtual
memory space.
This isn't "Web scale" as large servers will
definitely require files bigger than 32GiB these days, and
can easily create files at a rate of thousands per second. But,
the PDDB isn't performant enough nor targeted toward large
scale server applications. It should, however, be adequate for
pretty much any user data on a mobile phone if it were recompiled
for a 64-bit target. And, if you needed to scale up to bigger
files and/or more write cycles, the problem can be solved
with some simple memory allocation tricks on the large pool,
but because Precursor only has 16MiB of its own RAM to play
with, we don't implement that as the RAM overhead is both
detrimental and unnecessary at our scale of operation.
2021-11-25 09:56:39 +00:00
let ( key_lower_bound , key_upper_bound ) = maybe_key_sizes . unwrap_or ( ( LOWER_BOUND , UPPER_BOUND - 4 ) ) ;
let extra_reserved = maybe_extra_reserved . unwrap_or ( 0 ) ;
2021-11-22 18:57:13 +00:00
2021-12-25 17:42:36 +00:00
#[ cfg(feature = " deterministic " ) ]
2021-12-25 08:44:24 +00:00
let mut dict_list = BTreeSet ::< String > ::new ( ) ;
2021-12-25 17:42:36 +00:00
#[ cfg(feature = " deterministic " ) ]
{
let dict_list_unord = basis_cache . dict_list ( hw , None ) ;
for s in dict_list_unord {
dict_list . insert ( s ) ;
}
2021-12-25 08:44:24 +00:00
}
2021-12-25 17:42:36 +00:00
#[ cfg(not(feature = " deterministic " )) ]
let dict_list = basis_cache . dict_list ( hw , None ) ;
2021-11-22 18:57:13 +00:00
let dict_start_index = dict_list . len ( ) ;
for ( evicted , evict_dict ) in dict_list . iter ( ) . enumerate ( ) {
if evicted < evict_count {
2021-11-28 15:54:58 +00:00
match basis_cache . dict_remove ( hw , evict_dict , basis_name , false ) {
2021-11-22 18:57:13 +00:00
Ok ( _ ) = > { } ,
Err ( e ) = > log ::error! ( " Error evicting dictionary {}: {:?} " , evict_dict , e ) ,
2021-11-22 08:04:50 +00:00
}
2021-11-22 18:57:13 +00:00
} else {
break ;
}
}
for keynum in 1 ..= num_keys {
for dictnum in 1 ..= evict_count {
let dictname = format! ( " dict {} " , dictnum + dict_start_index ) ;
let ( keyname , keydata ) = gen_key ( & dictname , keynum , key_lower_bound , key_upper_bound ) ;
2021-11-22 08:04:50 +00:00
// now we're ready to write it out
small keys had their data missing because i deleted it :-/
it's one of those bugs where you're like oh...right. it's doing
exactly what i told it to. I just told it to do the wrong thing.
Right. If you're updating data at the end of a file, you kind of
don't want to delete the file entirely then do the update.
Fix the code so that in the case of a file extension of a small
key, you're re-inserting the key in its entirety (not just the
updated portion) on the extension case.
Also handled an issue with large files where key extension
should not lead to overwrite of the neighboring data, and put
a cap of the large file limit of 32GiB. See comments for thoughts
on the trade-off of the large file limit versus the allocation
limit of the number of files and the physically realistic
outcomes for the PDDB. Basically as written the PDDB can handle
32GiB files (big enough to hold a blu-ray movie, but not a 4k/8k
movie, uncompressed movies, and/or large virtual machine images),
and can handle creation of files at an average rate of one per
second for 10 years without stop before running out of virtual
memory space.
This isn't "Web scale" as large servers will
definitely require files bigger than 32GiB these days, and
can easily create files at a rate of thousands per second. But,
the PDDB isn't performant enough nor targeted toward large
scale server applications. It should, however, be adequate for
pretty much any user data on a mobile phone if it were recompiled
for a 64-bit target. And, if you needed to scale up to bigger
files and/or more write cycles, the problem can be solved
with some simple memory allocation tricks on the large pool,
but because Precursor only has 16MiB of its own RAM to play
with, we don't implement that as the RAM overhead is both
detrimental and unnecessary at our scale of operation.
2021-11-25 09:56:39 +00:00
if maybe_extra_reserved . is_none ( ) {
// we do this slightly funky way instead of just passing Some(0) because we want to test the "None" path explicitly
basis_cache . key_update ( hw , & dictname , & keyname , & keydata , None ,
None ,
2021-12-28 21:49:07 +00:00
basis_name , false ) ? ;
small keys had their data missing because i deleted it :-/
it's one of those bugs where you're like oh...right. it's doing
exactly what i told it to. I just told it to do the wrong thing.
Right. If you're updating data at the end of a file, you kind of
don't want to delete the file entirely then do the update.
Fix the code so that in the case of a file extension of a small
key, you're re-inserting the key in its entirety (not just the
updated portion) on the extension case.
Also handled an issue with large files where key extension
should not lead to overwrite of the neighboring data, and put
a cap of the large file limit of 32GiB. See comments for thoughts
on the trade-off of the large file limit versus the allocation
limit of the number of files and the physically realistic
outcomes for the PDDB. Basically as written the PDDB can handle
32GiB files (big enough to hold a blu-ray movie, but not a 4k/8k
movie, uncompressed movies, and/or large virtual machine images),
and can handle creation of files at an average rate of one per
second for 10 years without stop before running out of virtual
memory space.
This isn't "Web scale" as large servers will
definitely require files bigger than 32GiB these days, and
can easily create files at a rate of thousands per second. But,
the PDDB isn't performant enough nor targeted toward large
scale server applications. It should, however, be adequate for
pretty much any user data on a mobile phone if it were recompiled
for a 64-bit target. And, if you needed to scale up to bigger
files and/or more write cycles, the problem can be solved
with some simple memory allocation tricks on the large pool,
but because Precursor only has 16MiB of its own RAM to play
with, we don't implement that as the RAM overhead is both
detrimental and unnecessary at our scale of operation.
2021-11-25 09:56:39 +00:00
} else {
basis_cache . key_update ( hw , & dictname , & keyname , & keydata , None ,
Some ( keydata . len ( ) + extra_reserved ) ,
2021-12-28 21:49:07 +00:00
basis_name , false ) ? ;
small keys had their data missing because i deleted it :-/
it's one of those bugs where you're like oh...right. it's doing
exactly what i told it to. I just told it to do the wrong thing.
Right. If you're updating data at the end of a file, you kind of
don't want to delete the file entirely then do the update.
Fix the code so that in the case of a file extension of a small
key, you're re-inserting the key in its entirety (not just the
updated portion) on the extension case.
Also handled an issue with large files where key extension
should not lead to overwrite of the neighboring data, and put
a cap of the large file limit of 32GiB. See comments for thoughts
on the trade-off of the large file limit versus the allocation
limit of the number of files and the physically realistic
outcomes for the PDDB. Basically as written the PDDB can handle
32GiB files (big enough to hold a blu-ray movie, but not a 4k/8k
movie, uncompressed movies, and/or large virtual machine images),
and can handle creation of files at an average rate of one per
second for 10 years without stop before running out of virtual
memory space.
This isn't "Web scale" as large servers will
definitely require files bigger than 32GiB these days, and
can easily create files at a rate of thousands per second. But,
the PDDB isn't performant enough nor targeted toward large
scale server applications. It should, however, be adequate for
pretty much any user data on a mobile phone if it were recompiled
for a 64-bit target. And, if you needed to scale up to bigger
files and/or more write cycles, the problem can be solved
with some simple memory allocation tricks on the large pool,
but because Precursor only has 16MiB of its own RAM to play
with, we don't implement that as the RAM overhead is both
detrimental and unnecessary at our scale of operation.
2021-11-25 09:56:39 +00:00
}
2021-11-22 08:04:50 +00:00
}
}
2021-12-28 21:49:07 +00:00
Ok ( ( ) )
2021-11-22 08:28:26 +00:00
}
2021-11-22 20:36:58 +00:00
/// patch data check
pub ( crate ) fn patch_test ( hw : & mut PddbOs , basis_cache : & mut BasisCache ,
2021-12-28 21:49:07 +00:00
maybe_patch_offset : Option < usize > , maybe_patch_data : Option < String > , extend : bool ) -> Result < ( ) > {
2021-11-22 08:28:26 +00:00
2021-11-22 20:36:58 +00:00
let patch_offset = maybe_patch_offset . unwrap_or ( 5 ) ;
let patch_data = maybe_patch_data . unwrap_or ( " patched! " . to_string ( ) ) ;
2021-11-22 08:28:26 +00:00
2021-12-25 17:42:36 +00:00
#[ cfg(feature = " deterministic " ) ]
2021-12-25 08:44:24 +00:00
let mut dict_list = BTreeSet ::< String > ::new ( ) ;
2021-12-25 17:42:36 +00:00
#[ cfg(feature = " deterministic " ) ]
{
let dict_list_unord = basis_cache . dict_list ( hw , None ) ;
for s in dict_list_unord {
dict_list . insert ( s ) ;
}
2021-12-25 08:44:24 +00:00
}
2021-12-25 17:42:36 +00:00
#[ cfg(not(feature = " deterministic " )) ]
let dict_list = basis_cache . dict_list ( hw , None ) ;
2021-11-22 20:36:58 +00:00
for dict in dict_list . iter ( ) {
2021-12-25 08:44:24 +00:00
if let Ok ( key_list_unord ) = basis_cache . key_list ( hw , dict , None ) {
2021-12-25 17:42:36 +00:00
#[ cfg(feature = " deterministic " ) ]
2021-12-25 08:44:24 +00:00
let mut key_list = BTreeSet ::< String > ::new ( ) ;
2021-12-25 17:42:36 +00:00
#[ cfg(feature = " deterministic " ) ]
2021-12-25 08:44:24 +00:00
for s in key_list_unord {
key_list . insert ( s ) ;
}
2021-12-25 17:42:36 +00:00
#[ cfg(not(feature = " deterministic " )) ]
let key_list = key_list_unord ;
2021-11-22 20:36:58 +00:00
for key in key_list . iter ( ) {
// this actually does something a bit more complicated on a multi-basis system than you'd think:
// it will get the union of all key names, and then patch the *latest open basis* only with new data.
// note: if the key didn't already exist in the latest open basis, it's added, with just that patch data in it.
// to override this behavior, you'd want to specify a _specific_ basis, but for testing purposes, we only have one
// so we're doing this way that would lead to surprising results if it were copied as template code elsewhere.
2021-11-24 19:14:29 +00:00
match basis_cache . key_update ( hw , dict , key , patch_data . as_bytes ( ) , Some ( patch_offset ) , None , None , false ) {
Ok ( _ ) = > ( ) ,
Err ( e ) = > {
log ::error! ( " couldn't update key {}:{} with {} bytes data offset {}: {:?} " , dict , key , patch_data . as_bytes ( ) . len ( ) , patch_offset , e ) ;
panic! ( " error updating patch key " ) ;
}
}
2021-11-23 15:33:06 +00:00
2021-12-27 22:47:33 +00:00
log ::debug! ( " bef readback " ) ;
2021-11-23 15:33:06 +00:00
// now fix the CI checksum. structured as two separate patches. not because it's efficient,
// but because it exercises the code harder.
2021-11-24 06:50:44 +00:00
let mut patchbuf = [ 0 u8 ; UPPER_BOUND ] ;
2021-11-23 15:33:06 +00:00
let readlen = basis_cache . key_read ( hw , dict , key , & mut patchbuf , Some ( 0 ) , None ) . unwrap ( ) ;
2021-12-28 21:49:07 +00:00
log ::debug! ( " bef no extend " ) ;
2021-11-23 19:57:50 +00:00
if ! extend {
2021-12-28 21:49:07 +00:00
log ::debug! ( " bef no extend " ) ;
2021-11-23 19:57:50 +00:00
// now re-compute the checksum
let mut checkdata = Vec ::< u8 > ::new ( ) ;
for & b in & patchbuf [ .. readlen - 4 ] {
checkdata . push ( b ) ;
}
log ::trace! ( " checkdata len: {} " , checkdata . len ( ) ) ;
while checkdata . len ( ) % 4 ! = 0 {
checkdata . push ( 0 ) ;
}
let checksum = murmur3_32 ( & checkdata , 0 ) ;
2021-12-28 21:49:07 +00:00
basis_cache . key_update ( hw , dict , key , & checksum . to_le_bytes ( ) , Some ( readlen - 4 ) , None , None , false ) ? ;
2021-11-23 19:57:50 +00:00
} else {
2021-12-28 21:49:07 +00:00
log ::debug! ( " extend " ) ;
2021-11-23 19:57:50 +00:00
// this gloms a new checksum onto the existing record, adding 4 new bytes.
let mut checkdata = Vec ::< u8 > ::new ( ) ;
2021-11-24 19:14:29 +00:00
for & b in & patchbuf [ .. readlen ] {
2021-11-23 19:57:50 +00:00
checkdata . push ( b ) ;
}
2021-11-25 19:08:08 +00:00
log ::trace! ( " checkdata len: {} " , checkdata . len ( ) ) ;
2021-11-23 19:57:50 +00:00
while checkdata . len ( ) % 4 ! = 0 {
checkdata . push ( 0 ) ;
}
let checksum = murmur3_32 ( & checkdata , 0 ) ;
2021-12-28 21:49:07 +00:00
basis_cache . key_update ( hw , dict , key , & checksum . to_le_bytes ( ) , Some ( readlen ) , None , None , false ) ? ;
2021-11-23 15:33:06 +00:00
}
2021-11-22 20:36:58 +00:00
}
2021-11-22 08:28:26 +00:00
}
}
2021-12-28 21:49:07 +00:00
Ok ( ( ) )
2021-11-23 19:57:50 +00:00
}
2021-11-25 19:08:08 +00:00
pub ( crate ) fn delete_pattern ( hw : & mut PddbOs , basis_cache : & mut BasisCache ,
maybe_num_dicts : Option < usize > , maybe_num_keys : Option < usize > , maybe_key_sizes : Option < ( usize , usize ) > ,
maybe_extra_reserved : Option < usize > ,
2021-12-28 21:49:07 +00:00
) -> Result < ( ) > {
2021-11-25 19:08:08 +00:00
let evict_count = maybe_num_dicts . unwrap_or ( 2 ) ;
let num_keys = maybe_num_keys . unwrap_or ( 36 ) ;
let ( key_lower_bound , key_upper_bound ) = maybe_key_sizes . unwrap_or ( ( LOWER_BOUND , UPPER_BOUND - 4 ) ) ;
let extra_reserved = maybe_extra_reserved . unwrap_or ( 0 ) ;
let mut evicted_dicts = Vec ::< String > ::new ( ) ;
2021-12-25 17:42:36 +00:00
#[ cfg(feature = " deterministic " ) ]
2021-12-25 08:44:24 +00:00
let mut dict_list = BTreeSet ::< String > ::new ( ) ;
2021-12-25 17:42:36 +00:00
#[ cfg(feature = " deterministic " ) ]
{
let dict_list_unord = basis_cache . dict_list ( hw , None ) ;
for s in dict_list_unord {
dict_list . insert ( s ) ;
}
2021-12-25 08:44:24 +00:00
}
2021-12-25 17:42:36 +00:00
#[ cfg(not(feature = " deterministic " )) ]
let dict_list = basis_cache . dict_list ( hw , None ) ;
2021-11-25 19:08:08 +00:00
let mut evict_iter = 0 ;
for ( evicted , evict_dict ) in dict_list . iter ( ) . enumerate ( ) {
if evicted < evict_count {
2021-12-25 08:44:24 +00:00
let key_list_unord = basis_cache . key_list ( hw , evict_dict , None ) . unwrap ( ) ;
let mut key_list = BTreeSet ::< String > ::new ( ) ;
for s in key_list_unord {
key_list . insert ( s ) ;
}
for ( index , key ) in key_list . iter ( ) . enumerate ( ) {
2021-11-25 19:08:08 +00:00
if index % 2 = = ( evict_iter % 2 ) { // exercise odd/even patterns
log ::info! ( " deleting {}:{} " , evict_dict , key ) ;
basis_cache . key_remove ( hw , evict_dict , key , None , false ) . unwrap ( ) ;
let da = basis_cache . dict_attributes ( hw , evict_dict , None ) . unwrap ( ) ;
log ::info! ( " {:?} " , da ) ;
}
}
} else {
break ;
}
evicted_dicts . push ( evict_dict . to_string ( ) ) ;
evict_iter + = 1 ;
}
2021-12-25 17:42:36 +00:00
#[ cfg(feature = " deterministic " ) ]
2021-12-25 08:44:24 +00:00
let mut dict_list = BTreeSet ::< String > ::new ( ) ;
2021-12-25 17:42:36 +00:00
#[ cfg(feature = " deterministic " ) ]
{
let dict_list_unord = basis_cache . dict_list ( hw , None ) ;
for s in dict_list_unord {
dict_list . insert ( s ) ;
}
2021-12-25 08:44:24 +00:00
}
2021-12-25 17:42:36 +00:00
#[ cfg(not(feature = " deterministic " )) ]
let dict_list = basis_cache . dict_list ( hw , None ) ;
2021-12-25 08:44:24 +00:00
for dict in dict_list . iter ( ) {
2021-11-25 19:08:08 +00:00
let da = basis_cache . dict_attributes ( hw , dict , None ) . unwrap ( ) ;
2021-12-21 23:09:30 +00:00
log ::debug! ( " {:?} " , da ) ;
2021-11-25 19:08:08 +00:00
}
for keynum in 1 ..= num_keys {
for dictname in evicted_dicts . iter ( ) {
let ( keyname , keydata ) = gen_key ( dictname , keynum , key_lower_bound , key_upper_bound ) ;
// now we're ready to write it out
2022-01-01 07:14:44 +00:00
match basis_cache . key_attributes ( hw , dictname , & keyname , None ) {
Ok ( ka ) = > {
log ::warn! ( " rng collision on keygen: {}, deleting key " , keyname ) ;
basis_cache . key_remove ( hw , dictname , & keyname , None , false ) ? ;
}
_ = > {
}
}
2021-11-25 19:08:08 +00:00
if maybe_extra_reserved . is_none ( ) {
// we do this slightly funky way instead of just passing Some(0) because we want to test the "None" path explicitly
basis_cache . key_update ( hw , dictname , & keyname , & keydata , None ,
None ,
2021-12-28 21:49:07 +00:00
None , false ) ? ;
2021-11-25 19:08:08 +00:00
} else {
basis_cache . key_update ( hw , dictname , & keyname , & keydata , None ,
Some ( keydata . len ( ) + extra_reserved ) ,
2021-12-28 21:49:07 +00:00
None , false ) ? ;
2021-11-25 19:08:08 +00:00
}
}
}
2021-12-25 17:42:36 +00:00
#[ cfg(feature = " deterministic " ) ]
2021-12-25 08:44:24 +00:00
let mut dict_list = BTreeSet ::< String > ::new ( ) ;
2021-12-25 17:42:36 +00:00
#[ cfg(feature = " deterministic " ) ]
{
let dict_list_unord = basis_cache . dict_list ( hw , None ) ;
for s in dict_list_unord {
dict_list . insert ( s ) ;
}
2021-12-25 08:44:24 +00:00
}
2021-12-25 17:42:36 +00:00
#[ cfg(not(feature = " deterministic " )) ]
let dict_list = basis_cache . dict_list ( hw , None ) ;
2021-12-25 08:44:24 +00:00
for dict in dict_list . iter ( ) {
2021-11-25 19:36:36 +00:00
let da = basis_cache . dict_attributes ( hw , dict , None ) . unwrap ( ) ;
2021-12-21 23:09:30 +00:00
log ::debug! ( " {:?} " , da ) ;
2021-11-25 19:36:36 +00:00
}
2021-11-25 19:08:08 +00:00
log ::info! ( " doing all-basis sync " ) ;
basis_cache . sync ( hw , None ) . unwrap ( ) ;
log ::info! ( " all-basis sync done " ) ;
2021-11-25 19:36:36 +00:00
list_all ( hw , basis_cache ) ;
2021-12-25 17:42:36 +00:00
#[ cfg(feature = " deterministic " ) ]
2021-12-25 08:44:24 +00:00
let mut dict_list = BTreeSet ::< String > ::new ( ) ;
2021-12-25 17:42:36 +00:00
#[ cfg(feature = " deterministic " ) ]
{
let dict_list_unord = basis_cache . dict_list ( hw , None ) ;
for s in dict_list_unord {
dict_list . insert ( s ) ;
}
2021-12-25 08:44:24 +00:00
}
2021-12-25 17:42:36 +00:00
#[ cfg(not(feature = " deterministic " )) ]
let dict_list = basis_cache . dict_list ( hw , None ) ;
2021-12-25 08:44:24 +00:00
for dict in dict_list . iter ( ) {
2021-11-25 19:36:36 +00:00
let da = basis_cache . dict_attributes ( hw , dict , None ) . unwrap ( ) ;
log ::info! ( " {:?} " , da ) ;
}
2021-12-28 21:49:07 +00:00
Ok ( ( ) )
2021-11-25 19:36:36 +00:00
}
pub ( crate ) fn list_all ( hw : & mut PddbOs , basis_cache : & mut BasisCache ) {
2021-12-25 17:42:36 +00:00
#[ cfg(feature = " deterministic " ) ]
2021-12-25 08:44:24 +00:00
let mut dict_list = BTreeSet ::< String > ::new ( ) ;
2021-12-25 17:42:36 +00:00
#[ cfg(feature = " deterministic " ) ]
{
let dict_list_unord = basis_cache . dict_list ( hw , None ) ;
for s in dict_list_unord {
dict_list . insert ( s ) ;
}
2021-12-25 08:44:24 +00:00
}
2021-12-25 17:42:36 +00:00
#[ cfg(not(feature = " deterministic " )) ]
let dict_list = basis_cache . dict_list ( hw , None ) ;
2021-12-25 08:44:24 +00:00
2021-11-25 19:08:08 +00:00
// now list all the attributes of the basis
2021-12-25 08:44:24 +00:00
for dict in dict_list . iter ( ) {
2021-11-29 16:38:29 +00:00
let da = match basis_cache . dict_attributes ( hw , & dict , None ) {
Ok ( da ) = > da ,
Err ( e ) = > {
log ::warn! ( " dictionary {} not in sub-basis (this is normal for multi-basis systems, {:?} " , dict , e ) ;
continue ;
}
} ;
2021-12-21 23:09:30 +00:00
log ::debug! ( " {:?} " , da ) ;
2021-11-25 19:08:08 +00:00
let mut sanity_count = 0 ;
2021-11-29 16:38:29 +00:00
for key in basis_cache . key_list ( hw , dict , None ) . unwrap ( ) . iter ( ) {
let attrs = match basis_cache . key_attributes ( hw , dict , key , None ) {
Ok ( a ) = > a ,
Err ( e ) = > { log ::debug! ( " key not in basis, searching another basis, {:?} " , e ) ; continue } ,
} ;
2021-12-21 23:09:30 +00:00
log ::debug! ( " {}:{}=>{:?} " , dict , key , attrs ) ;
2021-11-25 19:08:08 +00:00
sanity_count + = 1 ;
}
log ::info! ( " sanity check count: {} " , sanity_count ) ;
}
}
2021-12-28 21:49:07 +00:00
2022-01-01 21:21:05 +00:00
/* list of test cases:
- [ done ] genenral integrity : allocate 4 dictionaries , each with 34 keys of various sizes ranging from 1 k - 9 k .
- [ done ] delete / add consistency : general integrity , delete a dictionary , then add a dictionary .
- [ done ] in - place update consistency : general integrity then patch all keys with a new test pattern
- [ done ] extend update consistency : general integrity then patch all keys with a longer test pattern
- [ done ] key deletion torture test : delete every other key in a dictionary , then regenerate some of them with new data .
- [ done ] fast space exhaustion test : allocate and delete a bunch of stuff . trigger a fast - space regenerate .
note : for faster stress - testing , we dialed the FSCB_PAGES to 4 and the FASTSPACE_PAGES to 1.
- [ done ] basis search : create basis A , populate with general integrity . create basis B , add test entries .
hide basis B , confirm original A ; mount basis B , confirm B overlay .
* /
#[ allow(dead_code) ]
2021-12-28 21:49:07 +00:00
pub ( crate ) fn ci_tests ( pddb_os : & mut PddbOs ) -> Result < ( ) > {
{
const EXTRA_BASIS : & 'static str = " Basis2 " ;
const EXTRA_BASIS_PW : & 'static str = " some password blah blah " ;
log ::set_max_level ( log ::LevelFilter ::Info ) ;
log ::info! ( " Seed for this run: {} " , xous ::TESTING_RNG_SEED . load ( core ::sync ::atomic ::Ordering ::SeqCst ) ) ;
pddb_os . test_reset ( ) ;
log ::info! ( " Creating `basecase1e` " ) ;
log ::set_max_level ( log ::LevelFilter ::Info ) ;
let mut basis_cache = BasisCache ::new ( ) ;
create_basis_testcase ( pddb_os , & mut basis_cache , None ,
None , None , Some ( 32 ) ) ? ;
log ::info! ( " Saving `basecase1e` to local host " ) ;
pddb_os . dbg_dump ( Some ( " basecase1e " . to_string ( ) ) , None ) ;
let extra_basis_key = pddb_os . basis_derive_key ( EXTRA_BASIS , EXTRA_BASIS_PW ) ;
let extra_export = KeyExport {
basis_name : BasisRootName ::try_from_str ( EXTRA_BASIS ) . unwrap ( ) . 0 ,
key : extra_basis_key ,
} ;
let mut export : Vec ::< KeyExport > = Vec ::new ( ) ;
export . push ( extra_export ) ;
log ::info! ( " Building a second basis " ) ;
basis_cache . basis_create ( pddb_os ,
EXTRA_BASIS , EXTRA_BASIS_PW ) . expect ( " couldn't build test basis " ) ;
log ::info! ( " Doing delete/add consistency with data extension " ) ;
delete_add_dict_consistency ( pddb_os , & mut basis_cache , None ,
None , None , None , None ) ? ;
log ::info! ( " Saving `dachecke` to local host " ) ;
pddb_os . dbg_dump ( Some ( " dachecke " . to_string ( ) ) , None ) ;
log ::info! ( " Doing patch test " ) ;
patch_test ( pddb_os , & mut basis_cache , None , None , true ) ? ;
pddb_os . dbg_dump ( Some ( " patche " . to_string ( ) ) , None ) ;
log ::info! ( " Doing delete pattern test " ) ;
delete_pattern ( pddb_os , & mut basis_cache , None , None , None , None ) ? ;
pddb_os . dbg_dump ( Some ( " patterne " . to_string ( ) ) , None ) ;
// extended tests.
// allocation space curtailed to force resource exhaustion faster.
// note to self: FSCB_PAGES revert to 16 (hw.rs), FASTSPACE_PAGES revert to 2 (fastspace.rs)
log ::info! ( " Doing patch test 2 " ) ;
patch_test ( pddb_os , & mut basis_cache , None , None , true ) ? ;
pddb_os . dbg_dump ( Some ( " patche2 " . to_string ( ) ) , None ) ;
log ::info! ( " Doing delete pattern test 2 " ) ;
delete_pattern ( pddb_os , & mut basis_cache , None , None , None , None ) ? ;
pddb_os . dbg_dump ( Some ( " patterne2 " . to_string ( ) ) , None ) ;
log ::info! ( " Doing delete/add consistency with data extension 2 " ) ;
delete_add_dict_consistency ( pddb_os , & mut basis_cache , Some ( 3 ) ,
Some ( 50 ) , None , None , None ) ? ;
log ::info! ( " Saving `dachecke2` to local host " ) ;
pddb_os . dbg_dump ( Some ( " dachecke2 " . to_string ( ) ) , None ) ;
log ::info! ( " Doing delete/add consistency with data extension 3 " ) ;
delete_add_dict_consistency ( pddb_os , & mut basis_cache , Some ( 3 ) ,
Some ( 50 ) , None , None , None ) ? ;
log ::info! ( " Saving `dachecke3` to local host " ) ;
pddb_os . dbg_dump ( Some ( " dachecke3 " . to_string ( ) ) , None ) ;
log ::info! ( " Doing delete/add consistency with data extension 4 " ) ;
delete_add_dict_consistency ( pddb_os , & mut basis_cache , Some ( 6 ) ,
Some ( 50 ) , None , None , None ) ? ;
log ::info! ( " Saving `dachecke4` to local host " ) ;
pddb_os . dbg_dump ( Some ( " dachecke4 " . to_string ( ) ) , None ) ;
let mut pre_list = HashSet ::< String > ::new ( ) ;
for dict in basis_cache . dict_list ( pddb_os , None ) . iter ( ) {
for key in basis_cache . key_list ( pddb_os , dict , None ) . unwrap ( ) . iter ( ) {
pre_list . insert ( key . to_string ( ) ) ;
}
}
log ::info! ( " Doing remount disk test " ) ;
let mut basis_cache = BasisCache ::new ( ) ;
if let Some ( sys_basis ) = pddb_os . pddb_mount ( ) {
basis_cache . basis_add ( sys_basis ) ;
list_all ( pddb_os , & mut basis_cache ) ;
pddb_os . dbg_dump ( Some ( " remounte " . to_string ( ) ) , Some ( & export ) ) ;
}
log ::info! ( " Mounting the second basis " ) ;
if let Some ( basis2 ) = basis_cache . basis_unlock ( pddb_os ,
EXTRA_BASIS , EXTRA_BASIS_PW , BasisRetentionPolicy ::Persist ) {
basis_cache . basis_add ( basis2 ) ;
}
2022-01-01 17:41:55 +00:00
log ::set_max_level ( log ::LevelFilter ::Debug ) ;
2021-12-28 21:49:07 +00:00
log ::info! ( " Adding keys to Basis2 " ) ;
delete_add_dict_consistency ( pddb_os , & mut basis_cache , Some ( 3 ) ,
Some ( 15 ) , None , None , Some ( EXTRA_BASIS ) ) ? ;
log ::info! ( " Saving `basis2` to local host " ) ;
pddb_os . dbg_dump ( Some ( " basis2 " . to_string ( ) ) , Some ( & export ) ) ;
2022-01-01 17:41:55 +00:00
log ::set_max_level ( log ::LevelFilter ::Info ) ;
2021-12-28 21:49:07 +00:00
let mut merge_list = HashSet ::< String > ::new ( ) ;
for dict in basis_cache . dict_list ( pddb_os , None ) . iter ( ) {
for key in basis_cache . key_list ( pddb_os , dict , None ) . unwrap ( ) . iter ( ) {
merge_list . insert ( key . to_string ( ) ) ;
}
}
assert! ( pre_list . is_subset ( & merge_list ) , " pre-merge list is not a subset of the merged basis " ) ;
let mut b2_list = HashSet ::< String > ::new ( ) ;
for dict in basis_cache . dict_list ( pddb_os , Some ( EXTRA_BASIS ) ) . iter ( ) {
for key in basis_cache . key_list ( pddb_os , dict , Some ( EXTRA_BASIS ) ) . unwrap ( ) . iter ( ) {
b2_list . insert ( key . to_string ( ) ) ;
}
}
assert! ( b2_list . is_subset ( & merge_list ) , " basis 2 is not a subset of the merged lists " ) ;
basis_cache . basis_unmount ( pddb_os , EXTRA_BASIS ) . unwrap ( ) ;
let mut post_list = HashSet ::< String > ::new ( ) ;
for dict in basis_cache . dict_list ( pddb_os , None ) . iter ( ) {
for key in basis_cache . key_list ( pddb_os , dict , None ) . unwrap ( ) . iter ( ) {
post_list . insert ( key . to_string ( ) ) ;
}
}
log ::info! ( " Doing remount disk test part 2 " ) ;
let mut basis_cache = BasisCache ::new ( ) ;
if let Some ( sys_basis ) = pddb_os . pddb_mount ( ) {
basis_cache . basis_add ( sys_basis ) ;
}
let mut remount_list = HashSet ::< String > ::new ( ) ;
for dict in basis_cache . dict_list ( pddb_os , None ) . iter ( ) {
for key in basis_cache . key_list ( pddb_os , dict , None ) . unwrap ( ) . iter ( ) {
remount_list . insert ( key . to_string ( ) ) ;
}
}
assert! ( remount_list . difference ( & pre_list ) . count ( ) = = 0 , " remounted list is not identical to the original list " ) ;
log ::info! ( " Mounting the second basis again " ) ;
if let Some ( basis2 ) = basis_cache . basis_unlock ( pddb_os ,
EXTRA_BASIS , EXTRA_BASIS_PW , BasisRetentionPolicy ::Persist ) {
basis_cache . basis_add ( basis2 ) ;
}
let mut merge2_list = HashSet ::< String > ::new ( ) ;
for dict in basis_cache . dict_list ( pddb_os , None ) . iter ( ) {
for key in basis_cache . key_list ( pddb_os , dict , None ) . unwrap ( ) . iter ( ) {
merge2_list . insert ( key . to_string ( ) ) ;
}
}
assert! ( merge2_list . difference ( & merge_list ) . count ( ) = = 0 , " merged list is different from the original list after remount " ) ;
list_all ( pddb_os , & mut basis_cache ) ;
log ::info! ( " CI done " ) ;
Ok ( ( ) )
}
2022-01-01 21:21:05 +00:00
}
#[ allow(dead_code) ]
pub ( crate ) fn manual_testcase ( hw : & mut PddbOs ) {
log ::info! ( " Initializing disk... " ) ;
hw . pddb_format ( true ) . unwrap ( ) ;
log ::info! ( " Done initializing disk " ) ;
// it's a vector because order is important: by default access to keys/dicts go into the latest entry first, and then recurse to the earliest
let mut basis_cache = BasisCache ::new ( ) ;
log ::info! ( " Attempting to mount the PDDB " ) ;
if let Some ( sys_basis ) = hw . pddb_mount ( ) {
log ::info! ( " PDDB mount operation finished successfully " ) ;
basis_cache . basis_add ( sys_basis ) ;
} else {
log ::info! ( " PDDB did not mount; did you remember to format the PDDB region? " ) ;
}
log ::info! ( " size of vpage: {} " , VPAGE_SIZE ) ;
// add a "system settings" dictionary to the default basis
log ::info! ( " adding 'system settings' dictionary " ) ;
basis_cache . dict_add ( hw , " system settings " , None ) . expect ( " couldn't add system settings dictionary " ) ;
basis_cache . key_update ( hw , " system settings " , " wifi/wpa_keys/Kosagi " , " my_wpa_key_here " . as_bytes ( ) , None , None , None , false ) . expect ( " couldn't add a key " ) ;
let mut readback = [ 0 u8 ; 15 ] ;
match basis_cache . key_read ( hw , " system settings " , " wifi/wpa_keys/Kosagi " , & mut readback , None , None ) {
Ok ( readsize ) = > {
log ::info! ( " read back {} bytes " , readsize ) ;
log ::info! ( " read data: {} " , String ::from_utf8_lossy ( & readback ) ) ;
} ,
Err ( e ) = > {
log ::info! ( " couldn't read data: {:?} " , e ) ;
}
}
basis_cache . key_update ( hw , " system settings " , " wifi/wpa_keys/e4200 " , " 12345678 " . as_bytes ( ) , None , None , None , false ) . expect ( " couldn't add a key " ) ;
// add a "big" key
let mut bigdata = [ 0 u8 ; 5000 ] ;
for ( i , d ) in bigdata . iter_mut ( ) . enumerate ( ) {
* d = i as u8 ;
}
basis_cache . key_update ( hw , " system settings " , " big_pool1 " , & bigdata , None , None , None , false ) . expect ( " couldn't add a key " ) ;
basis_cache . dict_add ( hw , " test_dict_2 " , None ) . expect ( " couldn't add test dictionary 2 " ) ;
basis_cache . key_update ( hw , " test_dict_2 " , " test key in dict 2 " , " some data " . as_bytes ( ) , None , Some ( 128 ) , None , false ) . expect ( " couldn't add a key to second dict " ) ;
basis_cache . key_update ( hw , " system settings " , " wifi/wpa_keys/e4200 " , " ABC " . as_bytes ( ) , Some ( 2 ) , None , None , false ) . expect ( " couldn't update e4200 key " ) ;
log ::info! ( " test readback of wifi/wpa_keys/e4200 " ) ;
match basis_cache . key_read ( hw , " system settings " , " wifi/wpa_keys/e4200 " , & mut readback , None , None ) {
Ok ( readsize ) = > {
log ::info! ( " read back {} bytes " , readsize ) ;
log ::info! ( " read data: {} " , String ::from_utf8_lossy ( & readback ) ) ;
} ,
Err ( e ) = > {
log ::info! ( " couldn't read data: {:?} " , e ) ;
}
}
}
#[ allow(dead_code) ]
pub ( crate ) fn hw_testcase ( pddb_os : & mut PddbOs ) {
log ::info! ( " Running `hw` test case " ) ;
#[ cfg(not(any(target_os = " none " , target_os = " xous " ))) ]
pddb_os . test_reset ( ) ;
manual_testcase ( pddb_os ) ;
log ::info! ( " Re-mount the PDDB " ) ;
let mut basis_cache = BasisCache ::new ( ) ;
if let Some ( sys_basis ) = pddb_os . pddb_mount ( ) {
log ::info! ( " PDDB mount operation finished successfully " ) ;
basis_cache . basis_add ( sys_basis ) ;
} else {
log ::info! ( " PDDB did not mount; did you remember to format the PDDB region? " ) ;
}
log ::info! ( " test readback of wifi/wpa_keys/e4200 " ) ;
let mut readback = [ 0 u8 ; 16 ] ; // this buffer is bigger than the data in the key, but that's alright...
match basis_cache . key_read ( pddb_os , " system settings " , " wifi/wpa_keys/e4200 " , & mut readback , None , None ) {
Ok ( readsize ) = > {
log ::info! ( " read back {} bytes " , readsize ) ;
log ::info! ( " read data: {} " , String ::from_utf8_lossy ( & readback ) ) ;
} ,
Err ( e ) = > {
log ::info! ( " couldn't read data: {:?} " , e ) ;
}
}
#[ cfg(not(any(target_os = " none " , target_os = " xous " ))) ]
pddb_os . dbg_dump ( Some ( " manual " . to_string ( ) ) , None ) ;
}