make some test utilities shareable
Some checks failed
Rust/sat-rs/pipeline/pr-main There was a failure building this commit

This commit is contained in:
2024-03-25 15:44:27 +01:00
parent cacff05b3c
commit 621e9c094a
11 changed files with 146 additions and 78 deletions

View File

@ -22,6 +22,7 @@ derive-new = "0.5"
[dependencies.satrs]
# version = "0.2.0-rc.0"
path = "../satrs"
features = ["test_util"]
[dependencies.satrs-mib]
# version = "0.1.1"

View File

@ -1,3 +1,5 @@
// TODO: Remove this at a later stage.
#![allow(dead_code)]
use std::sync::mpsc::{self};
use std::sync::{Arc, Mutex};

View File

@ -383,7 +383,7 @@ mod tests {
>
{
pub fn new_for_action() -> Self {
env_logger::init();
let _ = env_logger::builder().is_test(true).try_init();
let target_and_apid_id = TargetAndApidId::new(TEST_APID, TEST_APID_TARGET_ID);
let (tm_funnel_tx, tm_funnel_rx) = mpsc::channel();
let (pus_action_tx, pus_action_rx) = mpsc::channel();

View File

@ -367,6 +367,40 @@ impl<
}
#[cfg(test)]
pub mod tests {
// TODO: Add unittests for HK converter.
mod tests {
use satrs::{
pus::{
test_util::TEST_APID,
verification::{
test_util::{SharedVerificationMap, TestVerificationReporter},
VerificationReportingProvider,
},
PusTcToRequestConverter,
},
spacepackets::{
ecss::{
tc::{PusTcCreator, PusTcReader},
WritablePusPacket,
},
SpHeader,
},
};
use super::ExampleHkRequestConverter;
#[test]
fn test_hk_converter() {
let shared_verif_map = SharedVerificationMap::default();
let mut test_verif_reporter = TestVerificationReporter::new(shared_verif_map.clone());
let mut converter = ExampleHkRequestConverter::default();
let mut sp_header = SpHeader::tc_unseg(TEST_APID, 0, 0).unwrap();
let ping = PusTcCreator::new_simple(&mut sp_header, 3, 25, Some(&[1, 2, 3, 4]), true);
let token = test_verif_reporter.add_tc(&ping);
let accepted_token = test_verif_reporter
.acceptance_success(token, &[])
.expect("acceptance failed");
let pus_tc_raw = ping.to_vec().unwrap();
let pus_tc_reader = PusTcReader::new(&pus_tc_raw).expect("invalid pus tc");
converter.convert(accepted_token, &pus_tc_reader.0, &[], &test_verif_reporter);
}
}