<div dir="ltr"><div dir="ltr">Hi, Vlad.<br><br>Number 7 is the libcurl age. According to the documentation, age should be set to the version of this functionality by the time you write your program. This way, libcurl will always return a proper struct that your program understands, while programs in the future might get a different struct. See <a href="https://curl.haxx.se/libcurl/c/curl_version_info.html">https://curl.haxx.se/libcurl/c/curl_version_info.html</a><br><br>So it's safe enough to rely on the structure. And I think both checkes (libssl and libz) are important enough to be tracked by tests. We don't want them to be silently gone, do we?<div><br></div><div><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><span><div><div dir="ltr">Best regards</div><div>Yaroslav Dynnikov<br></div></div></span></div></div></div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, 11 Aug 2020 at 01:49, Vladislav Shpilevoy <<a href="mailto:v.shpilevoy@tarantool.org">v.shpilevoy@tarantool.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi! Thanks for the patch!<br>
<br>
> diff --git a/test/box-tap/gh-5223-curl-exports.test.lua b/test/box-tap/gh-5223-curl-exports.test.lua<br>
> new file mode 100755<br>
> index 000000000..300d60b07<br>
> --- /dev/null<br>
> +++ b/test/box-tap/gh-5223-curl-exports.test.lua<br>
> @@ -0,0 +1,177 @@<br>
> +#!/usr/bin/env tarantool<br>
> +<br>
> +local tap = require('tap')<br>
> +local ffi = require('ffi')<br>
> +ffi.cdef([[<br>
> + void *dlsym(void *handle, const char *symbol);<br>
> + struct curl_version_info_data {<br>
<br>
1. I don't think you need to copy-paste the entire structure. Anyway it is<br>
returned from curl_version_info() by pointer, so you can just announce the<br>
pointer type. And in the test check that ffi.C.curl_version_info(7) returned<br>
something not nil. I don't think you need to access any fields of this<br>
struct. It is going to lead to UB in case the struct will change anyhow in<br>
the sources.<br>
<br>
> + int age; /* see description below */<br>
> + const char *version; /* human readable string */<br>
> + unsigned int version_num; /* numeric representation */<br>
> + const char *host; /* human readable string */<br>
> + int features; /* bitmask, see below */<br>
> + char *ssl_version; /* human readable string */<br>
> + long ssl_version_num; /* not used, always zero */<br>
> + const char *libz_version; /* human readable string */<br>
> + const char * const *protocols; /* protocols */<br>
> +<br>
> + /* when 'age' is CURLVERSION_SECOND or higher, the members below exist */<br>
> + const char *ares; /* human readable string */<br>
> + int ares_num; /* number */<br>
> +<br>
> + /* when 'age' is CURLVERSION_THIRD or higher, the members below exist */<br>
> + const char *libidn; /* human readable string */<br>
> +<br>
> + /* when 'age' is CURLVERSION_FOURTH or higher (>= 7.16.1), the members<br>
> + below exist */<br>
> + int iconv_ver_num; /* '_libiconv_version' if iconv support enabled */<br>
> +<br>
> + const char *libssh_version; /* human readable string */<br>
> +<br>
> + /* when 'age' is CURLVERSION_FIFTH or higher (>= 7.57.0), the members<br>
> + below exist */<br>
> + unsigned int brotli_ver_num; /* Numeric Brotli version<br>
> + (MAJOR << 24) | (MINOR << 12) | PATCH */<br>
> + const char *brotli_version; /* human readable string. */<br>
> +<br>
> + /* when 'age' is CURLVERSION_SIXTH or higher (>= 7.66.0), the members<br>
> + below exist */<br>
> + unsigned int nghttp2_ver_num; /* Numeric nghttp2 version<br>
> + (MAJOR << 16) | (MINOR << 8) | PATCH */<br>
> + const char *nghttp2_version; /* human readable string. */<br>
> +<br>
> + const char *quic_version; /* human readable quic (+ HTTP/3) library +<br>
> + version or NULL */<br>
> +<br>
> + /* when 'age' is CURLVERSION_SEVENTH or higher (>= 7.70.0), the members<br>
> + below exist */<br>
> + const char *cainfo; /* the built-in default CURLOPT_CAINFO, might<br>
> + be NULL */<br>
> + const char *capath; /* the built-in default CURLOPT_CAPATH, might<br>
> + be NULL */<br>
> + };<br>
> +<br>
> + struct curl_version_info_data *curl_version_info(int age);<br>
> +]])<br>
> +<br>
> +local info = ffi.C.curl_version_info(7)<br>
<br>
2. Why '7'?<br>
<br>
> +local test = tap.test('curl-features')<br>
> +test:plan(3)<br>
> +<br>
</blockquote></div></div>