Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:24:34

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /*
0004  *  COPYRIGHT (c) 1989-2012.
0005  *  On-Line Applications Research Corporation (OAR).
0006  *
0007  * Redistribution and use in source and binary forms, with or without
0008  * modification, are permitted provided that the following conditions
0009  * are met:
0010  * 1. Redistributions of source code must retain the above copyright
0011  *    notice, this list of conditions and the following disclaimer.
0012  * 2. Redistributions in binary form must reproduce the above copyright
0013  *    notice, this list of conditions and the following disclaimer in the
0014  *    documentation and/or other materials provided with the distribution.
0015  *
0016  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0017  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0018  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0019  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0020  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0021  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0022  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0023  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0024  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0025  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0026  * POSSIBILITY OF SUCH DAMAGE.
0027  */
0028 
0029 #ifdef HAVE_CONFIG_H
0030 #include "config.h"
0031 #endif
0032 
0033 #include "tmacros.h"
0034 #include <termios.h>
0035 #include <errno.h>
0036 #include <unistd.h>
0037 
0038 const char rtems_test_name[] = "TERMIOS 2";
0039 
0040 /* forward declarations to avoid warnings */
0041 rtems_task Init(rtems_task_argument argument);
0042 
0043 rtems_task Init(
0044   rtems_task_argument ignored
0045 )
0046 {
0047   int sc;
0048   pid_t pid;
0049   char *term_name_p;
0050   char term_name[32];
0051 
0052   TEST_BEGIN();
0053 
0054   puts( "tcdrain(12) - EBADF" );
0055   sc = tcdrain(12);
0056   rtems_test_assert( sc == -1 );
0057   rtems_test_assert( errno == EBADF );
0058 
0059   puts( "tcdrain(stdin) - OK" );
0060   sc = tcdrain(0);
0061   rtems_test_assert( !sc );
0062 
0063   puts( "tcdrain(stdout) - OK" );
0064   tcdrain(1);
0065   rtems_test_assert( !sc );
0066 
0067   puts( "tcdrain(stderr) - OK" );
0068   tcdrain(2);
0069   rtems_test_assert( !sc );
0070 
0071   puts( "" );
0072 
0073   /***** TEST TCFLOW *****/
0074   puts( "tcflow(stdin, TCOOFF) - ENOTSUP" );
0075   errno = 0;
0076   sc = tcflow( 0, TCOOFF );
0077   rtems_test_assert( sc == -1 );
0078   rtems_test_assert( errno == ENOTSUP );
0079 
0080   puts( "tcflow(stdin, TCOON) - ENOTSUP" );
0081   errno = 0;
0082   sc = tcflow( 0, TCOON );
0083   rtems_test_assert( sc == -1 );
0084   rtems_test_assert( errno == ENOTSUP );
0085 
0086   puts( "tcflow(stdin, TCIOFF) - ENOTSUP" );
0087   errno = 0;
0088   sc = tcflow( 0, TCIOFF );
0089   rtems_test_assert( sc == -1 );
0090   rtems_test_assert( errno == ENOTSUP );
0091 
0092   puts( "tcflow(stdin, TCION) - ENOTSUP" );
0093   errno = 0;
0094   sc = tcflow( 0, TCION );
0095   rtems_test_assert( sc == -1 );
0096   rtems_test_assert( errno == ENOTSUP );
0097 
0098   puts( "tcflow(stdin, 22) - EINVAL" );
0099   errno = 0;
0100   sc = tcflow( 0, 22 );
0101   rtems_test_assert( sc == -1 );
0102   rtems_test_assert( errno == EINVAL );
0103 
0104   puts( "" );
0105 
0106   /***** TEST TCFLUSH *****/
0107   puts( "tcflush(stdin, TCIFLUSH) - OK" );
0108   errno = 0;
0109   sc = tcflush( 0, TCIFLUSH );
0110   rtems_test_assert( sc == 0 );
0111   rtems_test_assert( errno == 0 );
0112 
0113   puts( "tcflush(stdin, TCOFLUSH) - OK" );
0114   sc = tcflush( 0, TCOFLUSH );
0115   rtems_test_assert( sc == 0 );
0116   rtems_test_assert( errno == 0 );
0117 
0118   puts( "tcflush(stdin, TCIOFLUSH) - OK" );
0119   sc = tcflush( 0, TCIOFLUSH );
0120   rtems_test_assert( sc == 0 );
0121   rtems_test_assert( errno == 0 );
0122 
0123   puts( "tcflush(stdin, 22) - EINVAL" );
0124   errno = 0;
0125   sc = tcflush( 0, 22 );
0126   rtems_test_assert( sc == -1 );
0127   rtems_test_assert( errno == EINVAL );
0128 
0129   puts( "" );
0130 
0131   /***** TEST TCGETPGRP *****/
0132   puts( "tcgetpgrp( 1 ) - OK" );
0133   pid = tcgetpgrp(1);
0134   rtems_test_assert( pid == getpid() );
0135 
0136   puts( "tcsetpgrp( 1, 3 ) - OK" );
0137   sc = tcsetpgrp( 1, 3 );
0138   rtems_test_assert( !sc );
0139 
0140   puts( "" );
0141 
0142   /***** TEST TCSENDBREAK *****/
0143   puts( "tcsendbreak( 1, 0 ) - OK" );
0144   sc = tcsendbreak( 1, 0 );
0145   rtems_test_assert( !sc );
0146 
0147   puts( "" );
0148 
0149   /***** TEST CTERMID *****/
0150   puts( "ctermid( NULL ) - OK" );
0151   term_name_p = ctermid( NULL );
0152   rtems_test_assert( term_name_p );
0153   printf( "ctermid ==> %s\n", term_name_p );
0154 
0155   puts( "ctermid( term_name ) - OK" );
0156   term_name_p = ctermid( term_name );
0157   rtems_test_assert( term_name_p == term_name );
0158   printf( "ctermid ==> %s\n", term_name_p );
0159 
0160   TEST_END();
0161   exit( 0 );
0162 }
0163 
0164 
0165 /* NOTICE: the clock driver is explicitly disabled */
0166 #define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
0167 #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
0168 
0169 #define CONFIGURE_MAXIMUM_TASKS            1
0170 
0171 #define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
0172 
0173 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
0174 
0175 #define CONFIGURE_INIT
0176 #include <rtems/confdefs.h>