source: rtems/testsuites/libtests/devfs04/init.c @ acc9d064

5
Last change on this file since acc9d064 was acc9d064, checked in by Sebastian Huber <sebastian.huber@…>, on 10/26/17 at 11:59:10

tests: Remove obsolete TESTS_USE_PRINTK

Update #3170.
Update #3199.

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