aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEvgeny Grin (Karlson2k) <k2k@narod.ru>2017-01-22 21:16:11 +0300
committerEvgeny Grin (Karlson2k) <k2k@narod.ru>2017-01-23 00:10:02 +0300
commitc58fcc7391d0b6d1b493272d963c631d4f704c48 (patch)
tree9a1f8f4d03598c47162c643061be579f2752339f /src
parentf3010a183ca3c90262a692af0ef8bde512f005ce (diff)
downloadlibmicrohttpd-c58fcc7391d0b6d1b493272d963c631d4f704c48.tar.gz
libmicrohttpd-c58fcc7391d0b6d1b493272d963c631d4f704c48.zip
test_large_put: initialise test buffer with varied data to detect more errors.
Diffstat (limited to 'src')
-rw-r--r--src/testcurl/test_large_put.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/src/testcurl/test_large_put.c b/src/testcurl/test_large_put.c
index d916b053..b650e0b9 100644
--- a/src/testcurl/test_large_put.c
+++ b/src/testcurl/test_large_put.c
@@ -59,6 +59,31 @@ struct CBC
59 size_t size; 59 size_t size;
60}; 60};
61 61
62char*
63alloc_init(size_t buf_size)
64{
65 static const char template[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz";
66 static const size_t templ_size = sizeof(template) / sizeof(char) - 1;
67 char *buf;
68 char *fill_ptr;
69 size_t to_fill;
70
71 buf = malloc(buf_size);
72 if (NULL == buf)
73 return NULL;
74
75 fill_ptr = buf;
76 to_fill = buf_size;
77 while (to_fill > 0)
78 {
79 const size_t to_copy = to_fill > templ_size ? templ_size : to_fill;
80 memcpy (fill_ptr, template, to_copy);
81 fill_ptr += to_copy;
82 to_fill -= to_copy;
83 }
84 return buf;
85}
86
62static size_t 87static size_t
63putBuffer (void *stream, size_t size, size_t nmemb, void *ptr) 88putBuffer (void *stream, size_t size, size_t nmemb, void *ptr)
64{ 89{
@@ -482,10 +507,9 @@ main (int argc, char *const *argv)
482 incr_read = has_in_name(argv[0], "_inc"); 507 incr_read = has_in_name(argv[0], "_inc");
483 if (0 != curl_global_init (CURL_GLOBAL_WIN32)) 508 if (0 != curl_global_init (CURL_GLOBAL_WIN32))
484 return 99; 509 return 99;
485 put_buffer = malloc (PUT_SIZE); 510 put_buffer = alloc_init (PUT_SIZE);
486 if (NULL == put_buffer) 511 if (NULL == put_buffer)
487 return 99; 512 return 99;
488 memset (put_buffer, 1, PUT_SIZE);
489 errorCount += testPutInternalThread (); 513 errorCount += testPutInternalThread ();
490 errorCount += testPutThreadPerConn (); 514 errorCount += testPutThreadPerConn ();
491 errorCount += testPutThreadPool (); 515 errorCount += testPutThreadPool ();