almost done
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-02 14:44:31 +01:00
parent c45eb1495c
commit e0fa0ca7f7
5 changed files with 32 additions and 18 deletions

View File

@ -127,6 +127,7 @@ mod tests {
use std::sync::mpsc::{self, Sender}; use std::sync::mpsc::{self, Sender};
use crate::pus::event_man::EventRequest; use crate::pus::event_man::EventRequest;
use crate::pus::tests::SimplePusPacketHandler;
use crate::pus::verification::RequestId; use crate::pus::verification::RequestId;
use crate::{ use crate::{
events::EventU32, events::EventU32,
@ -166,6 +167,11 @@ mod tests {
fn check_next_verification_tm(&self, subservice: u8, expected_request_id: RequestId); fn check_next_verification_tm(&self, subservice: u8, expected_request_id: RequestId);
} }
}
}
impl SimplePusPacketHandler for Pus5HandlerWithStoreTester {
delegate! {
to self.handler { to self.handler {
fn handle_one_tc(&mut self) -> Result<PusPacketHandlerResult, PusPacketHandlingError>; fn handle_one_tc(&mut self) -> Result<PusPacketHandlerResult, PusPacketHandlingError>;
} }
@ -173,7 +179,7 @@ mod tests {
} }
fn event_test( fn event_test(
test_harness: &mut impl PusTestHarness, test_harness: &mut (impl PusTestHarness + SimplePusPacketHandler),
subservice: Subservice, subservice: Subservice,
expected_event_req: EventRequest, expected_event_req: EventRequest,
event_req_receiver: mpsc::Receiver<EventRequestWithToken>, event_req_receiver: mpsc::Receiver<EventRequestWithToken>,

View File

@ -956,6 +956,9 @@ pub mod tests {
fn read_next_tm(&mut self) -> PusTmReader<'_>; fn read_next_tm(&mut self) -> PusTmReader<'_>;
fn check_no_tm_available(&self) -> bool; fn check_no_tm_available(&self) -> bool;
fn check_next_verification_tm(&self, subservice: u8, expected_request_id: RequestId); fn check_next_verification_tm(&self, subservice: u8, expected_request_id: RequestId);
}
pub trait SimplePusPacketHandler {
fn handle_one_tc(&mut self) -> Result<PusPacketHandlerResult, PusPacketHandlingError>; fn handle_one_tc(&mut self) -> Result<PusPacketHandlerResult, PusPacketHandlingError>;
} }

View File

@ -1035,7 +1035,8 @@ mod tests {
.release_telecommands(&mut test_closure_1, &mut pool) .release_telecommands(&mut test_closure_1, &mut pool)
.expect("deletion failed"); .expect("deletion failed");
assert_eq!(released, 1); assert_eq!(released, 1);
assert!(pool.has_element_at(&tc_info_0.addr()).unwrap()); // TC is deleted.
assert!(!pool.has_element_at(&tc_info_0.addr()).unwrap());
// test 3, late timestamp, release 1 overdue tc // test 3, late timestamp, release 1 overdue tc
let mut test_closure_2 = |boolvar: bool, tc_info: &TcInfo, _tc: &[u8]| { let mut test_closure_2 = |boolvar: bool, tc_info: &TcInfo, _tc: &[u8]| {
@ -1049,7 +1050,8 @@ mod tests {
.release_telecommands(&mut test_closure_2, &mut pool) .release_telecommands(&mut test_closure_2, &mut pool)
.expect("deletion failed"); .expect("deletion failed");
assert_eq!(released, 1); assert_eq!(released, 1);
assert!(pool.has_element_at(&tc_info_1.addr()).unwrap()); // TC is deleted.
assert!(!pool.has_element_at(&tc_info_1.addr()).unwrap());
//test 4: no tcs left //test 4: no tcs left
scheduler scheduler
@ -1104,8 +1106,8 @@ mod tests {
.release_telecommands(&mut test_closure, &mut pool) .release_telecommands(&mut test_closure, &mut pool)
.expect("deletion failed"); .expect("deletion failed");
assert_eq!(released, 2); assert_eq!(released, 2);
assert!(pool.has_element_at(&tc_info_0.addr()).unwrap()); assert!(!pool.has_element_at(&tc_info_0.addr()).unwrap());
assert!(pool.has_element_at(&tc_info_1.addr()).unwrap()); assert!(!pool.has_element_at(&tc_info_1.addr()).unwrap());
//test 3: no tcs left //test 3: no tcs left
released = scheduler released = scheduler

View File

@ -190,8 +190,8 @@ mod tests {
struct Pus11HandlerWithStoreTester { struct Pus11HandlerWithStoreTester {
common: PusServiceHandlerWithSharedStoreCommon, common: PusServiceHandlerWithSharedStoreCommon,
handler: handler: PusService11SchedHandler<EcssTcInSharedStoreConverter, PusScheduler>,
PusService11SchedHandler<EcssTcInSharedStoreConverter, StaticMemoryPool, PusScheduler>, sched_tc_pool: StaticMemoryPool,
} }
impl Pus11HandlerWithStoreTester { impl Pus11HandlerWithStoreTester {
@ -199,7 +199,8 @@ mod tests {
let (common, srv_handler) = PusServiceHandlerWithSharedStoreCommon::new(); let (common, srv_handler) = PusServiceHandlerWithSharedStoreCommon::new();
Self { Self {
common, common,
handler: PusService11SchedHandler::new(srv_handler, sched_tc_pool, scheduler), handler: PusService11SchedHandler::new(srv_handler, scheduler),
sched_tc_pool,
} }
} }
} }
@ -212,10 +213,6 @@ mod tests {
fn check_no_tm_available(&self) -> bool; fn check_no_tm_available(&self) -> bool;
fn check_next_verification_tm(&self, subservice: u8, expected_request_id: RequestId); fn check_next_verification_tm(&self, subservice: u8, expected_request_id: RequestId);
} }
to self.handler {
fn handle_one_tc(&mut self) -> Result<PusPacketHandlerResult, PusPacketHandlingError>;
}
} }
} }
@ -233,7 +230,7 @@ mod tests {
fn reset( fn reset(
&mut self, &mut self,
store: &mut (impl crate::pool::PoolProviderMemInPlace + ?Sized), _store: &mut (impl crate::pool::PoolProviderMemInPlace + ?Sized),
) -> Result<(), crate::pool::StoreError> { ) -> Result<(), crate::pool::StoreError> {
self.reset_count += 1; self.reset_count += 1;
Ok(()) Ok(())
@ -255,7 +252,7 @@ mod tests {
fn insert_unwrapped_and_stored_tc( fn insert_unwrapped_and_stored_tc(
&mut self, &mut self,
time_stamp: spacepackets::time::UnixTimestamp, _time_stamp: spacepackets::time::UnixTimestamp,
info: crate::pus::scheduler::TcInfo, info: crate::pus::scheduler::TcInfo,
) -> Result<(), crate::pus::scheduler::ScheduleError> { ) -> Result<(), crate::pus::scheduler::ScheduleError> {
self.inserted_tcs.push_back(info); self.inserted_tcs.push_back(info);

View File

@ -93,7 +93,7 @@ impl<TcInMemConverter: EcssTcInMemConverter> PusService17TestHandler<TcInMemConv
mod tests { mod tests {
use crate::pus::tests::{ use crate::pus::tests::{
PusServiceHandlerWithSharedStoreCommon, PusServiceHandlerWithVecCommon, PusTestHarness, PusServiceHandlerWithSharedStoreCommon, PusServiceHandlerWithVecCommon, PusTestHarness,
TEST_APID, SimplePusPacketHandler, TEST_APID,
}; };
use crate::pus::verification::RequestId; use crate::pus::verification::RequestId;
use crate::pus::verification::{TcStateAccepted, VerificationToken}; use crate::pus::verification::{TcStateAccepted, VerificationToken};
@ -137,7 +137,10 @@ mod tests {
expected_request_id: RequestId expected_request_id: RequestId
); );
} }
}
}
impl SimplePusPacketHandler for Pus17HandlerWithStoreTester {
delegate! {
to self.handler { to self.handler {
fn handle_one_tc(&mut self) -> Result<PusPacketHandlerResult, PusPacketHandlingError>; fn handle_one_tc(&mut self) -> Result<PusPacketHandlerResult, PusPacketHandlingError>;
} }
@ -171,14 +174,17 @@ mod tests {
expected_request_id: RequestId, expected_request_id: RequestId,
); );
} }
}
}
impl SimplePusPacketHandler for Pus17HandlerWithVecTester {
delegate! {
to self.handler { to self.handler {
fn handle_one_tc(&mut self) -> Result<PusPacketHandlerResult, PusPacketHandlingError>; fn handle_one_tc(&mut self) -> Result<PusPacketHandlerResult, PusPacketHandlingError>;
} }
} }
} }
fn ping_test(test_harness: &mut impl PusTestHarness) { fn ping_test(test_harness: &mut (impl PusTestHarness + SimplePusPacketHandler)) {
// Create a ping TC, verify acceptance. // Create a ping TC, verify acceptance.
let mut sp_header = SpHeader::tc(TEST_APID, SequenceFlags::Unsegmented, 0, 0).unwrap(); let mut sp_header = SpHeader::tc(TEST_APID, SequenceFlags::Unsegmented, 0, 0).unwrap();
let sec_header = PusTcSecondaryHeader::new_simple(17, 1); let sec_header = PusTcSecondaryHeader::new_simple(17, 1);