diff packages/net/ftpclient/current/tests/ftpclient1.c @ 1004:c1abcb7d0cf8

* src/ftpclient.c (connect_to_server): Added support for IPv6. This meant changing from using the PORT command to using EPRT, when setting up the data connection. EPRT is protocol independant. * tests/ftpclient1.c (ftp_test): Added tests which use IPv6 addresses. Fixed a few minor bugs with format strings. * doc/ftpclient.sgml: Mention we support IPv6 and DNS.
author asl
date Mon, 12 May 2003 10:02:08 +0000
parents d2c90368aeef
children 74dbf4c3f2e1
line wrap: on
line diff
--- a/packages/net/ftpclient/current/tests/ftpclient1.c
+++ b/packages/net/ftpclient/current/tests/ftpclient1.c
@@ -9,6 +9,7 @@
 // -------------------------------------------
 // This file is part of eCos, the Embedded Configurable Operating System.
 // Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+// Copyright (C) 2003 Andrew Lunn.
 //
 // eCos is free software; you can redistribute it and/or modify it under
 // the terms of the GNU General Public License as published by the Free
@@ -66,7 +67,7 @@ static cyg_handle_t thread_handle;
 #define __xstring(_x) __string(_x)
  
 #define _FTP_SRV           __xstring(172.16.19.254) // farmnet dns0 address
-                                     
+#define _FTP_SRV_V6         __xstring(fec0:0:0:2::1)
 #define FTPBUFSIZE (1024 * 64)
 char ftpbuf[FTPBUFSIZE];
 char ftpbuf1[FTPBUFSIZE];
@@ -80,13 +81,13 @@ ftp_test(cyg_addrword_t p)
   
   init_all_network_interfaces();
  
-  CYG_TEST_INFO("Getting /etc/passwd from %s\n" _FTP_SRV);
+  CYG_TEST_INFO("Getting /etc/passwd from " _FTP_SRV);
   ret = ftp_get(_FTP_SRV,"anonymous","ftpclient1",
                  "/etc/passwd",ftpbuf,FTPBUFSIZE,
                 ftpclient_printf);
 
   if (ret > 0) {
-    diag_printf("PASS:< %s bytes received>\n",ret);
+    diag_printf("PASS:< %d bytes received>\n",ret);
   } else {
     diag_printf("FAIL:< ftp_get returned %d>\n",ret);
   }
@@ -108,13 +109,51 @@ ftp_test(cyg_addrword_t p)
                 ftpclient_printf);
   
   if (ret > 0) {
-    diag_printf("PASS:< %s bytes received>\n",ret);
+    diag_printf("PASS:< %d bytes received>\n",ret);
   } else {
     diag_printf("FAIL:< ftp_get returned %d>\n",ret);
   }
 
   CYG_TEST_PASS_FAIL(!memcmp(ftpbuf,ftpbuf1,ret),"Transfer integrity");
 
+#ifdef CYGPKG_NET_INET6
+  CYG_TEST_INFO("Getting /etc/passwd from " _FTP_SRV_V6);
+  ret = ftp_get(_FTP_SRV_V6,"anonymous","ftpclient1",
+                 "/etc/passwd",ftpbuf,FTPBUFSIZE,
+                ftpclient_printf);
+
+  if (ret > 0) {
+    diag_printf("PASS:< %d bytes received>\n",ret);
+  } else {
+    diag_printf("FAIL:< ftp_get returned %d>\n",ret);
+  }
+
+  CYG_TEST_INFO("Putting passwd file back in /incoming/passwd\n");
+  ret = ftp_put(_FTP_SRV_V6,"anonymous","ftpclient1",
+                "/incoming/passwd",ftpbuf,ret,
+                ftpclient_printf);
+  
+  if (ret > 0) {
+    diag_printf("PASS:\n");
+  } else {
+    diag_printf("FAIL:< ftp_get returned %d>\n",ret);
+  }
+
+  CYG_TEST_INFO("Reading back /incoming/passwd\n");
+  ret = ftp_get(_FTP_SRV_V6,"anonymous","ftpclient1",
+                 "/incoming/passwd",ftpbuf1,FTPBUFSIZE,
+                ftpclient_printf);
+  
+  if (ret > 0) {
+    diag_printf("PASS:< %d bytes received>\n",ret);
+  } else {
+    diag_printf("FAIL:< ftp_get returned %d>\n",ret);
+  }
+
+  CYG_TEST_PASS_FAIL(!memcmp(ftpbuf,ftpbuf1,ret),"Transfer integrity");
+
+#endif
+
   CYG_TEST_INFO("ftp_Get'ing with a bad username\n");
   ret = ftp_get(_FTP_SRV,"nosuchuser","ftpclient1",
                 "/incoming/passwd",ftpbuf1,FTPBUFSIZE,
@@ -140,7 +179,7 @@ ftp_test(cyg_addrword_t p)
   CYG_TEST_PASS_FAIL(ret==FTP_NOSUCHHOST,"Bad server");
 
   CYG_TEST_INFO("ftp_get'ing a file which is too big");
-  ret = ftp_get(_FTP_SRV,"nobody","ftpclient1",
+  ret = ftp_get(_FTP_SRV,"anonymous","ftpclient1",
                 "/incoming/passwd",ftpbuf,2,
                 ftpclient_printf);
   CYG_TEST_PASS_FAIL(ret==FTP_TOOBIG,"File too big");