]> granicus.if.org Git - curl/commitdiff
test583: verify early SSH multi remove handle
authorDaniel Stenberg <daniel@haxx.se>
Sat, 12 Mar 2011 23:18:04 +0000 (00:18 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Sat, 12 Mar 2011 23:18:04 +0000 (00:18 +0100)
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.

tests/data/Makefile.am
tests/data/test583 [new file with mode: 0644]
tests/libtest/Makefile.inc
tests/libtest/lib583.c [new file with mode: 0644]

index 3a76a288d801664836cd9e52750eb393eaf1d934..c3c68cae3a64d45d66eb148525e43456a509670d 100644 (file)
@@ -70,7 +70,7 @@ EXTRA_DIST = test1 test108 test117 test127 test20 test27 test34 test46           \
  test313 test1115 test578 test579 test1116 test1200 test1201 test1202     \
  test1203 test1117 test1118 test1119 test1120 test1300 test1301 test1302 \
  test1303 test320 test321 test322 test323 test324 test1121 test581 test580 \
- test1304 test1305 test1306 test1307 test582
+ test1304 test1305 test1306 test1307 test582 test583
 
 filecheck:
        @mkdir test-place; \
diff --git a/tests/data/test583 b/tests/data/test583
new file mode 100644 (file)
index 0000000..2129ee7
--- /dev/null
@@ -0,0 +1,43 @@
+<testcase>
+<info>
+<keywords>
+SFTP
+multi
+</keywords>
+</info>
+
+# Server-side
+<reply>
+<data>
+</data>
+</reply>
+
+# Client-side
+<client>
+<server>
+sftp
+</server>
+<tool>
+lib583
+</tool>
+ <name>
+SFTP with multi interface, remove handle early
+ </name>
+
+# The command here uses 'localhost' just to make sure that curl_multi_perform
+# won't reach too far in the first invoke. When using c-ares at least, the
+# name resolve will cause it to return rather quickly and thus we could trigger
+# the problem we're looking to verify.
+ <command>
+sftp://localhost:%SSHPORT%PWD/log/upload583.txt %USER:
+</command>
+</client>
+
+# Verify data after the test has been "shot"
+<verify>
+<strip>
+</strip>
+<protocol>
+</protocol>
+</verify>
+</testcase>
index c68f5af525fbfc2edef2e12717687ad1a422bb7f..a210cbfe310bbdb9de4438fe672b0562debba416 100644 (file)
@@ -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 (file)
index 0000000..d01d98f
--- /dev/null
@@ -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;
+}