start adding test helper for verification reporting
All checks were successful
Rust/sat-rs/pipeline/pr-main This commit looks good
All checks were successful
Rust/sat-rs/pipeline/pr-main This commit looks good
This commit is contained in:
parent
53ba2e005b
commit
931c37be7a
@ -405,7 +405,9 @@ pub trait VerificationReportingProvider {
|
||||
fn add_tc(
|
||||
&mut self,
|
||||
pus_tc: &(impl CcsdsPacket + IsPusTelecommand),
|
||||
) -> VerificationToken<TcStateNone>;
|
||||
) -> VerificationToken<TcStateNone> {
|
||||
self.add_tc_with_req_id(RequestId::new(pus_tc))
|
||||
}
|
||||
|
||||
fn add_tc_with_req_id(&mut self, req_id: RequestId) -> VerificationToken<TcStateNone>;
|
||||
|
||||
@ -1392,7 +1394,7 @@ mod std_mod {
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
pub mod tests {
|
||||
use crate::pool::{PoolProviderWithGuards, StaticMemoryPool, StaticPoolConfig};
|
||||
use crate::pus::tests::CommonTmInfo;
|
||||
use crate::pus::verification::{
|
||||
@ -1405,6 +1407,7 @@ mod tests {
|
||||
use crate::ChannelId;
|
||||
use alloc::boxed::Box;
|
||||
use alloc::format;
|
||||
use hashbrown::HashMap;
|
||||
use spacepackets::ecss::tc::{PusTcCreator, PusTcSecondaryHeader};
|
||||
use spacepackets::ecss::tm::PusTmReader;
|
||||
use spacepackets::ecss::{EcssEnumU16, EcssEnumU32, EcssEnumU8, PusError, PusPacket};
|
||||
@ -1423,6 +1426,105 @@ mod tests {
|
||||
#[allow(dead_code)]
|
||||
fn is_sync<T: Sync>(_: &T) {}
|
||||
|
||||
pub struct VerificationStatus {
|
||||
pub accepted: Option<bool>,
|
||||
pub started: Option<bool>,
|
||||
pub step: u32,
|
||||
pub completed: Option<bool>,
|
||||
}
|
||||
pub struct TestVerificationReporter {
|
||||
verification_map: HashMap<RequestId, VerificationStatus>,
|
||||
}
|
||||
|
||||
impl VerificationReportingProvider for TestVerificationReporter {
|
||||
fn add_tc_with_req_id(&mut self, req_id: RequestId) -> VerificationToken<TcStateNone> {
|
||||
self.verification_map.insert(
|
||||
req_id,
|
||||
VerificationStatus {
|
||||
accepted: None,
|
||||
started: None,
|
||||
step: 0,
|
||||
completed: None,
|
||||
},
|
||||
);
|
||||
VerificationToken {
|
||||
state: core::marker::PhantomData,
|
||||
req_id,
|
||||
}
|
||||
}
|
||||
|
||||
fn acceptance_success(
|
||||
&self,
|
||||
token: VerificationToken<TcStateNone>,
|
||||
time_stamp: Option<&[u8]>,
|
||||
) -> Result<
|
||||
VerificationToken<super::TcStateAccepted>,
|
||||
super::VerificationOrSendErrorWithToken<TcStateNone>,
|
||||
> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn acceptance_failure(
|
||||
&self,
|
||||
token: VerificationToken<TcStateNone>,
|
||||
params: FailParams,
|
||||
) -> Result<(), super::VerificationOrSendErrorWithToken<TcStateNone>> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn start_success(
|
||||
&self,
|
||||
token: VerificationToken<super::TcStateAccepted>,
|
||||
time_stamp: Option<&[u8]>,
|
||||
) -> Result<
|
||||
VerificationToken<super::TcStateStarted>,
|
||||
super::VerificationOrSendErrorWithToken<super::TcStateAccepted>,
|
||||
> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn start_failure(
|
||||
&self,
|
||||
token: VerificationToken<super::TcStateAccepted>,
|
||||
params: FailParams,
|
||||
) -> Result<(), super::VerificationOrSendErrorWithToken<super::TcStateAccepted>> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn step_success(
|
||||
&self,
|
||||
token: &VerificationToken<super::TcStateStarted>,
|
||||
time_stamp: Option<&[u8]>,
|
||||
step: impl spacepackets::ecss::EcssEnumeration,
|
||||
) -> Result<(), EcssTmtcError> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn step_failure(
|
||||
&self,
|
||||
token: VerificationToken<super::TcStateStarted>,
|
||||
params: FailParamsWithStep,
|
||||
) -> Result<(), super::VerificationOrSendErrorWithToken<super::TcStateStarted>> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn completion_success<TcState: super::WasAtLeastAccepted + Copy>(
|
||||
&self,
|
||||
token: VerificationToken<TcState>,
|
||||
time_stamp: Option<&[u8]>,
|
||||
) -> Result<(), super::VerificationOrSendErrorWithToken<TcState>> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn completion_failure<TcState: super::WasAtLeastAccepted + Copy>(
|
||||
&self,
|
||||
token: VerificationToken<TcState>,
|
||||
params: FailParams,
|
||||
) -> Result<(), super::VerificationOrSendErrorWithToken<TcState>> {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
const TEST_APID: u16 = 0x02;
|
||||
const EMPTY_STAMP: [u8; 7] = [0; 7];
|
||||
|
||||
@ -1984,7 +2086,7 @@ mod tests {
|
||||
.expect("Sending start success failed");
|
||||
b.vr.step_success(
|
||||
&started_token,
|
||||
&mut sender,
|
||||
&sender,
|
||||
Some(&EMPTY_STAMP),
|
||||
EcssEnumU8::new(0),
|
||||
)
|
||||
@ -2018,16 +2120,12 @@ mod tests {
|
||||
.helper
|
||||
.start_success(accepted_token, Some(&[0, 1, 0, 1, 0, 1, 0]))
|
||||
.expect("Sending start success failed");
|
||||
let mut empty = b
|
||||
.helper
|
||||
b.helper
|
||||
.step_success(&started_token, Some(&EMPTY_STAMP), EcssEnumU8::new(0))
|
||||
.expect("Sending completion success failed");
|
||||
assert_eq!(empty, ());
|
||||
empty = b
|
||||
.helper
|
||||
b.helper
|
||||
.step_failure(started_token, fail_params)
|
||||
.expect("Step failure failed");
|
||||
assert_eq!(empty, ());
|
||||
let sender: &mut TestSender = b.helper.sender.downcast_mut().unwrap();
|
||||
check_step_failure(sender, req_id, fail_data_raw);
|
||||
}
|
||||
@ -2087,12 +2185,12 @@ mod tests {
|
||||
let fail_params = FailParams::new(Some(&EMPTY_STAMP), &fail_code, None);
|
||||
|
||||
let accepted_token =
|
||||
b.vr.acceptance_success(tok, &mut sender, Some(&EMPTY_STAMP))
|
||||
b.vr.acceptance_success(tok, &sender, Some(&EMPTY_STAMP))
|
||||
.expect("Sending acceptance success failed");
|
||||
let started_token =
|
||||
b.vr.start_success(accepted_token, &mut sender, Some(&[0, 1, 0, 1, 0, 1, 0]))
|
||||
b.vr.start_success(accepted_token, &sender, Some(&[0, 1, 0, 1, 0, 1, 0]))
|
||||
.expect("Sending start success failed");
|
||||
b.vr.completion_failure(started_token, &mut sender, fail_params)
|
||||
b.vr.completion_failure(started_token, &sender, fail_params)
|
||||
.expect("Completion failure");
|
||||
completion_fail_check(&mut sender, req_id);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user