libtests/termios01: Add tests for cfsetspeed() and cfmakeraw()

This commit is contained in:
Daniel Ramirez
2013-12-06 16:13:27 -06:00
committed by Joel Sherrill
parent 1d325e7b4d
commit 3096f5c967
3 changed files with 106 additions and 3 deletions

View File

@@ -457,6 +457,62 @@ static void test_termios_cfinspeed(void)
}
}
static void test_termios_cfsetspeed(void)
{
int i;
int status;
speed_t speed;
struct termios term;
tcflag_t bad;
bad = CBAUD << 1;
memset( &term, '\0', sizeof(term) );
puts( "cfsetspeed(BAD BAUD) - EINVAL" );
status = cfsetspeed( &term, bad );
rtems_test_assert( status == -1 );
rtems_test_assert( errno == EINVAL );
for (i=0 ; baud_table[i].constant != INVALID_CONSTANT ; i++ ) {
memset( &term, '\0', sizeof(term) );
printf(
"cfsetspeed(B%" PRIdrtems_termios_baud_t ") - OK\n",
baud_table[i].baud
);
status = cfsetspeed( &term, baud_table[i].constant );
rtems_test_assert( !status );
printf(
"cfgetspeed(B%" PRIdrtems_termios_baud_t ") - checking both inspeed and outspeed - OK\n",
baud_table[i].baud
);
speed = cfgetispeed( &term );
rtems_test_assert( speed == baud_table[i].constant );
speed = cfgetospeed( &term );
rtems_test_assert( speed == baud_table[i].constant );
}
}
static void test_termios_cfmakeraw(void)
{
struct termios term;
memset( &term, '\0', sizeof(term) );
cfmakeraw( &term );
puts( "cfmakeraw - OK" );
/* Check that all of the flags were set correctly */
rtems_test_assert( ~(term.c_iflag & (IMAXBEL|IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON)) );
rtems_test_assert( ~(term.c_oflag & OPOST) );
rtems_test_assert( ~(term.c_lflag & (ECHO|ECHONL|ICANON|ISIG|IEXTEN)) );
rtems_test_assert( ~(term.c_cflag & (CSIZE|PARENB)) );
rtems_test_assert( term.c_cflag & CS8 );
}
static rtems_task Init(
rtems_task_argument ignored
)
@@ -505,6 +561,8 @@ static rtems_task Init(
rc = tcsetattr( test, INT_MAX, &t );
rtems_test_assert( rc == -1 );
rtems_test_assert( errno == ENOTSUP );
test_termios_cfmakeraw();
/*
* tcsetattr - TCSADRAIN
@@ -588,6 +646,8 @@ static rtems_task Init(
test_termios_cfinspeed();
test_termios_cfsetspeed();
puts( "Init - close - " TERMIOS_TEST_DRIVER_DEVICE_NAME " - OK" );
rc = close( test );
if ( rc != 0 ) {

View File

@@ -20,6 +20,10 @@ directives:
rtems_termios_open
rtems_termios_close
rtems_termios_set_initial_baud
cfmakeraw
cfsetspeed
cfsetispeed
cfsetospeed
concepts:

View File

@@ -1,7 +1,6 @@
*** TEST TERMIOS 01 ***
Test termios_baud2index...
termios_baud_to_index(-2) - NOT OK
termios_baud_to_index(572) - NOT OK
termios_baud_to_index(B0) - OK
termios_baud_to_index(B50) - OK
termios_baud_to_index(B75) - OK
@@ -25,7 +24,6 @@ termios_baud_to_index(B460800) - OK
Test termios_baud2number...
termios_baud_to_number(-2) - NOT OK
termios_baud_to_number(572) - NOT OK
termios_baud_to_number(B0) - OK
termios_baud_to_number(B50) - OK
termios_baud_to_number(B75) - OK
@@ -49,7 +47,6 @@ termios_baud_to_number(B460800) - OK
Test termios_number_to_baud...
termios_number_to_baud(-2) - NOT OK
termios_number_to_baud(572) - NOT OK
termios_number_to_baud(B0) - OK
termios_number_to_baud(B50) - OK
termios_number_to_baud(B75) - OK
@@ -78,6 +75,7 @@ Init - open - /dev/test - OK
Termios_test_driver - rtems_set_initial_baud - bad baud - OK
Termios_test_driver - rtems_set_initial_baud - 38400 - OK
tcsetattr - invalid operation - ENOTSUP
cfmakeraw - OK
tcsetattr - drain - OK
set_attributes - B0 5-NONE-1
@@ -301,6 +299,47 @@ cfsetispeed(B230400) - OK
cfgetispeed(B230400) - OK
cfsetispeed(B460800) - OK
cfgetispeed(B460800) - OK
cfsetspeed(BAD BAUD) - EINVAL
cfsetspeed(B0) - OK
cfgetspeed(B0) - checking both inspeed and outspeed - OK
cfsetspeed(B50) - OK
cfgetspeed(B50) - checking both inspeed and outspeed - OK
cfsetspeed(B75) - OK
cfgetspeed(B75) - checking both inspeed and outspeed - OK
cfsetspeed(B110) - OK
cfgetspeed(B110) - checking both inspeed and outspeed - OK
cfsetspeed(B134) - OK
cfgetspeed(B134) - checking both inspeed and outspeed - OK
cfsetspeed(B150) - OK
cfgetspeed(B150) - checking both inspeed and outspeed - OK
cfsetspeed(B200) - OK
cfgetspeed(B200) - checking both inspeed and outspeed - OK
cfsetspeed(B300) - OK
cfgetspeed(B300) - checking both inspeed and outspeed - OK
cfsetspeed(B600) - OK
cfgetspeed(B600) - checking both inspeed and outspeed - OK
cfsetspeed(B1200) - OK
cfgetspeed(B1200) - checking both inspeed and outspeed - OK
cfsetspeed(B1800) - OK
cfgetspeed(B1800) - checking both inspeed and outspeed - OK
cfsetspeed(B2400) - OK
cfgetspeed(B2400) - checking both inspeed and outspeed - OK
cfsetspeed(B4800) - OK
cfgetspeed(B4800) - checking both inspeed and outspeed - OK
cfsetspeed(B9600) - OK
cfgetspeed(B9600) - checking both inspeed and outspeed - OK
cfsetspeed(B19200) - OK
cfgetspeed(B19200) - checking both inspeed and outspeed - OK
cfsetspeed(B38400) - OK
cfgetspeed(B38400) - checking both inspeed and outspeed - OK
cfsetspeed(B57600) - OK
cfgetspeed(B57600) - checking both inspeed and outspeed - OK
cfsetspeed(B115200) - OK
cfgetspeed(B115200) - checking both inspeed and outspeed - OK
cfsetspeed(B230400) - OK
cfgetspeed(B230400) - checking both inspeed and outspeed - OK
cfsetspeed(B460800) - OK
cfgetspeed(B460800) - checking both inspeed and outspeed - OK
Init - close - /dev/test - OK
Multiple open of the device
Termios_test_driver - rtems_set_initial_baud - bad baud - OK