summaryrefslogtreecommitdiffstats
path: root/testsuites/libtests/termios01/init.c
diff options
context:
space:
mode:
authorDaniel Ramirez <javamonn@gmail.com>2013-12-06 16:13:27 -0600
committerJoel Sherrill <joel.sherrill@oarcorp.com>2014-01-09 09:21:49 -0600
commit3096f5c9670afbe52dd980e0f62d100b6624fed3 (patch)
tree6213611e6e7b105dcf611c0ebf516012cc6c75eb /testsuites/libtests/termios01/init.c
parentsparc BSP shared: Improve Doxygen (diff)
downloadrtems-3096f5c9670afbe52dd980e0f62d100b6624fed3.tar.bz2
libtests/termios01: Add tests for cfsetspeed() and cfmakeraw()
Diffstat (limited to 'testsuites/libtests/termios01/init.c')
-rw-r--r--testsuites/libtests/termios01/init.c60
1 files changed, 60 insertions, 0 deletions
diff --git a/testsuites/libtests/termios01/init.c b/testsuites/libtests/termios01/init.c
index b15c11c193..153b596ba2 100644
--- a/testsuites/libtests/termios01/init.c
+++ b/testsuites/libtests/termios01/init.c
@@ -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 ) {