@@ -24,8 +24,8 @@ module Defaults = struct
24
24
end
25
25
26
26
let random_buffer () =
27
- let sz = Cstruct.BE. get_uint16 (Stdlibrandom . generate 2 ) 0 in
28
- Stdlibrandom . generate sz
27
+ let sz = Cstruct.BE. get_uint16 (Mirage_random_test . generate 2 ) 0 in
28
+ Mirage_random_test . generate sz
29
29
30
30
let rec no_result t n () =
31
31
if n < = 0 then ()
@@ -39,17 +39,19 @@ let rec no_result t n () =
39
39
end
40
40
;;
41
41
42
- let parseable buf =
42
+ let parseable buf =
43
43
Alcotest. (check bool ) " buffer we constructed is valid dhcp" true (Dhcp_wire. is_dhcp buf (Cstruct. len buf))
44
44
45
+ let random_xid () = Cstruct.BE. get_uint32 (Mirage_random_test. generate 4 ) 0
46
+
45
47
let start_makes_dhcp () =
46
- let (_s, buf) = Dhcp_client. create Defaults. client_mac in
48
+ let (_s, buf) = Dhcp_client. create (random_xid () ) Defaults. client_mac in
47
49
(* for now, any positive result is fine *)
48
50
parseable buf
49
51
50
52
let client_to_selecting () =
51
53
let open Defaults in
52
- let (s, buf) = Dhcp_client. create client_mac in
54
+ let (s, buf) = Dhcp_client. create (random_xid () ) client_mac in
53
55
let answer = Dhcp_wire. pkt_of_buf buf (Cstruct. len buf) in
54
56
Alcotest. (check (result pass reject)) " input succeeds" answer answer;
55
57
(s, Rresult.R. get_ok answer)
@@ -136,7 +138,7 @@ Alcotest.fail "client wanted to send more packets after receiving DHCPACK"
136
138
Alcotest. (check (option pass)) " lease is held" (Some dhcpack) (Dhcp_client. lease s)
137
139
138
140
let random_init n =
139
- let (s, _) = Dhcp_client. create Defaults. client_mac in
141
+ let (s, _) = Dhcp_client. create (random_xid () ) Defaults. client_mac in
140
142
" random buffer entry to INIT client" , `Quick , (no_result s n)
141
143
142
144
let random_selecting n =
@@ -166,8 +168,9 @@ let random_bound n =
166
168
a new lease"
167
169
| `New_lease (s , response ) ->
168
170
" random buffer entry to BOUND client" , `Quick , (no_result s n)
169
-
171
+
170
172
let () =
173
+ Mirage_random_test. initialize () ;
171
174
let nfuzz = 100 in
172
175
Alcotest. run " client tests" [
173
176
(* these tests will programmatically put [Dhcp_client.t] into a particular
0 commit comments