mirror of
https://github.com/curl/curl.git
synced 2026-08-25 18:43:41 +03:00
lib: rename curlx_timediff to curlx_timeleft_ms
Rename `Curl_timeleft()` to `Curl_timeleft_ms()` to make the units in the returned `timediff_t` clear. (We used to always have ms there, but with QUIC started to sometimes calc ns as well). Rename some assigned vars without `_ms` suffix for clarity as well. Closes #19486
This commit is contained in:
parent
ca27404d27
commit
78a610cb83
53 changed files with 187 additions and 188 deletions
|
|
@ -2,7 +2,7 @@
|
|||
<info>
|
||||
<keywords>
|
||||
unittest
|
||||
Curl_timeleft
|
||||
Curl_timeleft_ms
|
||||
</keywords>
|
||||
</info>
|
||||
|
||||
|
|
@ -13,7 +13,7 @@ Curl_timeleft
|
|||
unittest
|
||||
</features>
|
||||
<name>
|
||||
Curl_timeleft unit tests
|
||||
Curl_timeleft_ms unit tests
|
||||
</name>
|
||||
</client>
|
||||
</testcase>
|
||||
|
|
|
|||
|
|
@ -461,7 +461,7 @@ void ws_close(CURL *curl);
|
|||
#define TEST_HANG_TIMEOUT 60 * 1000 /* global default */
|
||||
|
||||
#define exe_test_timedout(T,Y,Z) do { \
|
||||
timediff_t timediff = curlx_timediff(curlx_now(), tv_test_start); \
|
||||
timediff_t timediff = curlx_timediff_ms(curlx_now(), tv_test_start); \
|
||||
if(timediff > (T)) { \
|
||||
curl_mfprintf(stderr, "%s:%d ABORTING TEST, since it seems " \
|
||||
"that it would have run forever (%ld ms > %ld ms)\n", \
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ static CURLcode test_lib1501(const char *URL)
|
|||
abort_on_test_timeout_custom(HANG_TIMEOUT);
|
||||
|
||||
after = curlx_now();
|
||||
e = curlx_timediff(after, before);
|
||||
e = curlx_timediff_ms(after, before);
|
||||
curl_mfprintf(stderr, "pong = %ld\n", (long)e);
|
||||
|
||||
if(e > MAX_BLOCKED_TIME_MS) {
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ static CURLcode test_lib1507(const char *URL)
|
|||
|
||||
rc = select(maxfd + 1, &fdread, &fdwrite, &fdexcep, &timeout);
|
||||
|
||||
if(curlx_timediff(curlx_now(), mp_start) > MULTI_PERFORM_HANG_TIMEOUT) {
|
||||
if(curlx_timediff_ms(curlx_now(), mp_start) > MULTI_PERFORM_HANG_TIMEOUT) {
|
||||
curl_mfprintf(stderr, "ABORTING TEST, since it seems "
|
||||
"that it would have run forever.\n");
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ static CURLcode test_lib1564(const char *URL)
|
|||
multi_poll(multi, NULL, 0, 1000, &numfds);
|
||||
time_after_wait = curlx_now();
|
||||
|
||||
if(curlx_timediff(time_after_wait, time_before_wait) < 500) {
|
||||
if(curlx_timediff_ms(time_after_wait, time_before_wait) < 500) {
|
||||
curl_mfprintf(stderr, "%s:%d curl_multi_poll returned too early\n",
|
||||
__FILE__, __LINE__);
|
||||
res = TEST_ERR_MAJOR_BAD;
|
||||
|
|
@ -66,7 +66,7 @@ static CURLcode test_lib1564(const char *URL)
|
|||
multi_poll(multi, NULL, 0, 1000, &numfds);
|
||||
time_after_wait = curlx_now();
|
||||
|
||||
if(curlx_timediff(time_after_wait, time_before_wait) > 500) {
|
||||
if(curlx_timediff_ms(time_after_wait, time_before_wait) > 500) {
|
||||
curl_mfprintf(stderr, "%s:%d curl_multi_poll returned too late\n",
|
||||
__FILE__, __LINE__);
|
||||
res = TEST_ERR_MAJOR_BAD;
|
||||
|
|
@ -81,7 +81,7 @@ static CURLcode test_lib1564(const char *URL)
|
|||
multi_poll(multi, NULL, 0, 1000, &numfds);
|
||||
time_after_wait = curlx_now();
|
||||
|
||||
if(curlx_timediff(time_after_wait, time_before_wait) < 500) {
|
||||
if(curlx_timediff_ms(time_after_wait, time_before_wait) < 500) {
|
||||
curl_mfprintf(stderr, "%s:%d curl_multi_poll returned too early\n",
|
||||
__FILE__, __LINE__);
|
||||
res = TEST_ERR_MAJOR_BAD;
|
||||
|
|
@ -99,7 +99,7 @@ static CURLcode test_lib1564(const char *URL)
|
|||
multi_poll(multi, NULL, 0, 1000, &numfds);
|
||||
time_after_wait = curlx_now();
|
||||
|
||||
if(curlx_timediff(time_after_wait, time_before_wait) > 500) {
|
||||
if(curlx_timediff_ms(time_after_wait, time_before_wait) > 500) {
|
||||
curl_mfprintf(stderr, "%s:%d curl_multi_poll returned too late\n",
|
||||
__FILE__, __LINE__);
|
||||
res = TEST_ERR_MAJOR_BAD;
|
||||
|
|
@ -114,7 +114,7 @@ static CURLcode test_lib1564(const char *URL)
|
|||
multi_poll(multi, NULL, 0, 1000, &numfds);
|
||||
time_after_wait = curlx_now();
|
||||
|
||||
if(curlx_timediff(time_after_wait, time_before_wait) < 500) {
|
||||
if(curlx_timediff_ms(time_after_wait, time_before_wait) < 500) {
|
||||
curl_mfprintf(stderr, "%s:%d curl_multi_poll returned too early\n",
|
||||
__FILE__, __LINE__);
|
||||
res = TEST_ERR_MAJOR_BAD;
|
||||
|
|
|
|||
|
|
@ -148,7 +148,7 @@ static CURLcode test_unit1303(const char *arg)
|
|||
timediff_t timeout;
|
||||
NOW(run[i].now_s, run[i].now_us);
|
||||
TIMEOUTS(run[i].timeout_ms, run[i].connecttimeout_ms);
|
||||
timeout = Curl_timeleft(easy, &now, run[i].connecting);
|
||||
timeout = Curl_timeleft_ms(easy, &now, run[i].connecting);
|
||||
if(timeout != run[i].result)
|
||||
fail(run[i].comment);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ static CURLcode test_unit1323(const char *arg)
|
|||
size_t i;
|
||||
|
||||
for(i = 0; i < CURL_ARRAYSIZE(tests); i++) {
|
||||
timediff_t result = curlx_timediff(tests[i].first, tests[i].second);
|
||||
timediff_t result = curlx_timediff_ms(tests[i].first, tests[i].second);
|
||||
if(result != tests[i].result) {
|
||||
curl_mprintf("%ld.%06u to %ld.%06u got %" FMT_TIMEDIFF_T
|
||||
", but expected %" FMT_TIMEDIFF_T "\n",
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ static void cf_test_destroy(struct Curl_cfilter *cf, struct Curl_easy *data)
|
|||
struct cf_test_ctx *ctx = cf->ctx;
|
||||
#ifndef CURL_DISABLE_VERBOSE_STRINGS
|
||||
infof(data, "%04dms: cf[%s] destroyed",
|
||||
(int)curlx_timediff(curlx_now(), current_tr->started), ctx->id);
|
||||
(int)curlx_timediff_ms(curlx_now(), current_tr->started), ctx->id);
|
||||
#else
|
||||
(void)data;
|
||||
#endif
|
||||
|
|
@ -139,7 +139,7 @@ static CURLcode cf_test_connect(struct Curl_cfilter *cf,
|
|||
|
||||
(void)data;
|
||||
*done = FALSE;
|
||||
duration_ms = curlx_timediff(curlx_now(), ctx->started);
|
||||
duration_ms = curlx_timediff_ms(curlx_now(), ctx->started);
|
||||
if(duration_ms >= ctx->fail_delay_ms) {
|
||||
infof(data, "%04dms: cf[%s] fail delay reached",
|
||||
(int)duration_ms, ctx->id);
|
||||
|
|
@ -218,7 +218,7 @@ static CURLcode cf_test_create(struct Curl_cfilter **pcf,
|
|||
ctx->stats->creations++;
|
||||
}
|
||||
|
||||
created_at = curlx_timediff(ctx->started, current_tr->started);
|
||||
created_at = curlx_timediff_ms(ctx->started, current_tr->started);
|
||||
if(ctx->stats->creations == 1)
|
||||
ctx->stats->first_created = created_at;
|
||||
ctx->stats->last_created = created_at;
|
||||
|
|
@ -245,7 +245,7 @@ static void check_result(const struct test_case *tc,
|
|||
char msg[256];
|
||||
timediff_t duration_ms;
|
||||
|
||||
duration_ms = curlx_timediff(tr->ended, tr->started);
|
||||
duration_ms = curlx_timediff_ms(tr->ended, tr->started);
|
||||
curl_mfprintf(stderr, "%d: test case took %dms\n", tc->id, (int)duration_ms);
|
||||
|
||||
if(tr->result != tc->exp_result
|
||||
|
|
@ -267,7 +267,7 @@ static void check_result(const struct test_case *tc,
|
|||
fail(msg);
|
||||
}
|
||||
|
||||
duration_ms = curlx_timediff(tr->ended, tr->started);
|
||||
duration_ms = curlx_timediff_ms(tr->ended, tr->started);
|
||||
if(duration_ms < tc->min_duration_ms) {
|
||||
curl_msprintf(msg, "%d: expected min duration of %dms, but took %dms",
|
||||
tc->id, (int)tc->min_duration_ms, (int)duration_ms);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue