From 6a9f5fc8545d574a571969123294209bc86097f9 Mon Sep 17 00:00:00 2001 From: ygrek Date: Sat, 4 Aug 2018 13:34:13 -0700 Subject: [PATCH] enable test for outdated enums --- Makefile.in | 1 + curl-helper.c | 23 ++++++++++++----------- examples/Makefile.in | 4 ++-- examples/test_unit.ml | 17 ++++++++++------- 4 files changed, 25 insertions(+), 20 deletions(-) diff --git a/Makefile.in b/Makefile.in index 7612fcf..74c86f7 100644 --- a/Makefile.in +++ b/Makefile.in @@ -75,6 +75,7 @@ ifneq (@OCAML_PKG_lwt_unix@,no) examples/test_lwt_unit.opt endif endif + examples/test_unit doc: mkdir -p doc diff --git a/curl-helper.c b/curl-helper.c index 36b5c48..82e8ed1 100644 --- a/curl-helper.c +++ b/curl-helper.c @@ -4600,29 +4600,30 @@ struct used_enum #define CURL_ENUM(name,last_used) { CURL_ ## name ## _ ## last_used, CURL_ ## name ## _LAST, #name } struct used_enum check_enums[] = { - { CURLINFO_SSL_DATA_OUT, CURLINFO_END, "CURLINFO" }, + { CURLINFO_SSL_DATA_OUT, CURLINFO_END, "DEBUGFUNCTION curl_infotype" }, #if HAVE_DECL_CURL_HTTP_VERSION_2TLS CURL_ENUM(HTTP_VERSION, 2TLS), #endif }; -value caml_curl_outdated_enums(value v_unit) +value caml_curl_check_enums(value v_unit) { CAMLparam0(); - CAMLlocal1(v); - size_t i; + CAMLlocal2(v_r,v); + size_t len = sizeof(check_enums) / sizeof(struct used_enum); - v = Val_emptylist; + v_r = caml_alloc_tuple(len); - for (i = 0; i < sizeof(check_enums) / sizeof(struct used_enum); i++) + for (size_t i = 0; i < len; i++) { - if (check_enums[i].last_used + 1 != check_enums[i].last) - { - v = Val_cons(v, caml_copy_string(check_enums[i].name)); - } + v = caml_alloc_tuple(3); + Store_field(v, 0, Val_int(check_enums[i].last_used)); + Store_field(v, 1, Val_int(check_enums[i].last)); + Store_field(v, 2, caml_copy_string(check_enums[i].name)); + Store_field(v_r, i, v); } - CAMLreturn(v); + CAMLreturn(v_r); } #ifdef __cplusplus diff --git a/examples/Makefile.in b/examples/Makefile.in index 2a269b6..6094f28 100644 --- a/examples/Makefile.in +++ b/examples/Makefile.in @@ -19,7 +19,7 @@ OCURLOPTLIB = curl.cmxa unix.cmxa threads.cmxa LWT_UNIX=@OCAML_PKG_lwt_unix@ LWT_PPX=@OCAML_PKG_lwt_ppx@ -TARGETS = ocurl ominimal ossl ocurl_test_threads opar test_cb_exn test_memory_leaks +TARGETS = ocurl ominimal ossl ocurl_test_threads opar test_cb_exn test_memory_leaks test_unit ifneq (@OCAML_PKG_bytes@,no) TARGETS += oput endif @@ -31,7 +31,7 @@ endif endif ifeq (@OCAMLBEST@,opt) -TARGETS += ocurl.opt ominimal.opt ossl.opt ocurl_test_threads.opt opar.opt test_cb_exn.opt test_memory_leaks.opt +TARGETS += ocurl.opt ominimal.opt ossl.opt ocurl_test_threads.opt opar.opt test_cb_exn.opt test_memory_leaks.opt test_unit.opt ifneq (@OCAML_PKG_bytes@,no) TARGETS += oput.opt endif diff --git a/examples/test_unit.ml b/examples/test_unit.ml index bc073dd..edff146 100644 --- a/examples/test_unit.ml +++ b/examples/test_unit.ml @@ -2,12 +2,15 @@ open Printf let printfn fmt = ksprintf print_endline fmt -external outdated_enums : unit -> string list = "caml_curl_outdated_enums" +external check_enums : unit -> (int * int * string) array = "caml_curl_check_enums" let () = - match outdated_enums () with - | [] -> exit 0 - | l -> - print_endline "need update for :"; - List.iter print_endline l; - exit 1 + let ok = ref true in + Array.iter begin fun (last_used,last,name) -> + if last_used + 1 <> last then + begin + ok := false; + printfn "Need update for %s" name + end + end (check_enums ()); + exit (if !ok then 0 else 1) -- 2.11.4.GIT