source: rtems/testsuites/libtests/termios05/init.c @ 97417bb

5
Last change on this file since 97417bb was 97417bb, checked in by Sebastian Huber <sebastian.huber@…>, on 08/07/18 at 05:09:55

tests: Remove CONFIGURE_MAXIMUM_DRIVERS

This configuration is superfluous in these tests.

  • Property mode set to 100644
File size: 3.9 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 "termios_testdriver_intr.h"
17
18#include <sys/types.h>
19#include <sys/stat.h>
20#include <fcntl.h>
21#include <unistd.h>
22#include <termios.h>
23#include <rtems/dumpbuf.h>
24#include <rtems/termiostypes.h>
25
26const char rtems_test_name[] = "TERMIOS 5";
27
28/* forward declarations to avoid warnings */
29rtems_task Init(rtems_task_argument argument);
30void write_helper(int fd, const char *c);
31void read_helper(int fd, const char *expected);
32void open_it(void);
33void close_it(void);
34void change_iflag(const char *desc, int mask, int new);
35
36void write_helper(
37  int        fd,
38  const char *c
39)
40{
41  size_t   len;
42  int      rc;
43 
44  len = strlen( c );
45  printf( "Writing: %s", c );
46
47  rc = write( fd, c, len );
48  rtems_test_assert( rc == len );
49
50  termios_test_driver_dump_tx("Transmitted");
51}
52
53uint8_t read_helper_buffer[256];
54
55void read_helper(
56  int         fd,
57  const char *expected
58)
59{
60  int    rc;
61  size_t len;
62
63  len = strlen( expected );
64
65  termios_test_driver_set_rx( expected, len );
66  printf( "\nReading (expected):\n" );
67  rtems_print_buffer( (unsigned char *)expected, len-1 );
68
69  rc = read( fd, read_helper_buffer, sizeof(read_helper_buffer) );
70  rtems_test_assert( rc != -1 );
71
72  printf( "Read %d bytes from read(2)\n", rc );
73  rtems_print_buffer( read_helper_buffer, rc );
74
75  termios_test_driver_dump_tx("Echoed");
76}
77
78int Test_fd;
79
80void open_it(void)
81{
82  /* open the file */
83  puts( "open(" TERMIOS_TEST_DRIVER_DEVICE_NAME ") - OK " );
84  Test_fd = open( TERMIOS_TEST_DRIVER_DEVICE_NAME, O_RDWR );
85  rtems_test_assert( Test_fd != -1 );
86}
87
88void close_it(void)
89{
90  int rc;
91
92  puts( "close(" TERMIOS_TEST_DRIVER_DEVICE_NAME ") - OK " );
93  rc = close( Test_fd );
94  rtems_test_assert( rc == 0 );
95}
96
97void change_iflag( const char *desc, int mask, int new )
98{
99  int            rc;
100  struct termios attr;
101
102  printf( "Changing c_iflag to: %s\n", desc );
103  rc = tcgetattr( Test_fd, &attr );
104  rtems_test_assert( rc == 0 );
105
106  attr.c_iflag &= ~mask;
107  attr.c_iflag |= new;
108
109  rc = tcsetattr( Test_fd, TCSANOW, &attr );
110  rtems_test_assert( rc == 0 );
111}
112
113const char ExpectedOutput_1[] = "This is test output.\n";
114const char ExpectedInput_1[] = "Test input this is.\n";
115const char ExpectedInput_2[] = "1235\b456.\n";
116const char ExpectedInput_3[] = "tab\ttab.\n";
117const char ExpectedInput_4[] = "cr\r.";
118const char ExpectedInput_5[] = "aBcDeFgH.\n";
119
120rtems_task Init(
121  rtems_task_argument argument
122)
123{
124  TEST_BEGIN();
125
126  open_it();
127
128  /* some basic cases */
129  write_helper( Test_fd, ExpectedOutput_1 );
130  read_helper( Test_fd, ExpectedInput_1 );
131  read_helper( Test_fd, ExpectedInput_2 );
132  read_helper( Test_fd, ExpectedInput_3 );
133  read_helper( Test_fd, ExpectedInput_4 );
134
135  /* test to lower case input mapping */
136  read_helper( Test_fd, ExpectedInput_5 );
137  change_iflag( "Enable to lower case mapping on input", IUCLC, IUCLC );
138  read_helper( Test_fd, ExpectedInput_5 );
139  change_iflag( "Disable to lower case mapping on input", IUCLC, 0 );
140
141  close_it();
142
143  TEST_END();
144
145  rtems_test_exit(0);
146}
147
148/* configuration information */
149
150#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
151#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
152#define CONFIGURE_APPLICATION_EXTRA_DRIVERS \
153  TERMIOS_TEST_DRIVER_TABLE_ENTRY
154
155/* we need to be able to open the test device */
156#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 4
157
158#define CONFIGURE_MAXIMUM_TASKS             4
159#define CONFIGURE_MAXIMUM_TIMERS            2
160#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
161
162#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
163
164#define CONFIGURE_DISABLE_SMP_CONFIGURATION
165
166#define CONFIGURE_INIT
167
168#include <rtems/confdefs.h>
169/* end of file */
Note: See TracBrowser for help on using the repository browser.