On Fri, 2 Dec 2011, Gokhan Sengun wrote:

in function ftp_state_use_port(), direct call to socket() is used. However upon closing the socket fclosesocket function is used. It looks to me (if not missing something), it should check whether fopensocket is set and call this function if happens to be so.

Here's my two new test cases to verify that open/close socket callback are paired up properly - test 596 currently fails due to this mentioned bug. I'm slowly working on a fix.

--

 / daniel.haxx.se
From 5971d401d4fd184aedd3b439251a898ecdacb96e Mon Sep 17 00:00:00 2001
From: Daniel Stenberg <[email protected]>
Date: Sun, 4 Dec 2011 23:10:12 +0100
Subject: [PATCH] test: verify the opensocket callback for FTP

test 595: for passive FTP
test 596: for active FTP
---
 tests/data/Makefile.am |    2 +-
 tests/data/test595     |   57 ++++++++++++++++++++++++++++++++++++++++++++++++
 tests/data/test596     |   57 ++++++++++++++++++++++++++++++++++++++++++++++++
 tests/libtest/lib500.c |    3 ++
 4 files changed, 118 insertions(+), 1 deletions(-)
 create mode 100644 tests/data/test595
 create mode 100644 tests/data/test596

diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am
index 75b3781..23e2a7d 100644
--- a/tests/data/Makefile.am
+++ b/tests/data/Makefile.am
@@ -48,7 +48,7 @@ test551 test552 test553 test554 test555 test556 test557 test560 test561	\
 test562 test563 test564 test565 test566 test567 test568 test569 test570	\
 test571 test572 test573 test574 test575 test576 test578 test579 test580	\
 test581 test582 test583 test584 test585 test586 test587 test588 test590 \
-test591 test592 test593 test594 \
+test591 test592 test593 test594 test595 test596 \
 test600 test601 test602 test603 test604	\
 test605 test606 test607 test608 test609 test610 test611 test612 test613	\
 test614 test615 test616 test617 test618 test619 test620 test621 test622	\
diff --git a/tests/data/test595 b/tests/data/test595
new file mode 100644
index 0000000..28ff9c1
--- /dev/null
+++ b/tests/data/test595
@@ -0,0 +1,57 @@
+#
+# This test is like 585 but uses passive FTP instead of HTTP
+#
+<testcase>
+<info>
+<keywords>
+FTP
+</keywords>
+</info>
+#
+# Server-side
+<reply>
+<data>
+moo
+</data>
+<datacheck>
+[OPEN] counter: 1
+[OPEN] counter: 2
+moo
+[CLOSE] counter: 2
+[CLOSE] counter: 1
+</datacheck>
+</reply>
+
+# Client-side
+<client>
+<server>
+ftp
+</server>
+# tool is what to use instead of 'curl'
+<tool>
+lib585
+</tool>
+
+ <name>
+verify close callbacks with passive FTP
+ </name>
+ <command>
+ftp://%HOSTIP:%FTPPORT/595 log/ip595
+</command>
+</client>
+
+#
+# Verify data after the test has been "shot"
+<verify>
+<protocol>
+USER anonymous

+PASS [email protected]

+PWD

+EPSV

+TYPE I

+SIZE 595

+RETR 595

+QUIT

+</protocol>
+</verify>
+</testcase>
diff --git a/tests/data/test596 b/tests/data/test596
new file mode 100644
index 0000000..9703f04
--- /dev/null
+++ b/tests/data/test596
@@ -0,0 +1,57 @@
+#
+# This test is like 585 but uses active FTP instead of HTTP
+#
+<testcase>
+<info>
+<keywords>
+FTP
+</keywords>
+</info>
+#
+# Server-side
+<reply>
+<data>
+moo
+</data>
+<datacheck>
+[OPEN] counter: 1
+[OPEN] counter: 2
+moo
+[CLOSE] counter: 2
+[CLOSE] counter: 1
+</datacheck>
+</reply>
+
+# Client-side
+<client>
+<server>
+ftp
+</server>
+# tool is what to use instead of 'curl'
+<tool>
+lib585
+</tool>
+
+ <name>
+verify close callbacks with active FTP
+ </name>
+ <command>
+ftp://%HOSTIP:%FTPPORT/596 log/ip596 activeftp
+</command>
+</client>
+
+#
+# Verify data after the test has been "shot"
+<verify>
+<protocol>
+USER anonymous

+PASS [email protected]

+PWD

+EPSV

+TYPE I

+SIZE 596

+RETR 596

+QUIT

+</protocol>
+</verify>
+</testcase>
diff --git a/tests/libtest/lib500.c b/tests/libtest/lib500.c
index 51680fc..812fb0d 100644
--- a/tests/libtest/lib500.c
+++ b/tests/libtest/lib500.c
@@ -76,6 +76,9 @@ int test(char *URL)
   test_setopt(curl, CURLOPT_URL, URL);
   test_setopt(curl, CURLOPT_HEADER, 1L);
 
+  if(libtest_arg3 && !strcmp(libtest_arg3, "activeftp"))
+    test_setopt(curl, CURLOPT_FTPPORT, "-");
+
   setupcallbacks(curl);
 
   res = curl_easy_perform(curl);
-- 
1.7.7.3

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html

Reply via email to