aboutsummaryrefslogtreecommitdiff
path: root/tests/libtest/lib553.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/libtest/lib553.c')
-rw-r--r--tests/libtest/lib553.c68
1 files changed, 39 insertions, 29 deletions
diff --git a/tests/libtest/lib553.c b/tests/libtest/lib553.c
index 7af9e4e42..c5644a04d 100644
--- a/tests/libtest/lib553.c
+++ b/tests/libtest/lib553.c
@@ -49,42 +49,52 @@ int test(char *URL)
int i;
struct curl_slist *headerlist=NULL, *hl;
- curl_global_init(CURL_GLOBAL_ALL);
- curl = curl_easy_init();
-
- if(curl) {
- for (i = 0; i < NUM_HEADERS; i++) {
- int len = sprintf(buf, "Header%d: ", i);
- memset(&buf[len], 'A', SIZE_HEADERS);
- buf[len + SIZE_HEADERS]=0; /* zero terminate */
- hl = curl_slist_append(headerlist, buf);
- if (!hl)
- goto errout;
- headerlist = hl;
- }
- hl = curl_slist_append(headerlist, "Expect: ");
+ if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
+ fprintf(stderr, "curl_global_init() failed\n");
+ return TEST_ERR_MAJOR_BAD;
+ }
+
+ if((curl = curl_easy_init()) == NULL) {
+ fprintf(stderr, "curl_easy_init() failed\n");
+ curl_global_cleanup();
+ return TEST_ERR_MAJOR_BAD;
+ }
+
+ for (i = 0; i < NUM_HEADERS; i++) {
+ int len = sprintf(buf, "Header%d: ", i);
+ memset(&buf[len], 'A', SIZE_HEADERS);
+ buf[len + SIZE_HEADERS]=0; /* zero terminate */
+ hl = curl_slist_append(headerlist, buf);
if (!hl)
- goto errout;
+ goto test_cleanup;
headerlist = hl;
+ }
- curl_easy_setopt(curl, CURLOPT_URL, URL);
- curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerlist);
- curl_easy_setopt(curl, CURLOPT_POST, 1L);
+ hl = curl_slist_append(headerlist, "Expect: ");
+ if (!hl)
+ goto test_cleanup;
+ headerlist = hl;
+
+ test_setopt(curl, CURLOPT_URL, URL);
+ test_setopt(curl, CURLOPT_HTTPHEADER, headerlist);
+ test_setopt(curl, CURLOPT_POST, 1L);
#ifdef CURL_DOES_CONVERSIONS
- /* Convert the POST data to ASCII */
- curl_easy_setopt(curl, CURLOPT_TRANSFERTEXT, 1L);
+ /* Convert the POST data to ASCII */
+ test_setopt(curl, CURLOPT_TRANSFERTEXT, 1L);
#endif
- curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)POSTLEN);
- curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
- curl_easy_setopt(curl, CURLOPT_HEADER, 1L);
- curl_easy_setopt(curl, CURLOPT_READFUNCTION, myreadfunc);
- res = curl_easy_perform(curl);
+ test_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)POSTLEN);
+ test_setopt(curl, CURLOPT_VERBOSE, 1L);
+ test_setopt(curl, CURLOPT_HEADER, 1L);
+ test_setopt(curl, CURLOPT_READFUNCTION, myreadfunc);
-errout:
- curl_easy_cleanup(curl);
+ res = curl_easy_perform(curl);
+
+test_cleanup:
+
+ curl_easy_cleanup(curl);
+
+ curl_slist_free_all(headerlist);
- curl_slist_free_all(headerlist);
- }
curl_global_cleanup();
return (int)res;