source: rtems/testsuites/sptests/spfifo04/init.c @ d5d071d

Last change on this file since d5d071d was d5d071d, checked in by Sebastian Huber <sebastian.huber@…>, on 05/14/12 at 07:06:58

Merge branch 'upstream'

  • Property mode set to 100644
File size: 2.4 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2010.
3 *  On-Line Applications Research Corporation (OAR).
4 *
5 *  The license and distribution terms for this file may be
6 *  found in the file LICENSE in this distribution or at
7 *  http://www.rtems.com/license/LICENSE.
8 */
9
10#ifdef HAVE_CONFIG_H
11#include "config.h"
12#endif
13
14#include <bsp.h>
15#include <tmacros.h>
16#include <stdio.h>
17#include <sys/types.h>
18#include <sys/stat.h>
19#include <fcntl.h>
20#include <unistd.h>
21#include <errno.h>
22
23#include <rtems.h>
24#include <rtems/libio.h>
25
26#define SEND_RCV_BUFSIZ 12
27
28rtems_task Init(
29  rtems_task_argument not_used
30)
31{
32  int fd = -1;
33  int status = -1;
34  off_t offset = 4;
35  int pipe_length = -1;
36  int flag = 1;
37
38  puts( "\n\n*** TEST PIPE/FIFO - 04 ***" );
39
40  puts( "Init - Creating /fifo" );
41  status = mkfifo( "/fifo", 0777 );
42  rtems_test_assert( status == 0 );
43 
44  puts( "Init - Opening /fifo in readonly, non-blocking mode" );
45  fd = open( "/fifo", O_RDONLY | O_NONBLOCK );
46  rtems_test_assert( fd != -1 );
47 
48  puts( "Init - Attempt to lseek on fifo -- Expected ESPIPE" );
49  offset = lseek( fd, offset, SEEK_CUR );
50  rtems_test_assert( offset == -1 );
51  rtems_test_assert( errno == ESPIPE );
52
53  puts( "Init - ioctl: FIONBIO -- OK" );
54  status = ioctl( fd, FIONBIO, &flag );
55  rtems_test_assert( status == 0 );
56 
57  flag = 0;
58  puts( "Init - ioctl: FIONBIO -- OK" );
59  status = ioctl( fd, FIONBIO, &flag );
60  rtems_test_assert( status == 0 );
61
62  puts( "Init - ioctl: Dummy Command -- Expected EINVAL" );
63  status = ioctl( fd, -1 );
64  rtems_test_assert( status == -1 );
65  rtems_test_assert( errno == EINVAL );
66
67  puts( "Init - ioctl: FIONREAD -- OK" );
68  status = ioctl( fd, FIONREAD, &pipe_length );
69  rtems_test_assert( status == 0 );
70  rtems_test_assert( pipe_length == 0 );
71 
72  puts( "Init - closing /fifo" );
73  status = close( fd );
74  rtems_test_assert( status == 0 );
75 
76  puts( "Init - removing /fifo" );
77  status = unlink( "/fifo" );
78  rtems_test_assert( status == 0 );
79
80  puts( "*** END OF TEST PIPE/FIFO - 04 ***" );
81  rtems_test_exit(0);
82}
83
84#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
85#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
86
87#define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM
88#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 6
89
90#define CONFIGURE_MAXIMUM_TASKS 3
91#define CONFIGURE_MAXIMUM_BARRIERS 1
92#define CONFIGURE_MAXIMUM_FIFOS 1
93
94#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
95
96#define CONFIGURE_FIFOS_ENABLED
97
98#define CONFIGURE_INIT
99#include <rtems/confdefs.h>
100/* end of file */
Note: See TracBrowser for help on using the repository browser.