source: rtems/testsuites/libtests/termios03/init.c @ 9b4422a2

4.115
Last change on this file since 9b4422a2 was 9b4422a2, checked in by Joel Sherrill <joel.sherrill@…>, on 05/03/12 at 15:09:24

Remove All CVS Id Strings Possible Using a Script

Script does what is expected and tries to do it as
smartly as possible.

+ remove occurrences of two blank comment lines

next to each other after Id string line removed.

+ remove entire comment blocks which only exited to

contain CVS Ids

+ If the processing left a blank line at the top of

a file, it was removed.

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