summaryrefslogtreecommitdiffstats
path: root/testsuites
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2013-01-28 10:23:28 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2013-01-28 16:46:02 +0100
commitb63c8f9b50c45d33e12a3776cbf03e498b2a6b99 (patch)
treeabceaf58bc24e12ea3d1996cb7a52e0c1e22595a /testsuites
parentbsp/mpc55xx: Add BSP_DATA_CACHE_USE_WRITE_THROUGH (diff)
downloadrtems-b63c8f9b50c45d33e12a3776cbf03e498b2a6b99.tar.bz2
ftpfs: Fix SIZE command handling
It is invalid to issue a SIZE command once a data transfer is in progress. For reads we issue the SIZE command before the RETR command and get a snapshot of the file size. For writes the file size is initialized to zero and incremented for each write chunk.
Diffstat (limited to 'testsuites')
-rw-r--r--testsuites/libtests/ftp01/ftp01.scn4
-rw-r--r--testsuites/libtests/ftp01/init.c26
2 files changed, 26 insertions, 4 deletions
diff --git a/testsuites/libtests/ftp01/ftp01.scn b/testsuites/libtests/ftp01/ftp01.scn
index a3292961c8..a27da4b698 100644
--- a/testsuites/libtests/ftp01/ftp01.scn
+++ b/testsuites/libtests/ftp01/ftp01.scn
@@ -17,6 +17,8 @@ USER anonymous
230 User logged in.
TYPE I
200 Type set to I.
+SIZE a.txt
+213 1102
PASV
227 Entering passive mode (127,0,0,1,4,4).
RETR a.txt
@@ -41,6 +43,8 @@ USER anonymous
230 User logged in.
TYPE I
200 Type set to I.
+SIZE b.txt
+213 1102
PASV
227 Entering passive mode (127,0,0,1,4,10).
RETR b.txt
diff --git a/testsuites/libtests/ftp01/init.c b/testsuites/libtests/ftp01/init.c
index 354c0f045a..369aebe92a 100644
--- a/testsuites/libtests/ftp01/init.c
+++ b/testsuites/libtests/ftp01/init.c
@@ -104,7 +104,7 @@ static void change_self_priority(void)
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
}
-static void create_file(const char *path)
+static void create_file(const char *path, const void *begin, size_t size)
{
int rv = 0;
int fd = open(path, O_WRONLY);
@@ -112,8 +112,8 @@ static void create_file(const char *path)
rtems_test_assert(fd >= 0);
- n = write(fd, &content [0], sizeof(content));
- rtems_test_assert(n == (ssize_t) sizeof(content));
+ n = write(fd, begin, size);
+ rtems_test_assert(n == (ssize_t) size);
rv = close(fd);
rtems_test_assert(rv == 0);
@@ -126,15 +126,33 @@ static void copy_file(const char *src_path, const char *dest_path)
int out = open(dest_path, O_WRONLY);
ssize_t n_in = 0;
char buf [64];
+ struct stat st_in;
+ struct stat st_out;
+
+ memset(&st_in, 0xff, sizeof(st_in));
+ memset(&st_out, 0xff, sizeof(st_out));
rtems_test_assert(in >= 0);
rtems_test_assert(out >= 0);
+ rv = fstat(out, &st_out);
+ rtems_test_assert(rv == 0);
+
+ rtems_test_assert(st_out.st_size == 0);
+
while ((n_in = read(in, buf, sizeof(buf))) > 0) {
ssize_t n_out = write(out, buf, (size_t) n_in);
rtems_test_assert(n_out == n_in);
}
+ rv = fstat(out, &st_out);
+ rtems_test_assert(rv == 0);
+
+ rv = fstat(in, &st_in);
+ rtems_test_assert(rv == 0);
+
+ rtems_test_assert(st_in.st_size == st_out.st_size);
+
rv = close(out);
rtems_test_assert(rv == 0);
@@ -189,7 +207,7 @@ static void test(void)
initialize_ftpfs();
change_self_priority();
- create_file(file_a);
+ create_file(file_a, &content [0], sizeof(content));
copy_file(file_a, file_b);
check_file(file_b);
check_file_size(file_a, sizeof(content));