CCSDS AOS (Advanced Orbiting Systems) Transfer Frame for satellite downlinks
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

test(space): expand test suites for CCSDS and space protocol packages

+55
+55
test/test_aos.ml
··· 127 127 let wire = Aos.encode_string packed in 128 128 Alcotest.(check string) "wire=manual" manual wire 129 129 130 + (* Test: VC count cycle wraparound (4-bit field, 0-15) *) 131 + let test_vc_count_cycle_wraparound () = 132 + let scid = Aos.scid_exn 1 in 133 + let vcid = Aos.vcid_exn 1 in 134 + (* Max value = 15 *) 135 + let frame_max = 136 + Aos.v ~scid ~vcid ~vcfc:0 ~vc_count_cycle:15 ~vc_count_flag:true "data" 137 + in 138 + let encoded_max = Aos.encode frame_max in 139 + (match Aos.decode encoded_max with 140 + | Error e -> Alcotest.failf "decode max failed: %a" Aos.pp_error e 141 + | Ok decoded -> 142 + Alcotest.(check int) "vc_count_cycle=15" 15 decoded.header.vc_count_cycle); 143 + (* Wraparound back to 0 *) 144 + let frame_zero = 145 + Aos.v ~scid ~vcid ~vcfc:0 ~vc_count_cycle:0 ~vc_count_flag:true "data" 146 + in 147 + let encoded_zero = Aos.encode frame_zero in 148 + match Aos.decode encoded_zero with 149 + | Error e -> Alcotest.failf "decode zero failed: %a" Aos.pp_error e 150 + | Ok decoded -> 151 + Alcotest.(check int) "vc_count_cycle=0" 0 decoded.header.vc_count_cycle 152 + 153 + (* Test: replay_flag=true roundtrip *) 154 + let test_replay_flag () = 155 + let scid = Aos.scid_exn 50 in 156 + let vcid = Aos.vcid_exn 2 in 157 + let frame = Aos.v ~scid ~vcid ~vcfc:100 ~replay_flag:true "replay data" in 158 + Alcotest.(check bool) "replay_flag set" true frame.header.replay_flag; 159 + let encoded = Aos.encode frame in 160 + match Aos.decode encoded with 161 + | Error e -> Alcotest.failf "decode failed: %a" Aos.pp_error e 162 + | Ok decoded -> 163 + Alcotest.(check bool) 164 + "replay_flag roundtrip" true decoded.header.replay_flag 165 + 166 + (* Test: Insert zone roundtrip *) 167 + let test_insert_zone () = 168 + let scid = Aos.scid_exn 30 in 169 + let vcid = Aos.vcid_exn 3 in 170 + let insert = "\x01\x02\x03\x04" in 171 + let frame = Aos.v ~scid ~vcid ~vcfc:50 ~insert_zone:(Some insert) "payload" in 172 + Alcotest.(check (option string)) 173 + "insert_zone set" (Some insert) frame.insert_zone; 174 + let encoded = Aos.encode ~insert_zone_len:4 frame in 175 + match Aos.decode ~insert_zone_len:4 encoded with 176 + | Error e -> Alcotest.failf "decode failed: %a" Aos.pp_error e 177 + | Ok decoded -> 178 + Alcotest.(check (option string)) 179 + "insert_zone roundtrip" (Some insert) decoded.insert_zone 180 + 130 181 let suite = 131 182 ( "Aos", 132 183 [ ··· 140 191 Alcotest.test_case "scid_bounds" `Quick test_scid_bounds; 141 192 Alcotest.test_case "wire_roundtrip" `Quick test_wire_roundtrip; 142 193 Alcotest.test_case "wire_vs_manual" `Quick test_wire_vs_manual; 194 + Alcotest.test_case "vc_count_cycle_wraparound" `Quick 195 + test_vc_count_cycle_wraparound; 196 + Alcotest.test_case "replay_flag" `Quick test_replay_flag; 197 + Alcotest.test_case "insert_zone" `Quick test_insert_zone; 143 198 ] )