diff options
author | Daniel Stenberg <daniel@haxx.se> | 2011-03-13 00:18:04 +0100 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2011-03-13 00:18:04 +0100 |
commit | 0718b7e31ecb429ce3de7a98e725750b518f489a (patch) | |
tree | 672456b2a1b9218c482768e9c07fa079d29b3334 /tests/libtest | |
parent | 60172a0446bbe3f8bf1c7b066a03b7febfc96ceb (diff) |
test583: verify early SSH multi remove handle
This test case is meant to verify that the logic in commit
60172a0446bbe3f8b actually works. This test failed for me before that
change and it works after it.
Diffstat (limited to 'tests/libtest')
-rw-r--r-- | tests/libtest/Makefile.inc | 17 | ||||
-rw-r--r-- | tests/libtest/lib583.c | 73 |
2 files changed, 82 insertions, 8 deletions
diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc index c68f5af52..a210cbfe3 100644 --- a/tests/libtest/Makefile.inc +++ b/tests/libtest/Makefile.inc @@ -5,14 +5,14 @@ TESTUTIL = testutil.c testutil.h SUPPORTFILES = first.c test.h # These are all libcurl test programs -noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 \ - lib507 lib508 lib510 lib511 lib512 lib513 lib514 lib515 lib516 \ - lib517 lib518 lib519 lib520 lib521 lib523 lib524 lib525 lib526 lib527 \ - lib574 lib575 lib576 lib578 lib579 \ - lib529 lib530 lib532 lib533 lib536 lib537 lib540 lib541 lib542 lib543 \ - lib544 lib545 lib547 lib548 lib549 lib552 lib553 lib554 lib555 lib556 \ - lib539 lib557 lib560 lib562 lib564 lib565 lib566 lib567 \ - lib568 lib569 lib570 lib571 lib572 lib573 lib582 chkhostname +noinst_PROGRAMS = chkhostname \ + lib500 lib501 lib502 lib503 lib504 lib505 lib506 lib507 lib508 lib510 \ + lib511 lib512 lib513 lib514 lib515 lib516 lib517 lib518 lib519 lib520 \ + lib521 lib523 lib524 lib525 lib526 lib527 lib574 lib575 lib576 lib578 \ + lib579 lib529 lib530 lib532 lib533 lib536 lib537 lib540 lib541 lib542 \ + lib543 lib544 lib545 lib547 lib548 lib549 lib552 lib553 lib554 lib555 \ + lib556 lib539 lib557 lib560 lib562 lib564 lib565 lib566 lib567 lib568 \ + lib569 lib570 lib571 lib572 lib573 lib582 lib583 chkhostname_SOURCES = chkhostname.c $(top_srcdir)/lib/curl_gethostname.c chkhostname_LDADD = @CURL_NETWORK_LIBS@ @@ -159,3 +159,4 @@ lib579_SOURCES = lib579.c $(SUPPORTFILES) lib582_SOURCES = lib582.c $(SUPPORTFILES) $(TESTUTIL) +lib583_SOURCES = lib583.c $(SUPPORTFILES) diff --git a/tests/libtest/lib583.c b/tests/libtest/lib583.c new file mode 100644 index 000000000..d01d98f1f --- /dev/null +++ b/tests/libtest/lib583.c @@ -0,0 +1,73 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ***************************************************************************/ +/* + * This test case is based on the sample code provided by Saqib Ali + * http://curl.haxx.se/mail/lib-2011-03/0066.html + */ + +#include "test.h" + +#include <unistd.h> +#include <sys/stat.h> + +int test(char *URL) +{ + CURLMcode retVal; + int stillRunning, retValcm; + CURLM* multiHandle; + CURL* curl; + int res; + + curl_global_init(CURL_GLOBAL_ALL); + + multiHandle = curl_multi_init(); + curl = curl_easy_init(); + + 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); + + curl_easy_setopt(curl, CURLOPT_URL, URL); + curl_easy_setopt(curl, CURLOPT_INFILESIZE, (long)5); + + curl_multi_add_handle(multiHandle, curl); + retVal = curl_multi_perform(multiHandle, &stillRunning); + if (retVal != CURLM_OK) + fprintf(stderr, "curl_multi_perform() failed!n"); + + 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"); + else + fprintf(stderr, "curl_multi_remove_handle() failed\n"); + +test_cleanup: + + curl_easy_cleanup(curl); + curl_multi_cleanup(multiHandle); + + return res; +} |