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

4.104.114.84.95
Last change on this file since d802489 was d802489, checked in by Joel Sherrill <joel.sherrill@…>, on 08/02/02 at 00:53:21

2002-08-01 Joel Sherrill <joel@…>

  • Per PR47 add support for buffered test output. This involved adding defines to redirect output to a buffer and dump it when full, at "test pause", and at exit. To avoid problems when redefining exit(), all tests were modified to call rtems_test_exit(). Some tests, notable psxtests, had to be modified to include the standard test macro .h file (pmacros.h or tmacros.h) to enable this support.
  • include/pmacros.h, psx01/task.c, psx02/init.c, psx02/task.c, psx03/init.c, psx04/init.c, psx05/init.c, psx06/init.c, psx07/init.c, psx08/task3.c, psx09/init.c, psx10/init.c, psx11/init.c, psx12/init.c, psx13/Makefile.am, psx13/main.c, psx13/test.c, psxcancel/init.c, psxchroot01/Makefile.am, psxchroot01/main.c, psxchroot01/test.c, psxfile01/Makefile.am, psxfile01/main.c, psxfile01/test.c, psxfile01/test_cat.c, psxfile01/test_extend.c, psxfile01/test_write.c, psxmount/Makefile.am, psxmount/main.c, psxmount/test.c, psxmsgq01/init.c, psxreaddir/Makefile.am, psxreaddir/main.c, psxreaddir/test.c, psxsem01/init.c, psxstat/Makefile.am, psxstat/main.c, psxstat/test.c, psxtime/main.c, psxtime/test.c, psxtimer/psxtimer.c: Modified.
  • Property mode set to 100644
File size: 1.2 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 *  $Id$
10 */
11
12#include <stdio.h>
13
14#include <sys/types.h>
15#include <sys/stat.h>
16#include <fcntl.h>
17#include <unistd.h>
18#include <errno.h>
19#include <string.h>
20#include <ctype.h>
21
22#include <assert.h>
23
24#include <pmacros.h>
25
26/*
27 *  test_extend routine
28 */
29
30void test_extend(
31  char   *file,
32  off_t  offset
33)
34{
35  int   fd;
36  int   status;
37  char  c = 0;
38
39  fd = open( file, O_WRONLY );
40  if ( fd == -1 ) {
41    printf( "test_extend: open( %s ) failed : %s\n", file, strerror( errno ) );
42    rtems_test_exit( 0 );
43  }
44
45  status = lseek( fd, offset - 1, SEEK_SET );
46  assert( status != -1 );
47
48  status = write( fd, &c, 1 );
49  if ( status == -1 ) {
50    printf( "test_extend: write( %s ) failed : %s\n", file, strerror( errno ) );
51    rtems_test_exit( 0 );
52  }
53
54  if ( status != 1 ) {
55    printf( "test_extend: write( %s ) only wrote %d of %d bytes\n",
56            file, status, 1 );
57    rtems_test_exit( 0 );
58  }
59
60  status = close( fd );
61  assert( !status );
62}
Note: See TracBrowser for help on using the repository browser.