libmicrohttpd

HTTP/1.x server C library (MHD 1.x, stable)
Log | Files | Refs | Submodules | README | LICENSE

commit 4bc166ee2fc716f68e120fce514bd69a26146f28
parent 3cb0b6cf17e2cc6cd62133a0beffa998b1e53c23
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date:   Mon, 17 Jun 2019 14:49:18 +0300

test_long_header: use power of two for size to properly test allocations,
test various buffer sizes

Diffstat:
Msrc/testcurl/test_long_header.c | 20+++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/src/testcurl/test_long_header.c b/src/testcurl/test_long_header.c @@ -42,7 +42,7 @@ * half of this value, so the actual value does not have * to be big at all... */ -#define VERY_LONG (1024*10) +#define VERY_LONG (1024*8) static int oneone; @@ -94,7 +94,7 @@ ahc_echo (void *cls, static int -testLongUrlGet () +testLongUrlGet (size_t buff_size) { struct MHD_Daemon *d; CURL *c; @@ -108,7 +108,7 @@ testLongUrlGet () port = 0; else { - port = 1330; + port = 1330 + buff_size % 20; if (oneone) port += 5; } @@ -122,7 +122,7 @@ testLongUrlGet () &ahc_echo, "GET", MHD_OPTION_CONNECTION_MEMORY_LIMIT, - (size_t) (VERY_LONG / 2), MHD_OPTION_END); + (size_t) buff_size, MHD_OPTION_END); if (d == NULL) return 1; if (0 == port) @@ -182,7 +182,7 @@ testLongUrlGet () static int -testLongHeaderGet () +testLongHeaderGet (size_t buff_size) { struct MHD_Daemon *d; CURL *c; @@ -197,7 +197,7 @@ testLongHeaderGet () port = 0; else { - port = 1331; + port = 1331 + buff_size % 20; if (oneone) port += 5; } @@ -212,7 +212,7 @@ testLongHeaderGet () &ahc_echo, "GET", MHD_OPTION_CONNECTION_MEMORY_LIMIT, - (size_t) (VERY_LONG / 2), MHD_OPTION_END); + (size_t) buff_size, MHD_OPTION_END); if (d == NULL) return 16; if (0 == port) @@ -288,8 +288,10 @@ main (int argc, char *const *argv) oneone = has_in_name (argv[0], "11"); if (0 != curl_global_init (CURL_GLOBAL_WIN32)) return 2; - errorCount += testLongUrlGet (); - errorCount += testLongHeaderGet (); + errorCount += testLongUrlGet (VERY_LONG / 2); + errorCount += testLongUrlGet (VERY_LONG / 2 + 978); + errorCount += testLongHeaderGet (VERY_LONG / 2); + errorCount += testLongHeaderGet (VERY_LONG / 2 + 1893); if (errorCount != 0) fprintf (stderr, "Error (code: %u)\n", errorCount); curl_global_cleanup ();