[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libmicrohttpd] branch master updated: test_timeout: improved: added mor
From: |
gnunet |
Subject: |
[libmicrohttpd] branch master updated: test_timeout: improved: added more error detection and reporting |
Date: |
Sun, 29 Aug 2021 17:05:23 +0200 |
This is an automated email from the git hooks/post-receive script.
karlson2k pushed a commit to branch master
in repository libmicrohttpd.
The following commit(s) were added to refs/heads/master by this push:
new c9d390f4 test_timeout: improved: added more error detection and
reporting
c9d390f4 is described below
commit c9d390f42df8f8311cac0a254c7819d93e3a7334
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
AuthorDate: Sun Aug 29 18:01:32 2021 +0300
test_timeout: improved: added more error detection and reporting
---
src/testcurl/test_timeout.c | 57 +++++++++++++++++++++++++++++++++++----------
1 file changed, 45 insertions(+), 12 deletions(-)
diff --git a/src/testcurl/test_timeout.c b/src/testcurl/test_timeout.c
index 73a4e60f..957fb2cc 100644
--- a/src/testcurl/test_timeout.c
+++ b/src/testcurl/test_timeout.c
@@ -41,9 +41,9 @@
static int oneone;
-static int withTimeout = 1;
+static int withTimeout = 0;
-static int withoutTimeout = 1;
+static int withoutTimeout = 0;
struct CBC
{
@@ -67,21 +67,40 @@ termination_cb (void *cls,
case MHD_REQUEST_TERMINATED_COMPLETED_OK:
if (test == &withoutTimeout)
{
- withoutTimeout = 0;
+ withoutTimeout = 1;
+ }
+ else
+ {
+ fprintf (stderr, "Connection completed without errors while "
+ "timeout is expected.\n");
}
break;
case MHD_REQUEST_TERMINATED_WITH_ERROR:
+ fprintf (stderr, "Connection terminated with error.\n");
+ exit (4);
+ break;
case MHD_REQUEST_TERMINATED_READ_ERROR:
+ fprintf (stderr, "Connection terminated with read error.\n");
+ exit (4);
break;
case MHD_REQUEST_TERMINATED_TIMEOUT_REACHED:
if (test == &withTimeout)
{
- withTimeout = 0;
+ withTimeout = 1;
+ }
+ else
+ {
+ fprintf (stderr, "Connection terminated with timeout while expected "
+ "to be successfully completed.\n");
}
break;
case MHD_REQUEST_TERMINATED_DAEMON_SHUTDOWN:
+ fprintf (stderr, "Connection terminated by daemon shutdown.\n");
+ exit (4);
break;
case MHD_REQUEST_TERMINATED_CLIENT_ABORT:
+ fprintf (stderr, "Connection terminated by client.\n");
+ exit (4);
break;
}
}
@@ -193,7 +212,7 @@ testWithoutTimeout ()
NULL, NULL, &ahc_echo, &done_flag,
MHD_OPTION_CONNECTION_TIMEOUT, 2,
MHD_OPTION_NOTIFY_COMPLETED, &termination_cb,
- &withTimeout,
+ &withoutTimeout,
MHD_OPTION_END);
if (d == NULL)
return 1;
@@ -227,6 +246,7 @@ testWithoutTimeout ()
* setting NOSIGNAL results in really weird
* crashes on my system! */
curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L);
+ withoutTimeout = 0;
if (CURLE_OK != (errornum = curl_easy_perform (c)))
{
fprintf (stderr, "curl_easy_perform failed: '%s'\n",
@@ -237,6 +257,11 @@ testWithoutTimeout ()
}
curl_easy_cleanup (c);
MHD_stop_daemon (d);
+ if (0 == withoutTimeout)
+ {
+ fprintf (stderr, "Request wasn't processed successfully.\n");
+ return 2;
+ }
if (cbc.pos != strlen ("/hello_world"))
return 4;
if (0 != strncmp ("/hello_world", cbc.buf, strlen ("/hello_world")))
@@ -273,7 +298,7 @@ testWithTimeout ()
NULL, NULL, &ahc_echo, &done_flag,
MHD_OPTION_CONNECTION_TIMEOUT, 2,
MHD_OPTION_NOTIFY_COMPLETED, &termination_cb,
- &withoutTimeout,
+ &withTimeout,
MHD_OPTION_END);
if (d == NULL)
return 16;
@@ -307,13 +332,24 @@ testWithTimeout ()
* setting NOSIGNAL results in really weird
* crashes on my system! */
curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L);
+ withTimeout = 0;
if (CURLE_OK != (errornum = curl_easy_perform (c)))
{
curl_easy_cleanup (c);
MHD_stop_daemon (d);
if (errornum == CURLE_GOT_NOTHING)
- /* mhd had the timeout */
- return 0;
+ {
+ if (0 != withTimeout)
+ {
+ /* mhd had the timeout */
+ return 0;
+ }
+ else
+ {
+ fprintf (stderr, "Timeout wasn't detected.\n");
+ return 8;
+ }
+ }
else
/* curl had the timeout first */
return 32;
@@ -342,8 +378,5 @@ main (int argc, char *const *argv)
"Error during test execution (code: %u)\n",
errorCount);
curl_global_cleanup ();
- if ((withTimeout == 0) && (withoutTimeout == 0))
- return 0;
- else
- return errorCount; /* 0 == pass */
+ return errorCount; /* 0 == pass */
}
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [libmicrohttpd] branch master updated: test_timeout: improved: added more error detection and reporting,
gnunet <=