created baseline for tests
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:
parent
9a761cc799
commit
4588d00291
@ -168,18 +168,23 @@ pub mod std_mod {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use core::cell::RefCell;
|
use core::cell::RefCell;
|
||||||
|
use delegate::delegate;
|
||||||
|
|
||||||
use alloc::{collections::VecDeque, vec::Vec};
|
use alloc::{collections::VecDeque, vec::Vec};
|
||||||
use spacepackets::{
|
use spacepackets::{
|
||||||
ecss::{tc::PusTcReader, PusPacket},
|
ecss::{
|
||||||
|
tc::{PusTcCreator, PusTcReader},
|
||||||
|
tm::PusTmReader,
|
||||||
|
PusPacket,
|
||||||
|
},
|
||||||
CcsdsPacket,
|
CcsdsPacket,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::pus::{
|
use crate::pus::{
|
||||||
tests::PusServiceHandlerWithVecCommon,
|
tests::{PusServiceHandlerWithVecCommon, PusTestHarness, SimplePusPacketHandler},
|
||||||
verification::{tests::TestVerificationReporter, VerificationReportingProvider},
|
verification::{tests::TestVerificationReporter, RequestId, VerificationReportingProvider},
|
||||||
EcssTcInVecConverter, GenericRoutingError, PusPacketHandlingError, PusRoutingErrorHandler,
|
EcssTcInVecConverter, GenericRoutingError, PusPacketHandlerResult, PusPacketHandlingError,
|
||||||
PusServiceHelper,
|
PusRoutingErrorHandler, PusServiceHelper,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
@ -187,6 +192,7 @@ mod tests {
|
|||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct TestRouter {
|
pub struct TestRouter {
|
||||||
pub routing_requests: RefCell<VecDeque<(TargetId, ActionRequest)>>,
|
pub routing_requests: RefCell<VecDeque<(TargetId, ActionRequest)>>,
|
||||||
|
pub routing_error: RefCell<VecDeque<(TargetId, GenericRoutingError)>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PusActionRequestRouter for TestRouter {
|
impl PusActionRequestRouter for TestRouter {
|
||||||
@ -211,13 +217,15 @@ mod tests {
|
|||||||
fn handle_error(
|
fn handle_error(
|
||||||
&self,
|
&self,
|
||||||
target_id: TargetId,
|
target_id: TargetId,
|
||||||
token: VerificationToken<TcStateAccepted>,
|
_token: VerificationToken<TcStateAccepted>,
|
||||||
tc: &PusTcReader,
|
_tc: &PusTcReader,
|
||||||
error: Self::Error,
|
error: Self::Error,
|
||||||
time_stamp: &[u8],
|
_time_stamp: &[u8],
|
||||||
verif_reporter: &impl VerificationReportingProvider,
|
_verif_reporter: &impl VerificationReportingProvider,
|
||||||
) {
|
) {
|
||||||
todo!()
|
self.routing_error
|
||||||
|
.borrow_mut()
|
||||||
|
.push_back((target_id, error));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -230,14 +238,17 @@ mod tests {
|
|||||||
type Error = PusPacketHandlingError;
|
type Error = PusPacketHandlingError;
|
||||||
fn convert(
|
fn convert(
|
||||||
&mut self,
|
&mut self,
|
||||||
_token: VerificationToken<TcStateAccepted>,
|
token: VerificationToken<TcStateAccepted>,
|
||||||
tc: &PusTcReader,
|
tc: &PusTcReader,
|
||||||
_time_stamp: &[u8],
|
time_stamp: &[u8],
|
||||||
_verif_reporter: &impl VerificationReportingProvider,
|
verif_reporter: &impl VerificationReportingProvider,
|
||||||
) -> Result<(TargetId, ActionRequest), Self::Error> {
|
) -> Result<(TargetId, ActionRequest), Self::Error> {
|
||||||
self.conversion_request.push_back(tc.raw_data().to_vec());
|
self.conversion_request.push_back(tc.raw_data().to_vec());
|
||||||
let target_id = tc.apid();
|
let target_id = tc.apid();
|
||||||
if tc.subservice() == 1 {
|
if tc.subservice() == 1 {
|
||||||
|
verif_reporter
|
||||||
|
.start_success(token, Some(time_stamp))
|
||||||
|
.expect("start success failure");
|
||||||
return Ok((
|
return Ok((
|
||||||
target_id.into(),
|
target_id.into(),
|
||||||
ActionRequest::UnsignedIdAndVecData {
|
ActionRequest::UnsignedIdAndVecData {
|
||||||
@ -279,9 +290,30 @@ mod tests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl PusTestHarness for Pus8HandlerWithVecTester {
|
||||||
|
delegate! {
|
||||||
|
to self.common {
|
||||||
|
fn send_tc(&mut self, tc: &PusTcCreator) -> VerificationToken<TcStateAccepted>;
|
||||||
|
fn read_next_tm(&mut self) -> PusTmReader<'_>;
|
||||||
|
fn check_no_tm_available(&self) -> bool;
|
||||||
|
fn check_next_verification_tm(
|
||||||
|
&self,
|
||||||
|
subservice: u8,
|
||||||
|
expected_request_id: RequestId,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl SimplePusPacketHandler for Pus8HandlerWithVecTester {
|
||||||
|
delegate! {
|
||||||
|
to self.handler {
|
||||||
|
fn handle_one_tc(&mut self) -> Result<PusPacketHandlerResult, PusPacketHandlingError>;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn basic_test() {
|
fn basic_test() {
|
||||||
//let service_helper = PusServiceHelper::new();
|
let _action_handler = Pus8HandlerWithVecTester::new();
|
||||||
let action_handler = Pus8HandlerWithVecTester::new();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user