Ignore:
Timestamp:
Mar 21, 2017, 7:39:48 PM (3 years ago)
Author:
Kevin Kirspel <kevin-kirspel@…>
Branches:
master
Children:
94a4865
Parents:
c4b058ca
git-author:
Kevin Kirspel <kevin-kirspel@…> (03/21/17 19:39:48)
git-committer:
Sebastian Huber <sebastian.huber@…> (03/22/17 10:55:04)
Message:

termios: Synchronize with latest FreeBSD headers

Adding modified FreeBSD headers to synchronize RTEMS termios with
FreeBSD. Modify termios to support dedicated input and output baud for
termios structure. Updated BSPs to use dedicated input and output baud
in termios structure. Updated tools to use dedicated input and output
baud in termios structure. Updated termios testsuites to use dedicated
input and output baud in termios structure.

Close #2897.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • testsuites/libtests/termios01/init.c

    rc4b058ca r1c6926c1  
    1313
    1414#include "tmacros.h"
     15#define TTYDEFCHARS
    1516#include <termios.h>
    1617#include <rtems/libcsupport.h>
     
    6768  { B19200,   19200 },
    6869  { B38400,   38400 },
     70  { B7200,     7200 },
     71  { B14400,   14400 },
     72  { B28800,   28800 },
    6973  { B57600,   57600 },
     74  { B76800,   76800 },
    7075  { B115200, 115200 },
    7176  { B230400, 230400 },
    7277  { B460800, 460800 },
     78  { B921600, 921600 },
    7379  { INVALID_CONSTANT, INVALID_BAUD }
    7480};
     
    234240  puts( "Test termios setting device baud rate..." );
    235241  for (i=0 ; baud_table[i].constant != INVALID_CONSTANT ; i++ ) {
    236     tcflag_t cbaud = CBAUD;
    237 
    238242    sc = tcgetattr( test, &attr );
    239243    if ( sc != 0 ) {
     
    242246    }
    243247
    244     attr.c_cflag &= ~cbaud;
    245     attr.c_cflag |= baud_table[i].constant;
     248    attr.c_ispeed = baud_table[i].constant;
     249    attr.c_ospeed = baud_table[i].constant;
    246250
    247251    printf(
     
    259263      baud_table[i].baud
    260264    );
    261     sc = tcsetattr( test, TCSANOW, &attr );
     265    sc = tcsetattr( test, TCSADRAIN, &attr );
     266    if ( sc != 0 ) {
     267      printf( "ERROR - return %d\n", sc );
     268      rtems_test_exit(0);
     269    }
     270
     271    printf(
     272      "tcsetattr(TCSAFLUSH, B%" PRIdrtems_termios_baud_t ") - OK\n",
     273      baud_table[i].baud
     274    );
     275    sc = tcsetattr( test, TCSAFLUSH, &attr );
    262276    if ( sc != 0 ) {
    263277      printf( "ERROR - return %d\n", sc );
     
    302316
    303317    printf( "tcsetattr(TCSADRAIN, CS%d) - OK\n", char_size_table[i].bits );
    304     sc = tcsetattr( test, TCSANOW, &attr );
     318    sc = tcsetattr( test, TCSADRAIN, &attr );
     319    if ( sc != 0 ) {
     320      printf( "ERROR - return %d\n", sc );
     321      rtems_test_exit(0);
     322    }
     323
     324    printf( "tcsetattr(TCSAFLUSH, CS%d) - OK\n", char_size_table[i].bits );
     325    sc = tcsetattr( test, TCSAFLUSH, &attr );
     326    if ( sc != 0 ) {
     327      printf( "ERROR - return %d\n", sc );
     328      rtems_test_exit(0);
     329    }
     330
     331    printf( "tcsetattr(TCSASOFT, CS%d) - OK\n", char_size_table[i].bits );
     332    sc = tcsetattr( test, TCSASOFT, &attr );
    305333    if ( sc != 0 ) {
    306334      printf( "ERROR - return %d\n", sc );
     
    345373
    346374    printf( "tcsetattr(TCSADRAIN, %s) - OK\n", parity_table[i].parity );
    347     sc = tcsetattr( test, TCSANOW, &attr );
     375    sc = tcsetattr( test, TCSADRAIN, &attr );
     376    if ( sc != 0 ) {
     377      printf( "ERROR - return %d\n", sc );
     378      rtems_test_exit(0);
     379    }
     380
     381    printf( "tcsetattr(TCSAFLUSH, %s) - OK\n", parity_table[i].parity );
     382    sc = tcsetattr( test, TCSAFLUSH, &attr );
     383    if ( sc != 0 ) {
     384      printf( "ERROR - return %d\n", sc );
     385      rtems_test_exit(0);
     386    }
     387
     388    printf( "tcsetattr(TCSASOFT, %s) - OK\n", parity_table[i].parity );
     389    sc = tcsetattr( test, TCSASOFT, &attr );
    348390    if ( sc != 0 ) {
    349391      printf( "ERROR - return %d\n", sc );
     
    391433
    392434    printf( "tcsetattr(TCSADRAIN, %d bits) - OK\n", stop_bits_table[i].stop );
    393     sc = tcsetattr( test, TCSANOW, &attr );
     435    sc = tcsetattr( test, TCSADRAIN, &attr );
     436    if ( sc != 0 ) {
     437      printf( "ERROR - return %d\n", sc );
     438      rtems_test_exit(0);
     439    }
     440
     441    printf( "tcsetattr(TCSAFLUSH, %d bits) - OK\n", stop_bits_table[i].stop );
     442    sc = tcsetattr( test, TCSAFLUSH, &attr );
     443    if ( sc != 0 ) {
     444      printf( "ERROR - return %d\n", sc );
     445      rtems_test_exit(0);
     446    }
     447
     448    printf( "tcsetattr(TCSASOFT, %d bits) - OK\n", stop_bits_table[i].stop );
     449    sc = tcsetattr( test, TCSASOFT, &attr );
    394450    if ( sc != 0 ) {
    395451      printf( "ERROR - return %d\n", sc );
     
    405461  speed_t speed;
    406462  struct termios term;
    407   tcflag_t        bad;
    408 
    409   bad = CBAUD << 1;
     463  speed_t bad;
     464
     465  bad = B921600 << 1;
    410466  memset( &term, '\0', sizeof(term) );
    411467  puts( "cfsetospeed(BAD BAUD) - EINVAL" );
     
    437493  speed_t         speed;
    438494  struct termios  term;
    439   tcflag_t        bad;
    440 
    441   bad = CBAUD << 1;
     495  speed_t         bad;
     496
     497  bad = B921600 << 1;
    442498  memset( &term, '\0', sizeof(term) );
    443499  puts( "cfsetispeed(BAD BAUD) - EINVAL" );
     
    470526  speed_t         speed;
    471527  struct termios  term;
    472   tcflag_t        bad;
    473 
    474   bad = CBAUD << 1;
     528  speed_t         bad;
     529
     530  bad = B921600 << 1;
    475531  memset( &term, '\0', sizeof(term) );
    476532  puts( "cfsetspeed(BAD BAUD) - EINVAL" );
     
    509565
    510566  /* Check that all of the flags were set correctly */
    511   rtems_test_assert( ~(term.c_iflag & (IMAXBEL|IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON)) );
     567  rtems_test_assert( ~(term.c_iflag & (IMAXBEL|IXOFF|INPCK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON|IGNPAR)) );
     568
     569  rtems_test_assert( term.c_iflag & (IGNBRK) );
    512570
    513571  rtems_test_assert( ~(term.c_oflag & OPOST) );
    514572
    515   rtems_test_assert( ~(term.c_lflag & (ECHO|ECHONL|ICANON|ISIG|IEXTEN)) );
     573  rtems_test_assert( ~(term.c_lflag & (ECHO|ECHOE|ECHOK|ECHONL|ICANON|ISIG|IEXTEN|NOFLSH|TOSTOP|PENDIN)) );
    516574
    517575  rtems_test_assert( ~(term.c_cflag & (CSIZE|PARENB)) );
    518576
    519   rtems_test_assert( term.c_cflag & CS8 );
     577  rtems_test_assert( term.c_cflag & (CS8|CREAD) );
     578
     579  rtems_test_assert( term.c_cc[VMIN] == 1 );
     580
     581  rtems_test_assert( term.c_cc[VTIME] == 0 );
     582}
     583
     584static void test_termios_cfmakesane(void)
     585{
     586  struct termios  term;
     587
     588  memset( &term, '\0', sizeof(term) );
     589  cfmakesane( &term );
     590  puts( "cfmakesane - OK" );
     591
     592  /* Check that all of the flags were set correctly */
     593  rtems_test_assert( term.c_iflag == TTYDEF_IFLAG );
     594
     595  rtems_test_assert( term.c_oflag == TTYDEF_OFLAG );
     596
     597  rtems_test_assert( term.c_lflag == TTYDEF_LFLAG );
     598
     599  rtems_test_assert( term.c_cflag == TTYDEF_CFLAG );
     600
     601  rtems_test_assert( term.c_ispeed == TTYDEF_SPEED );
     602
     603  rtems_test_assert( term.c_ospeed == TTYDEF_SPEED );
     604
     605  rtems_test_assert( memcmp(&term.c_cc, ttydefchars, sizeof(term.c_cc)) == 0 );
    520606}
    521607
     
    685771  rtems_test_assert( !ctx.done );
    686772  errno = 0;
    687   rv = ioctl( fd, RTEMS_IO_SET_ATTRIBUTES, &term );
     773  rv = ioctl( fd, TIOCSETA, &term );
    688774  rtems_test_assert( rv == -1 );
    689775  rtems_test_assert( errno == EIO );
     
    703789  static const struct {
    704790    uint32_t baud;
    705     tcflag_t cflag;
    706   } baud_to_cflag_table[] = {
     791    speed_t speed;
     792  } baud_to_speed_table[] = {
    707793    { 0,          B0 },
    708794    { 25,         B0 },
     
    732818  };
    733819
    734   size_t n = RTEMS_ARRAY_SIZE(baud_to_cflag_table);
     820  size_t n = RTEMS_ARRAY_SIZE(baud_to_speed_table);
    735821  size_t i;
    736822
    737823  for ( i = 0; i < n; ++i ) {
    738824    struct termios term;
    739     tcflag_t cbaud_mask = CBAUD;
    740825
    741826    memset( &term, 0xff, sizeof( term ) );
    742     rtems_termios_set_best_baud( &term, baud_to_cflag_table[ i ].baud );
    743 
    744     rtems_test_assert(
    745       (term.c_cflag & cbaud_mask) == baud_to_cflag_table[ i ].cflag
    746     );
     827    rtems_termios_set_best_baud( &term, baud_to_speed_table[ i ].baud );
     828
     829    rtems_test_assert( term.c_ispeed == baud_to_speed_table[ i ].speed );
     830    rtems_test_assert( term.c_ospeed == baud_to_speed_table[ i ].speed );
    747831  }
    748832}
     
    792876   * tcsetattr - ERROR invalid operation
    793877   */
    794   puts( "tcsetattr - invalid operation - ENOTSUP" );
     878  puts( "tcsetattr - invalid operation - EINVAL" );
    795879  rc = tcsetattr( test, INT_MAX, &t );
    796880  rtems_test_assert( rc == -1 );
    797   rtems_test_assert( errno == ENOTSUP );
     881  rtems_test_assert( errno == EINVAL );
    798882
    799883  test_termios_cfmakeraw();
    800  
     884  test_termios_cfmakesane();
     885
    801886  /*
    802887   * tcsetattr - TCSADRAIN
Note: See TracChangeset for help on using the changeset viewer.