forked from Imagelibrary/rtems
* Makefile.am, configure.ac, psx01/Makefile.am, psx02/Makefile.am, psx03/Makefile.am, psx04/Makefile.am, psx05/Makefile.am, psx06/Makefile.am, psx07/Makefile.am, psx08/Makefile.am, psx09/Makefile.am, psx10/Makefile.am, psx11/Makefile.am, psx12/Makefile.am, psx13/Makefile.am, psx14/Makefile.am, psxalarm01/Makefile.am, psxautoinit01/Makefile.am, psxautoinit02/Makefile.am, psxbarrier01/Makefile.am, psxcancel/Makefile.am, psxcancel01/Makefile.am, psxchroot01/Makefile.am, psxcleanup/Makefile.am, psxcleanup01/Makefile.am, psxclock/Makefile.am, psxcond01/Makefile.am, psxenosys/Makefile.am, psxfatal01/Makefile.am, psxfatal02/Makefile.am, psxfile01/Makefile.am, psxfile02/init.c, psxfile02/psxfile02.doc, psxfile02/psxfile02.scn, psxintrcritical01/Makefile.am, psxitimer/Makefile.am, psxkey01/Makefile.am, psxkey02/Makefile.am, psxkey03/Makefile.am, psxmount/Makefile.am, psxmsgq01/Makefile.am, psxmsgq02/Makefile.am, psxmsgq03/Makefile.am, psxmsgq04/Makefile.am, psxmutexattr01/Makefile.am, psxobj01/Makefile.am, psxpasswd01/Makefile.am, psxrdwrv/Makefile.am, psxreaddir/Makefile.am, psxrwlock01/Makefile.am, psxsem01/Makefile.am, psxsignal01/Makefile.am, psxsignal02/Makefile.am, psxsignal03/Makefile.am, psxsignal04/Makefile.am, psxsignal05/Makefile.am, psxspin01/Makefile.am, psxspin02/Makefile.am, psxstack01/Makefile.am, psxstat/Makefile.am, psxsysconf/Makefile.am, psxtime/Makefile.am, psxtimer01/Makefile.am, psxtimer02/Makefile.am, psxualarm/Makefile.am, psxusleep/Makefile.am: Add test for fd greater than number of file descriptors configured.
147 lines
3.7 KiB
C
147 lines
3.7 KiB
C
/*
|
|
* COPYRIGHT (c) 1989-2010.
|
|
* On-Line Applications Research Corporation (OAR).
|
|
*
|
|
* The license and distribution terms for this file may be
|
|
* found in the file LICENSE in this distribution or at
|
|
* http://www.rtems.com/license/LICENSE.
|
|
*
|
|
* $Id$
|
|
*/
|
|
#include <stdio.h>
|
|
#include <sys/uio.h>
|
|
#include <sys/types.h>
|
|
#include <sys/stat.h>
|
|
#include <fcntl.h>
|
|
#include <unistd.h>
|
|
#include <errno.h>
|
|
#include <string.h>
|
|
#include <ctype.h>
|
|
#include <rtems/imfs.h>
|
|
#include <reent.h>
|
|
|
|
#include <rtems.h>
|
|
#include <rtems/libio.h>
|
|
|
|
#include <tmacros.h>
|
|
#include "test_support.h"
|
|
|
|
void do_with_fd(
|
|
int fd,
|
|
const char *description
|
|
)
|
|
{
|
|
struct stat stat_buff;
|
|
struct iovec vec[4];
|
|
off_t res;
|
|
int status;
|
|
|
|
printf("ftruncate %s\n", description);
|
|
status = ftruncate(fd, 40);
|
|
rtems_test_assert( status == -1 );
|
|
printf( "%d: %s\n", errno, strerror( errno ) );
|
|
rtems_test_assert( errno == EBADF );
|
|
|
|
printf("_fcntl_r %s\n", description);
|
|
status = _fcntl_r( NULL, fd, F_SETFD, 1 );
|
|
rtems_test_assert( status == -1 );
|
|
printf( "%d: %s\n", errno, strerror( errno ) );
|
|
rtems_test_assert( errno == EBADF );
|
|
|
|
printf("fdatasync %s\n", description);
|
|
status = fdatasync( fd );
|
|
rtems_test_assert( status == -1 );
|
|
printf( "%d: %s\n", errno, strerror( errno ) );
|
|
rtems_test_assert( errno == EBADF );
|
|
|
|
printf("fstat %s\n", description);
|
|
status = fstat( fd, &stat_buff );
|
|
rtems_test_assert( status == -1 );
|
|
printf( "%d: %s\n", errno, strerror( errno ) );
|
|
rtems_test_assert( errno == EBADF );
|
|
|
|
printf("fsync %s\n", description);
|
|
status = fsync( fd );
|
|
rtems_test_assert( status == -1 );
|
|
printf( "%d: %s\n", errno, strerror( errno ) );
|
|
rtems_test_assert( errno == EBADF );
|
|
|
|
printf("ioctl %s\n", description);
|
|
status = ioctl( fd, 0 );
|
|
rtems_test_assert( status == -1 );
|
|
printf( "%d: %s\n", errno, strerror( errno ) );
|
|
rtems_test_assert( errno == EBADF );
|
|
|
|
printf("_lseek_r %s\n", description);
|
|
res = _lseek_r (NULL, fd, 0, SEEK_SET);
|
|
rtems_test_assert( res == -1 );
|
|
printf( "%d: %s\n", errno, strerror( errno ) );
|
|
rtems_test_assert( errno == EBADF );
|
|
|
|
printf("readv %s\n", description);
|
|
status = readv(fd, vec, 4);
|
|
rtems_test_assert( status == -1 );
|
|
printf( "%d: %s\n", errno, strerror( errno ) );
|
|
rtems_test_assert( errno == EBADF );
|
|
|
|
printf("writev %s\n", description);
|
|
status = writev(fd, vec, 4);
|
|
rtems_test_assert( status == -1 );
|
|
printf( "%d: %s\n", errno, strerror( errno ) );
|
|
rtems_test_assert( errno == EBADF );
|
|
|
|
printf("write %s\n", description);
|
|
status = write(fd, "1234", 4);
|
|
rtems_test_assert( status == -1 );
|
|
printf( "%d: %s\n", errno, strerror( errno ) );
|
|
rtems_test_assert( errno == EBADF );
|
|
}
|
|
|
|
rtems_task Init(
|
|
rtems_task_argument argument
|
|
)
|
|
{
|
|
int status;
|
|
int fd;
|
|
|
|
puts( "\n\n*** PSXFILE02 TEST ***" );
|
|
|
|
/*
|
|
* Simple open case where the file is created.
|
|
*/
|
|
puts( "mkdir /tmp" );
|
|
status = mkdir( "/tmp", S_IRWXU );
|
|
rtems_test_assert( !status );
|
|
|
|
puts( "open /tmp/j" );
|
|
fd = open( "/tmp/j", O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO );
|
|
rtems_test_assert( fd != -1 );
|
|
printf( "open returned file descriptor %d\n", fd );
|
|
|
|
puts( "close /tmp/j" );
|
|
status = close( fd );
|
|
rtems_test_assert( !status );
|
|
|
|
do_with_fd( fd, "an unopened file" );
|
|
puts("");
|
|
do_with_fd( 1000, "a too large file descriptor" );
|
|
|
|
puts( "*** END OF PSXFILE02 TEST ***" );
|
|
|
|
rtems_test_exit(0);
|
|
}
|
|
|
|
/* configuration information */
|
|
|
|
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
|
|
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
|
|
#define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM
|
|
#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 4
|
|
#define CONFIGURE_MAXIMUM_TASKS 1
|
|
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
|
|
|
|
#define CONFIGURE_INIT
|
|
|
|
#include <rtems/confdefs.h>
|
|
/* end of file */
|