add some more HK 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
e314a858ad
commit
c42fbeef1c
@ -648,4 +648,14 @@ mod tests {
|
|||||||
fn reply_handling_step_failure() {
|
fn reply_handling_step_failure() {
|
||||||
// TODO: Implement
|
// TODO: Implement
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn reply_handling_unrequested_reply() {
|
||||||
|
// TODO: Implement
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn reply_handling_reply_timeout() {
|
||||||
|
// TODO: Implement
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -450,12 +450,82 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn hk_conversion_disable_periodic_generation() {
|
fn hk_conversion_disable_periodic_generation() {
|
||||||
// TODO: Implement
|
let mut hk_bench = PusConverterTestbench::new(HkRequestConverter::default());
|
||||||
|
let mut sp_header = SpHeader::tc_unseg(TEST_APID, 0, 0).unwrap();
|
||||||
|
let target_id = TEST_APID_TARGET_ID;
|
||||||
|
let unique_id = 5_u32;
|
||||||
|
let mut app_data: [u8; 8] = [0; 8];
|
||||||
|
app_data[0..4].copy_from_slice(&target_id.to_be_bytes());
|
||||||
|
app_data[4..8].copy_from_slice(&unique_id.to_be_bytes());
|
||||||
|
let mut generic_check = |tc: &PusTcCreator| {
|
||||||
|
let accepted_token = hk_bench.add_tc(tc);
|
||||||
|
let (_active_req, req) = hk_bench
|
||||||
|
.convert(accepted_token, &[], TEST_APID, TEST_APID_TARGET_ID)
|
||||||
|
.expect("conversion failed");
|
||||||
|
if let HkRequest::Disable(id) = req {
|
||||||
|
assert_eq!(id, unique_id);
|
||||||
|
} else {
|
||||||
|
panic!("unexpected HK request")
|
||||||
|
}
|
||||||
|
};
|
||||||
|
let tc0 = PusTcCreator::new_simple(
|
||||||
|
&mut sp_header,
|
||||||
|
3,
|
||||||
|
Subservice::TcDisableHkGeneration as u8,
|
||||||
|
Some(&app_data),
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
generic_check(&tc0);
|
||||||
|
let tc1 = PusTcCreator::new_simple(
|
||||||
|
&mut sp_header,
|
||||||
|
3,
|
||||||
|
Subservice::TcDisableDiagGeneration as u8,
|
||||||
|
Some(&app_data),
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
generic_check(&tc1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn hk_conversion_modify_interval() {
|
fn hk_conversion_modify_interval() {
|
||||||
// TODO: Implement
|
let mut hk_bench = PusConverterTestbench::new(HkRequestConverter::default());
|
||||||
|
let mut sp_header = SpHeader::tc_unseg(TEST_APID, 0, 0).unwrap();
|
||||||
|
let target_id = TEST_APID_TARGET_ID;
|
||||||
|
let unique_id = 5_u32;
|
||||||
|
let mut app_data: [u8; 12] = [0; 12];
|
||||||
|
let collection_interval_factor = 5_u32;
|
||||||
|
app_data[0..4].copy_from_slice(&target_id.to_be_bytes());
|
||||||
|
app_data[4..8].copy_from_slice(&unique_id.to_be_bytes());
|
||||||
|
app_data[8..12].copy_from_slice(&collection_interval_factor.to_be_bytes());
|
||||||
|
|
||||||
|
let mut generic_check = |tc: &PusTcCreator| {
|
||||||
|
let accepted_token = hk_bench.add_tc(tc);
|
||||||
|
let (_active_req, req) = hk_bench
|
||||||
|
.convert(accepted_token, &[], TEST_APID, TEST_APID_TARGET_ID)
|
||||||
|
.expect("conversion failed");
|
||||||
|
if let HkRequest::ModifyCollectionInterval(id, interval_factor) = req {
|
||||||
|
assert_eq!(id, unique_id);
|
||||||
|
assert_eq!(interval_factor, collection_interval_factor);
|
||||||
|
} else {
|
||||||
|
panic!("unexpected HK request")
|
||||||
|
}
|
||||||
|
};
|
||||||
|
let tc0 = PusTcCreator::new_simple(
|
||||||
|
&mut sp_header,
|
||||||
|
3,
|
||||||
|
Subservice::TcModifyHkCollectionInterval as u8,
|
||||||
|
Some(&app_data),
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
generic_check(&tc0);
|
||||||
|
let tc1 = PusTcCreator::new_simple(
|
||||||
|
&mut sp_header,
|
||||||
|
3,
|
||||||
|
Subservice::TcModifyDiagCollectionInterval as u8,
|
||||||
|
Some(&app_data),
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
generic_check(&tc1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -471,5 +541,5 @@ mod tests {
|
|||||||
reply_testbench.verif_reporter.check_completed(&req_id);
|
reply_testbench.verif_reporter.check_completed(&req_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Add more tests for reply handler.
|
// TODO: Add more tests for reply handler: Request timeout and unrequested reply.
|
||||||
}
|
}
|
||||||
|
@ -199,7 +199,7 @@ impl PusTcToRequestConverter<ActivePusRequestStd, ModeRequest> for ModeRequestCo
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use satrs::{
|
use satrs::{
|
||||||
mode::ModeRequest,
|
mode::{ModeAndSubmode, ModeRequest},
|
||||||
pus::mode::Subservice,
|
pus::mode::Subservice,
|
||||||
spacepackets::{
|
spacepackets::{
|
||||||
ecss::tc::{PusTcCreator, PusTcSecondaryHeader},
|
ecss::tc::{PusTcCreator, PusTcSecondaryHeader},
|
||||||
@ -212,12 +212,11 @@ mod tests {
|
|||||||
use super::ModeRequestConverter;
|
use super::ModeRequestConverter;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn mode_converter_set_mode_request() {
|
fn mode_converter_read_mode_request() {
|
||||||
let mut testbench = PusConverterTestbench::new(ModeRequestConverter::default());
|
let mut testbench = PusConverterTestbench::new(ModeRequestConverter::default());
|
||||||
let mut sp_header = SpHeader::tc_unseg(TEST_APID, 0, 0).unwrap();
|
let mut sp_header = SpHeader::tc_unseg(TEST_APID, 0, 0).unwrap();
|
||||||
let sec_header = PusTcSecondaryHeader::new_simple(200, Subservice::TcReadMode as u8);
|
let sec_header = PusTcSecondaryHeader::new_simple(200, Subservice::TcReadMode as u8);
|
||||||
let mut app_data: [u8; 4] = [0; 4];
|
let mut app_data: [u8; 4] = [0; 4];
|
||||||
// Invalid ID, routing should fail.
|
|
||||||
app_data[0..4].copy_from_slice(&TEST_APID_TARGET_ID.to_be_bytes());
|
app_data[0..4].copy_from_slice(&TEST_APID_TARGET_ID.to_be_bytes());
|
||||||
let tc = PusTcCreator::new(&mut sp_header, sec_header, &app_data, true);
|
let tc = PusTcCreator::new(&mut sp_header, sec_header, &app_data, true);
|
||||||
let token = testbench.add_tc(&tc);
|
let token = testbench.add_tc(&tc);
|
||||||
@ -226,4 +225,54 @@ mod tests {
|
|||||||
.expect("conversion has failed");
|
.expect("conversion has failed");
|
||||||
assert_eq!(req, ModeRequest::ReadMode);
|
assert_eq!(req, ModeRequest::ReadMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn mode_converter_set_mode_request() {
|
||||||
|
let mut testbench = PusConverterTestbench::new(ModeRequestConverter::default());
|
||||||
|
let mut sp_header = SpHeader::tc_unseg(TEST_APID, 0, 0).unwrap();
|
||||||
|
let sec_header = PusTcSecondaryHeader::new_simple(200, Subservice::TcSetMode as u8);
|
||||||
|
let mut app_data: [u8; 4 + ModeAndSubmode::RAW_LEN] = [0; 4 + ModeAndSubmode::RAW_LEN];
|
||||||
|
let mode_and_submode = ModeAndSubmode::new(2, 1);
|
||||||
|
app_data[0..4].copy_from_slice(&TEST_APID_TARGET_ID.to_be_bytes());
|
||||||
|
mode_and_submode.write_to_be_bytes(&mut app_data[4..]).unwrap();
|
||||||
|
let tc = PusTcCreator::new(&mut sp_header, sec_header, &app_data, true);
|
||||||
|
let token = testbench.add_tc(&tc);
|
||||||
|
let (_active_req, req) = testbench
|
||||||
|
.convert(token, &[], TEST_APID, TEST_APID_TARGET_ID)
|
||||||
|
.expect("conversion has failed");
|
||||||
|
assert_eq!(req, ModeRequest::SetMode(mode_and_submode));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn mode_converter_announce_mode() {
|
||||||
|
let mut testbench = PusConverterTestbench::new(ModeRequestConverter::default());
|
||||||
|
let mut sp_header = SpHeader::tc_unseg(TEST_APID, 0, 0).unwrap();
|
||||||
|
let sec_header = PusTcSecondaryHeader::new_simple(200, Subservice::TcAnnounceMode as u8);
|
||||||
|
let mut app_data: [u8; 4] = [0; 4];
|
||||||
|
app_data[0..4].copy_from_slice(&TEST_APID_TARGET_ID.to_be_bytes());
|
||||||
|
let tc = PusTcCreator::new(&mut sp_header, sec_header, &app_data, true);
|
||||||
|
let token = testbench.add_tc(&tc);
|
||||||
|
let (_active_req, req) = testbench
|
||||||
|
.convert(token, &[], TEST_APID, TEST_APID_TARGET_ID)
|
||||||
|
.expect("conversion has failed");
|
||||||
|
assert_eq!(req, ModeRequest::AnnounceMode);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn mode_converter_announce_mode_recursively() {
|
||||||
|
let mut testbench = PusConverterTestbench::new(ModeRequestConverter::default());
|
||||||
|
let mut sp_header = SpHeader::tc_unseg(TEST_APID, 0, 0).unwrap();
|
||||||
|
let sec_header = PusTcSecondaryHeader::new_simple(200, Subservice::TcAnnounceModeRecursive as u8);
|
||||||
|
let mut app_data: [u8; 4] = [0; 4];
|
||||||
|
app_data[0..4].copy_from_slice(&TEST_APID_TARGET_ID.to_be_bytes());
|
||||||
|
let tc = PusTcCreator::new(&mut sp_header, sec_header, &app_data, true);
|
||||||
|
let token = testbench.add_tc(&tc);
|
||||||
|
let (_active_req, req) = testbench
|
||||||
|
.convert(token, &[], TEST_APID, TEST_APID_TARGET_ID)
|
||||||
|
.expect("conversion has failed");
|
||||||
|
assert_eq!(req, ModeRequest::AnnounceModeRecursive);
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Add reply handler tests.
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user