source: rtems/testsuites/libtests/termios02/init.c

Last change on this file was acceb47, checked in by Joel Sherrill <joel@…>, on 04/01/22 at 19:24:13

testsuites/libtests/[p-z]*: Change license to BSD-2

Updates #3053.

  • Property mode set to 100644
File size: 4.7 KB
Line 
1/* SPDX-License-Identifier: BSD-2-Clause */
2
3/*
4 *  COPYRIGHT (c) 1989-2012.
5 *  On-Line Applications Research Corporation (OAR).
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 *    notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 *    notice, this list of conditions and the following disclaimer in the
14 *    documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#ifdef HAVE_CONFIG_H
30#include "config.h"
31#endif
32
33#include "tmacros.h"
34#include <termios.h>
35#include <errno.h>
36#include <unistd.h>
37
38const char rtems_test_name[] = "TERMIOS 2";
39
40/* forward declarations to avoid warnings */
41rtems_task Init(rtems_task_argument argument);
42
43rtems_task Init(
44  rtems_task_argument ignored
45)
46{
47  int sc;
48  pid_t pid;
49  char *term_name_p;
50  char term_name[32];
51
52  TEST_BEGIN();
53
54  puts( "tcdrain(12) - EBADF" );
55  sc = tcdrain(12);
56  rtems_test_assert( sc == -1 );
57  rtems_test_assert( errno == EBADF );
58
59  puts( "tcdrain(stdin) - OK" );
60  sc = tcdrain(0);
61  rtems_test_assert( !sc );
62
63  puts( "tcdrain(stdout) - OK" );
64  tcdrain(1);
65  rtems_test_assert( !sc );
66
67  puts( "tcdrain(stderr) - OK" );
68  tcdrain(2);
69  rtems_test_assert( !sc );
70
71  puts( "" );
72
73  /***** TEST TCFLOW *****/
74  puts( "tcflow(stdin, TCOOFF) - ENOTSUP" );
75  errno = 0;
76  sc = tcflow( 0, TCOOFF );
77  rtems_test_assert( sc == -1 );
78  rtems_test_assert( errno == ENOTSUP );
79
80  puts( "tcflow(stdin, TCOON) - ENOTSUP" );
81  errno = 0;
82  sc = tcflow( 0, TCOON );
83  rtems_test_assert( sc == -1 );
84  rtems_test_assert( errno == ENOTSUP );
85
86  puts( "tcflow(stdin, TCIOFF) - ENOTSUP" );
87  errno = 0;
88  sc = tcflow( 0, TCIOFF );
89  rtems_test_assert( sc == -1 );
90  rtems_test_assert( errno == ENOTSUP );
91
92  puts( "tcflow(stdin, TCION) - ENOTSUP" );
93  errno = 0;
94  sc = tcflow( 0, TCION );
95  rtems_test_assert( sc == -1 );
96  rtems_test_assert( errno == ENOTSUP );
97
98  puts( "tcflow(stdin, 22) - EINVAL" );
99  errno = 0;
100  sc = tcflow( 0, 22 );
101  rtems_test_assert( sc == -1 );
102  rtems_test_assert( errno == EINVAL );
103
104  puts( "" );
105
106  /***** TEST TCFLUSH *****/
107  puts( "tcflush(stdin, TCIFLUSH) - OK" );
108  errno = 0;
109  sc = tcflush( 0, TCIFLUSH );
110  rtems_test_assert( sc == 0 );
111  rtems_test_assert( errno == 0 );
112
113  puts( "tcflush(stdin, TCOFLUSH) - OK" );
114  sc = tcflush( 0, TCOFLUSH );
115  rtems_test_assert( sc == 0 );
116  rtems_test_assert( errno == 0 );
117
118  puts( "tcflush(stdin, TCIOFLUSH) - OK" );
119  sc = tcflush( 0, TCIOFLUSH );
120  rtems_test_assert( sc == 0 );
121  rtems_test_assert( errno == 0 );
122
123  puts( "tcflush(stdin, 22) - EINVAL" );
124  errno = 0;
125  sc = tcflush( 0, 22 );
126  rtems_test_assert( sc == -1 );
127  rtems_test_assert( errno == EINVAL );
128
129  puts( "" );
130
131  /***** TEST TCGETPGRP *****/
132  puts( "tcgetpgrp( 1 ) - OK" );
133  pid = tcgetpgrp(1);
134  rtems_test_assert( pid == getpid() );
135
136  puts( "tcsetpgrp( 1, 3 ) - OK" );
137  sc = tcsetpgrp( 1, 3 );
138  rtems_test_assert( !sc );
139
140  puts( "" );
141
142  /***** TEST TCSENDBREAK *****/
143  puts( "tcsendbreak( 1, 0 ) - OK" );
144  sc = tcsendbreak( 1, 0 );
145  rtems_test_assert( !sc );
146
147  puts( "" );
148
149  /***** TEST CTERMID *****/
150  puts( "ctermid( NULL ) - OK" );
151  term_name_p = ctermid( NULL );
152  rtems_test_assert( term_name_p );
153  printf( "ctermid ==> %s\n", term_name_p );
154
155  puts( "ctermid( term_name ) - OK" );
156  term_name_p = ctermid( term_name );
157  rtems_test_assert( term_name_p == term_name );
158  printf( "ctermid ==> %s\n", term_name_p );
159
160  TEST_END();
161  exit( 0 );
162}
163
164
165/* NOTICE: the clock driver is explicitly disabled */
166#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
167#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
168
169#define CONFIGURE_MAXIMUM_TASKS            1
170
171#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
172
173#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
174
175#define CONFIGURE_INIT
176#include <rtems/confdefs.h>
Note: See TracBrowser for help on using the repository browser.