CCSDS USLP (Unified Space Link Protocol) Transfer Frame- unified TM/TC/AOS
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

+57
+57
test/test_uslp.ml
··· 171 171 let wire = Uslp.encode_string packed in 172 172 Alcotest.(check string) "wire=manual" manual wire 173 173 174 + (* Test: VCFC length variants (0-7 bytes) *) 175 + let test_vcfc_length_variants () = 176 + let scid = Uslp.scid_exn 100 in 177 + let vcid = Uslp.vcid_exn 1 in 178 + let map_id = Uslp.map_id_exn 0 in 179 + List.iter 180 + (fun vcfc_len -> 181 + let vcfc = if vcfc_len = 0 then 0 else (1 lsl (vcfc_len * 8)) - 1 in 182 + let frame = 183 + Uslp.v ~scid ~vcid ~map_id ~vcfc ~vcfc_len 184 + (Printf.sprintf "vcfc_len=%d" vcfc_len) 185 + in 186 + let encoded = Uslp.encode frame in 187 + match Uslp.decode ~vcfc_len encoded with 188 + | Error e -> 189 + Alcotest.failf "decode vcfc_len=%d failed: %a" vcfc_len Uslp.pp_error 190 + e 191 + | Ok decoded -> 192 + Alcotest.(check int) 193 + (Printf.sprintf "vcfc_len=%d header" vcfc_len) 194 + vcfc_len decoded.header.vcfc_len; 195 + Alcotest.(check int) 196 + (Printf.sprintf "vcfc_len=%d value" vcfc_len) 197 + vcfc decoded.header.vcfc) 198 + [ 0; 1; 2; 3; 4 ] 199 + 200 + (* Test: MAP ID boundary (4-bit field, 0 and 15) *) 201 + let test_map_id_boundary () = 202 + let scid = Uslp.scid_exn 200 in 203 + let vcid = Uslp.vcid_exn 0 in 204 + (* MAP ID = 0 *) 205 + let map0 = Uslp.map_id_exn 0 in 206 + let frame0 = Uslp.v ~scid ~vcid ~map_id:map0 ~vcfc:0 ~vcfc_len:0 "map0" in 207 + let enc0 = Uslp.encode frame0 in 208 + (match Uslp.decode enc0 with 209 + | Error e -> Alcotest.failf "decode map=0 failed: %a" Uslp.pp_error e 210 + | Ok decoded -> 211 + Alcotest.(check int) 212 + "map_id=0" 0 213 + (Uslp.map_id_to_int decoded.header.map_id)); 214 + (* MAP ID = 15 *) 215 + let map15 = Uslp.map_id_exn 15 in 216 + let frame15 = Uslp.v ~scid ~vcid ~map_id:map15 ~vcfc:0 ~vcfc_len:0 "map15" in 217 + let enc15 = Uslp.encode frame15 in 218 + match Uslp.decode enc15 with 219 + | Error e -> Alcotest.failf "decode map=15 failed: %a" Uslp.pp_error e 220 + | Ok decoded -> 221 + Alcotest.(check int) 222 + "map_id=15" 15 223 + (Uslp.map_id_to_int decoded.header.map_id) 224 + 174 225 let suite = 175 226 [ 176 227 ( "uslp", ··· 192 243 [ 193 244 Alcotest.test_case "wire_roundtrip" `Quick test_wire_roundtrip; 194 245 Alcotest.test_case "wire_vs_manual" `Quick test_wire_vs_manual; 246 + ] ); 247 + ( "spec_vectors", 248 + [ 249 + Alcotest.test_case "vcfc_length_variants" `Quick 250 + test_vcfc_length_variants; 251 + Alcotest.test_case "map_id_boundary" `Quick test_map_id_boundary; 195 252 ] ); 196 253 ]