Skip to content

Commit

Permalink
Merge pull request mirage#254 from hannesm/fix-random
Browse files Browse the repository at this point in the history
tests need stdlibrandom as well
  • Loading branch information
hannesm authored Oct 3, 2016
2 parents ec97c99 + f92664c commit d080d3a
Show file tree
Hide file tree
Showing 8 changed files with 5,768 additions and 3,471 deletions.
3 changes: 2 additions & 1 deletion _oasis
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ Executable test
mirage-clock-unix,pcap-format,
tcpip.ethif,tcpip.arpv4,tcpip.ipv4,tcpip.tcp,tcpip.udp,
tcpip.stack-direct,tcpip.icmpv4,
tcpip.udpv4-socket, tcpip.tcpv4-socket, tcpip.stack-socket, duration
tcpip.udpv4-socket, tcpip.tcpv4-socket, tcpip.stack-socket, duration,
mirage-stdlib-random

Test test
Run$: flag(tests)
Expand Down
4 changes: 3 additions & 1 deletion _tags
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# OASIS_START
# DO NOT EDIT (digest: bb445ce5e2101b5879bf9a10a8602530)
# DO NOT EDIT (digest: 932c2d4a28d84c22430fe4df82d8b59a)
# Ignore VCS directories, you can use the same kind of rule outside
# OASIS_START/STOP if you want to exclude directories that contains
# useless stuff for the build process
Expand Down Expand Up @@ -210,6 +210,7 @@ true: annot, bin_annot
<lib_test/test.{native,byte}>: pkg_mirage-clock-unix
<lib_test/test.{native,byte}>: pkg_mirage-flow
<lib_test/test.{native,byte}>: pkg_mirage-profile
<lib_test/test.{native,byte}>: pkg_mirage-stdlib-random
<lib_test/test.{native,byte}>: pkg_mirage-types
<lib_test/test.{native,byte}>: pkg_mirage-types.lwt
<lib_test/test.{native,byte}>: pkg_mirage-vnetif
Expand Down Expand Up @@ -246,6 +247,7 @@ true: annot, bin_annot
<lib_test/*.ml{,i,y}>: pkg_mirage-clock-unix
<lib_test/*.ml{,i,y}>: pkg_mirage-flow
<lib_test/*.ml{,i,y}>: pkg_mirage-profile
<lib_test/*.ml{,i,y}>: pkg_mirage-stdlib-random
<lib_test/*.ml{,i,y}>: pkg_mirage-types
<lib_test/*.ml{,i,y}>: pkg_mirage-types.lwt
<lib_test/*.ml{,i,y}>: pkg_mirage-vnetif
Expand Down
6 changes: 4 additions & 2 deletions lib/tcp/pcb.ml
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,8 @@ struct
Logs.(log_with_stats Debug "process-syn" t);
match listeners @@ WIRE.src_port_of_id id with
| Some pushf ->
let tx_isn = Sequence.of_int32 (Randomconv.int32 Random.generate) in
(* XXX: I've no clue why this is the way it is, static 16 bits plus some random -- hannes *)
let tx_isn = Sequence.of_int ((Randomconv.int ~bound:65535 Random.generate) + 0x1AFE0000) in
(* TODO: make this configurable per listener *)
let rx_wnd = 65535 in
let rx_wnd_scaleoffer = wscale_default in
Expand Down Expand Up @@ -581,7 +582,8 @@ struct

let connect t ~dst ~dst_port =
let id = getid t dst dst_port in
let tx_isn = Sequence.of_int32 (Randomconv.int32 Random.generate) in
(* XXX: I've no clue why this is the way it is, static 16 bits plus some random -- hannes *)
let tx_isn = Sequence.of_int ((Randomconv.int ~bound:65535 Random.generate) + 0x1BCD0000) in
(* TODO: This is hardcoded for now - make it configurable *)
let rx_wnd_scaleoffer = wscale_default in
let options =
Expand Down
2 changes: 2 additions & 0 deletions lib_test/test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ let run test () =
Lwt_main.run (test ())

let () =
(* someone has to call Stdlibrandom.initialize () *)
Stdlibrandom.initialize ();
(* enable logging to stdout for all modules *)
Logs.set_reporter (Logs_fmt.reporter ());
Logs.set_level ~all:true (Some Logs.Debug);
Expand Down
4 changes: 2 additions & 2 deletions lib_test/vnetif_common.ml
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ module VNETIF_STACK ( B : Vnetif_backends.Backend) : (VNETIF_STACK with type bac
module Ip = Ipv4.Make(E)(A)
module Icmp = Icmpv4.Make(Ip)
module U = Udp.Make(Ip)
module T = Tcp.Flow.Make(Ip)(Time)(Clock)(Random)
module T = Tcp.Flow.Make(Ip)(Time)(Clock)(Stdlibrandom)
module Stackv4 =
Tcpip_stack_direct.Make(Time)(Random)(V)(E)(A)(Ip)(Icmp)(U)(T)
Tcpip_stack_direct.Make(Time)(Stdlibrandom)(V)(E)(A)(Ip)(Icmp)(U)(T)

let create_backend () =
B.create ()
Expand Down
Loading

0 comments on commit d080d3a

Please sign in to comment.