source: rtems/testsuites/psxtests/psxfile01/test_extend.c @ 2317457

4.104.115
Last change on this file since 2317457 was 2317457, checked in by Joel Sherrill <joel.sherrill@…>, on 12/08/09 at 17:52:53

2009-12-08 Joel Sherrill <joel.sherrill@…>

  • include/pmacros.h, psx01/task.c, psx02/init.c, psx02/task.c, psx03/init.c, psx03/task.c, psx04/init.c, psx04/task1.c, psx04/task2.c, psx04/task3.c, psx05/init.c, psx05/task.c, psx05/task2.c, psx05/task3.c, psx06/init.c, psx06/task.c, psx06/task2.c, psx07/init.c, psx08/init.c, psx08/task2.c, psx08/task3.c, psx09/init.c, psx10/init.c, psx10/task.c, psx10/task2.c, psx10/task3.c, psx11/init.c, psx11/task.c, psx12/init.c, psxalarm01/init.c, psxbarrier01/test.c, psxcancel01/init.c, psxchroot01/test.c, psxclock/init.c, psxfile01/test.c, psxfile01/test_cat.c, psxfile01/test_extend.c, psxfile01/test_write.c, psxitimer/init.c, psxkey01/task.c, psxkey02/init.c, psxkey03/init.c, psxmount/test.c, psxmsgq01/init.c, psxmsgq03/init.c, psxmsgq04/init.c, psxreaddir/test.c, psxrwlock01/test.c, psxsem01/init.c, psxsignal01/init.c, psxsignal01/task1.c, psxsignal02/init.c, psxsignal03/init.c, psxsignal05/init.c, psxspin01/test.c, psxspin02/test.c, psxstack01/init.c, psxstat/test.c, psxtime/test.c, psxualarm/init.c: Use rtems_test_assert() consistently instead of system assert(). rtems_test_assert() is designed to integrate into the RTEMS test suite infrastructure.
  • Property mode set to 100644
File size: 1.5 KB
Line 
1/*
2 *  A test support function which extends the file to the specified
3 *  length.  This handles the implied open(), lseek(), write(), and close()
4 *  operations.
5 *
6 *  The defined behavior is a seek() followed by a write() extends the file
7 *  and zero fills the new length part.
8 *
9 *  COPYRIGHT (c) 1989-2009.
10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.rtems.com/license/LICENSE.
15 *
16 *  $Id$
17 */
18
19#include <stdio.h>
20
21#include <sys/types.h>
22#include <sys/stat.h>
23#include <fcntl.h>
24#include <unistd.h>
25#include <errno.h>
26#include <string.h>
27#include <ctype.h>
28
29#include <pmacros.h>
30
31/*
32 *  test_extend routine
33 */
34
35void test_extend(
36  char   *file,
37  off_t  offset
38)
39{
40  int   fd;
41  int   status;
42  char  c = 0;
43
44  fd = open( file, O_WRONLY );
45  if ( fd == -1 ) {
46    printf( "test_extend: open( %s ) failed : %s\n", file, strerror( errno ) );
47    rtems_test_exit( 0 );
48  }
49
50  status = lseek( fd, offset - 1, SEEK_SET );
51  rtems_test_assert( status != -1 );
52
53  status = write( fd, &c, 1 );
54  if ( status == -1 ) {
55    printf( "test_extend: write( %s ) failed : %s\n", file, strerror( errno ) );
56    rtems_test_exit( 0 );
57  }
58
59  if ( status != 1 ) {
60    printf( "test_extend: write( %s ) only wrote %d of %d bytes\n",
61            file, status, 1 );
62    rtems_test_exit( 0 );
63  }
64
65  status = close( fd );
66  rtems_test_assert( !status );
67}
Note: See TracBrowser for help on using the repository browser.