This commit is contained in:
parent
aa2ff7b2f0
commit
2f3113f55d
11742 changed files with 1223940 additions and 0 deletions
26
unikernel/duniverse/mirage-tcpip/test/common.ml
Normal file
26
unikernel/duniverse/mirage-tcpip/test/common.ml
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
open Lwt.Infix
|
||||
|
||||
let failf fmt = Fmt.kstr (fun s -> Alcotest.fail s) fmt
|
||||
|
||||
let ( let* ) = Result.bind
|
||||
|
||||
let or_error name fn t =
|
||||
fn t >>= function
|
||||
| Error _ -> failf "or_error starting %s" name
|
||||
| Ok t -> Lwt.return t
|
||||
|
||||
let expect_error error name fn t =
|
||||
fn t >>= function
|
||||
| Error error2 when error2 = error -> Lwt.return t
|
||||
| _ -> failf "expected error on %s" name
|
||||
|
||||
let ipv4_packet = Alcotest.testable Ipv4_packet.pp Ipv4_packet.equal
|
||||
let udp_packet = Alcotest.testable Udp_packet.pp Udp_packet.equal
|
||||
let tcp_packet = Alcotest.testable Tcp.Tcp_packet.pp Tcp.Tcp_packet.equal
|
||||
let cstruct = Alcotest.testable Cstruct.hexdump_pp Cstruct.equal
|
||||
|
||||
let sequence =
|
||||
let eq x y = Tcp.Sequence.compare x y = 0 in
|
||||
Alcotest.testable Tcp.Sequence.pp eq
|
||||
|
||||
let options = Alcotest.testable Tcp.Options.pp Tcp.Options.equal
|
||||
Loading…
Add table
Add a link
Reference in a new issue