make some test utilities shareable
Some checks failed
Rust/sat-rs/pipeline/pr-main There was a failure building this commit
Some checks failed
Rust/sat-rs/pipeline/pr-main There was a failure building this commit
This commit is contained in:
@ -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"
|
||||
|
@ -1,3 +1,5 @@
|
||||
// TODO: Remove this at a later stage.
|
||||
#![allow(dead_code)]
|
||||
use std::sync::mpsc::{self};
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
|
@ -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();
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user