CCSDS File Delivery Protocol (CCSDS 727.0-B-5) for space file transfer
0
fork

Configure Feed

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

fix(lint): resolve E205 Printf/Format usage and add missing fmt deps

Replace Printf.sprintf/printf with Fmt.str/pr across cbort, cfdp,
cgr, claudeio, clcw, conpool, cookeio, and cpio packages. Add fmt
library dependency to dune files where needed.

+17 -31
+1 -1
test/dune
··· 1 1 (test 2 2 (name test) 3 - (libraries cfdp alcotest)) 3 + (libraries cfdp alcotest fmt))
+16 -30
test/test_cfdp.ml
··· 147 147 match parse_header encoded with 148 148 | Ok (decoded, _cfg, _consumed) -> 149 149 Alcotest.(check header) "roundtrip" original decoded 150 - | Error e -> 151 - Alcotest.fail (Format.asprintf "decode failed: %a" Cfdp.pp_error e) 150 + | Error e -> Alcotest.fail (Fmt.str "decode failed: %a" Cfdp.pp_error e) 152 151 153 152 let test_header_file_data () = 154 153 let cfg = Cfdp.default_config in ··· 172 171 match parse_header encoded with 173 172 | Ok (decoded, _cfg, _consumed) -> 174 173 Alcotest.(check header) "file data header" original decoded 175 - | Error e -> 176 - Alcotest.fail (Format.asprintf "decode failed: %a" Cfdp.pp_error e) 174 + | Error e -> Alcotest.fail (Fmt.str "decode failed: %a" Cfdp.pp_error e) 177 175 178 176 let test_header_truncated () = 179 177 let buf = String.make 2 '\x00' in ··· 182 180 let buf = Bytes.to_string buf in 183 181 match parse_header buf with 184 182 | Error (Cfdp.Truncated _) -> () 185 - | Error e -> Alcotest.fail (Format.asprintf "wrong error: %a" Cfdp.pp_error e) 183 + | Error e -> Alcotest.fail (Fmt.str "wrong error: %a" Cfdp.pp_error e) 186 184 | _ -> Alcotest.fail "should reject truncated header" 187 185 188 186 (* {1 Directive Tests} *) ··· 197 195 Alcotest.(check int32) "checksum" original.checksum decoded.checksum; 198 196 Alcotest.(check int64) "file_size" original.file_size decoded.file_size 199 197 | Ok _ -> Alcotest.fail "wrong directive type" 200 - | Error e -> 201 - Alcotest.fail (Format.asprintf "parse failed: %a" Cfdp.pp_error e) 198 + | Error e -> Alcotest.fail (Fmt.str "parse failed: %a" Cfdp.pp_error e) 202 199 203 200 let test_eof_with_fault () = 204 201 let original = ··· 219 216 (Cfdp.Entity_id.to_int64 eid) 220 217 | None -> Alcotest.fail "expected fault location") 221 218 | Ok _ -> Alcotest.fail "wrong directive type" 222 - | Error e -> 223 - Alcotest.fail (Format.asprintf "parse failed: %a" Cfdp.pp_error e) 219 + | Error e -> Alcotest.fail (Fmt.str "parse failed: %a" Cfdp.pp_error e) 224 220 225 221 let test_metadata_roundtrip () = 226 222 let original = ··· 238 234 "src" original.source_filename decoded.source_filename; 239 235 Alcotest.(check string) "dst" original.dest_filename decoded.dest_filename 240 236 | Ok _ -> Alcotest.fail "wrong directive type" 241 - | Error e -> 242 - Alcotest.fail (Format.asprintf "parse failed: %a" Cfdp.pp_error e) 237 + | Error e -> Alcotest.fail (Fmt.str "parse failed: %a" Cfdp.pp_error e) 243 238 244 239 let test_finished_roundtrip () = 245 240 let original = ··· 258 253 (decoded.file_status = Cfdp.Retained_successfully) 259 254 true 260 255 | Ok _ -> Alcotest.fail "wrong directive type" 261 - | Error e -> 262 - Alcotest.fail (Format.asprintf "parse failed: %a" Cfdp.pp_error e) 256 + | Error e -> Alcotest.fail (Fmt.str "parse failed: %a" Cfdp.pp_error e) 263 257 264 258 let test_ack_roundtrip () = 265 259 let original = ··· 275 269 (decoded.transaction_status = Cfdp.Tx_active) 276 270 true 277 271 | Ok _ -> Alcotest.fail "wrong directive type" 278 - | Error e -> 279 - Alcotest.fail (Format.asprintf "parse failed: %a" Cfdp.pp_error e) 272 + | Error e -> Alcotest.fail (Fmt.str "parse failed: %a" Cfdp.pp_error e) 280 273 281 274 let test_nak_roundtrip () = 282 275 let original = ··· 291 284 Alcotest.(check int64) "end_scope" original.end_scope decoded.end_scope; 292 285 Alcotest.(check int) "segments" 2 (List.length decoded.segments) 293 286 | Ok _ -> Alcotest.fail "wrong directive type" 294 - | Error e -> 295 - Alcotest.fail (Format.asprintf "parse failed: %a" Cfdp.pp_error e) 287 + | Error e -> Alcotest.fail (Fmt.str "parse failed: %a" Cfdp.pp_error e) 296 288 297 289 let test_prompt_roundtrip () = 298 290 let original = Cfdp.prompt Cfdp.Prompt_nak in ··· 301 293 | Ok (Cfdp.Prompt decoded, _) -> 302 294 Alcotest.(check bool) "response" (decoded.response = Cfdp.Prompt_nak) true 303 295 | Ok _ -> Alcotest.fail "wrong directive type" 304 - | Error e -> 305 - Alcotest.fail (Format.asprintf "parse failed: %a" Cfdp.pp_error e) 296 + | Error e -> Alcotest.fail (Fmt.str "parse failed: %a" Cfdp.pp_error e) 306 297 307 298 let test_keep_alive_roundtrip () = 308 299 let original = Cfdp.keep_alive 12345L in ··· 311 302 | Ok (Cfdp.Keep_alive decoded, _) -> 312 303 Alcotest.(check int64) "progress" original.progress decoded.progress 313 304 | Ok _ -> Alcotest.fail "wrong directive type" 314 - | Error e -> 315 - Alcotest.fail (Format.asprintf "parse failed: %a" Cfdp.pp_error e) 305 + | Error e -> Alcotest.fail (Fmt.str "parse failed: %a" Cfdp.pp_error e) 316 306 317 307 (* {1 File Data Tests} *) 318 308 ··· 330 320 | Ok (decoded, _) -> 331 321 Alcotest.(check int64) "offset" original.offset decoded.offset; 332 322 Alcotest.(check bytes) "data" original.data decoded.data 333 - | Error e -> 334 - Alcotest.fail (Format.asprintf "parse failed: %a" Cfdp.pp_error e) 323 + | Error e -> Alcotest.fail (Fmt.str "parse failed: %a" Cfdp.pp_error e) 335 324 336 325 let test_file_data_large_file () = 337 326 let original = ··· 346 335 with 347 336 | Ok (decoded, _) -> 348 337 Alcotest.(check int64) "large offset" original.offset decoded.offset 349 - | Error e -> 350 - Alcotest.fail (Format.asprintf "parse failed: %a" Cfdp.pp_error e) 338 + | Error e -> Alcotest.fail (Fmt.str "parse failed: %a" Cfdp.pp_error e) 351 339 352 340 (* {1 Complete PDU Tests} *) 353 341 ··· 379 367 | Ok (Cfdp.Pdu_directive (_, Cfdp.Metadata decoded), _) -> 380 368 Alcotest.(check string) "src" meta.source_filename decoded.source_filename 381 369 | Ok _ -> Alcotest.fail "wrong PDU type" 382 - | Error e -> 383 - Alcotest.fail (Format.asprintf "parse failed: %a" Cfdp.pp_error e) 370 + | Error e -> Alcotest.fail (Fmt.str "parse failed: %a" Cfdp.pp_error e) 384 371 385 372 let test_pdu_roundtrip_file_data () = 386 373 let cfg = Cfdp.default_config in ··· 407 394 | Ok (Cfdp.Pdu_file_data (_, decoded), _) -> 408 395 Alcotest.(check bytes) "data" fd.data decoded.data 409 396 | Ok _ -> Alcotest.fail "wrong PDU type" 410 - | Error e -> 411 - Alcotest.fail (Format.asprintf "parse failed: %a" Cfdp.pp_error e) 397 + | Error e -> Alcotest.fail (Fmt.str "parse failed: %a" Cfdp.pp_error e) 412 398 413 399 (* {1 Checksum Tests} *) 414 400 ··· 468 454 match Cfdp.condition_of_int code with 469 455 | Some decoded -> 470 456 Alcotest.(check bool) 471 - (Format.asprintf "condition %a" Cfdp.pp_condition cond) 457 + (Fmt.str "condition %a" Cfdp.pp_condition cond) 472 458 true (cond = decoded) 473 459 | None -> Alcotest.fail "should decode condition") 474 460 conditions