source: rtems/testsuites/libtests/termios06/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.5 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 <sys/ioctl.h>
23#include <rtems/dumpbuf.h>
24#include <rtems/termiostypes.h>
25
26void pppasyncattach(void);
27void ppp_test_driver_set_rx( const char *expected, size_t len );
28
29int Test_fd;
30int InitialDiscipline;
31
32void open_it(void)
33{
34  /* open the file */
35  puts( "open(" TERMIOS_TEST_DRIVER_DEVICE_NAME ") - OK " );
36  Test_fd = open( TERMIOS_TEST_DRIVER_DEVICE_NAME, O_RDWR );
37  rtems_test_assert( Test_fd != -1 );
38}
39
40void Rx_Wake(
41  struct termios *tty,
42  void           *arg
43)
44{
45  printk( "Rx_Wake - invoked\n" );
46}
47
48void Tx_Wake(
49  struct termios *tty,
50  void           *arg
51)
52{
53  printk( "Tx_Wake - invoked\n" );
54}
55
56struct ttywakeup RxWake = { Rx_Wake, NULL };
57struct ttywakeup TxWake = { Tx_Wake, NULL };
58
59void set_wakeups(void)
60{
61  int sc;
62
63  puts( "ioctl - RTEMS_IO_SNDWAKEUP - OK" );
64  sc = ioctl( Test_fd, RTEMS_IO_SNDWAKEUP, &TxWake );
65  rtems_test_assert( sc == 0 );
66
67  puts( "ioctl - RTEMS_IO_RCVWAKEUP - OK" );
68  sc = ioctl( Test_fd, RTEMS_IO_RCVWAKEUP, &RxWake );
69  rtems_test_assert( sc == 0 );
70
71}
72
73void set_discipline(void)
74{
75  int pppdisc = PPPDISC;
76  int sc;
77
78  puts( "ioctl - TIOCGETD - OK" );
79  sc = ioctl(Test_fd, TIOCGETD, &InitialDiscipline);
80  rtems_test_assert( sc == 0 );
81
82  puts( "ioctl - TIOCSETD - OK" );
83  sc = ioctl(Test_fd, TIOCSETD, &pppdisc);
84  rtems_test_assert( sc == 0 );
85
86  puts( "ioctl - TIOCSETD - OK" );
87  sc = ioctl(Test_fd, TIOCSETD, &pppdisc);
88  rtems_test_assert( sc == 0 );
89}
90
91void ioctl_it(void)
92{
93  int rc;
94  struct termios t;
95
96  puts( "ioctl(" TERMIOS_TEST_DRIVER_DEVICE_NAME ") - OK " );
97  rc = ioctl( Test_fd, 0xFFFF, NULL );
98  rtems_test_assert( rc == 0 );
99
100  puts( "tcgetattr(" TERMIOS_TEST_DRIVER_DEVICE_NAME ") - OK " );
101  rc = tcgetattr( Test_fd, &t );
102  rtems_test_assert( rc == 0 );
103
104  puts( "Turn on flow control on output - OK" );
105  t.c_iflag |= IXON;
106  rc = tcsetattr( Test_fd, TCSANOW, &t );
107  rtems_test_assert( rc == 0 );
108
109  puts( "Turn off flow control on output - OK" );
110  t.c_iflag &= ~IXON;
111  rc = tcsetattr( Test_fd, TCSANOW, &t );
112  rtems_test_assert( rc == 0 );
113
114  puts( "Turn on flow control on input - OK" );
115  t.c_iflag |= IXOFF;
116  rc = tcsetattr( Test_fd, TCSANOW, &t );
117  rtems_test_assert( rc == 0 );
118
119  puts( "Turn off flow control on input - OK" );
120  t.c_iflag &= ~IXOFF;
121  rc = tcsetattr( Test_fd, TCSANOW, &t );
122  rtems_test_assert( rc == 0 );
123}
124
125void close_it(void)
126{
127  int rc;
128
129  puts( "close(" TERMIOS_TEST_DRIVER_DEVICE_NAME ") - OK " );
130  rc = close( Test_fd );
131  rtems_test_assert( rc == 0 );
132}
133
134void write_it(void)
135{
136  ssize_t sc;
137  char    ch[10] = "PPPD TEST";
138
139  puts( "write(PPPD TEST) - OK " );
140  sc = write(Test_fd, ch, sizeof(ch));
141  rtems_test_assert( sc == sizeof(ch) );
142}
143
144uint8_t read_helper_buffer[256];
145
146void read_helper(
147  int         fd,
148  const char *expected
149)
150{
151  int    rc;
152  size_t len;
153
154  len = strlen( expected );
155
156  ppp_test_driver_set_rx( expected, len );
157  printf( "\nReading (expected):\n" );
158  rtems_print_buffer( (unsigned char *)expected, len-1 );
159
160  rc = read( fd, read_helper_buffer, sizeof(read_helper_buffer) );
161  rtems_test_assert( rc != -1 );
162
163  printf( "Read %d bytes from read(2)\n", rc );
164  rtems_print_buffer( read_helper_buffer, rc );
165}
166
167void read_it(void)
168{
169  read_helper( Test_fd, "This is test PPP input." );
170}
171
172rtems_task Init(
173  rtems_task_argument argument
174)
175{
176  puts( "\n\n*** TEST TERMIOS06 ***" );
177
178  pppasyncattach();
179  open_it();
180  set_wakeups();
181  set_discipline();
182  write_it();
183  ioctl_it();
184  read_it();
185  close_it();
186 
187  puts( "*** END OF TEST TERMIOS06 ***" );
188
189  rtems_test_exit(0);
190}
191
192/* configuration information */
193
194#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
195#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
196#define CONFIGURE_APPLICATION_EXTRA_DRIVERS TERMIOS_TEST_DRIVER_TABLE_ENTRY
197
198/* one for the console and one for the test port */
199#define CONFIGURE_NUMBER_OF_TERMIOS_PORTS 3
200
201/* we need to be able to open the test device */
202#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 4
203
204#define CONFIGURE_MAXIMUM_TASKS             1
205#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
206
207#define CONFIGURE_INIT
208
209#include <rtems/confdefs.h>
210/* end of file */
Note: See TracBrowser for help on using the repository browser.