Changeset 6fed43e in rtems


Ignore:
Timestamp:
Aug 2, 2011, 2:24:59 PM (10 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.11, 5, master
Children:
d83f90b
Parents:
f8d760b
Message:

2011-08-02 Xiang Cui <medivhc@…>

  • 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.
Location:
testsuites/fstests
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • testsuites/fstests/ChangeLog

    rf8d760b r6fed43e  
     12011-08-02      Xiang Cui <medivhc@gmail.com>
     2
     3        * configure.ac, fserror/test.c, fslink/test.c, fspermission/test.c,
     4        fsrdwr/init.c, fssymlink/test.c, fstime/test.c,
     5        mdosfs_support/fs_config.h, mdosfs_support/fs_support.c,
     6        mimfs_support/fs_support.c, mrfs_support/fs_config.h,
     7        support/fstest.h, support/fstest_support.c,
     8        support/ramdisk_support.c, support/ramdisk_support.h: Perform first
     9        phase of clean up.
     10
    1112011-08-01      Xiang Cui <medivhc@gmail.com>
    212
  • testsuites/fstests/configure.ac

    rf8d760b r6fed43e  
    11## Process this file with autoconf to produce a configure script.
    2 ## 
     2##
    33## $Id$
    44
     
    7979
    8080# Explicitly list all Makefiles here
    81 AC_CONFIG_FILES([Makefile 
    82 imfs_fserror/Makefile 
    83 imfs_fslink/Makefile 
    84 imfs_fspatheval/Makefile 
    85 imfs_fspermission/Makefile 
    86 imfs_fsrdwr/Makefile 
    87 imfs_fssymlink/Makefile 
    88 imfs_fstime/Makefile 
    89 mdosfs_fserror/Makefile 
    90 mdosfs_fspatheval/Makefile 
    91 mdosfs_fsrdwr/Makefile 
    92 mdosfs_fstime/Makefile 
    93 mimfs_fserror/Makefile 
    94 mimfs_fslink/Makefile 
    95 mimfs_fspatheval/Makefile 
    96 mimfs_fspermission/Makefile 
    97 mimfs_fsrdwr/Makefile 
    98 mimfs_fssymlink/Makefile 
    99 mimfs_fstime/Makefile 
    100 mrfs_fserror/Makefile 
    101 mrfs_fslink/Makefile 
    102 mrfs_fspatheval/Makefile 
    103 mrfs_fspermission/Makefile 
    104 mrfs_fsrdwr/Makefile 
    105 mrfs_fssymlink/Makefile 
    106 mrfs_fstime/Makefile 
     81AC_CONFIG_FILES([Makefile
     82imfs_fserror/Makefile
     83imfs_fslink/Makefile
     84imfs_fspatheval/Makefile
     85imfs_fspermission/Makefile
     86imfs_fsrdwr/Makefile
     87imfs_fssymlink/Makefile
     88imfs_fstime/Makefile
     89mdosfs_fserror/Makefile
     90mdosfs_fspatheval/Makefile
     91mdosfs_fsrdwr/Makefile
     92mdosfs_fstime/Makefile
     93mimfs_fserror/Makefile
     94mimfs_fslink/Makefile
     95mimfs_fspatheval/Makefile
     96mimfs_fspermission/Makefile
     97mimfs_fsrdwr/Makefile
     98mimfs_fssymlink/Makefile
     99mimfs_fstime/Makefile
     100mrfs_fserror/Makefile
     101mrfs_fslink/Makefile
     102mrfs_fspatheval/Makefile
     103mrfs_fspermission/Makefile
     104mrfs_fsrdwr/Makefile
     105mrfs_fssymlink/Makefile
     106mrfs_fstime/Makefile
    107107
    108108])
  • testsuites/fstests/fserror/test.c

    rf8d760b r6fed43e  
    7070   * O_CREAT is not set and the named file does not exist
    7171   * or O_CREAT is set and either the path prefix does not exist or
    72    * the path argument points to an empty string. 
     72   * the path argument points to an empty string.
    7373   */
    7474
     
    129129
    130130  /*
    131    * Create a new directory and a new directory in it 
     131   * Create a new directory and a new directory in it
    132132   */
    133133
     
    148148  rtems_test_assert (errno == EEXIST || errno == ENOTEMPTY);
    149149  /*
    150    * The new directory pathname contains a path prefix 
     150   * The new directory pathname contains a path prefix
    151151   *  that names the old directory.
    152152   */
    153153  EXPECT_ERROR (EINVAL, rename, name01, name);
    154154  /*
    155    * The new argument points to a directory and 
     155   * The new argument points to a directory and
    156156   *  the old argument points to a file that is not a directory.
    157157   */
     
    207207  rtems_test_assert (status == 0);
    208208  /*
    209    * Create a file 
     209   * Create a file
    210210   */
    211211  fd = creat (file, mode);
     
    257257  /*
    258258   * The path argument names a directory that is not an empty directory,
    259    * or there are hard links to the directory other than dot or a single entry in dot-dot.
     259   * or there are hard links to the directory other than
     260   * dot or a single entry in dot-dot.
    260261   */
    261262
     
    273274
    274275  /*
    275    * A component of path does not name an existing file,
    276    * or the path argument names a nonexistent directory or points to an empty string
     276   * A component of path does not name an existing file,
     277   * or the path argument names a nonexistent directory or
     278   * points to an empty string
    277279   */
    278280  EXPECT_ERROR (ENOENT, rmdir, "");
     
    339341
    340342  /*
    341    * The whence argument is not a proper value, 
     343   * The whence argument is not a proper value,
    342344   * or the resulting file offset would be negative for a regular file,
    343345   * block special file, or directory.
  • testsuites/fstests/fslink/test.c

    rf8d760b r6fed43e  
    6666
    6767  /*
    68    * link the file and check the nlink 
     68   * link the file and check the nlink
    6969   */
    7070  status = link (name1, name2);
  • testsuites/fstests/fspermission/test.c

    rf8d760b r6fed43e  
    4141
    4242  const char* wd=__func__;
    43  
     43
    4444  mode_t mode=S_IRWXU|S_IRWXG|S_IRWXO ;
    45  
     45
    4646
    4747
     
    8989  printf("The file mode of %s is %03o\n",file02,(unsigned int)tmp_mode);
    9090  rtems_test_assert(tmp_mode==file_mode);
    91  
     91
    9292  status = stat (directory01, &statbuf);
    9393  rtems_test_assert (status == 0);
     
    137137  printf("The file mode of %s is %03o\n",file02,(unsigned int)tmp_mode);
    138138  rtems_test_assert(tmp_mode==file_mode);
    139  
     139
    140140  status = stat (directory01, &statbuf);
    141141  rtems_test_assert (status == 0);
     
    168168  char* test_data="Test Data";
    169169  char* data_buf;
    170   size_t len=strlen(test_data); 
     170  size_t len=strlen(test_data);
    171171
    172172  int n;
     
    174174
    175175  const char* wd=__func__;
    176  
     176
    177177  mode_t mode=S_IRWXU|S_IRWXG|S_IRWXO ;
    178178  uid_t user_id =65534;
    179179  gid_t group_id =65534;
    180  
     180
    181181  uid_t another_user_id =65533;
    182182  gid_t another_group_id =65533;
     
    235235
    236236  /*
    237    * Create directory and a file in it for tese 
     237   * Create directory and a file in it for tese
    238238   */
    239239
     
    254254
    255255  /*
    256    * Check the file with open and write 
     256   * Check the file with open and write
    257257   */
    258258
     
    265265  status=close(fd);
    266266  rtems_test_assert(status==0);
    267  
     267
    268268  fd=open(file02,O_WRONLY);
    269269  n=write(fd,test_data,len);
     
    282282  status=close(fd);
    283283  rtems_test_assert(status==0);
    284  
     284
    285285  EXPECT_ERROR(EACCES,open,file02,O_RDONLY);
    286286  EXPECT_ERROR(EACCES,open,file02,O_RDWR);
     
    350350  status=seteuid(another_user_id);
    351351  rtems_test_assert(status==0);
    352  
     352
    353353  EXPECT_ERROR(EACCES,open,file02,O_WRONLY);
    354354  EXPECT_ERROR(EACCES,open,file02,O_RDONLY);
     
    396396
    397397  const char* wd=__func__;
    398  
     398
    399399  mode_t mode=S_IRWXU|S_IRWXG|S_IRWXO ;
    400400  uid_t user_id =65534;
  • testsuites/fstests/fsrdwr/init.c

    rf8d760b r6fed43e  
    2222
    2323const char *databuf =
    24     "Happy days are here again.  Happy days are here again.1Happy "
    25     "days are here again.2Happy days are here again.3Happy days are here again."
    26     "4Happy days are here again.5Happy days are here again.6Happy days are here "
    27     "again.7Happy days are here again.";
    28 
    29 void read_write_test (void)
     24  "Happy days are here again.  Happy days are here again.1Happy "
     25  "days are here again.2Happy days are here again.3Happy days are here again."
     26  "4Happy days are here again.5Happy days are here again.6Happy days are here "
     27  "again.7Happy days are here again.";
     28
     29void
     30read_write_test (void)
    3031{
    3132
     
    4344
    4445
    45   const char* wd=__func__;
     46  const char *wd = __func__;
    4647
    4748  /*
    4849   * Create a new directory and change the current directory to  this
    4950   */
    50   status=mkdir(wd,mode);
    51   rtems_test_assert(status==0);
    52   status=chdir(wd);
    53   rtems_test_assert(status==0);
     51  status = mkdir (wd, mode);
     52  rtems_test_assert (status == 0);
     53  status = chdir (wd);
     54  rtems_test_assert (status == 0);
    5455  /*
    5556   * Create an empty file
     
    143144
    144145  /*
    145    * Open the file using O_TRUNC 
     146   * Open the file using O_TRUNC
    146147   */
    147148
     
    174175   * Go back to parent directory
    175176   */
    176   status=chdir("..");
    177   rtems_test_assert(status==0);
     177  status = chdir ("..");
     178  rtems_test_assert (status == 0);
    178179}
    179180
    180 void truncate_test03(void )
     181void
     182truncate_test03 (void)
    181183{
    182184
    183   int   fd;
    184   int   status;
    185   char *name01="name01";
     185  int fd;
     186  int status;
     187  char *name01 = "name01";
    186188  struct stat statbuf;
    187189
    188   char  data;
    189   int   n;
    190   int   i;
    191 
    192   size_t  len = strlen(databuf);
     190  char data;
     191  int n;
     192  int i;
     193
     194  size_t len = strlen (databuf);
    193195
    194196  char *readbuf;
    195   off_t good_size=100;
    196   mode_t mode = S_IRWXU|S_IRWXG|S_IRWXO;
    197 
    198 
    199   const char* wd=__func__;
     197  off_t good_size = 100;
     198  mode_t mode = S_IRWXU | S_IRWXG | S_IRWXO;
     199
     200
     201  const char *wd = __func__;
    200202
    201203  /*
    202204   * Create a new directory and change the current directory to  this
    203205   */
    204   status=mkdir(wd,mode);
    205   rtems_test_assert(status==0);
    206   status=chdir(wd);
    207   rtems_test_assert(status==0);
     206  status = mkdir (wd, mode);
     207  rtems_test_assert (status == 0);
     208  status = chdir (wd);
     209  rtems_test_assert (status == 0);
    208210
    209211  /*
    210212   * Create an empty file
    211213   */
    212   fd=creat(name01,mode);
    213   status=close(fd);
    214   rtems_test_assert(status==0);
     214  fd = creat (name01, mode);
     215  status = close (fd);
     216  rtems_test_assert (status == 0);
    215217
    216218
     
    218220   * Truncate it to a valid size
    219221   */
    220   status=truncate(name01,good_size);
    221   rtems_test_assert(status==0);
     222  status = truncate (name01, good_size);
     223  rtems_test_assert (status == 0);
    222224  /*
    223225   * Verify the size and the data
    224226   */
    225   status=stat(name01,&statbuf);
    226   rtems_test_assert(status==0);
    227   rtems_test_assert(good_size==statbuf.st_size);
    228 
    229   fd=open(name01,O_RDONLY);
    230   while ((n=read(fd,&data,1))>0) {
    231     rtems_test_assert(data==0);
     227  status = stat (name01, &statbuf);
     228  rtems_test_assert (status == 0);
     229  rtems_test_assert (good_size == statbuf.st_size);
     230
     231  fd = open (name01, O_RDONLY);
     232  while ((n = read (fd, &data, 1)) > 0) {
     233    rtems_test_assert (data == 0);
    232234  }
    233235
    234   status=close(fd);
    235   rtems_test_assert(status==0);
     236  status = close (fd);
     237  rtems_test_assert (status == 0);
    236238
    237239  /*
    238240   * Fill a file with data
    239241   */
    240   fd=open(name01,O_WRONLY);
    241   rtems_test_assert(fd!=-1);
    242   n=write(fd,databuf,len);
    243   rtems_test_assert(n==len);
    244 
    245   /*
    246    * Truncate it to the half size 
    247    */
    248 
    249   status=truncate(name01,len/2);
    250   status=truncate(name01,len);
     242  fd = open (name01, O_WRONLY);
     243  rtems_test_assert (fd != -1);
     244  n = write (fd, databuf, len);
     245  rtems_test_assert (n == len);
     246
     247  /*
     248   * Truncate it to the half size
     249   */
     250
     251  status = truncate (name01, len / 2);
     252  status = truncate (name01, len);
    251253
    252254  /*
    253255   * verify the data
    254256   */
    255   readbuf = (char *)malloc(len/2);
    256   rtems_test_assert( readbuf );
    257   fd=open(name01,O_RDONLY);
    258   rtems_test_assert(fd!=-1);
    259   n=read(fd,readbuf,len/2);
    260   rtems_test_assert(n==len/2);
    261   rtems_test_assert(!strncmp(databuf,readbuf,len/2));
    262   n=read(fd,readbuf,len/2);
    263   rtems_test_assert(n==len/2);
    264   for (i=0;i<len/2;i++){
    265     rtems_test_assert(readbuf[i]==0);
     257  readbuf = (char *) malloc (len / 2);
     258  rtems_test_assert (readbuf);
     259  fd = open (name01, O_RDONLY);
     260  rtems_test_assert (fd != -1);
     261  n = read (fd, readbuf, len / 2);
     262  rtems_test_assert (n == len / 2);
     263  rtems_test_assert (!strncmp (databuf, readbuf, len / 2));
     264  n = read (fd, readbuf, len / 2);
     265  rtems_test_assert (n == len / 2);
     266  for (i = 0; i < len / 2; i++) {
     267    rtems_test_assert (readbuf[i] == 0);
    266268  }
    267   status=close(fd);
    268   rtems_test_assert( status==0 );
     269  status = close (fd);
     270  rtems_test_assert (status == 0);
    269271
    270272  /*
    271273   * Go back to parent directory
    272274   */
    273   status=chdir("..");
    274   rtems_test_assert(status==0);
     275  status = chdir ("..");
     276  rtems_test_assert (status == 0);
    275277}
    276278
    277 void lseek_test(void)
     279void
     280lseek_test (void)
    278281{
    279   int   fd;
    280   int   status;
    281   char *name01="test_name01";
     282  int fd;
     283  int status;
     284  char *name01 = "test_name01";
    282285  struct stat statbuf;
    283286
    284   int   n;
    285   int   i;
    286 
    287   size_t  len = strlen(databuf);
     287  int n;
     288  int i;
     289
     290  size_t len = strlen (databuf);
    288291  off_t pos;
    289   int     total_written=0;
     292  int total_written = 0;
    290293
    291294  char *readbuf;
    292   mode_t mode = S_IRWXU|S_IRWXG|S_IRWXO;
    293 
    294 
    295 
    296   const char* wd=__func__;
     295  mode_t mode = S_IRWXU | S_IRWXG | S_IRWXO;
     296
     297
     298
     299  const char *wd = __func__;
    297300
    298301  /*
    299302   * Create a new directory and change the current directory to this
    300303   */
    301   status=mkdir(wd,mode);
    302   rtems_test_assert(status==0);
    303   status=chdir(wd);
    304   rtems_test_assert(status==0);
     304  status = mkdir (wd, mode);
     305  rtems_test_assert (status == 0);
     306  status = chdir (wd);
     307  rtems_test_assert (status == 0);
    305308
    306309  /*
    307310   * Create a file and fill with the data.
    308311   */
    309   puts("Create a new file");
    310   fd=creat(name01,mode);
    311   rtems_test_assert(fd!=-1);
    312 
    313   pos=lseek(fd,0,SEEK_CUR);
    314   rtems_test_assert(pos==0);
    315 
    316   pos=lseek(fd,0,SEEK_END);
    317   rtems_test_assert(pos==0);
    318  
    319   pos=lseek(fd,0,SEEK_SET);
    320   rtems_test_assert(pos==0);
    321  
    322 
    323   printf( "Writing %d bytes to file\n", len * 10 );
    324   for (i=0; i<10; i++) {
    325     n = write(fd, databuf, len);
    326     rtems_test_assert( n != -1 );
     312  puts ("Create a new file");
     313  fd = creat (name01, mode);
     314  rtems_test_assert (fd != -1);
     315
     316  pos = lseek (fd, 0, SEEK_CUR);
     317  rtems_test_assert (pos == 0);
     318
     319  pos = lseek (fd, 0, SEEK_END);
     320  rtems_test_assert (pos == 0);
     321
     322  pos = lseek (fd, 0, SEEK_SET);
     323  rtems_test_assert (pos == 0);
     324
     325
     326  printf ("Writing %d bytes to file\n", len * 10);
     327  for (i = 0; i < 10; i++) {
     328    n = write (fd, databuf, len);
     329    rtems_test_assert (n != -1);
    327330    total_written += n;
    328331  }
    329   printf("Successfully wrote %d\n", total_written);
     332  printf ("Successfully wrote %d\n", total_written);
    330333
    331334  /*
    332335   * Check the current position
    333336   */
    334   puts("Check the current position");
    335   pos=lseek(fd,0,SEEK_CUR);
    336   rtems_test_assert(pos==total_written);
    337 
    338   pos=lseek(fd,0,SEEK_END);
    339   rtems_test_assert(pos==total_written);
     337  puts ("Check the current position");
     338  pos = lseek (fd, 0, SEEK_CUR);
     339  rtems_test_assert (pos == total_written);
     340
     341  pos = lseek (fd, 0, SEEK_END);
     342  rtems_test_assert (pos == total_written);
    340343
    341344  /*
    342345   * ftruncate shall not change the posistion
    343346   */
    344   status=ftruncate(fd,total_written+1);
    345   rtems_test_assert(status==0);
    346 
    347   pos=lseek(fd,0,SEEK_CUR);
    348   rtems_test_assert(pos==total_written);
    349 
    350   pos=lseek(fd,0,SEEK_END);
    351   printf("%jd\n",(intmax_t)pos);
    352   rtems_test_assert(pos==total_written+1);
    353 
    354   status=ftruncate(fd,total_written);
    355   rtems_test_assert(status==0);
    356  
    357   pos=lseek(fd,0,SEEK_CUR);
    358   rtems_test_assert(pos==total_written+1);
    359 
    360 
    361   status=close(fd);
    362   rtems_test_assert(status==0);
     347  status = ftruncate (fd, total_written + 1);
     348  rtems_test_assert (status == 0);
     349
     350  pos = lseek (fd, 0, SEEK_CUR);
     351  rtems_test_assert (pos == total_written);
     352
     353  pos = lseek (fd, 0, SEEK_END);
     354  printf ("%jd\n", (intmax_t) pos);
     355  rtems_test_assert (pos == total_written + 1);
     356
     357  status = ftruncate (fd, total_written);
     358  rtems_test_assert (status == 0);
     359
     360  pos = lseek (fd, 0, SEEK_CUR);
     361  rtems_test_assert (pos == total_written + 1);
     362
     363
     364  status = close (fd);
     365  rtems_test_assert (status == 0);
    363366
    364367  /*
    365368   * Check the file size
    366369   */
    367   status=stat(name01,&statbuf);
    368   rtems_test_assert(statbuf.st_size==total_written);
     370  status = stat (name01, &statbuf);
     371  rtems_test_assert (statbuf.st_size == total_written);
    369372
    370373  /*
    371374   * Open the file with O_RDONLY and check the lseek
    372375   */
    373   readbuf=(char*)malloc(len);
    374   fd=open(name01,O_RDONLY);
    375   pos=lseek(fd,len,SEEK_CUR);
    376   rtems_test_assert(pos==len);
    377   n=read(fd,readbuf,len);
    378   rtems_test_assert(n==len);
    379   rtems_test_assert(!strncmp(databuf,readbuf,len));
    380 
    381   pos=lseek(fd,len,SEEK_CUR);
    382   rtems_test_assert(pos==3*len);
    383   n=read(fd,readbuf,len);
    384   rtems_test_assert(n==len);
    385   rtems_test_assert(!strncmp(databuf,readbuf,len));
    386 
    387   pos=lseek(fd,-len,SEEK_CUR);
    388   rtems_test_assert(pos==3*len);
    389   n=read(fd,readbuf,len);
    390   rtems_test_assert(n==len);
    391   rtems_test_assert(!strncmp(databuf,readbuf,len));
    392 
    393   pos=lseek(fd,4*len,SEEK_SET);
    394   n=read(fd,readbuf,len);
    395   rtems_test_assert(n==len);
    396   rtems_test_assert(!strncmp(databuf,readbuf,len));
    397 
    398  
    399   pos=lseek(fd,10,SEEK_SET);
    400   n=read(fd,readbuf,len);
    401   rtems_test_assert(n==len);
    402   rtems_test_assert(strncmp(databuf,readbuf,len)!=0);
    403 
    404   pos=lseek(fd,-len,SEEK_END);
    405   n=read(fd,readbuf,2*len);
    406   rtems_test_assert(n==len);
    407   rtems_test_assert(!strncmp(databuf,readbuf,len));
    408 
    409   status=close(fd);
    410   rtems_test_assert(status==0);
     376  readbuf = (char *) malloc (len);
     377  fd = open (name01, O_RDONLY);
     378  pos = lseek (fd, len, SEEK_CUR);
     379  rtems_test_assert (pos == len);
     380  n = read (fd, readbuf, len);
     381  rtems_test_assert (n == len);
     382  rtems_test_assert (!strncmp (databuf, readbuf, len));
     383
     384  pos = lseek (fd, len, SEEK_CUR);
     385  rtems_test_assert (pos == 3 * len);
     386  n = read (fd, readbuf, len);
     387  rtems_test_assert (n == len);
     388  rtems_test_assert (!strncmp (databuf, readbuf, len));
     389
     390  pos = lseek (fd, -len, SEEK_CUR);
     391  rtems_test_assert (pos == 3 * len);
     392  n = read (fd, readbuf, len);
     393  rtems_test_assert (n == len);
     394  rtems_test_assert (!strncmp (databuf, readbuf, len));
     395
     396  pos = lseek (fd, 4 * len, SEEK_SET);
     397  n = read (fd, readbuf, len);
     398  rtems_test_assert (n == len);
     399  rtems_test_assert (!strncmp (databuf, readbuf, len));
     400
     401
     402  pos = lseek (fd, 10, SEEK_SET);
     403  n = read (fd, readbuf, len);
     404  rtems_test_assert (n == len);
     405  rtems_test_assert (strncmp (databuf, readbuf, len) != 0);
     406
     407  pos = lseek (fd, -len, SEEK_END);
     408  n = read (fd, readbuf, 2 * len);
     409  rtems_test_assert (n == len);
     410  rtems_test_assert (!strncmp (databuf, readbuf, len));
     411
     412  status = close (fd);
     413  rtems_test_assert (status == 0);
    411414
    412415  /*
     
    414417   */
    415418
    416   fd=open(name01,O_RDWR);
    417 
    418   pos=lseek(fd,len,SEEK_CUR);
    419   rtems_test_assert(pos==len);
    420   n=read(fd,readbuf,len);
    421   rtems_test_assert(n==len);
    422   rtems_test_assert(!strncmp(databuf,readbuf,len));
    423 
    424   pos=lseek(fd,len,SEEK_CUR);
    425   rtems_test_assert(pos==3*len);
    426   n=read(fd,readbuf,len);
    427   rtems_test_assert(n==len);
    428   rtems_test_assert(!strncmp(databuf,readbuf,len));
    429 
    430   pos=lseek(fd,-len,SEEK_CUR);
    431   rtems_test_assert(pos==3*len);
    432   n=read(fd,readbuf,len);
    433   rtems_test_assert(n==len);
    434   rtems_test_assert(!strncmp(databuf,readbuf,len));
    435 
    436   pos=lseek(fd,4*len,SEEK_SET);
    437   n=read(fd,readbuf,len);
    438   rtems_test_assert(n==len);
    439   rtems_test_assert(!strncmp(databuf,readbuf,len));
    440 
    441   /*
    442    * Go to the wrong position, so the data is not the same 
    443    */
    444   pos=lseek(fd,10,SEEK_SET);
    445   n=read(fd,readbuf,len);
    446   rtems_test_assert(n==len);
    447   rtems_test_assert(strncmp(databuf,readbuf,len)!=0);
    448 
    449   /*
    450    * Use SEEK_END 
    451    */
    452   pos=lseek(fd,-len,SEEK_END);
    453   n=read(fd,readbuf,2*len);
    454   rtems_test_assert(n==len);
    455   rtems_test_assert(!strncmp(databuf,readbuf,len));
    456 
    457   memset(readbuf,0,len);
     419  fd = open (name01, O_RDWR);
     420
     421  pos = lseek (fd, len, SEEK_CUR);
     422  rtems_test_assert (pos == len);
     423  n = read (fd, readbuf, len);
     424  rtems_test_assert (n == len);
     425  rtems_test_assert (!strncmp (databuf, readbuf, len));
     426
     427  pos = lseek (fd, len, SEEK_CUR);
     428  rtems_test_assert (pos == 3 * len);
     429  n = read (fd, readbuf, len);
     430  rtems_test_assert (n == len);
     431  rtems_test_assert (!strncmp (databuf, readbuf, len));
     432
     433  pos = lseek (fd, -len, SEEK_CUR);
     434  rtems_test_assert (pos == 3 * len);
     435  n = read (fd, readbuf, len);
     436  rtems_test_assert (n == len);
     437  rtems_test_assert (!strncmp (databuf, readbuf, len));
     438
     439  pos = lseek (fd, 4 * len, SEEK_SET);
     440  n = read (fd, readbuf, len);
     441  rtems_test_assert (n == len);
     442  rtems_test_assert (!strncmp (databuf, readbuf, len));
     443
     444  /*
     445   * Go to the wrong position, so the data is not the same
     446   */
     447  pos = lseek (fd, 10, SEEK_SET);
     448  n = read (fd, readbuf, len);
     449  rtems_test_assert (n == len);
     450  rtems_test_assert (strncmp (databuf, readbuf, len) != 0);
     451
     452  /*
     453   * Use SEEK_END
     454   */
     455  pos = lseek (fd, -len, SEEK_END);
     456  n = read (fd, readbuf, 2 * len);
     457  rtems_test_assert (n == len);
     458  rtems_test_assert (!strncmp (databuf, readbuf, len));
     459
     460  memset (readbuf, 0, len);
    458461
    459462  /*
    460463   * Write the zero to the end of file.
    461464   */
    462   pos=lseek(fd,-len,SEEK_END);
    463   rtems_test_assert(pos==total_written-len);
    464   n=write(fd,readbuf,len);
    465   rtems_test_assert(n==len);
    466   /*
    467    * Verify it 
    468    */
    469   pos=lseek(fd,total_written-len,SEEK_SET);
    470   n=read(fd,readbuf,len);
    471   rtems_test_assert(n==len);
    472   for (i=0;i<n;i++){
    473     rtems_test_assert(readbuf[i]==0);
     465  pos = lseek (fd, -len, SEEK_END);
     466  rtems_test_assert (pos == total_written - len);
     467  n = write (fd, readbuf, len);
     468  rtems_test_assert (n == len);
     469  /*
     470   * Verify it
     471   */
     472  pos = lseek (fd, total_written - len, SEEK_SET);
     473  n = read (fd, readbuf, len);
     474  rtems_test_assert (n == len);
     475  for (i = 0; i < n; i++) {
     476    rtems_test_assert (readbuf[i] == 0);
    474477  }
    475478
     
    477480   * Write the zero to the beginning of file.
    478481   */
    479   pos=lseek(fd,-total_written,SEEK_END);
    480   rtems_test_assert(pos==0);
    481   n=write(fd,readbuf,len);
    482   rtems_test_assert(n==len);
     482  pos = lseek (fd, -total_written, SEEK_END);
     483  rtems_test_assert (pos == 0);
     484  n = write (fd, readbuf, len);
     485  rtems_test_assert (n == len);
    483486
    484487  /*
     
    486489   */
    487490
    488   pos=lseek(fd,0,SEEK_SET);
    489   n=read(fd,readbuf,len);
    490   rtems_test_assert(n==len);
    491   for (i=0;i<n;i++){
    492     rtems_test_assert(readbuf[i]==0);
     491  pos = lseek (fd, 0, SEEK_SET);
     492  n = read (fd, readbuf, len);
     493  rtems_test_assert (n == len);
     494  for (i = 0; i < n; i++) {
     495    rtems_test_assert (readbuf[i] == 0);
    493496  }
    494497
    495   n=read(fd,readbuf,len);
    496   rtems_test_assert(n==len);
    497   rtems_test_assert(strncmp(databuf,readbuf,len)==0);
     498  n = read (fd, readbuf, len);
     499  rtems_test_assert (n == len);
     500  rtems_test_assert (strncmp (databuf, readbuf, len) == 0);
    498501  /*
    499502   * Call ftruncate to decrease the file and the position not change
    500503   */
    501   status=ftruncate(fd,len);
    502   rtems_test_assert(status==0);
    503   pos=lseek(fd,0,SEEK_CUR);
    504   rtems_test_assert(pos==len*2);
    505 
    506   status=close(fd);
    507   rtems_test_assert(status==0);
     504  status = ftruncate (fd, len);
     505  rtems_test_assert (status == 0);
     506  pos = lseek (fd, 0, SEEK_CUR);
     507  rtems_test_assert (pos == len * 2);
     508
     509  status = close (fd);
     510  rtems_test_assert (status == 0);
    508511  /*
    509512   * Go back to parent directory
    510513   */
    511   status=chdir("..");
    512   rtems_test_assert(status==0);
     514  status = chdir ("..");
     515  rtems_test_assert (status == 0);
    513516
    514517}
    515 void test(void )
     518
     519void
     520test (void)
    516521{
    517   read_write_test();
    518   lseek_test();
     522  read_write_test ();
     523  lseek_test ();
    519524}
  • testsuites/fstests/fssymlink/test.c

    rf8d760b r6fed43e  
    2525
    2626/*
    27  * Test the function of symlink 
     27 * Test the function of symlink
    2828 */
    2929
     
    3838  size_t   len=strlen(file01);
    3939  size_t   name_len;
    40  
     40
    4141
    4242  printf("Create a file named %s\n",file01);
     
    5959  rtems_test_assert(len==statbuf.st_size);
    6060
    61  
     61
    6262  puts("call readlink ");
    6363  name_len=readlink(symlink_file01,name,sizeof(name)-1);
     
    6868
    6969  puts("Unlink the file");
    70  
     70
    7171  status=unlink(file01);
    7272  rtems_test_assert(status==0);
     
    7676  rtems_test_assert(S_ISLNK(statbuf.st_mode));
    7777  rtems_test_assert(len==statbuf.st_size);
    78  
     78
    7979  puts("call readlink ");
    8080  name_len=readlink(symlink_file01,name,sizeof(name)-1);
     
    8787  printf("Create a dir named %s\n",file01);
    8888  status=mkdir (file01,0777);
    89  
     89
    9090  printf("Create a symlink named %s to %s\n",symlink_file01,file01);
    9191  status=symlink(file01,symlink_file01);
     
    9797  rtems_test_assert(len==statbuf.st_size);
    9898
    99  
     99
    100100  puts("call readlink ");
    101101  name_len=readlink(symlink_file01,name,sizeof(name)-1);
     
    142142  status=symlink(file02,file01);
    143143  rtems_test_assert(status==0);
    144  
     144
    145145
    146146  EXPECT_ERROR(ELOOP,creat,path,mode);
  • testsuites/fstests/fstime/test.c

    rf8d760b r6fed43e  
    8181
    8282  /*
    83    * Make sure they are the same 
     83   * Make sure they are the same
    8484   */
    8585
     
    9999
    100100  /*
    101    * Make sure they are the same 
     101   * Make sure they are the same
    102102   */
    103103  rtems_test_assert (TIME_EQUAL (ctime1, mtime1));
     
    113113
    114114  /*
    115    * Create an empty directory 
     115   * Create an empty directory
    116116   */
    117117  status = mkdir (dir01, mode);
     
    134134   *   descriptions associated with the file. Upon successful completion,
    135135   *   if the file size is changed, this function shall mark for update
    136    *   the st_ctime and st_mtime fields of the file 
    137    */
    138 
    139   /*
    140    * file01 shall not update 
     136   *   the st_ctime and st_mtime fields of the file
     137   */
     138
     139  /*
     140   * file01 shall not update
    141141   */
    142142  status = stat (file01, &statbuf);
     
    161161
    162162  /*
    163    *  Upon successful completion, mkdir() shall mark for update the 
     163   *  Upon successful completion, mkdir() shall mark for update the
    164164   *  5st_atime, st_ctime, and st_mtime fields of the directory.
    165165   *  Also, the st_ctime and st_mtime fields of the directory that
     
    253253
    254254/*
    255  * These tests only get time_t value, and test 
     255 * These tests only get time_t value, and test
    256256 * if they are changed. Thest tests don't check atime
    257257 */
  • testsuites/fstests/mdosfs_support/fs_config.h

    rf8d760b r6fed43e  
    1616
    1717#define FILESYSTEM "MOUNTED DOSFS"
    18 #define BASE_FOR_TEST "/mnt/"
    1918
    2019#endif
  • testsuites/fstests/mdosfs_support/fs_support.c

    rf8d760b r6fed43e  
    2121#include <rtems/libio.h>
    2222#include <rtems/dosfs.h>
     23
    2324#include "ramdisk_support.h"
     25#include "fstest.h"
    2426
    2527#define BLOCK_SIZE 512
  • testsuites/fstests/mimfs_support/fs_support.c

    rf8d760b r6fed43e  
    5454#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
    5555
    56 #define CONFIGURE_MAXIMUM_TASKS                  10 
     56#define CONFIGURE_MAXIMUM_TASKS                  10
    5757#define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM
    5858#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 40
  • testsuites/fstests/mrfs_support/fs_config.h

    rf8d760b r6fed43e  
    11/*
    2  *  $Id$
     2 *  COPYRIGHT (c) 1989-2011.
     3 *  On-Line Applications Research Corporation (OAR).
     4 *
     5 *  The license and distribution terms for this file may be
     6 *  found in the file LICENSE in this distribution or at
     7 *  http://www.rtems.com/license/LICENSE.
     8 *
     9 *  $Id Exp $
    310 */
    411
  • testsuites/fstests/support/fstest.h

    rf8d760b r6fed43e  
    2323
    2424#define FS_PASS() do {puts("PASS");} while (0)
    25 #define FS_FAIL() do {printf( "FAIL    %s: %d \n", __FILE__, __LINE__ ); } while (0)
     25#define FS_FAIL() do {\
     26  printf( "FAIL   %s: %d \n", __FILE__, __LINE__ );\
     27 } while (0)
    2628
    2729
     
    5658
    5759#define BASE_FOR_TEST "/mnt"
    58 #endif 
     60#endif
    5961
    6062
  • testsuites/fstests/support/fstest_support.c

    rf8d760b r6fed43e  
    99 *  $Id Exp $
    1010 */
    11 
    12 #include <stdio.h> 
    13 #include <errno.h> 
    14 #include <fcntl.h> 
    15 #include <string.h> 
    16 #include <unistd.h> 
    17 #include <sys/stat.h> 
    18 #include <sys/types.h> 
     11#include <stdio.h>
     12#include <errno.h>
     13#include <fcntl.h>
     14#include <string.h>
     15#include <unistd.h>
     16#include <sys/stat.h>
     17#include <sys/types.h>
    1918
    2019#include "rtems.h"
     
    2524#include "fstest.h"
    2625
    27 #define TEMP_DIR "waterbuffalo" 
     26#define TEMP_DIR "waterbuffalo"
    2827
    2928
    30 /* Break out of a chroot() environment in C */ 
     29/* Break out of a chroot() environment in C */
    3130void break_out_of_chroot(void)
    3231{
    3332
    34   int dir_fd;       /* File descriptor to directory */ 
    35   struct stat sbuf; /* The stat() buffer */ 
     33  int dir_fd;       /* File descriptor to directory */
     34  struct stat sbuf; /* The stat() buffer */
    3635  chdir("/");
    3736
    38   if (stat(TEMP_DIR,&sbuf)<0) { 
    39     if (errno==ENOENT) { 
    40       if (mkdir(TEMP_DIR,0755)<0) { 
    41         fprintf(stderr,"Failed to create %s - %s\n", TEMP_DIR, 
    42             strerror(errno)); 
    43         exit(1); 
    44       } 
    45     } else { 
    46       fprintf(stderr,"Failed to stat %s - %s\n", TEMP_DIR, 
    47           strerror(errno)); 
    48       exit(1); 
    49     } 
    50   } else if (!S_ISDIR(sbuf.st_mode)) { 
    51     fprintf(stderr,"Error - %s is not a directory!\n",TEMP_DIR); 
    52     exit(1); 
    53   } 
     37  if (stat(TEMP_DIR,&sbuf)<0) {
     38    if (errno==ENOENT) {
     39      if (mkdir(TEMP_DIR,0755)<0) {
     40        fprintf(stderr,"Failed to create %s - %s\n", TEMP_DIR,
     41            strerror(errno));
     42        exit(1);
     43      }
     44    } else {
     45      fprintf(stderr,"Failed to stat %s - %s\n", TEMP_DIR,
     46          strerror(errno));
     47      exit(1);
     48    }
     49  } else if (!S_ISDIR(sbuf.st_mode)) {
     50    fprintf(stderr,"Error - %s is not a directory!\n",TEMP_DIR);
     51    exit(1);
     52  }
    5453
    55   if ((dir_fd=open(".",O_RDONLY))<0) { 
    56     fprintf(stderr,"Failed to open \".\" for reading - %s\n", strerror(errno)); 
    57     exit(1); 
    58   } 
     54  if ((dir_fd=open(".",O_RDONLY))<0) {
     55    fprintf(stderr,"Failed to open ""."
     56        " for reading - %s\n", strerror(errno));
     57    exit(1);
     58  }
    5959
    60   if (chroot(TEMP_DIR)<0) { 
    61     fprintf(stderr,"Failed to chroot to %s - %s\n",TEMP_DIR, 
    62         strerror(errno)); 
    63     exit(1); 
    64   } 
     60  if (chroot(TEMP_DIR)<0) {
     61    fprintf(stderr,"Failed to chroot to %s - %s\n",TEMP_DIR,
     62        strerror(errno));
     63    exit(1);
     64  }
    6565
    66   if (fchdir(dir_fd)<0) { 
    67     fprintf(stderr,"Failed to fchdir - %s\n", 
    68         strerror(errno)); 
    69     exit(1); 
    70   } 
    71   close(dir_fd); 
    72   chdir(".."); 
    73   chroot("."); 
     66  if (fchdir(dir_fd)<0) {
     67    fprintf(stderr,"Failed to fchdir - %s\n",
     68        strerror(errno));
     69    exit(1);
     70  }
     71  close(dir_fd);
     72  chdir("..");
     73  chroot(".");
    7474
    7575}
    76 
    7776
    7877/*
     
    104103  puts( "*** END OF FILE SYSTEM TEST ( " FILESYSTEM " ) ***" );
    105104  rtems_test_exit(0);
    106 
    107105}
  • testsuites/fstests/support/ramdisk_support.c

    rf8d760b r6fed43e  
    1616#include "fstest.h"
    1717/*
    18  * Ramdisk information 
     18 * Ramdisk information
    1919 */
    2020
    2121dev_t dev = 0;
    2222
    23 void init_ramdisk(void)
     23void
     24init_ramdisk (void)
    2425{
    2526
    26   int rc=0;
    27   rc =rtems_disk_io_initialize();
    28   rtems_test_assert( rc == 0 );
    29   rc =ramdisk_register(RAMDISK_BLOCK_SIZE,RAMDISK_BLOCK_COUNT,\
    30       false,RAMDISK_PATH,&dev);
    31   rtems_test_assert( rc == 0 );
     27  int rc = 0;
     28  rc = rtems_disk_io_initialize ();
     29  rtems_test_assert (rc == 0);
     30  rc = ramdisk_register (RAMDISK_BLOCK_SIZE, RAMDISK_BLOCK_COUNT,
     31                         false, RAMDISK_PATH, &dev);
     32  rtems_test_assert (rc == 0);
    3233
    3334}
    3435
    35 void del_ramdisk(void )
     36void
     37del_ramdisk (void)
    3638{
    37   int rc=0;
    38   rtems_device_major_number major=0;
    39   rtems_device_minor_number minor=0;
    4039
    41   rc=rtems_disk_delete (dev);
    42   rtems_test_assert( rc == 0 );
     40  int rc = 0;
     41  rtems_device_major_number major = 0;
     42  rtems_device_minor_number minor = 0;
    4343
    44   rtems_filesystem_split_dev_t(dev,major,minor);
    45  
    46   rtems_test_assert(major>=0);
    47   rtems_test_assert(minor>=0);
    48  
    49   rc=rtems_io_unregister_driver(major);
    50   rtems_test_assert( rc == 0 );
     44  rc = rtems_disk_delete (dev);
     45  rtems_test_assert (rc == 0);
    5146
    52   rc=rtems_disk_io_done();
    53   rtems_test_assert( rc == 0 );
     47  rtems_filesystem_split_dev_t (dev, major, minor);
     48
     49  rtems_test_assert (major >= 0);
     50  rtems_test_assert (minor >= 0);
     51
     52  rc = rtems_io_unregister_driver (major);
     53  rtems_test_assert (rc == 0);
     54  rc = rtems_disk_io_done ();
     55  rtems_test_assert (rc == 0);
    5456
    5557}
    56 
  • testsuites/fstests/support/ramdisk_support.h

    rf8d760b r6fed43e  
    1414#ifdef HAVE_CONFIG_H
    1515#include "config.h"
    16 #endif 
     16#endif
    1717
    1818#define  RAMDISK_BLOCK_SIZE  (512)
Note: See TracChangeset for help on using the changeset viewer.