CCSDS Command Link Control Word (CLCW) for spacecraft command
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

+80
+80
test/test_clcw.ml
··· 65 65 Alcotest.(check bool) "vcid -1 invalid" true (Option.is_none (Clcw.vcid (-1))); 66 66 Alcotest.(check bool) "vcid 64 invalid" true (Option.is_none (Clcw.vcid 64)) 67 67 68 + (* Test: All COP-in-effect values (2-bit field, 0-3) *) 69 + let test_cop_values () = 70 + let vcid = Clcw.vcid_exn 0 in 71 + List.iter 72 + (fun cop -> 73 + let t = Clcw.v ~vcid ~report_value:0 ~cop_in_effect:cop () in 74 + let word = Clcw.encode t in 75 + match Clcw.decode word with 76 + | Error e -> Alcotest.failf "decode cop=%d failed: %a" cop Clcw.pp_error e 77 + | Ok t' -> 78 + Alcotest.(check int) 79 + (Printf.sprintf "cop_in_effect=%d" cop) 80 + cop t'.cop_in_effect) 81 + [ 0; 1; 2; 3 ] 82 + 83 + (* Test: All status field values *) 84 + let test_status_values () = 85 + let vcid = Clcw.vcid_exn 0 in 86 + let status_testable = Alcotest.testable Clcw.pp_status Clcw.equal_status in 87 + (* Ready = 0, Active = 1, Reserved 2-7 *) 88 + let cases = 89 + [ 90 + (Clcw.Ready, "Ready"); 91 + (Clcw.Active, "Active"); 92 + (Clcw.Reserved 2, "Reserved 2"); 93 + (Clcw.Reserved 3, "Reserved 3"); 94 + (Clcw.Reserved 4, "Reserved 4"); 95 + (Clcw.Reserved 5, "Reserved 5"); 96 + (Clcw.Reserved 6, "Reserved 6"); 97 + (Clcw.Reserved 7, "Reserved 7"); 98 + ] 99 + in 100 + List.iter 101 + (fun (status, label) -> 102 + let t = Clcw.v ~vcid ~report_value:0 ~status () in 103 + let word = Clcw.encode t in 104 + match Clcw.decode word with 105 + | Error e -> 106 + Alcotest.failf "decode status=%s failed: %a" label Clcw.pp_error e 107 + | Ok t' -> Alcotest.check status_testable label status t'.status) 108 + cases 109 + 110 + (* Test: report_value boundary (8-bit field, 0 and 255) *) 111 + let test_report_value_boundary () = 112 + let vcid = Clcw.vcid_exn 0 in 113 + (* report_value = 0 *) 114 + let t0 = Clcw.v ~vcid ~report_value:0 () in 115 + let word0 = Clcw.encode t0 in 116 + (match Clcw.decode word0 with 117 + | Error e -> Alcotest.failf "decode rv=0 failed: %a" Clcw.pp_error e 118 + | Ok t' -> Alcotest.(check int) "report_value=0" 0 t'.report_value); 119 + (* report_value = 255 *) 120 + let t255 = Clcw.v ~vcid ~report_value:255 () in 121 + let word255 = Clcw.encode t255 in 122 + match Clcw.decode word255 with 123 + | Error e -> Alcotest.failf "decode rv=255 failed: %a" Clcw.pp_error e 124 + | Ok t' -> Alcotest.(check int) "report_value=255" 255 t'.report_value 125 + 126 + (* Test: FARM-B counter boundary (2-bit field, 0-3) *) 127 + let test_farm_b_counter_boundary () = 128 + let vcid = Clcw.vcid_exn 0 in 129 + List.iter 130 + (fun fb -> 131 + let t = Clcw.v ~vcid ~report_value:0 ~farm_b_counter:fb () in 132 + let word = Clcw.encode t in 133 + match Clcw.decode word with 134 + | Error e -> 135 + Alcotest.failf "decode farm_b=%d failed: %a" fb Clcw.pp_error e 136 + | Ok t' -> 137 + Alcotest.(check int) 138 + (Printf.sprintf "farm_b_counter=%d" fb) 139 + fb t'.farm_b_counter) 140 + [ 0; 1; 2; 3 ] 141 + 68 142 let suite = 69 143 ( "clcw", 70 144 [ ··· 72 146 Alcotest.test_case "decode_known" `Quick test_decode_known; 73 147 Alcotest.test_case "flags" `Quick test_flags; 74 148 Alcotest.test_case "vcid_bounds" `Quick test_vcid_bounds; 149 + Alcotest.test_case "cop_values" `Quick test_cop_values; 150 + Alcotest.test_case "status_values" `Quick test_status_values; 151 + Alcotest.test_case "report_value_boundary" `Quick 152 + test_report_value_boundary; 153 + Alcotest.test_case "farm_b_counter_boundary" `Quick 154 + test_farm_b_counter_boundary; 75 155 ] )