Skip to content

Commit e746181

Browse files
author
Marcello Seri
committed
test, test_tuntap: update tests
Signed-off-by: Marcello Seri <[email protected]>
1 parent 6a42f1c commit e746181

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

test/test.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@ open Fd_send_recv
33

44
let t_receivefd fd =
55
Printf.printf "[receiver] t_receivedfd thread started!\n%!";
6-
let buf = "**" in
6+
let buf = Bytes.of_string "**" in
77
let nb_read, remote_saddr, fd_recv = recv_fd fd buf 0 2 [] in
88
Printf.printf "[receiver] Received %d bytes, received fd = %d\n%!" nb_read (int_of_fd fd_recv);
99
let message = "[receiver] I'm the receiver, and I'm writing into the fd you passed to me :p\n" in
10-
let nb_written = write fd_recv message 0 (String.length message) in
10+
let nb_written = write fd_recv (Bytes.unsafe_of_string message) 0 (String.length message) in
1111
assert (nb_written = String.length message)
1212

1313
let t_sendfd fd =
1414
let fd_to_send = stdout in
15-
let buf = " " in
15+
let buf = Bytes.of_string " " in
1616
let nb_sent = send_fd fd buf 0 2 [] fd_to_send in
1717
Printf.printf "[sender] sent %d bytes, sent fd = %d\n%!" nb_sent (int_of_fd fd_to_send)
1818

test/test_fork.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@ open Fd_send_recv
33

44
let t_receivefd fd =
55
Printf.printf "[receiver] t_receivedfd thread started!\n%!";
6-
let buf = "**" in
6+
let buf = Bytes.of_string "**" in
77
let nb_read, remote_saddr, fd_recv = recv_fd fd buf 0 2 [] in
88
Printf.printf "[receiver] Received %d bytes, received fd = %d\n%!" nb_read (int_of_fd fd_recv);
99
let message = "[receiver] I'm the receiver, and I'm writing into the fd you passed to me :p\n" in
10-
let nb_written = write fd_recv message 0 (String.length message) in
10+
let nb_written = write fd_recv (Bytes.unsafe_of_string message) 0 (String.length message) in
1111
assert (nb_written = String.length message)
1212

1313
let t_sendfd fd =
1414
let fd_to_send = stdout in
15-
let buf = " " in
15+
let buf = Bytes.of_string " " in
1616
let nb_sent = send_fd fd buf 0 2 [] fd_to_send in
1717
Printf.printf "[sender] sent %d bytes, sent fd = %d\n%!" nb_sent (int_of_fd fd_to_send)
1818

test_tuntap/test_tuntap.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ open Fd_send_recv
33

44
let t_receivefd fd =
55
Printf.printf "[receiver] t_receivedfd thread started!\n%!";
6-
let buf = String.make (Tuntap.get_ifnamsiz ()) '\000' in
7-
let nb_read, remote_saddr, fd_recv = recv_fd fd buf 0 (String.length buf) [] in
6+
let buf = Bytes.make (Tuntap.get_ifnamsiz ()) '\000' in
7+
let nb_read, remote_saddr, fd_recv = recv_fd fd buf 0 (Bytes.length buf) [] in
88
Printf.printf "[receiver] Received %d bytes [%s], received fd = %d\n%!"
9-
nb_read (String.sub buf 0 nb_read) (int_of_fd fd_recv)
9+
nb_read (Bytes.sub_string buf 0 nb_read) (int_of_fd fd_recv)
1010

1111
let t_sendfd fd =
1212
let fd_to_send, iface_name = Tuntap.opentap () in
13-
let nb_sent = send_fd fd iface_name 0 (String.length iface_name) [] fd_to_send in
13+
let nb_sent = send_fd fd (Bytes.unsafe_of_string iface_name) 0 (String.length iface_name) [] fd_to_send in
1414
Printf.printf "[sender] sent %d bytes [%s], sent fd = %d\n%!" nb_sent
1515
(String.sub iface_name 0 nb_sent) (int_of_fd fd_to_send)
1616

0 commit comments

Comments
 (0)