From e26106e3341b01c3dce214e2d43fa48a78dc5bd7 Mon Sep 17 00:00:00 2001 From: bunnie Date: Mon, 4 Jul 2022 18:13:11 +0800 Subject: [PATCH] fix warnings and clean up configs tighten up the scope of some features to reduce warning messages --- services/pddb/src/api.rs | 7 +++++-- services/pddb/src/backend/hw.rs | 2 +- services/pddb/src/lib.rs | 2 +- services/pddb/src/main.rs | 2 +- services/shellchat/Cargo.toml | 2 +- services/shellchat/src/cmds/pddb_cmd.rs | 8 +++++++- 6 files changed, 16 insertions(+), 7 deletions(-) diff --git a/services/pddb/src/api.rs b/services/pddb/src/api.rs index 77cea8b74..5f56735f2 100644 --- a/services/pddb/src/api.rs +++ b/services/pddb/src/api.rs @@ -39,7 +39,10 @@ pub(crate) const PDDB_VERSION: u32 = 0x00_00_02_01; #[allow(dead_code)] // PDDB_A_LEN may be shorter than xous::PDDB_LEN, to speed up testing. #[allow(dead_code)] -// pub(crate) const PDDB_A_LEN: usize = xous::PDDB_LEN as usize; +#[cfg(not(any(feature="pddbtest",feature="autobasis",feature="ci")))] +pub(crate) const PDDB_A_LEN: usize = xous::PDDB_LEN as usize; +#[allow(dead_code)] +#[cfg(any(feature="pddbtest",feature="autobasis",feature="ci"))] pub const PDDB_A_LEN: usize = 4 * 1024 * 1024; /// range for the starting point of a journal number, picked from a random seed @@ -133,7 +136,7 @@ pub(crate) enum Opcode { /// Write debug dump (only available in hosted mode) #[cfg(not(any(target_os = "none", target_os = "xous")))] DangerousDebug = 25, - #[cfg(feature="pddbtest")] + #[cfg(all(feature="pddbtest", feature="autobasis"))] BasisTesting = 26, /// This key type could not be decoded diff --git a/services/pddb/src/backend/hw.rs b/services/pddb/src/backend/hw.rs index 3c470b932..54771c384 100644 --- a/services/pddb/src/backend/hw.rs +++ b/services/pddb/src/backend/hw.rs @@ -47,7 +47,7 @@ pub const KCOM_CT_LEN: usize = 4004; pub(crate) const WRAPPED_AES_KEYSIZE: usize = AES_KEYSIZE + 8; const SCD_VERSION: u32 = 2; -#[cfg(feature="pddbtest")] +#[cfg(all(feature="pddbtest", feature="autobasis"))] pub const BASIS_TEST_ROOTNAME: &'static str = "test"; #[derive(Zeroize)] diff --git a/services/pddb/src/lib.rs b/services/pddb/src/lib.rs index fbab48180..774dd1b6e 100644 --- a/services/pddb/src/lib.rs +++ b/services/pddb/src/lib.rs @@ -654,7 +654,7 @@ impl Pddb { .or(Err(Error::new(ErrorKind::Other, "Xous internal error"))).map(|_| ()) } - #[cfg(feature="pddbtest")] + #[cfg(all(feature="pddbtest", feature="autobasis"))] pub fn basis_testing(&self, config: &[Option; 32]) { let mut op = 0; let mut valid = 0; diff --git a/services/pddb/src/main.rs b/services/pddb/src/main.rs index c2aad1065..47d16e1b4 100644 --- a/services/pddb/src/main.rs +++ b/services/pddb/src/main.rs @@ -1265,7 +1265,7 @@ fn wrapped_main() -> ! { } } } - #[cfg(feature="pddbtest")] + #[cfg(all(feature="pddbtest", feature="autobasis"))] Opcode::BasisTesting => xous::msg_scalar_unpack!(msg, op, valid, _, _, { let mut config: [Option; 32] = [None::; 32]; for i in 0..32 { diff --git a/services/shellchat/Cargo.toml b/services/shellchat/Cargo.toml index 0e71f8085..5da901c52 100644 --- a/services/shellchat/Cargo.toml +++ b/services/shellchat/Cargo.toml @@ -101,7 +101,7 @@ spinortest = [] # for spinor testing. contra-indicated with PDDB, as it steals m benchmarks = [] # adds the benchmark routines. Left off normally to free up code and memory space. aestests = [] # adds AES tests tts = [] # adds text to speech plugin -pddbtest = [] +pddbtest = ["rand_chacha"] autobasis = ["rand_chacha"] autobasis-ci = [] ditherpunk = ["png"] diff --git a/services/shellchat/src/cmds/pddb_cmd.rs b/services/shellchat/src/cmds/pddb_cmd.rs index c70256b47..2e3ff4d9e 100644 --- a/services/shellchat/src/cmds/pddb_cmd.rs +++ b/services/shellchat/src/cmds/pddb_cmd.rs @@ -1,4 +1,5 @@ use crate::{ShellCmdApi, CommonEnv}; +#[cfg(all(feature="pddbtest", feature="autobasis"))] use pddb::PDDB_A_LEN; use xous_ipc::String; #[allow(unused_imports)] @@ -307,7 +308,7 @@ impl<'a> ShellCmdApi<'a> for PddbCmd { log::info!("largetest failed"); } } - #[cfg(feature="pddbtest")] + #[cfg(all(feature="pddbtest", feature="autobasis"))] "btest" => { // This test will: // - generate bases iteratively: @@ -824,14 +825,19 @@ impl<'a> ShellCmdApi<'a> for PddbCmd { } } +#[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:: { use rand::prelude::*; use rand_chacha::ChaCha8Rng;