File indexing completed on 2025-05-11 08:24:47
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029 #ifdef HAVE_CONFIG_H
0030 #include "config.h"
0031 #endif
0032
0033 #include <bsp.h>
0034 #include <tmacros.h>
0035 #include <stdio.h>
0036 #include <sys/types.h>
0037 #include <sys/stat.h>
0038 #include <sys/ioctl.h>
0039 #include <fcntl.h>
0040 #include <unistd.h>
0041 #include <errno.h>
0042
0043 #include <rtems.h>
0044 #include <rtems/libio.h>
0045
0046 const char rtems_test_name[] = "SPFIFO 4";
0047
0048
0049 rtems_task Init(rtems_task_argument argument);
0050
0051 #define SEND_RCV_BUFSIZ 12
0052
0053 rtems_task Init(
0054 rtems_task_argument not_used
0055 )
0056 {
0057 int fd = -1;
0058 int status = -1;
0059 off_t offset = 4;
0060 int pipe_length = -1;
0061 int flag = 1;
0062
0063 TEST_BEGIN();
0064
0065 puts( "Init - Creating /fifo" );
0066 status = mkfifo( "/fifo", 0777 );
0067 rtems_test_assert( status == 0 );
0068
0069 puts( "Init - Opening /fifo in readonly, non-blocking mode" );
0070 fd = open( "/fifo", O_RDONLY | O_NONBLOCK );
0071 rtems_test_assert( fd != -1 );
0072
0073 puts( "Init - Attempt to lseek on fifo -- Expected ESPIPE" );
0074 offset = lseek( fd, offset, SEEK_CUR );
0075 rtems_test_assert( offset == -1 );
0076 rtems_test_assert( errno == ESPIPE );
0077
0078 puts( "Init - ioctl: FIONBIO -- Expected EFAULT" );
0079 status = ioctl( fd, FIONBIO, NULL );
0080 rtems_test_assert( status == -1 );
0081 rtems_test_assert( errno == EFAULT );
0082
0083 puts( "Init - ioctl: FIONBIO -- OK" );
0084 status = ioctl( fd, FIONBIO, &flag );
0085 rtems_test_assert( status == 0 );
0086
0087 flag = 0;
0088 puts( "Init - ioctl: FIONBIO -- OK" );
0089 status = ioctl( fd, FIONBIO, &flag );
0090 rtems_test_assert( status == 0 );
0091
0092 puts( "Init - ioctl: Dummy Command -- Expected EINVAL" );
0093 status = ioctl( fd, -1, NULL );
0094 rtems_test_assert( status == -1 );
0095 rtems_test_assert( errno == EINVAL );
0096
0097 puts( "Init - ioctl: FIONREAD -- Expected EFAULT" );
0098 status = ioctl( fd, FIONREAD, NULL );
0099 rtems_test_assert( status == -1 );
0100 rtems_test_assert( errno == EFAULT );
0101
0102 puts( "Init - ioctl: FIONREAD -- OK" );
0103 status = ioctl( fd, FIONREAD, &pipe_length );
0104 rtems_test_assert( status == 0 );
0105 rtems_test_assert( pipe_length == 0 );
0106
0107 puts( "Init - closing /fifo" );
0108 status = close( fd );
0109 rtems_test_assert( status == 0 );
0110
0111 puts( "Init - removing /fifo" );
0112 status = unlink( "/fifo" );
0113 rtems_test_assert( status == 0 );
0114
0115 TEST_END();
0116 rtems_test_exit(0);
0117 }
0118
0119 #define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
0120 #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
0121
0122 #define CONFIGURE_MAXIMUM_FILE_DESCRIPTORS 6
0123
0124 #define CONFIGURE_MAXIMUM_TASKS 3
0125
0126 #define CONFIGURE_IMFS_ENABLE_MKFIFO
0127
0128 #define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
0129
0130 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
0131
0132 #define CONFIGURE_INIT
0133 #include <rtems/confdefs.h>
0134