Changeset 2f9cef88 in rtems for testsuites/fstests


Ignore:
Timestamp:
Aug 7, 2013, 10:09:51 PM (7 years ago)
Author:
Chris Johns <chrisj@…>
Branches:
4.11, master
Children:
f65e8e6
Parents:
b45b0ff7
git-author:
Chris Johns <chrisj@…> (08/07/13 22:09:51)
git-committer:
Chris Johns <chrisj@…> (08/07/13 22:11:57)
Message:

Check times with a no change truncate via open.

The open path should update the times even if the truncate does not
change the size.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • testsuites/fstests/fstime/test.c

    rb45b0ff7 r2f9cef88  
    3838  char *file01 = "test01";
    3939  char *file02 = "test02";
     40  char *file03 = "test03";
    4041  char *dir01 = "dir01";
    4142
     
    5455
    5556  /*
    56    * Create two files
     57   * Create the test files
    5758   */
    5859  fd = open (file01, O_CREAT | O_WRONLY, mode);
     
    6768  status = close (fd);
    6869  rtems_test_assert (status == 0);
     70
     71  /* A simple C version of touch */
     72  fd = open (file03, O_CREAT | O_WRONLY, mode);
     73  status = close (fd);
     74  rtems_test_assert (status == 0);
     75
    6976  /*
    7077   * If O_CREAT is set and the file did not previously exist, upon
     
    9198  rtems_test_assert (TIME_EQUAL (ctime1, ctime2));
    9299
     100
    93101  status = stat (file02, &statbuf);
    94102  rtems_test_assert (status == 0);
     
    120128  status = mkdir (dir01, mode);
    121129  rtems_test_assert (status == 0);
     130
    122131  /*
    123132   * truncate file01 to len, so it does not changes the file size
     
    130139   */
    131140  status = truncate (file02, len + 1);
     141  rtems_test_assert (status == 0);
     142
     143  /*
     144   * Truncate an empty file which does not change the length.
     145   */
     146  fd = open (file03, O_TRUNC | O_WRONLY, mode);
     147  status = close (fd);
    132148  rtems_test_assert (status == 0);
    133149
     
    138154   *   if the file size is changed, this function shall mark for update
    139155   *   the st_ctime and st_mtime fields of the file
     156   *
     157   *  open with O_TRUNC must update the file fields.
    140158   */
    141159
     
    155173   */
    156174  status = stat (file02, &statbuf);
     175  rtems_test_assert (status == 0);
     176  ctime2 = statbuf.st_ctime;
     177  mtime2 = statbuf.st_mtime;
     178
     179  rtems_test_assert (TIME_EQUAL (ctime2, mtime2));
     180  rtems_test_assert (!TIME_EQUAL (ctime1, mtime2));
     181  rtems_test_assert (!TIME_EQUAL (ctime1, ctime2));
     182
     183  /*
     184   * file03 shall update
     185   */
     186  status = stat (file03, &statbuf);
    157187  rtems_test_assert (status == 0);
    158188  ctime2 = statbuf.st_ctime;
Note: See TracChangeset for help on using the changeset viewer.