source: rtems/testsuites/libtests/termios07/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.0 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_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/libio.h>
25
26void write_helper(
27  int        fd,
28  const char *c
29)
30{
31  size_t   len;
32  int      rc;
33 
34  len = strlen( c );
35  printf( "Writing: %s", c );
36
37  rc = write( fd, c, len );
38  rtems_test_assert( rc == len );
39
40  termios_test_driver_dump_tx("Transmitted");
41}
42
43uint8_t read_helper_buffer[256];
44
45void read_helper(
46  int         fd,
47  const char *expected
48)
49{
50  int    rc;
51  size_t len;
52
53  len = strlen( expected );
54
55  termios_test_driver_set_rx( expected, len );
56  printf( "\nReading (expected):\n" );
57  rtems_print_buffer( (unsigned char *)expected, len-1 );
58
59  rc = read( fd, read_helper_buffer, sizeof(read_helper_buffer) );
60  rtems_test_assert( rc != -1 );
61
62  printf( "Read %d bytes from read(2)\n", rc );
63  rtems_print_buffer( read_helper_buffer, rc );
64
65  termios_test_driver_dump_tx("As Read");
66}
67
68int Test_fd;
69
70void open_it(void)
71{
72  /* open the file */
73  puts( "open(" TERMIOS_TEST_DRIVER_DEVICE_NAME ") - OK " );
74  Test_fd = open( TERMIOS_TEST_DRIVER_DEVICE_NAME, O_RDWR );
75  rtems_test_assert( Test_fd != -1 );
76}
77
78void close_it(void)
79{
80  int rc;
81
82  puts( "close(" TERMIOS_TEST_DRIVER_DEVICE_NAME ") - OK " );
83  rc = close( Test_fd );
84  rtems_test_assert( rc == 0 );
85}
86
87void change_iflag( const char *desc, int mask, int new )
88{
89  int            rc;
90  struct termios attr;
91
92  printf( "Changing c_iflag to: %s\n", desc );
93  rc = tcgetattr( Test_fd, &attr );
94  rtems_test_assert( rc == 0 );
95
96  attr.c_iflag &= ~mask;
97  attr.c_iflag |= new;
98
99  rc = tcsetattr( Test_fd, TCSANOW, &attr );
100  rtems_test_assert( rc == 0 );
101}
102
103const char XON_String[] = "\021";
104const char XOFF_String[] = "\023";
105
106const char ExpectedOutput_1[] =
107"0123456789012345678901234567890123456789"
108"0123456789012345678901234567890123456789"
109"0123456789012345678901234567890123456789"
110"0123456789012345678901234567890123456789"
111"0123456789012345678901234567890123456789";
112#if 0
113const char ExpectedInput_1[] = "Blocking interrupt driven read.\n";
114const char ExpectedInput_2[] = "Non-Blocking interrupt driven read.\n";
115#endif
116
117rtems_task Init(
118  rtems_task_argument argument
119)
120{
121  rtems_status_code sc;
122
123  puts( "\n\n*** TEST TERMIOS07 ***" );
124
125  puts( "rtems_termios_bufsize( 64, 64, 64 ) - OK" );
126  sc = rtems_termios_bufsize ( 64, 64, 64 );
127  rtems_test_assert( sc == RTEMS_SUCCESSFUL );
128
129  open_it();
130
131  change_iflag( "Set XON/XOFF", IXON|IXOFF, IXON|IXOFF );
132
133  termios_test_driver_set_rx( XOFF_String, 1 );
134  sc = rtems_task_wake_after( 2 * rtems_clock_get_ticks_per_second() );
135  rtems_test_assert( sc == RTEMS_SUCCESSFUL );
136
137  write_helper( Test_fd, ExpectedOutput_1 );
138
139#if 0
140  /* some basic cases */
141  write_helper( Test_fd, ExpectedOutput_1 );
142  read_helper( Test_fd, ExpectedInput_1 );
143  termios_test_driver_set_rx_enqueue_now( true );
144  read_helper( Test_fd, ExpectedInput_2 );
145#endif
146
147  close_it();
148
149  puts( "*** END OF TEST TERMIOS07 ***" );
150
151  rtems_test_exit(0);
152}
153
154/* configuration information */
155
156#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
157#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
158#define CONFIGURE_APPLICATION_EXTRA_DRIVERS \
159  TERMIOS_TEST_DRIVER_TABLE_ENTRY
160
161/* include an extra slot for registering the termios one dynamically */
162#define CONFIGURE_MAXIMUM_DRIVERS 3
163
164/* one for the console and one for the test port */
165#define CONFIGURE_NUMBER_OF_TERMIOS_PORTS 3
166
167/* we need to be able to open the test device */
168#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 4
169#define CONFIGURE_MAXIMUM_TASKS                  1
170#define CONFIGURE_MAXIMUM_TIMERS                 2
171#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
172
173#define CONFIGURE_INIT
174
175#include <rtems/confdefs.h>
176/* end of file */
Note: See TracBrowser for help on using the repository browser.