remove last qtest

This commit is contained in:
Simon Cruanes 2023-08-08 14:41:58 -04:00
parent b36ea35703
commit 572168967f
No known key found for this signature in database
GPG key ID: EBFFF6F283F3A2B4
3 changed files with 25 additions and 18 deletions

View file

@ -349,22 +349,6 @@ module Request = struct
end
end
(*$R
let q = "GET hello HTTP/1.1\r\nHost: coucou\r\nContent-Length: 11\r\n\r\nsalutationsSOMEJUNK" in
let str = Tiny_httpd.Byte_stream.of_string q in
let r = Request.Internal_.parse_req_start ~get_time_s:(fun _ -> 0.) str in
match r with
| None -> assert_failure "should parse"
| Some req ->
assert_equal (Some "coucou") (Headers.get "Host" req.Request.headers);
assert_equal (Some "coucou") (Headers.get "host" req.Request.headers);
assert_equal (Some "11") (Headers.get "content-length" req.Request.headers);
assert_equal "hello" req.Request.path;
let req = Request.Internal_.parse_body req str |> Request.read_body_full in
assert_equal ~printer:(fun s->s) "salutations" req.Request.body;
()
*)
module Response = struct
type body =
[ `String of string
@ -967,7 +951,7 @@ module Unix_tcp_server_ = struct
(try Unix.close client_sock with _ -> ());
Sem_.release 1 self.sem_max_connections;
raise e);
ignore Unix.(sigprocmask SIG_UNBLOCK Sys.[ sigint; sighup ]);
ignore Unix.(sigprocmask SIG_UNBLOCK Sys.[ sigint; sighup ])
with e ->
Sem_.release 1 self.sem_max_connections;
_debug (fun k ->

View file

@ -1,5 +1,5 @@
(tests
(names t_util t_buf)
(names t_util t_buf t_server)
(package tiny_httpd)
(libraries tiny_httpd qcheck-core qcheck-core.runner test_util))

23
tests/unit/t_server.ml Normal file
View file

@ -0,0 +1,23 @@
open Test_util
open Tiny_httpd_server
let () =
let q =
"GET hello HTTP/1.1\r\n\
Host: coucou\r\n\
Content-Length: 11\r\n\
\r\n\
salutationsSOMEJUNK"
in
let str = Tiny_httpd.Byte_stream.of_string q in
let r = Request.Internal_.parse_req_start ~get_time_s:(fun _ -> 0.) str in
match r with
| None -> failwith "should parse"
| Some req ->
assert_eq (Some "coucou") (Headers.get "Host" req.Request.headers);
assert_eq (Some "coucou") (Headers.get "host" req.Request.headers);
assert_eq (Some "11") (Headers.get "content-length" req.Request.headers);
assert_eq "hello" req.Request.path;
let req = Request.Internal_.parse_body req str |> Request.read_body_full in
assert_eq ~to_string:(fun s -> s) "salutations" req.Request.body;
()