Changeset 25f814c in rtems


Ignore:
Timestamp:
May 11, 2012, 11:22:48 AM (7 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
be366508
Parents:
86ef0df
git-author:
Sebastian Huber <sebastian.huber@…> (05/11/12 11:22:48)
git-committer:
Sebastian Huber <sebastian.huber@…> (05/11/12 11:58:44)
Message:

fstests/fsrdwr: Avoid copy and paste

File:
1 edited

Legend:

Unmodified
Added
Removed
  • testsuites/fstests/fsrdwr/init.c

    r86ef0df r25f814c  
    2727#include "pmacros.h"
    2828
    29 const char *databuf =
     29static const mode_t mode = S_IRWXU | S_IRWXG | S_IRWXO;
     30
     31static const char databuf [] =
    3032  "Happy days are here again.  Happy days are here again.1Happy "
    3133  "days are here again.2Happy days are here again.3Happy days are here again."
    3234  "4Happy days are here again.5Happy days are here again.6Happy days are here "
    3335  "again.7Happy days are here again.";
     36
     37static const size_t len = sizeof (databuf) - 1;
     38
     39static void
     40test_case_enter (const char *wd)
     41{
     42  int status;
     43
     44  printf ("test case: %s\n", wd);
     45
     46  status = mkdir (wd, mode);
     47  rtems_test_assert (status == 0);
     48
     49  status = chdir (wd);
     50  rtems_test_assert (status == 0);
     51}
     52
     53static void
     54test_case_leave (void)
     55{
     56  int status;
     57
     58  status = chdir ("..");
     59  rtems_test_assert (status == 0);
     60}
    3461
    3562static void
     
    4370  struct stat statbuf;
    4471  char *readbuf;
    45   size_t len = strlen (databuf);
    4672  off_t pos = 0;
    4773
    4874  int n;
    49   mode_t mode = S_IRWXU | S_IRWXG | S_IRWXO;
    50 
    51 
    52   const char *wd = __func__;
    53 
    54   /*
    55    * Create a new directory and change the current directory to  this
    56    */
    57   status = mkdir (wd, mode);
    58   rtems_test_assert (status == 0);
    59   status = chdir (wd);
    60   rtems_test_assert (status == 0);
     75
     76  test_case_enter (__func__);
     77
    6178  /*
    6279   * Create an empty file
     
    186203  free (readbuf);
    187204
    188   /*
    189    * Go back to parent directory
    190    */
    191   status = chdir ("..");
    192   rtems_test_assert (status == 0);
     205  test_case_leave ();
    193206}
    194207
     
    206219  int i;
    207220
    208   size_t len = strlen (databuf);
    209 
    210221  char *readbuf;
    211222  off_t good_size = 100;
    212   mode_t mode = S_IRWXU | S_IRWXG | S_IRWXO;
    213 
    214 
    215   const char *wd = __func__;
    216 
    217   /*
    218    * Create a new directory and change the current directory to  this
    219    */
    220   status = mkdir (wd, mode);
    221   rtems_test_assert (status == 0);
    222   status = chdir (wd);
    223   rtems_test_assert (status == 0);
     223
     224  test_case_enter (__func__);
    224225
    225226  /*
     
    299300  struct stat statbuf;
    300301
    301   int n;
     302  ssize_t n;
    302303  int i;
    303304
    304   size_t len = strlen (databuf);
    305305  off_t pos;
    306306  ssize_t total_written = 0;
    307307
    308308  char *readbuf;
    309   mode_t mode = S_IRWXU | S_IRWXG | S_IRWXO;
    310 
    311 
    312 
    313   const char *wd = __func__;
    314 
    315   /*
    316    * Create a new directory and change the current directory to this
    317    */
    318   status = mkdir (wd, mode);
    319   rtems_test_assert (status == 0);
    320   status = chdir (wd);
    321   rtems_test_assert (status == 0);
     309
     310  test_case_enter (__func__);
    322311
    323312  /*
     
    526515  status = close (fd);
    527516  rtems_test_assert (status == 0);
    528   /*
    529    * Go back to parent directory
    530    */
    531   status = chdir ("..");
    532   rtems_test_assert (status == 0);
    533 
     517
     518  test_case_leave ();
    534519}
    535520
Note: See TracChangeset for help on using the changeset viewer.