created baseline for tests
Some checks failed
Rust/sat-rs/pipeline/pr-main There was a failure building this commit

This commit is contained in:
Robin Müller 2024-02-17 14:43:46 +01:00
parent 9a761cc799
commit 4588d00291
Signed by: muellerr
GPG Key ID: A649FB78196E3849

View File

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