Skip to content

Commit

Permalink
Delete Alcotest tests converted so far
Browse files Browse the repository at this point in the history
  • Loading branch information
aantron committed Jan 22, 2024
1 parent cc7d97c commit 246c24c
Show file tree
Hide file tree
Showing 10 changed files with 0 additions and 1,107 deletions.
146 changes: 0 additions & 146 deletions test/TCP.ml
Original file line number Diff line number Diff line change
Expand Up @@ -40,152 +40,6 @@ let with_server_and_client ~server_logic ~client_logic =

let tests = [
"tcp", [
"init, close", `Quick, begin fun () ->
with_tcp ignore
end;

"nodelay", `Quick, begin fun () ->
with_tcp begin fun tcp ->
Luv.TCP.nodelay tcp true
|> check_success_result "nodelay"
end
end;

"keepalive", `Quick, begin fun () ->
with_tcp begin fun tcp ->
Luv.TCP.keepalive tcp None
|> check_success_result "keepalive"
end
end;

"simultaneous_accepts", `Quick, begin fun () ->
with_tcp begin fun tcp ->
Luv.TCP.simultaneous_accepts tcp true
|> check_success_result "simultaneous_accepts"
end
end;

"bind, getsockname", `Quick, begin fun () ->
with_tcp begin fun tcp ->
let address = fresh_address () in

Luv.TCP.bind tcp address
|> check_success_result "bind";

Luv.TCP.getsockname tcp
|> check_success_result "getsockname result"
|> Luv.Sockaddr.to_string
|> Alcotest.(check (option string)) "getsockname address"
(Luv.Sockaddr.to_string address)
end
end;

"connect", `Quick, begin fun () ->
with_tcp begin fun tcp ->
let finished = ref false in
let address = fresh_address () in

Luv.TCP.connect tcp address begin fun result ->
check_error_result "connect" `ECONNREFUSED result;
finished := true
end;

run ();
Alcotest.(check bool) "finished" true !finished
end
end;

(* Fails with a segfault if the binding doesn't retain a reference to the
callback. *)
"gc", `Quick, begin fun () ->
with_tcp begin fun tcp ->
let finished = ref false in
let address = fresh_address () in

Luv.TCP.connect tcp address begin fun _result ->
finished := true
end;

Gc.full_major ();

run ();
Alcotest.(check bool) "finished" true !finished
end
end;

"connect, callback leak", `Slow, begin fun () ->
let address = fresh_address () in

no_memory_leak ~base_repetitions:1 begin fun _n ->
with_tcp begin fun tcp ->
Luv.TCP.connect tcp address (make_callback ());
run ()
end
end
end;

"connect, synchronous error", `Quick, begin fun () ->
let address = fresh_address () in
let result = ref (Result.Ok ()) in

with_tcp begin fun tcp ->
Luv.TCP.connect tcp address ignore;
Luv.TCP.connect tcp address begin fun result' ->
result := result'
end;

check_error_results "connect" [`EALREADY; `EINVAL] !result;
run ()
end
end;

"connect, synchronous error leak", `Slow, begin fun () ->
let address = fresh_address () in

no_memory_leak ~base_repetitions:1 begin fun _n ->
with_tcp begin fun tcp ->
Luv.TCP.connect tcp address ignore;
Luv.TCP.connect tcp address ignore;
run ()
end
end
end;

"connect, handle lifetime", `Quick, begin fun () ->
with_tcp begin fun tcp ->
let address = fresh_address () in
Luv.TCP.connect tcp address begin fun result ->
check_error_result "connect" `ECANCELED result
end
end
end;

"listen, accept", `Quick, begin fun () ->
let accepted = ref false in
let connected = ref false in

with_server_and_client
~server_logic:
begin fun server client ->
accepted := true;
Luv.Handle.close client ignore;
Luv.Handle.close server ignore
end
~client_logic:
begin fun client address ->
Luv.TCP.getpeername client
|> check_success_result "getpeername result"
|> Luv.Sockaddr.to_string
|> Alcotest.(check (option string)) "getpeername address"
(Luv.Sockaddr.to_string address);
connected := true;
Luv.Handle.close client ignore
end;

Alcotest.(check bool) "accepted" true !accepted;
Alcotest.(check bool) "connected" true !connected
end;

"listen: exception", `Quick, begin fun () ->
check_exception Exit begin fun () ->
with_server_and_client
Expand Down
76 changes: 0 additions & 76 deletions test/async.ml

This file was deleted.

Loading

0 comments on commit 246c24c

Please sign in to comment.