Skip to content

Commit ced7d6e

Browse files
committed
Show the unexpected error on our fuzzer
1 parent d5e23ae commit ced7d6e

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

miou/tests/dune

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
ptime
99
ptime.clock.os
1010
crowbar
11+
hxd.core
12+
hxd.string
1113
tls-miou-unix)
1214
(instrumentation
1315
(backend bisect_ppx)))

miou/tests/fuzz.ml

+8-2
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,9 @@ let compile to_client to_server =
248248
go 0x0 to_client to_server;
249249
(Buffer.contents client, Buffer.contents server)
250250

251+
let pp_exn ppf exn = Fmt.string ppf (Printexc.to_string exn)
252+
let pp_str ppf str = Hxd_string.pp Hxd.default ppf str
253+
251254
let run seed operations =
252255
Miou_unix.run ~domains:1 @@ fun () ->
253256
let rng = Mirage_crypto_rng_miou_unix.(initialize (module Pfortuna)) in
@@ -278,9 +281,12 @@ let run seed operations =
278281
let m = String.length send_to_server in
279282
Mirage_crypto_rng_miou_unix.kill rng;
280283
epr "[%a] %db %db transmitted\n%!" Fmt.(styled `Green string) "OK" n m
281-
| _ ->
284+
| a, b ->
282285
Mirage_crypto_rng_miou_unix.kill rng;
283-
Crowbar.failf "[%a] Unexpected result\n%!" Fmt.(styled `Red string) "ERROR"
286+
Crowbar.failf "[%a] Unexpected result: %a & %a\n%!"
287+
Fmt.(styled `Red string) "ERROR"
288+
Fmt.(Dump.result ~error:pp_exn ~ok:Fmt.(Dump.list (Dump.result ~error:pp_exn ~ok:pp_str))) a
289+
Fmt.(Dump.result ~error:pp_exn ~ok:pp_str) b
284290

285291
let label name gen = Crowbar.with_printer Fmt.(const string name) gen
286292

tls-miou-unix.opam

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,14 @@ depends: [
1717
"ocaml" {>= "5.0.0"}
1818
"dune" {>= "3.0"}
1919
"tls" {= version}
20-
"mirage-crypto-rng-miou-unix" {>= "1.0.0"}
20+
"mirage-crypto-rng-miou-unix" {>= "1.0.0" & with-test}
2121
"x509" {>= "1.0.0"}
2222
"miou" {>= "0.2.0"}
2323
"crowbar" {with-test}
2424
"rresult" {with-test}
2525
"ohex" {with-test}
2626
"ptime" {with-test}
27+
"hxd" {with-test}
2728
]
2829
tags: [ "org:mirage"]
2930
synopsis: "Transport Layer Security purely in OCaml, Miou+Unix layer"

0 commit comments

Comments
 (0)