mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2025-12-28 23:40:15 +00:00
* 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.
62 lines
1.1 KiB
C
62 lines
1.1 KiB
C
/*
|
|
* A test support function which performs a write() and
|
|
* handles implied open(), lseek(), write(), and close() operations.
|
|
*
|
|
* $Id$
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <sys/types.h>
|
|
#include <sys/stat.h>
|
|
#include <fcntl.h>
|
|
#include <unistd.h>
|
|
#include <errno.h>
|
|
#include <string.h>
|
|
|
|
#include <assert.h>
|
|
|
|
#include <pmacros.h>
|
|
|
|
/*
|
|
* test_write routine
|
|
*/
|
|
|
|
void test_write(
|
|
char *file,
|
|
off_t offset,
|
|
char *buffer
|
|
)
|
|
{
|
|
int fd;
|
|
int status;
|
|
int length;
|
|
|
|
|
|
length = strlen( buffer );
|
|
|
|
fd = open( file, O_WRONLY );
|
|
if ( fd == -1 ) {
|
|
printf( "test_write: open( %s ) failed : %s\n", file, strerror( errno ) );
|
|
rtems_test_exit( 0 );
|
|
}
|
|
|
|
status = lseek( fd, offset, SEEK_SET );
|
|
assert( status != -1 );
|
|
|
|
status = write( fd, buffer, length );
|
|
if ( status == -1 ) {
|
|
printf( "test_write: write( %s ) failed : %s\n", file, strerror( errno ) );
|
|
rtems_test_exit( 0 );
|
|
}
|
|
|
|
if ( status != length ) {
|
|
printf( "test_write: write( %s ) only wrote %d of %d bytes\n",
|
|
file, status, length );
|
|
rtems_test_exit( 0 );
|
|
}
|
|
|
|
status = close( fd );
|
|
assert( !status );
|
|
}
|