diff options
author | Yang Tse <yangsita@gmail.com> | 2011-09-06 17:56:39 +0200 |
---|---|---|
committer | Yang Tse <yangsita@gmail.com> | 2011-09-06 17:56:39 +0200 |
commit | f764da8afbda7d2c343b47d091609dc5853ac05a (patch) | |
tree | 7c4ed3a48aaa9af9528c0d7c02a839389c83784e /tests/libtest | |
parent | c8ba8740b9c3e7a5054c2d7ba5689778aa26618b (diff) |
test case 583: ensure that test failures don't go unnoticed
Diffstat (limited to 'tests/libtest')
-rw-r--r-- | tests/libtest/lib583.c | 68 |
1 files changed, 50 insertions, 18 deletions
diff --git a/tests/libtest/lib583.c b/tests/libtest/lib583.c index 57c9365bc..fca22d65b 100644 --- a/tests/libtest/lib583.c +++ b/tests/libtest/lib583.c @@ -34,43 +34,75 @@ int test(char *URL) { - CURLMcode retVal; int stillRunning; CURLM* multiHandle; CURL* curl; + int res1 = 0; int res; - curl_global_init(CURL_GLOBAL_ALL); + if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { + fprintf(stderr, "curl_global_init() failed\n"); + return TEST_ERR_MAJOR_BAD; + } - multiHandle = curl_multi_init(); - curl = curl_easy_init(); + if((multiHandle = curl_multi_init()) == NULL) { + fprintf(stderr, "curl_multi_init() failed\n"); + curl_global_cleanup(); + return TEST_ERR_MAJOR_BAD; + } + + if((curl = curl_easy_init()) == NULL) { + fprintf(stderr, "curl_easy_init() failed\n"); + curl_multi_cleanup(multiHandle); + curl_global_cleanup(); + return TEST_ERR_MAJOR_BAD; + } test_setopt(curl, CURLOPT_USERPWD, libtest_arg2); test_setopt(curl, CURLOPT_SSH_PUBLIC_KEYFILE, "curl_client_key.pub"); test_setopt(curl, CURLOPT_SSH_PRIVATE_KEYFILE, "curl_client_key"); - curl_easy_setopt(curl, CURLOPT_UPLOAD, 1); - curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); + test_setopt(curl, CURLOPT_UPLOAD, 1); + test_setopt(curl, CURLOPT_VERBOSE, 1); + + test_setopt(curl, CURLOPT_URL, URL); + test_setopt(curl, CURLOPT_INFILESIZE, (long)5); - curl_easy_setopt(curl, CURLOPT_URL, URL); - curl_easy_setopt(curl, CURLOPT_INFILESIZE, (long)5); + if((res = (int)curl_multi_add_handle(multiHandle, curl)) != CURLM_OK) { + fprintf(stderr, "curl_multi_add_handle() failed, " + "with code %d\n", res); + curl_easy_cleanup(curl); + curl_multi_cleanup(multiHandle); + curl_global_cleanup(); + return TEST_ERR_MAJOR_BAD; + } - curl_multi_add_handle(multiHandle, curl); - retVal = curl_multi_perform(multiHandle, &stillRunning); - if (retVal != CURLM_OK) - fprintf(stderr, "curl_multi_perform() failed!n"); + /* this tests if removing an easy handle immediately after multi + perform has been called succeeds or not. Logged afterwards */ + + res1 = (int) curl_multi_perform(multiHandle, &stillRunning); + res = (int) curl_multi_remove_handle(multiHandle, curl); - fprintf(stderr, "curl_multi_remove_handle()!\n"); - retVal = curl_multi_remove_handle(multiHandle, curl); - if (retVal == CURLM_OK) - fprintf(stderr, "curl_multi_remove_handle() was successful!\n"); + if(res1) + fprintf(stderr, "curl_multi_perform() failed, " + "with code %d\n", res1); else - fprintf(stderr, "curl_multi_remove_handle() failed\n"); + fprintf(stderr, "curl_multi_perform() succeeded\n"); + + if(res) + fprintf(stderr, "curl_multi_remove_handle() failed, " + "with code %d\n", res); + else + fprintf(stderr, "curl_multi_remove_handle() succeeded\n"); test_cleanup: curl_easy_cleanup(curl); curl_multi_cleanup(multiHandle); + curl_global_cleanup(); - return res; + if(res) + return res; + else + return res1; } |