source: rtems/testsuites/libtests/deviceio01/init.c @ c4b8b147

5
Last change on this file since c4b8b147 was c4b8b147, checked in by Sebastian Huber <sebastian.huber@…>, on 11/03/17 at 07:35:38

tests: Use simple console driver

Update #3170.
Update #3199.

  • Property mode set to 100644
File size: 2.2 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2012.
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.org/license/LICENSE.
8 */
9
10#ifdef HAVE_CONFIG_H
11#include "config.h"
12#endif
13
14#include <tmacros.h>
15#include "test_support.h"
16#include <rtems/devfs.h>
17#include <errno.h>
18#include <unistd.h>
19#include <sys/types.h>
20#include <sys/stat.h>
21#include <fcntl.h>
22#include "test_driver.h"
23#include <rtems/devnull.h>
24
25const char rtems_test_name[] = "DEVICEIO 1";
26
27/* forward declarations to avoid warnings */
28rtems_task Init(rtems_task_argument argument);
29
30rtems_task Init(
31  rtems_task_argument argument
32)
33{
34  int status;
35  int fdr = 0, fdw = 0;
36  char buf[10];
37
38  TEST_BEGIN();
39
40  puts( "Init - attempt to open the /dev/test WR mode -- OK" );
41  fdw = open( "/dev/test", O_WRONLY );
42  rtems_test_assert( fdw != -1 );
43 
44  puts( "Init - attempt to write to /dev/test - expect ENOSYS" );
45  status = write( fdw, "data", 10 );
46  rtems_test_assert( status == -1 );
47  rtems_test_assert( errno == ENOSYS );
48
49  puts( "Init - attempt to open the /dev/test RD mode -- OK" );
50  fdr = open( "/dev/test", O_RDONLY );
51  rtems_test_assert( fdr != -1 );
52
53  puts( "Init - attempt to read from /dev/test - expect ENOSYS" );
54  status = read( fdr, buf, 10 );
55  rtems_test_assert( status == -1 );
56  rtems_test_assert( errno == ENOSYS );
57
58  puts( "Init - attempt ioctl on the device - expect ENOSYS" );
59  status = ioctl( fdr, -1 );
60  rtems_test_assert( status == -1 );
61  rtems_test_assert( errno == ENOSYS );
62
63  TEST_END();
64  rtems_test_exit(0);
65}
66
67/* configuration information */
68
69#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
70#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
71#define CONFIGURE_APPLICATION_EXTRA_DRIVERS TEST_DRIVER_TABLE_ENTRY
72
73/* include an extra slot for registering the termios one dynamically */
74#define CONFIGURE_MAXIMUM_DRIVERS 3
75
76#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 5
77
78#define CONFIGURE_MAXIMUM_TASKS             1
79#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
80
81#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
82
83#define CONFIGURE_INIT
84#include <rtems/confdefs.h>
85/* end of file */
Note: See TracBrowser for help on using the repository browser.