source: rtems/testsuites/libtests/termios06/init.c @ 3e0310e3

4.115
Last change on this file since 3e0310e3 was 3e0310e3, checked in by Joel Sherrill <joel.sherrill@…>, on 07/06/10 at 19:54:00

2010-07-06 Joel Sherrill <joel.sherrilL@…>

  • termios06/init.c, termios06/termios06.scn: Add a couple more PPPDISC cases. Coverage of these paths is near complete.
  • Property mode set to 100644
File size: 3.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 *  $Id$
10 */
11
12#include <tmacros.h>
13#include "test_support.h"
14#include "termios_testdriver_polled.h"
15
16#include <sys/types.h>
17#include <sys/stat.h>
18#include <fcntl.h>
19#include <unistd.h>
20#include <sys/ioctl.h>
21#include <rtems/dumpbuf.h>
22
23void pppasyncattach(void);
24void ppp_test_driver_set_rx( const char *expected, size_t len );
25
26int Test_fd;
27int InitialDiscipline;
28
29void open_it(void)
30{
31  /* open the file */
32  puts( "open(" TERMIOS_TEST_DRIVER_DEVICE_NAME ") - OK " );
33  Test_fd = open( TERMIOS_TEST_DRIVER_DEVICE_NAME, O_RDWR );
34  rtems_test_assert( Test_fd != -1 );
35}
36
37void set_discipline(void)
38{
39  int pppdisc = PPPDISC;
40  int sc;
41
42  puts( "ioctl - TIOCGETD - OK" );
43  sc = ioctl(Test_fd, TIOCGETD, &InitialDiscipline);
44  rtems_test_assert( sc == 0 );
45
46  puts( "ioctl - TIOCSETD - OK" );
47  sc = ioctl(Test_fd, TIOCSETD, &pppdisc);
48  rtems_test_assert( sc == 0 );
49
50  puts( "ioctl - TIOCSETD - OK" );
51  sc = ioctl(Test_fd, TIOCSETD, &pppdisc);
52  rtems_test_assert( sc == 0 );
53}
54
55void ioctl_it(void)
56{
57  int rc;
58
59  puts( "ioctl(" TERMIOS_TEST_DRIVER_DEVICE_NAME ") - OK " );
60  rc = ioctl( Test_fd, 0xFFFF, NULL );
61  rtems_test_assert( rc == 0 );
62}
63
64void close_it(void)
65{
66  int rc;
67
68  puts( "close(" TERMIOS_TEST_DRIVER_DEVICE_NAME ") - OK " );
69  rc = close( Test_fd );
70  rtems_test_assert( rc == 0 );
71}
72
73void write_it(void)
74{
75  ssize_t sc;
76  char    ch[10] = "PPPD TEST";
77
78  puts( "write(PPPD TEST) - OK " );
79  sc = write(Test_fd, ch, sizeof(ch));
80  rtems_test_assert( sc == sizeof(ch) );
81}
82
83uint8_t read_helper_buffer[256];
84
85void read_helper(
86  int         fd,
87  const char *expected
88)
89{
90  int    rc;
91  size_t len;
92
93  len = strlen( expected );
94
95  ppp_test_driver_set_rx( expected, len );
96  printf( "\nReading (expected):\n" );
97  rtems_print_buffer( (unsigned char *)expected, len-1 );
98
99  rc = read( fd, read_helper_buffer, sizeof(read_helper_buffer) );
100  rtems_test_assert( rc != -1 );
101
102  printf( "Read %d bytes from read(2)\n", rc );
103  rtems_print_buffer( read_helper_buffer, rc );
104}
105
106void read_it(void)
107{
108  read_helper( Test_fd, "This is test PPP input." );
109}
110
111rtems_task Init(
112  rtems_task_argument argument
113)
114{
115  puts( "\n\n*** TEST TERMIOS06 ***" );
116
117  pppasyncattach();
118  open_it();
119  set_discipline();
120  write_it();
121  ioctl_it();
122  read_it();
123  close_it();
124 
125  puts( "*** END OF TEST TERMIOS06 ***" );
126
127  rtems_test_exit(0);
128}
129
130/* configuration information */
131
132#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
133#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
134#define CONFIGURE_APPLICATION_EXTRA_DRIVERS TERMIOS_TEST_DRIVER_TABLE_ENTRY
135
136/* one for the console and one for the test port */
137#define CONFIGURE_NUMBER_OF_TERMIOS_PORTS 3
138
139/* we need to be able to open the test device */
140#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 4
141
142#define CONFIGURE_MAXIMUM_TASKS             1
143#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
144
145#define CONFIGURE_INIT
146
147#include <rtems/confdefs.h>
148/* end of file */
Note: See TracBrowser for help on using the repository browser.