aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeny Grin (Karlson2k) <k2k@narod.ru>2019-06-17 14:49:18 +0300
committerEvgeny Grin (Karlson2k) <k2k@narod.ru>2019-06-17 15:01:46 +0300
commit4bc166ee2fc716f68e120fce514bd69a26146f28 (patch)
tree4535bc64584229681bf490cf3ea17b106f6a6d70
parent3cb0b6cf17e2cc6cd62133a0beffa998b1e53c23 (diff)
downloadlibmicrohttpd-4bc166ee2fc716f68e120fce514bd69a26146f28.tar.gz
libmicrohttpd-4bc166ee2fc716f68e120fce514bd69a26146f28.zip
test_long_header: use power of two for size to properly test allocations,
test various buffer sizes
-rw-r--r--src/testcurl/test_long_header.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/testcurl/test_long_header.c b/src/testcurl/test_long_header.c
index 80842622..dc76a136 100644
--- a/src/testcurl/test_long_header.c
+++ b/src/testcurl/test_long_header.c
@@ -42,7 +42,7 @@
42 * half of this value, so the actual value does not have 42 * half of this value, so the actual value does not have
43 * to be big at all... 43 * to be big at all...
44 */ 44 */
45#define VERY_LONG (1024*10) 45#define VERY_LONG (1024*8)
46 46
47static int oneone; 47static int oneone;
48 48
@@ -94,7 +94,7 @@ ahc_echo (void *cls,
94 94
95 95
96static int 96static int
97testLongUrlGet () 97testLongUrlGet (size_t buff_size)
98{ 98{
99 struct MHD_Daemon *d; 99 struct MHD_Daemon *d;
100 CURL *c; 100 CURL *c;
@@ -108,7 +108,7 @@ testLongUrlGet ()
108 port = 0; 108 port = 0;
109 else 109 else
110 { 110 {
111 port = 1330; 111 port = 1330 + buff_size % 20;
112 if (oneone) 112 if (oneone)
113 port += 5; 113 port += 5;
114 } 114 }
@@ -122,7 +122,7 @@ testLongUrlGet ()
122 &ahc_echo, 122 &ahc_echo,
123 "GET", 123 "GET",
124 MHD_OPTION_CONNECTION_MEMORY_LIMIT, 124 MHD_OPTION_CONNECTION_MEMORY_LIMIT,
125 (size_t) (VERY_LONG / 2), MHD_OPTION_END); 125 (size_t) buff_size, MHD_OPTION_END);
126 if (d == NULL) 126 if (d == NULL)
127 return 1; 127 return 1;
128 if (0 == port) 128 if (0 == port)
@@ -182,7 +182,7 @@ testLongUrlGet ()
182 182
183 183
184static int 184static int
185testLongHeaderGet () 185testLongHeaderGet (size_t buff_size)
186{ 186{
187 struct MHD_Daemon *d; 187 struct MHD_Daemon *d;
188 CURL *c; 188 CURL *c;
@@ -197,7 +197,7 @@ testLongHeaderGet ()
197 port = 0; 197 port = 0;
198 else 198 else
199 { 199 {
200 port = 1331; 200 port = 1331 + buff_size % 20;
201 if (oneone) 201 if (oneone)
202 port += 5; 202 port += 5;
203 } 203 }
@@ -212,7 +212,7 @@ testLongHeaderGet ()
212 &ahc_echo, 212 &ahc_echo,
213 "GET", 213 "GET",
214 MHD_OPTION_CONNECTION_MEMORY_LIMIT, 214 MHD_OPTION_CONNECTION_MEMORY_LIMIT,
215 (size_t) (VERY_LONG / 2), MHD_OPTION_END); 215 (size_t) buff_size, MHD_OPTION_END);
216 if (d == NULL) 216 if (d == NULL)
217 return 16; 217 return 16;
218 if (0 == port) 218 if (0 == port)
@@ -288,8 +288,10 @@ main (int argc, char *const *argv)
288 oneone = has_in_name (argv[0], "11"); 288 oneone = has_in_name (argv[0], "11");
289 if (0 != curl_global_init (CURL_GLOBAL_WIN32)) 289 if (0 != curl_global_init (CURL_GLOBAL_WIN32))
290 return 2; 290 return 2;
291 errorCount += testLongUrlGet (); 291 errorCount += testLongUrlGet (VERY_LONG / 2);
292 errorCount += testLongHeaderGet (); 292 errorCount += testLongUrlGet (VERY_LONG / 2 + 978);
293 errorCount += testLongHeaderGet (VERY_LONG / 2);
294 errorCount += testLongHeaderGet (VERY_LONG / 2 + 1893);
293 if (errorCount != 0) 295 if (errorCount != 0)
294 fprintf (stderr, "Error (code: %u)\n", errorCount); 296 fprintf (stderr, "Error (code: %u)\n", errorCount);
295 curl_global_cleanup (); 297 curl_global_cleanup ();