From 8bb7786803f830084604d03cbcffbd7fa02bd09f Mon Sep 17 00:00:00 2001 From: Hannes Mehnert Date: Wed, 25 Nov 2020 12:52:38 +0100 Subject: [PATCH 1/5] port build system to dune 2 --- .ocamlformat | 2 ++ dune-project | 2 +- examples/ping/dune | 2 +- src/stack-unix/dune | 5 ++++- src/tcpip_checksum/dune | 5 ++++- tcpip.opam | 2 +- test/dune | 14 ++++---------- 7 files changed, 17 insertions(+), 15 deletions(-) create mode 100644 .ocamlformat diff --git a/.ocamlformat b/.ocamlformat new file mode 100644 index 000000000..2e686658c --- /dev/null +++ b/.ocamlformat @@ -0,0 +1,2 @@ +version = 0.15.0 +disable = true diff --git a/dune-project b/dune-project index 6a4a87f19..6d722c804 100644 --- a/dune-project +++ b/dune-project @@ -1,2 +1,2 @@ -(lang dune 1.0) +(lang dune 2.7) (name tcpip) diff --git a/examples/ping/dune b/examples/ping/dune index 16813355d..2c9ccbb2c 100644 --- a/examples/ping/dune +++ b/examples/ping/dune @@ -1,3 +1,3 @@ (executables (names ping) - (libraries cmdliner logs logs.fmt tcpip.icmpv4-socket)) + (libraries cmdliner logs logs.fmt tcpip.icmpv4-socket tcpip.unix)) diff --git a/src/stack-unix/dune b/src/stack-unix/dune index f1dc1e1e8..14d5146f1 100644 --- a/src/stack-unix/dune +++ b/src/stack-unix/dune @@ -24,7 +24,10 @@ (name tcp_socket_options) (public_name tcpip.tcp_socket_options) (modules tcp_socket_options) - (c_names tcp_socket_options_stubs) + (foreign_stubs + (language c) + (names tcp_socket_options_stubs) + (flags :standard)) (wrapped false) (libraries lwt.unix duration)) diff --git a/src/tcpip_checksum/dune b/src/tcpip_checksum/dune index 8c28b96cf..170f15177 100644 --- a/src/tcpip_checksum/dune +++ b/src/tcpip_checksum/dune @@ -9,5 +9,8 @@ (name tcpip_unix) (public_name tcpip.unix) (modules tcpip_unix) - (c_names checksum_stubs) + (foreign_stubs + (language c) + (names checksum_stubs) + (flags :standard)) (wrapped false)) diff --git a/tcpip.opam b/tcpip.opam index eaf0d008d..8bcd5b8b1 100644 --- a/tcpip.opam +++ b/tcpip.opam @@ -19,7 +19,7 @@ build: [ ] conflicts: [ "mirage-xen" {< "6.0.0"} ] depends: [ - "dune" + "dune" {>= "2.7.0"} "ocaml" {>= "4.06.0"} "rresult" {>= "0.5.0"} "cstruct" {>= "3.2.0"} diff --git a/test/dune b/test/dune index 8aa4ca180..36f83b41e 100644 --- a/test/dune +++ b/test/dune @@ -1,16 +1,10 @@ -(executables - (names test) +(test + (name test) (libraries alcotest mirage-random-test lwt.unix logs logs.fmt mirage-profile mirage-flow mirage-vnetif mirage-clock-unix pcap-format duration mirage-random rresult mirage-protocols mirage-stack arp arp-mirage ethernet tcpip.ipv4 tcpip.tcp tcpip.udp tcpip.stack-direct tcpip.icmpv4 tcpip.udpv4-socket tcpip.tcpv4-socket tcpip.icmpv4-socket tcpip.stack-socket tcpip.ipv6 ipaddr-cstruct - macaddr-cstruct tcpip.unix)) - -(alias - (name runtest) - (deps - (:< test.exe)) - (action - (run %{<} -q -e --color=always))) + macaddr-cstruct tcpip.unix) + (action (run %{test} -q -e --color=always))) From 3c674db5b14b894ebdd6d5f05b99d67f5981e443 Mon Sep 17 00:00:00 2001 From: Hannes Mehnert Date: Wed, 25 Nov 2020 12:54:29 +0100 Subject: [PATCH 2/5] dune build @fmt --auto --- src/icmp/dune | 3 ++- src/ipv4/dune | 7 ++++--- src/ipv6/dune | 3 ++- src/stack-direct/dune | 4 ++-- src/stack-unix/dune | 10 +++++----- src/tcp/dune | 7 ++++--- src/udp/dune | 3 ++- test/dune | 16 ++++++++-------- 8 files changed, 29 insertions(+), 24 deletions(-) diff --git a/src/icmp/dune b/src/icmp/dune index e44427007..0286c10f6 100644 --- a/src/icmp/dune +++ b/src/icmp/dune @@ -2,5 +2,6 @@ (name tcpip_icmpv4) (public_name tcpip.icmpv4) (libraries mirage-protocols rresult logs tcpip mirage-profile tcpip.udp) - (preprocess (pps ppx_cstruct)) + (preprocess + (pps ppx_cstruct)) (wrapped false)) diff --git a/src/ipv4/dune b/src/ipv4/dune index b59bf9cb7..b21407386 100644 --- a/src/ipv4/dune +++ b/src/ipv4/dune @@ -1,7 +1,8 @@ (library (name tcpip_ipv4) (public_name tcpip.ipv4) - (libraries logs mirage-protocols ipaddr cstruct rresult tcpip - tcpip.udp mirage-random mirage-clock randomconv lru) - (preprocess (pps ppx_cstruct)) + (libraries logs mirage-protocols ipaddr cstruct rresult tcpip tcpip.udp + mirage-random mirage-clock randomconv lru) + (preprocess + (pps ppx_cstruct)) (wrapped false)) diff --git a/src/ipv6/dune b/src/ipv6/dune index 28b467d80..76bfd9bfb 100644 --- a/src/ipv6/dune +++ b/src/ipv6/dune @@ -4,5 +4,6 @@ (libraries logs mirage-protocols mirage-time mirage-net macaddr-cstruct mirage-clock duration ipaddr cstruct rresult mirage-random tcpip randomconv ethernet) - (preprocess (pps ppx_cstruct)) + (preprocess + (pps ppx_cstruct)) (wrapped false)) diff --git a/src/stack-direct/dune b/src/stack-direct/dune index f6dbf7163..ead5530f3 100644 --- a/src/stack-direct/dune +++ b/src/stack-direct/dune @@ -1,5 +1,5 @@ (library (name tcpip_stack_direct) (public_name tcpip.stack-direct) - (libraries logs ipaddr lwt fmt mirage-time mirage-random - mirage-protocols mirage-stack mirage-net ethernet)) + (libraries logs ipaddr lwt fmt mirage-time mirage-random mirage-protocols + mirage-stack mirage-net ethernet)) diff --git a/src/stack-unix/dune b/src/stack-unix/dune index 14d5146f1..54c208a9c 100644 --- a/src/stack-unix/dune +++ b/src/stack-unix/dune @@ -3,8 +3,8 @@ (public_name tcpip.icmpv4-socket) (modules icmpv4_socket) (wrapped false) - (libraries lwt.unix ipaddr.unix cstruct-lwt tcpip.icmpv4 - tcpip.ipv4 tcpip.ipv6 mirage-protocols)) + (libraries lwt.unix ipaddr.unix cstruct-lwt tcpip.icmpv4 tcpip.ipv4 + tcpip.ipv6 mirage-protocols)) (library (name udpv4_socket) @@ -52,6 +52,6 @@ (public_name tcpip.stack-socket) (modules tcpip_stack_socket ipv4_socket ipv6_socket) (wrapped false) - (libraries lwt.unix cstruct-lwt ipaddr.unix logs - tcpip.tcpv4-socket tcpip.udpv4-socket tcpip.ipv4 tcpip.ipv6 tcpip.icmpv4 - mirage-protocols mirage-stack)) + (libraries lwt.unix cstruct-lwt ipaddr.unix logs tcpip.tcpv4-socket + tcpip.udpv4-socket tcpip.ipv4 tcpip.ipv6 tcpip.icmpv4 mirage-protocols + mirage-stack)) diff --git a/src/tcp/dune b/src/tcp/dune index 997de9caf..babf7975b 100644 --- a/src/tcp/dune +++ b/src/tcp/dune @@ -2,6 +2,7 @@ (name tcp) (public_name tcpip.tcp) (libraries logs mirage-protocols ipaddr cstruct lwt-dllist rresult - mirage-profile tcpip duration randomconv fmt mirage-time - mirage-clock mirage-random) - (preprocess (pps ppx_cstruct))) + mirage-profile tcpip duration randomconv fmt mirage-time mirage-clock + mirage-random) + (preprocess + (pps ppx_cstruct))) diff --git a/src/udp/dune b/src/udp/dune index 8ed39f677..deae0448f 100644 --- a/src/udp/dune +++ b/src/udp/dune @@ -2,5 +2,6 @@ (name tcpip_udpv4) (public_name tcpip.udp) (libraries mirage-protocols mirage-random rresult logs tcpip randomconv) - (preprocess (pps ppx_cstruct)) + (preprocess + (pps ppx_cstruct)) (wrapped false)) diff --git a/test/dune b/test/dune index 36f83b41e..00275c7d3 100644 --- a/test/dune +++ b/test/dune @@ -1,10 +1,10 @@ (test (name test) - (libraries alcotest mirage-random-test lwt.unix logs - logs.fmt mirage-profile mirage-flow mirage-vnetif mirage-clock-unix - pcap-format duration mirage-random rresult mirage-protocols - mirage-stack arp arp-mirage ethernet tcpip.ipv4 tcpip.tcp tcpip.udp - tcpip.stack-direct tcpip.icmpv4 tcpip.udpv4-socket tcpip.tcpv4-socket - tcpip.icmpv4-socket tcpip.stack-socket tcpip.ipv6 ipaddr-cstruct - macaddr-cstruct tcpip.unix) - (action (run %{test} -q -e --color=always))) + (libraries alcotest mirage-random-test lwt.unix logs logs.fmt mirage-profile + mirage-flow mirage-vnetif mirage-clock-unix pcap-format duration + mirage-random rresult mirage-protocols mirage-stack arp arp-mirage + ethernet tcpip.ipv4 tcpip.tcp tcpip.udp tcpip.stack-direct tcpip.icmpv4 + tcpip.udpv4-socket tcpip.tcpv4-socket tcpip.icmpv4-socket + tcpip.stack-socket tcpip.ipv6 ipaddr-cstruct macaddr-cstruct tcpip.unix) + (action + (run %{test} -q -e --color=always))) From e6b20e97fab4210370381f44ff432accee6cb307 Mon Sep 17 00:00:00 2001 From: Hannes Mehnert Date: Wed, 25 Nov 2020 12:58:06 +0100 Subject: [PATCH 3/5] add bisect_ppx instrumentation runes as advertised on the bisect_ppx repository: dune runtest --instrument-with bisect_ppx --force bisect-ppx-report summary (or html) -> Coverage: 2232/3604 (61.93%) --- src/icmp/dune | 2 ++ src/ipv4/dune | 2 ++ src/ipv6/dune | 2 ++ src/stack-direct/dune | 2 ++ src/stack-unix/dune | 14 ++++++++++++++ src/tcp/dune | 2 ++ src/tcpip_checksum/dune | 4 ++++ src/udp/dune | 2 ++ tcpip.opam | 1 + 9 files changed, 31 insertions(+) diff --git a/src/icmp/dune b/src/icmp/dune index 0286c10f6..ba3f02e0f 100644 --- a/src/icmp/dune +++ b/src/icmp/dune @@ -1,6 +1,8 @@ (library (name tcpip_icmpv4) (public_name tcpip.icmpv4) + (instrumentation + (backend bisect_ppx)) (libraries mirage-protocols rresult logs tcpip mirage-profile tcpip.udp) (preprocess (pps ppx_cstruct)) diff --git a/src/ipv4/dune b/src/ipv4/dune index b21407386..8d6838118 100644 --- a/src/ipv4/dune +++ b/src/ipv4/dune @@ -1,6 +1,8 @@ (library (name tcpip_ipv4) (public_name tcpip.ipv4) + (instrumentation + (backend bisect_ppx)) (libraries logs mirage-protocols ipaddr cstruct rresult tcpip tcpip.udp mirage-random mirage-clock randomconv lru) (preprocess diff --git a/src/ipv6/dune b/src/ipv6/dune index 76bfd9bfb..11817c413 100644 --- a/src/ipv6/dune +++ b/src/ipv6/dune @@ -1,6 +1,8 @@ (library (name tcpip_ipv6) (public_name tcpip.ipv6) + (instrumentation + (backend bisect_ppx)) (libraries logs mirage-protocols mirage-time mirage-net macaddr-cstruct mirage-clock duration ipaddr cstruct rresult mirage-random tcpip randomconv ethernet) diff --git a/src/stack-direct/dune b/src/stack-direct/dune index ead5530f3..884fd6789 100644 --- a/src/stack-direct/dune +++ b/src/stack-direct/dune @@ -1,5 +1,7 @@ (library (name tcpip_stack_direct) (public_name tcpip.stack-direct) + (instrumentation + (backend bisect_ppx)) (libraries logs ipaddr lwt fmt mirage-time mirage-random mirage-protocols mirage-stack mirage-net ethernet)) diff --git a/src/stack-unix/dune b/src/stack-unix/dune index 54c208a9c..a3b111376 100644 --- a/src/stack-unix/dune +++ b/src/stack-unix/dune @@ -3,6 +3,8 @@ (public_name tcpip.icmpv4-socket) (modules icmpv4_socket) (wrapped false) + (instrumentation + (backend bisect_ppx)) (libraries lwt.unix ipaddr.unix cstruct-lwt tcpip.icmpv4 tcpip.ipv4 tcpip.ipv6 mirage-protocols)) @@ -11,6 +13,8 @@ (public_name tcpip.udpv4-socket) (modules udpv4_socket) (wrapped false) + (instrumentation + (backend bisect_ppx)) (libraries lwt.unix ipaddr.unix cstruct-lwt fmt mirage-protocols)) (library @@ -18,6 +22,8 @@ (public_name tcpip.udpv6-socket) (modules udpv6_socket) (wrapped false) + (instrumentation + (backend bisect_ppx)) (libraries lwt.unix ipaddr.unix cstruct-lwt fmt mirage-protocols)) (library @@ -29,6 +35,8 @@ (names tcp_socket_options_stubs) (flags :standard)) (wrapped false) + (instrumentation + (backend bisect_ppx)) (libraries lwt.unix duration)) (library @@ -36,6 +44,8 @@ (public_name tcpip.tcpv4-socket) (modules tcpv4_socket tcp_socket) (wrapped false) + (instrumentation + (backend bisect_ppx)) (libraries lwt.unix ipaddr.unix cstruct-lwt fmt mirage-protocols tcp_socket_options)) @@ -44,6 +54,8 @@ (public_name tcpip.tcpv6-socket) (modules tcpv6_socket) (wrapped false) + (instrumentation + (backend bisect_ppx)) (libraries lwt.unix ipaddr.unix cstruct-lwt fmt mirage-protocols tcpv4_socket tcp_socket_options)) @@ -52,6 +64,8 @@ (public_name tcpip.stack-socket) (modules tcpip_stack_socket ipv4_socket ipv6_socket) (wrapped false) + (instrumentation + (backend bisect_ppx)) (libraries lwt.unix cstruct-lwt ipaddr.unix logs tcpip.tcpv4-socket tcpip.udpv4-socket tcpip.ipv4 tcpip.ipv6 tcpip.icmpv4 mirage-protocols mirage-stack)) diff --git a/src/tcp/dune b/src/tcp/dune index babf7975b..0765f2dbf 100644 --- a/src/tcp/dune +++ b/src/tcp/dune @@ -1,6 +1,8 @@ (library (name tcp) (public_name tcpip.tcp) + (instrumentation + (backend bisect_ppx)) (libraries logs mirage-protocols ipaddr cstruct lwt-dllist rresult mirage-profile tcpip duration randomconv fmt mirage-time mirage-clock mirage-random) diff --git a/src/tcpip_checksum/dune b/src/tcpip_checksum/dune index 170f15177..3779e54aa 100644 --- a/src/tcpip_checksum/dune +++ b/src/tcpip_checksum/dune @@ -2,6 +2,8 @@ (name tcpip) (public_name tcpip) (modules tcpip_checksum) + (instrumentation + (backend bisect_ppx)) (libraries cstruct) (wrapped false)) @@ -9,6 +11,8 @@ (name tcpip_unix) (public_name tcpip.unix) (modules tcpip_unix) + (instrumentation + (backend bisect_ppx)) (foreign_stubs (language c) (names checksum_stubs) diff --git a/src/udp/dune b/src/udp/dune index deae0448f..05b926d90 100644 --- a/src/udp/dune +++ b/src/udp/dune @@ -1,6 +1,8 @@ (library (name tcpip_udpv4) (public_name tcpip.udp) + (instrumentation + (backend bisect_ppx)) (libraries mirage-protocols mirage-random rresult logs tcpip randomconv) (preprocess (pps ppx_cstruct)) diff --git a/tcpip.opam b/tcpip.opam index 8bcd5b8b1..caa4a6b1d 100644 --- a/tcpip.opam +++ b/tcpip.opam @@ -20,6 +20,7 @@ build: [ conflicts: [ "mirage-xen" {< "6.0.0"} ] depends: [ "dune" {>= "2.7.0"} + "bisect_ppx" {dev & >= "2.5.0"} "ocaml" {>= "4.06.0"} "rresult" {>= "0.5.0"} "cstruct" {>= "3.2.0"} From 09e77a7995f4fbf0e4db8919135e075147a1682b Mon Sep 17 00:00:00 2001 From: Hannes Mehnert Date: Wed, 25 Nov 2020 13:19:36 +0100 Subject: [PATCH 4/5] iperf: increase timeout from 120 to 240 seconds, mark ipv6 iperf as slow --- test/test_iperf.ml | 2 +- test/test_iperf_ipv6.ml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/test_iperf.ml b/test/test_iperf.ml index 5f92d1f17..230cb0c3c 100644 --- a/test/test_iperf.ml +++ b/test/test_iperf.ml @@ -252,7 +252,7 @@ let suite = [ test_tcp_iperf_two_stacks_uniform_packet_loss amt_quick 120.0; "iperf with two stacks and uniform packet loss of packets with no payload", `Quick, - test_tcp_iperf_two_stacks_uniform_packet_loss_no_payload amt_quick 120.0; + test_tcp_iperf_two_stacks_uniform_packet_loss_no_payload amt_quick 240.0; "iperf with two stacks and uniform packet loss of packets with no payload, longer", `Slow, test_tcp_iperf_two_stacks_uniform_packet_loss_no_payload amt_slow 240.0; diff --git a/test/test_iperf_ipv6.ml b/test/test_iperf_ipv6.ml index a4572dd08..aa1099bb6 100644 --- a/test/test_iperf_ipv6.ml +++ b/test/test_iperf_ipv6.ml @@ -250,8 +250,8 @@ let suite = [ "iperf with two stacks and uniform packet loss", `Quick, test_tcp_iperf_ipv6_two_stacks_uniform_packet_loss amt_quick 120.0; - "iperf with two stacks and uniform packet loss of packets with no payload", `Quick, - test_tcp_iperf_ipv6_two_stacks_uniform_packet_loss_no_payload amt_quick 120.0; + "iperf with two stacks and uniform packet loss of packets with no payload", `Slow, + test_tcp_iperf_ipv6_two_stacks_uniform_packet_loss_no_payload amt_quick 240.0; "iperf with two stacks and uniform packet loss of packets with no payload, longer", `Slow, test_tcp_iperf_ipv6_two_stacks_uniform_packet_loss_no_payload amt_slow 240.0; From 8142d95282c48b4e5e5fc083eb130b5644239345 Mon Sep 17 00:00:00 2001 From: Hannes Mehnert Date: Mon, 30 Nov 2020 10:25:38 +0100 Subject: [PATCH 5/5] opam: upper bound to mirage-protocols <5.0.0 --- tcpip.opam | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tcpip.opam b/tcpip.opam index caa4a6b1d..4b5dd68e8 100644 --- a/tcpip.opam +++ b/tcpip.opam @@ -29,7 +29,7 @@ depends: [ "mirage-clock" {>= "3.0.0"} "mirage-random" {>= "2.0.0"} "mirage-stack" {>= "2.1.0"} - "mirage-protocols" {>= "4.0.0"} + "mirage-protocols" {>= "4.0.0" & < "5.0.0"} "mirage-time" {>= "2.0.0"} "ipaddr" {>= "5.0.0"} "macaddr" {>="4.0.0"}