source: rtems/testsuites/libtests/devfs04/init.c @ 610b9ef1

5
Last change on this file since 610b9ef1 was 610b9ef1, checked in by Sebastian Huber <sebastian.huber@…>, on 09/19/16 at 05:51:07

libtests/devfs: Use printk()

This avoids problems with console drivers that use generic nodes of the
IMFS.

  • Property mode set to 100644
File size: 2.7 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#define TESTS_USE_PRINTK
15#include <tmacros.h>
16#include "test_support.h"
17#include <rtems/devfs.h>
18#include <errno.h>
19#include <unistd.h>
20#include <sys/types.h>
21#include <sys/stat.h>
22#include <fcntl.h>
23#include "test_driver.h"
24#include <rtems/devnull.h>
25
26const char rtems_test_name[] = "DEVFS 4";
27
28/* forward declarations to avoid warnings */
29rtems_task Init(rtems_task_argument argument);
30
31rtems_task Init(
32  rtems_task_argument argument
33)
34{
35  int status;
36  int fdr = 0, fdw = 0;
37  char buf[10];
38
39  TEST_BEGIN();
40
41  puts( "Init - attempt to open the /dev/test WR mode -- OK" );
42  fdw = open( "/dev/test", O_WRONLY );
43  rtems_test_assert( fdw != -1 );
44 
45  puts( "Init - attempt to write to /dev/test -- OK" );
46  status = write( fdw, "data", 5 );
47  rtems_test_assert( status == 5 );
48
49  puts( "Init - attempt to write to /dev/test - expect ENOSYS" );
50  status = write( fdw, "data", 10 );
51  rtems_test_assert( status == -1 );
52  rtems_test_assert( errno == ENOSYS );
53
54  puts( "Init - attempt to open the /dev/test RD mode -- OK" );
55  fdr = open( "/dev/test", O_RDONLY );
56  rtems_test_assert( fdr != -1 );
57
58  puts( "Init - attempt to read from /dev/test -- OK" );
59  status = read( fdr, buf, 5 );
60  rtems_test_assert( status == 0 );
61
62  puts( "Init - attempt to read from /dev/test - expect ENOSYS" );
63  status = read( fdr, buf, 10 );
64  rtems_test_assert( status == -1 );
65  rtems_test_assert( errno == ENOSYS );
66
67  puts( "Init - attempt ioctl on the device - expect ENOSYS" );
68  status = ioctl( fdr, -1 );
69  rtems_test_assert( status == -1 );
70  rtems_test_assert( errno == ENOSYS );
71
72  puts( "Init - mknod(/dev/null)-- OK" );
73  status = mknod( "/dev/null", 0777 | S_IFCHR, 0LL );
74  rtems_test_assert( status == 0 );
75
76  TEST_END();
77  rtems_test_exit(0);
78}
79
80/* configuration information */
81
82#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
83#define CONFIGURE_APPLICATION_EXTRA_DRIVERS TEST_DRIVER_TABLE_ENTRY
84
85/* include an extra slot for registering the termios one dynamically */
86#define CONFIGURE_MAXIMUM_DRIVERS 3
87
88#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 2
89
90#define CONFIGURE_MAXIMUM_TASKS             1
91#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
92
93#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
94
95/* Make sure that we have enough devices for all BSPs */
96#define CONFIGURE_MAXIMUM_DEVICES 64
97
98#define CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM
99
100#define CONFIGURE_INIT
101#include <rtems/confdefs.h>
102/* end of file */
Note: See TracBrowser for help on using the repository browser.