forked from Imagelibrary/rtems
2011-08-02 Xiang Cui <medivhc@gmail.com>
* configure.ac, fserror/test.c, fslink/test.c, fspermission/test.c, fsrdwr/init.c, fssymlink/test.c, fstime/test.c, mdosfs_support/fs_config.h, mdosfs_support/fs_support.c, mimfs_support/fs_support.c, mrfs_support/fs_config.h, support/fstest.h, support/fstest_support.c, support/ramdisk_support.c, support/ramdisk_support.h: Perform first phase of clean up.
This commit is contained in:
@@ -1,3 +1,13 @@
|
|||||||
|
2011-08-02 Xiang Cui <medivhc@gmail.com>
|
||||||
|
|
||||||
|
* configure.ac, fserror/test.c, fslink/test.c, fspermission/test.c,
|
||||||
|
fsrdwr/init.c, fssymlink/test.c, fstime/test.c,
|
||||||
|
mdosfs_support/fs_config.h, mdosfs_support/fs_support.c,
|
||||||
|
mimfs_support/fs_support.c, mrfs_support/fs_config.h,
|
||||||
|
support/fstest.h, support/fstest_support.c,
|
||||||
|
support/ramdisk_support.c, support/ramdisk_support.h: Perform first
|
||||||
|
phase of clean up.
|
||||||
|
|
||||||
2011-08-01 Xiang Cui <medivhc@gmail.com>
|
2011-08-01 Xiang Cui <medivhc@gmail.com>
|
||||||
|
|
||||||
* imfs_fslink/Makefile.am, imfs_fssymlink/Makefile.am,
|
* imfs_fslink/Makefile.am, imfs_fssymlink/Makefile.am,
|
||||||
|
|||||||
@@ -256,7 +256,8 @@ void rmdir_unlink_error (void)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* The path argument names a directory that is not an empty directory,
|
* The path argument names a directory that is not an empty directory,
|
||||||
* or there are hard links to the directory other than dot or a single entry in dot-dot.
|
* or there are hard links to the directory other than
|
||||||
|
* dot or a single entry in dot-dot.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
EXPECT_ERROR (ENOTEMPTY, rmdir, "..");
|
EXPECT_ERROR (ENOTEMPTY, rmdir, "..");
|
||||||
@@ -273,7 +274,8 @@ void rmdir_unlink_error (void)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* A component of path does not name an existing file,
|
* A component of path does not name an existing file,
|
||||||
* or the path argument names a nonexistent directory or points to an empty string
|
* or the path argument names a nonexistent directory or
|
||||||
|
* points to an empty string
|
||||||
*/
|
*/
|
||||||
EXPECT_ERROR (ENOENT, rmdir, "");
|
EXPECT_ERROR (ENOENT, rmdir, "");
|
||||||
EXPECT_ERROR (ENOENT, rmdir, nonexistence);
|
EXPECT_ERROR (ENOENT, rmdir, nonexistence);
|
||||||
|
|||||||
@@ -21,12 +21,13 @@
|
|||||||
#include "fstest.h"
|
#include "fstest.h"
|
||||||
|
|
||||||
const char *databuf =
|
const char *databuf =
|
||||||
"Happy days are here again. Happy days are here again.1Happy "
|
"Happy days are here again. Happy days are here again.1Happy "
|
||||||
"days are here again.2Happy days are here again.3Happy days are here again."
|
"days are here again.2Happy days are here again.3Happy days are here again."
|
||||||
"4Happy days are here again.5Happy days are here again.6Happy days are here "
|
"4Happy days are here again.5Happy days are here again.6Happy days are here "
|
||||||
"again.7Happy days are here again.";
|
"again.7Happy days are here again.";
|
||||||
|
|
||||||
void read_write_test (void)
|
void
|
||||||
|
read_write_test (void)
|
||||||
{
|
{
|
||||||
|
|
||||||
int fd;
|
int fd;
|
||||||
@@ -42,15 +43,15 @@ void read_write_test (void)
|
|||||||
mode_t mode = S_IRWXU | S_IRWXG | S_IRWXO;
|
mode_t mode = S_IRWXU | S_IRWXG | S_IRWXO;
|
||||||
|
|
||||||
|
|
||||||
const char* wd=__func__;
|
const char *wd = __func__;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create a new directory and change the current directory to this
|
* Create a new directory and change the current directory to this
|
||||||
*/
|
*/
|
||||||
status=mkdir(wd,mode);
|
status = mkdir (wd, mode);
|
||||||
rtems_test_assert(status==0);
|
rtems_test_assert (status == 0);
|
||||||
status=chdir(wd);
|
status = chdir (wd);
|
||||||
rtems_test_assert(status==0);
|
rtems_test_assert (status == 0);
|
||||||
/*
|
/*
|
||||||
* Create an empty file
|
* Create an empty file
|
||||||
*/
|
*/
|
||||||
@@ -173,347 +174,351 @@ void read_write_test (void)
|
|||||||
/*
|
/*
|
||||||
* Go back to parent directory
|
* Go back to parent directory
|
||||||
*/
|
*/
|
||||||
status=chdir("..");
|
status = chdir ("..");
|
||||||
rtems_test_assert(status==0);
|
rtems_test_assert (status == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void truncate_test03(void )
|
void
|
||||||
|
truncate_test03 (void)
|
||||||
{
|
{
|
||||||
|
|
||||||
int fd;
|
int fd;
|
||||||
int status;
|
int status;
|
||||||
char *name01="name01";
|
char *name01 = "name01";
|
||||||
struct stat statbuf;
|
struct stat statbuf;
|
||||||
|
|
||||||
char data;
|
char data;
|
||||||
int n;
|
int n;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
size_t len = strlen(databuf);
|
size_t len = strlen (databuf);
|
||||||
|
|
||||||
char *readbuf;
|
char *readbuf;
|
||||||
off_t good_size=100;
|
off_t good_size = 100;
|
||||||
mode_t mode = S_IRWXU|S_IRWXG|S_IRWXO;
|
mode_t mode = S_IRWXU | S_IRWXG | S_IRWXO;
|
||||||
|
|
||||||
|
|
||||||
const char* wd=__func__;
|
const char *wd = __func__;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create a new directory and change the current directory to this
|
* Create a new directory and change the current directory to this
|
||||||
*/
|
*/
|
||||||
status=mkdir(wd,mode);
|
status = mkdir (wd, mode);
|
||||||
rtems_test_assert(status==0);
|
rtems_test_assert (status == 0);
|
||||||
status=chdir(wd);
|
status = chdir (wd);
|
||||||
rtems_test_assert(status==0);
|
rtems_test_assert (status == 0);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create an empty file
|
* Create an empty file
|
||||||
*/
|
*/
|
||||||
fd=creat(name01,mode);
|
fd = creat (name01, mode);
|
||||||
status=close(fd);
|
status = close (fd);
|
||||||
rtems_test_assert(status==0);
|
rtems_test_assert (status == 0);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Truncate it to a valid size
|
* Truncate it to a valid size
|
||||||
*/
|
*/
|
||||||
status=truncate(name01,good_size);
|
status = truncate (name01, good_size);
|
||||||
rtems_test_assert(status==0);
|
rtems_test_assert (status == 0);
|
||||||
/*
|
/*
|
||||||
* Verify the size and the data
|
* Verify the size and the data
|
||||||
*/
|
*/
|
||||||
status=stat(name01,&statbuf);
|
status = stat (name01, &statbuf);
|
||||||
rtems_test_assert(status==0);
|
rtems_test_assert (status == 0);
|
||||||
rtems_test_assert(good_size==statbuf.st_size);
|
rtems_test_assert (good_size == statbuf.st_size);
|
||||||
|
|
||||||
fd=open(name01,O_RDONLY);
|
fd = open (name01, O_RDONLY);
|
||||||
while ((n=read(fd,&data,1))>0) {
|
while ((n = read (fd, &data, 1)) > 0) {
|
||||||
rtems_test_assert(data==0);
|
rtems_test_assert (data == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
status=close(fd);
|
status = close (fd);
|
||||||
rtems_test_assert(status==0);
|
rtems_test_assert (status == 0);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Fill a file with data
|
* Fill a file with data
|
||||||
*/
|
*/
|
||||||
fd=open(name01,O_WRONLY);
|
fd = open (name01, O_WRONLY);
|
||||||
rtems_test_assert(fd!=-1);
|
rtems_test_assert (fd != -1);
|
||||||
n=write(fd,databuf,len);
|
n = write (fd, databuf, len);
|
||||||
rtems_test_assert(n==len);
|
rtems_test_assert (n == len);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Truncate it to the half size
|
* Truncate it to the half size
|
||||||
*/
|
*/
|
||||||
|
|
||||||
status=truncate(name01,len/2);
|
status = truncate (name01, len / 2);
|
||||||
status=truncate(name01,len);
|
status = truncate (name01, len);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* verify the data
|
* verify the data
|
||||||
*/
|
*/
|
||||||
readbuf = (char *)malloc(len/2);
|
readbuf = (char *) malloc (len / 2);
|
||||||
rtems_test_assert( readbuf );
|
rtems_test_assert (readbuf);
|
||||||
fd=open(name01,O_RDONLY);
|
fd = open (name01, O_RDONLY);
|
||||||
rtems_test_assert(fd!=-1);
|
rtems_test_assert (fd != -1);
|
||||||
n=read(fd,readbuf,len/2);
|
n = read (fd, readbuf, len / 2);
|
||||||
rtems_test_assert(n==len/2);
|
rtems_test_assert (n == len / 2);
|
||||||
rtems_test_assert(!strncmp(databuf,readbuf,len/2));
|
rtems_test_assert (!strncmp (databuf, readbuf, len / 2));
|
||||||
n=read(fd,readbuf,len/2);
|
n = read (fd, readbuf, len / 2);
|
||||||
rtems_test_assert(n==len/2);
|
rtems_test_assert (n == len / 2);
|
||||||
for (i=0;i<len/2;i++){
|
for (i = 0; i < len / 2; i++) {
|
||||||
rtems_test_assert(readbuf[i]==0);
|
rtems_test_assert (readbuf[i] == 0);
|
||||||
}
|
}
|
||||||
status=close(fd);
|
status = close (fd);
|
||||||
rtems_test_assert( status==0 );
|
rtems_test_assert (status == 0);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Go back to parent directory
|
* Go back to parent directory
|
||||||
*/
|
*/
|
||||||
status=chdir("..");
|
status = chdir ("..");
|
||||||
rtems_test_assert(status==0);
|
rtems_test_assert (status == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void lseek_test(void)
|
void
|
||||||
|
lseek_test (void)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
int status;
|
int status;
|
||||||
char *name01="test_name01";
|
char *name01 = "test_name01";
|
||||||
struct stat statbuf;
|
struct stat statbuf;
|
||||||
|
|
||||||
int n;
|
int n;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
size_t len = strlen(databuf);
|
size_t len = strlen (databuf);
|
||||||
off_t pos;
|
off_t pos;
|
||||||
int total_written=0;
|
int total_written = 0;
|
||||||
|
|
||||||
char *readbuf;
|
char *readbuf;
|
||||||
mode_t mode = S_IRWXU|S_IRWXG|S_IRWXO;
|
mode_t mode = S_IRWXU | S_IRWXG | S_IRWXO;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const char* wd=__func__;
|
const char *wd = __func__;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create a new directory and change the current directory to this
|
* Create a new directory and change the current directory to this
|
||||||
*/
|
*/
|
||||||
status=mkdir(wd,mode);
|
status = mkdir (wd, mode);
|
||||||
rtems_test_assert(status==0);
|
rtems_test_assert (status == 0);
|
||||||
status=chdir(wd);
|
status = chdir (wd);
|
||||||
rtems_test_assert(status==0);
|
rtems_test_assert (status == 0);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create a file and fill with the data.
|
* Create a file and fill with the data.
|
||||||
*/
|
*/
|
||||||
puts("Create a new file");
|
puts ("Create a new file");
|
||||||
fd=creat(name01,mode);
|
fd = creat (name01, mode);
|
||||||
rtems_test_assert(fd!=-1);
|
rtems_test_assert (fd != -1);
|
||||||
|
|
||||||
pos=lseek(fd,0,SEEK_CUR);
|
pos = lseek (fd, 0, SEEK_CUR);
|
||||||
rtems_test_assert(pos==0);
|
rtems_test_assert (pos == 0);
|
||||||
|
|
||||||
pos=lseek(fd,0,SEEK_END);
|
pos = lseek (fd, 0, SEEK_END);
|
||||||
rtems_test_assert(pos==0);
|
rtems_test_assert (pos == 0);
|
||||||
|
|
||||||
pos=lseek(fd,0,SEEK_SET);
|
pos = lseek (fd, 0, SEEK_SET);
|
||||||
rtems_test_assert(pos==0);
|
rtems_test_assert (pos == 0);
|
||||||
|
|
||||||
|
|
||||||
printf( "Writing %d bytes to file\n", len * 10 );
|
printf ("Writing %d bytes to file\n", len * 10);
|
||||||
for (i=0; i<10; i++) {
|
for (i = 0; i < 10; i++) {
|
||||||
n = write(fd, databuf, len);
|
n = write (fd, databuf, len);
|
||||||
rtems_test_assert( n != -1 );
|
rtems_test_assert (n != -1);
|
||||||
total_written += n;
|
total_written += n;
|
||||||
}
|
}
|
||||||
printf("Successfully wrote %d\n", total_written);
|
printf ("Successfully wrote %d\n", total_written);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check the current position
|
* Check the current position
|
||||||
*/
|
*/
|
||||||
puts("Check the current position");
|
puts ("Check the current position");
|
||||||
pos=lseek(fd,0,SEEK_CUR);
|
pos = lseek (fd, 0, SEEK_CUR);
|
||||||
rtems_test_assert(pos==total_written);
|
rtems_test_assert (pos == total_written);
|
||||||
|
|
||||||
pos=lseek(fd,0,SEEK_END);
|
pos = lseek (fd, 0, SEEK_END);
|
||||||
rtems_test_assert(pos==total_written);
|
rtems_test_assert (pos == total_written);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ftruncate shall not change the posistion
|
* ftruncate shall not change the posistion
|
||||||
*/
|
*/
|
||||||
status=ftruncate(fd,total_written+1);
|
status = ftruncate (fd, total_written + 1);
|
||||||
rtems_test_assert(status==0);
|
rtems_test_assert (status == 0);
|
||||||
|
|
||||||
pos=lseek(fd,0,SEEK_CUR);
|
pos = lseek (fd, 0, SEEK_CUR);
|
||||||
rtems_test_assert(pos==total_written);
|
rtems_test_assert (pos == total_written);
|
||||||
|
|
||||||
pos=lseek(fd,0,SEEK_END);
|
pos = lseek (fd, 0, SEEK_END);
|
||||||
printf("%jd\n",(intmax_t)pos);
|
printf ("%jd\n", (intmax_t) pos);
|
||||||
rtems_test_assert(pos==total_written+1);
|
rtems_test_assert (pos == total_written + 1);
|
||||||
|
|
||||||
status=ftruncate(fd,total_written);
|
status = ftruncate (fd, total_written);
|
||||||
rtems_test_assert(status==0);
|
rtems_test_assert (status == 0);
|
||||||
|
|
||||||
pos=lseek(fd,0,SEEK_CUR);
|
pos = lseek (fd, 0, SEEK_CUR);
|
||||||
rtems_test_assert(pos==total_written+1);
|
rtems_test_assert (pos == total_written + 1);
|
||||||
|
|
||||||
|
|
||||||
status=close(fd);
|
status = close (fd);
|
||||||
rtems_test_assert(status==0);
|
rtems_test_assert (status == 0);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check the file size
|
* Check the file size
|
||||||
*/
|
*/
|
||||||
status=stat(name01,&statbuf);
|
status = stat (name01, &statbuf);
|
||||||
rtems_test_assert(statbuf.st_size==total_written);
|
rtems_test_assert (statbuf.st_size == total_written);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Open the file with O_RDONLY and check the lseek
|
* Open the file with O_RDONLY and check the lseek
|
||||||
*/
|
*/
|
||||||
readbuf=(char*)malloc(len);
|
readbuf = (char *) malloc (len);
|
||||||
fd=open(name01,O_RDONLY);
|
fd = open (name01, O_RDONLY);
|
||||||
pos=lseek(fd,len,SEEK_CUR);
|
pos = lseek (fd, len, SEEK_CUR);
|
||||||
rtems_test_assert(pos==len);
|
rtems_test_assert (pos == len);
|
||||||
n=read(fd,readbuf,len);
|
n = read (fd, readbuf, len);
|
||||||
rtems_test_assert(n==len);
|
rtems_test_assert (n == len);
|
||||||
rtems_test_assert(!strncmp(databuf,readbuf,len));
|
rtems_test_assert (!strncmp (databuf, readbuf, len));
|
||||||
|
|
||||||
pos=lseek(fd,len,SEEK_CUR);
|
pos = lseek (fd, len, SEEK_CUR);
|
||||||
rtems_test_assert(pos==3*len);
|
rtems_test_assert (pos == 3 * len);
|
||||||
n=read(fd,readbuf,len);
|
n = read (fd, readbuf, len);
|
||||||
rtems_test_assert(n==len);
|
rtems_test_assert (n == len);
|
||||||
rtems_test_assert(!strncmp(databuf,readbuf,len));
|
rtems_test_assert (!strncmp (databuf, readbuf, len));
|
||||||
|
|
||||||
pos=lseek(fd,-len,SEEK_CUR);
|
pos = lseek (fd, -len, SEEK_CUR);
|
||||||
rtems_test_assert(pos==3*len);
|
rtems_test_assert (pos == 3 * len);
|
||||||
n=read(fd,readbuf,len);
|
n = read (fd, readbuf, len);
|
||||||
rtems_test_assert(n==len);
|
rtems_test_assert (n == len);
|
||||||
rtems_test_assert(!strncmp(databuf,readbuf,len));
|
rtems_test_assert (!strncmp (databuf, readbuf, len));
|
||||||
|
|
||||||
pos=lseek(fd,4*len,SEEK_SET);
|
pos = lseek (fd, 4 * len, SEEK_SET);
|
||||||
n=read(fd,readbuf,len);
|
n = read (fd, readbuf, len);
|
||||||
rtems_test_assert(n==len);
|
rtems_test_assert (n == len);
|
||||||
rtems_test_assert(!strncmp(databuf,readbuf,len));
|
rtems_test_assert (!strncmp (databuf, readbuf, len));
|
||||||
|
|
||||||
|
|
||||||
pos=lseek(fd,10,SEEK_SET);
|
pos = lseek (fd, 10, SEEK_SET);
|
||||||
n=read(fd,readbuf,len);
|
n = read (fd, readbuf, len);
|
||||||
rtems_test_assert(n==len);
|
rtems_test_assert (n == len);
|
||||||
rtems_test_assert(strncmp(databuf,readbuf,len)!=0);
|
rtems_test_assert (strncmp (databuf, readbuf, len) != 0);
|
||||||
|
|
||||||
pos=lseek(fd,-len,SEEK_END);
|
pos = lseek (fd, -len, SEEK_END);
|
||||||
n=read(fd,readbuf,2*len);
|
n = read (fd, readbuf, 2 * len);
|
||||||
rtems_test_assert(n==len);
|
rtems_test_assert (n == len);
|
||||||
rtems_test_assert(!strncmp(databuf,readbuf,len));
|
rtems_test_assert (!strncmp (databuf, readbuf, len));
|
||||||
|
|
||||||
status=close(fd);
|
status = close (fd);
|
||||||
rtems_test_assert(status==0);
|
rtems_test_assert (status == 0);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Open the file withe O_RDWR and check the lseek
|
* Open the file withe O_RDWR and check the lseek
|
||||||
*/
|
*/
|
||||||
|
|
||||||
fd=open(name01,O_RDWR);
|
fd = open (name01, O_RDWR);
|
||||||
|
|
||||||
pos=lseek(fd,len,SEEK_CUR);
|
pos = lseek (fd, len, SEEK_CUR);
|
||||||
rtems_test_assert(pos==len);
|
rtems_test_assert (pos == len);
|
||||||
n=read(fd,readbuf,len);
|
n = read (fd, readbuf, len);
|
||||||
rtems_test_assert(n==len);
|
rtems_test_assert (n == len);
|
||||||
rtems_test_assert(!strncmp(databuf,readbuf,len));
|
rtems_test_assert (!strncmp (databuf, readbuf, len));
|
||||||
|
|
||||||
pos=lseek(fd,len,SEEK_CUR);
|
pos = lseek (fd, len, SEEK_CUR);
|
||||||
rtems_test_assert(pos==3*len);
|
rtems_test_assert (pos == 3 * len);
|
||||||
n=read(fd,readbuf,len);
|
n = read (fd, readbuf, len);
|
||||||
rtems_test_assert(n==len);
|
rtems_test_assert (n == len);
|
||||||
rtems_test_assert(!strncmp(databuf,readbuf,len));
|
rtems_test_assert (!strncmp (databuf, readbuf, len));
|
||||||
|
|
||||||
pos=lseek(fd,-len,SEEK_CUR);
|
pos = lseek (fd, -len, SEEK_CUR);
|
||||||
rtems_test_assert(pos==3*len);
|
rtems_test_assert (pos == 3 * len);
|
||||||
n=read(fd,readbuf,len);
|
n = read (fd, readbuf, len);
|
||||||
rtems_test_assert(n==len);
|
rtems_test_assert (n == len);
|
||||||
rtems_test_assert(!strncmp(databuf,readbuf,len));
|
rtems_test_assert (!strncmp (databuf, readbuf, len));
|
||||||
|
|
||||||
pos=lseek(fd,4*len,SEEK_SET);
|
pos = lseek (fd, 4 * len, SEEK_SET);
|
||||||
n=read(fd,readbuf,len);
|
n = read (fd, readbuf, len);
|
||||||
rtems_test_assert(n==len);
|
rtems_test_assert (n == len);
|
||||||
rtems_test_assert(!strncmp(databuf,readbuf,len));
|
rtems_test_assert (!strncmp (databuf, readbuf, len));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Go to the wrong position, so the data is not the same
|
* Go to the wrong position, so the data is not the same
|
||||||
*/
|
*/
|
||||||
pos=lseek(fd,10,SEEK_SET);
|
pos = lseek (fd, 10, SEEK_SET);
|
||||||
n=read(fd,readbuf,len);
|
n = read (fd, readbuf, len);
|
||||||
rtems_test_assert(n==len);
|
rtems_test_assert (n == len);
|
||||||
rtems_test_assert(strncmp(databuf,readbuf,len)!=0);
|
rtems_test_assert (strncmp (databuf, readbuf, len) != 0);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Use SEEK_END
|
* Use SEEK_END
|
||||||
*/
|
*/
|
||||||
pos=lseek(fd,-len,SEEK_END);
|
pos = lseek (fd, -len, SEEK_END);
|
||||||
n=read(fd,readbuf,2*len);
|
n = read (fd, readbuf, 2 * len);
|
||||||
rtems_test_assert(n==len);
|
rtems_test_assert (n == len);
|
||||||
rtems_test_assert(!strncmp(databuf,readbuf,len));
|
rtems_test_assert (!strncmp (databuf, readbuf, len));
|
||||||
|
|
||||||
memset(readbuf,0,len);
|
memset (readbuf, 0, len);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Write the zero to the end of file.
|
* Write the zero to the end of file.
|
||||||
*/
|
*/
|
||||||
pos=lseek(fd,-len,SEEK_END);
|
pos = lseek (fd, -len, SEEK_END);
|
||||||
rtems_test_assert(pos==total_written-len);
|
rtems_test_assert (pos == total_written - len);
|
||||||
n=write(fd,readbuf,len);
|
n = write (fd, readbuf, len);
|
||||||
rtems_test_assert(n==len);
|
rtems_test_assert (n == len);
|
||||||
/*
|
/*
|
||||||
* Verify it
|
* Verify it
|
||||||
*/
|
*/
|
||||||
pos=lseek(fd,total_written-len,SEEK_SET);
|
pos = lseek (fd, total_written - len, SEEK_SET);
|
||||||
n=read(fd,readbuf,len);
|
n = read (fd, readbuf, len);
|
||||||
rtems_test_assert(n==len);
|
rtems_test_assert (n == len);
|
||||||
for (i=0;i<n;i++){
|
for (i = 0; i < n; i++) {
|
||||||
rtems_test_assert(readbuf[i]==0);
|
rtems_test_assert (readbuf[i] == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Write the zero to the beginning of file.
|
* Write the zero to the beginning of file.
|
||||||
*/
|
*/
|
||||||
pos=lseek(fd,-total_written,SEEK_END);
|
pos = lseek (fd, -total_written, SEEK_END);
|
||||||
rtems_test_assert(pos==0);
|
rtems_test_assert (pos == 0);
|
||||||
n=write(fd,readbuf,len);
|
n = write (fd, readbuf, len);
|
||||||
rtems_test_assert(n==len);
|
rtems_test_assert (n == len);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Verify it
|
* Verify it
|
||||||
*/
|
*/
|
||||||
|
|
||||||
pos=lseek(fd,0,SEEK_SET);
|
pos = lseek (fd, 0, SEEK_SET);
|
||||||
n=read(fd,readbuf,len);
|
n = read (fd, readbuf, len);
|
||||||
rtems_test_assert(n==len);
|
rtems_test_assert (n == len);
|
||||||
for (i=0;i<n;i++){
|
for (i = 0; i < n; i++) {
|
||||||
rtems_test_assert(readbuf[i]==0);
|
rtems_test_assert (readbuf[i] == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
n=read(fd,readbuf,len);
|
n = read (fd, readbuf, len);
|
||||||
rtems_test_assert(n==len);
|
rtems_test_assert (n == len);
|
||||||
rtems_test_assert(strncmp(databuf,readbuf,len)==0);
|
rtems_test_assert (strncmp (databuf, readbuf, len) == 0);
|
||||||
/*
|
/*
|
||||||
* Call ftruncate to decrease the file and the position not change
|
* Call ftruncate to decrease the file and the position not change
|
||||||
*/
|
*/
|
||||||
status=ftruncate(fd,len);
|
status = ftruncate (fd, len);
|
||||||
rtems_test_assert(status==0);
|
rtems_test_assert (status == 0);
|
||||||
pos=lseek(fd,0,SEEK_CUR);
|
pos = lseek (fd, 0, SEEK_CUR);
|
||||||
rtems_test_assert(pos==len*2);
|
rtems_test_assert (pos == len * 2);
|
||||||
|
|
||||||
status=close(fd);
|
status = close (fd);
|
||||||
rtems_test_assert(status==0);
|
rtems_test_assert (status == 0);
|
||||||
/*
|
/*
|
||||||
* Go back to parent directory
|
* Go back to parent directory
|
||||||
*/
|
*/
|
||||||
status=chdir("..");
|
status = chdir ("..");
|
||||||
rtems_test_assert(status==0);
|
rtems_test_assert (status == 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
void test(void )
|
|
||||||
|
void
|
||||||
|
test (void)
|
||||||
{
|
{
|
||||||
read_write_test();
|
read_write_test ();
|
||||||
lseek_test();
|
lseek_test ();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,5 @@
|
|||||||
#define MDOSFS_TEST
|
#define MDOSFS_TEST
|
||||||
|
|
||||||
#define FILESYSTEM "MOUNTED DOSFS"
|
#define FILESYSTEM "MOUNTED DOSFS"
|
||||||
#define BASE_FOR_TEST "/mnt/"
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -20,7 +20,9 @@
|
|||||||
|
|
||||||
#include <rtems/libio.h>
|
#include <rtems/libio.h>
|
||||||
#include <rtems/dosfs.h>
|
#include <rtems/dosfs.h>
|
||||||
|
|
||||||
#include "ramdisk_support.h"
|
#include "ramdisk_support.h"
|
||||||
|
#include "fstest.h"
|
||||||
|
|
||||||
#define BLOCK_SIZE 512
|
#define BLOCK_SIZE 512
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,12 @@
|
|||||||
/*
|
/*
|
||||||
* $Id$
|
* COPYRIGHT (c) 1989-2011.
|
||||||
|
* On-Line Applications Research Corporation (OAR).
|
||||||
|
*
|
||||||
|
* The license and distribution terms for this file may be
|
||||||
|
* found in the file LICENSE in this distribution or at
|
||||||
|
* http://www.rtems.com/license/LICENSE.
|
||||||
|
*
|
||||||
|
* $Id Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __MIMFS_SUPPORT_h
|
#ifndef __MIMFS_SUPPORT_h
|
||||||
|
|||||||
@@ -22,7 +22,9 @@
|
|||||||
|
|
||||||
|
|
||||||
#define FS_PASS() do {puts("PASS");} while (0)
|
#define FS_PASS() do {puts("PASS");} while (0)
|
||||||
#define FS_FAIL() do {printf( "FAIL %s: %d \n", __FILE__, __LINE__ ); } while (0)
|
#define FS_FAIL() do {\
|
||||||
|
printf( "FAIL %s: %d \n", __FILE__, __LINE__ );\
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
|
||||||
#define SHOW_MESSAGE(e, func, ...) printf(\
|
#define SHOW_MESSAGE(e, func, ...) printf(\
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
*
|
*
|
||||||
* $Id Exp $
|
* $Id Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
@@ -53,7 +52,8 @@ void break_out_of_chroot(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((dir_fd=open(".",O_RDONLY))<0) {
|
if ((dir_fd=open(".",O_RDONLY))<0) {
|
||||||
fprintf(stderr,"Failed to open \".\" for reading - %s\n", strerror(errno));
|
fprintf(stderr,"Failed to open ""."
|
||||||
|
" for reading - %s\n", strerror(errno));
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,7 +74,6 @@ void break_out_of_chroot(void)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Main entry point of every filesystem test
|
* Main entry point of every filesystem test
|
||||||
*/
|
*/
|
||||||
@@ -103,5 +102,4 @@ rtems_task Init(
|
|||||||
|
|
||||||
puts( "*** END OF FILE SYSTEM TEST ( " FILESYSTEM " ) ***" );
|
puts( "*** END OF FILE SYSTEM TEST ( " FILESYSTEM " ) ***" );
|
||||||
rtems_test_exit(0);
|
rtems_test_exit(0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,37 +20,38 @@
|
|||||||
|
|
||||||
dev_t dev = 0;
|
dev_t dev = 0;
|
||||||
|
|
||||||
void init_ramdisk(void)
|
void
|
||||||
|
init_ramdisk (void)
|
||||||
{
|
{
|
||||||
|
|
||||||
int rc=0;
|
int rc = 0;
|
||||||
rc =rtems_disk_io_initialize();
|
rc = rtems_disk_io_initialize ();
|
||||||
rtems_test_assert( rc == 0 );
|
rtems_test_assert (rc == 0);
|
||||||
rc =ramdisk_register(RAMDISK_BLOCK_SIZE,RAMDISK_BLOCK_COUNT,\
|
rc = ramdisk_register (RAMDISK_BLOCK_SIZE, RAMDISK_BLOCK_COUNT,
|
||||||
false,RAMDISK_PATH,&dev);
|
false, RAMDISK_PATH, &dev);
|
||||||
rtems_test_assert( rc == 0 );
|
rtems_test_assert (rc == 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void del_ramdisk(void )
|
void
|
||||||
|
del_ramdisk (void)
|
||||||
{
|
{
|
||||||
int rc=0;
|
|
||||||
rtems_device_major_number major=0;
|
|
||||||
rtems_device_minor_number minor=0;
|
|
||||||
|
|
||||||
rc=rtems_disk_delete (dev);
|
int rc = 0;
|
||||||
rtems_test_assert( rc == 0 );
|
rtems_device_major_number major = 0;
|
||||||
|
rtems_device_minor_number minor = 0;
|
||||||
|
|
||||||
rtems_filesystem_split_dev_t(dev,major,minor);
|
rc = rtems_disk_delete (dev);
|
||||||
|
rtems_test_assert (rc == 0);
|
||||||
|
|
||||||
rtems_test_assert(major>=0);
|
rtems_filesystem_split_dev_t (dev, major, minor);
|
||||||
rtems_test_assert(minor>=0);
|
|
||||||
|
|
||||||
rc=rtems_io_unregister_driver(major);
|
rtems_test_assert (major >= 0);
|
||||||
rtems_test_assert( rc == 0 );
|
rtems_test_assert (minor >= 0);
|
||||||
|
|
||||||
rc=rtems_disk_io_done();
|
rc = rtems_io_unregister_driver (major);
|
||||||
rtems_test_assert( rc == 0 );
|
rtems_test_assert (rc == 0);
|
||||||
|
rc = rtems_disk_io_done ();
|
||||||
|
rtems_test_assert (rc == 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user