[rtems commit] libtests/termios01: Add tests for cfsetspeed() and cfmakeraw ()

Joel Sherrill joel at rtems.org
Thu Jan 9 15:14:34 UTC 2014


Module:    rtems
Branch:    master
Commit:    3096f5c9670afbe52dd980e0f62d100b6624fed3
Changeset: http://git.rtems.org/rtems/commit/?id=3096f5c9670afbe52dd980e0f62d100b6624fed3

Author:    Daniel Ramirez <javamonn at gmail.com>
Date:      Fri Dec  6 16:13:27 2013 -0600

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

---

 testsuites/libtests/termios01/init.c        |   60 +++++++++++++++++++++++++++
 testsuites/libtests/termios01/termios01.doc |    4 ++
 testsuites/libtests/termios01/termios01.scn |   45 +++++++++++++++++++-
 3 files changed, 106 insertions(+), 3 deletions(-)

diff --git a/testsuites/libtests/termios01/init.c b/testsuites/libtests/termios01/init.c
index b15c11c..153b596 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 ) {
diff --git a/testsuites/libtests/termios01/termios01.doc b/testsuites/libtests/termios01/termios01.doc
index 98d549b..d734522 100644
--- a/testsuites/libtests/termios01/termios01.doc
+++ b/testsuites/libtests/termios01/termios01.doc
@@ -20,6 +20,10 @@ directives:
   rtems_termios_open
   rtems_termios_close
   rtems_termios_set_initial_baud
+  cfmakeraw
+  cfsetspeed
+  cfsetispeed
+  cfsetospeed
 
 concepts:
 
diff --git a/testsuites/libtests/termios01/termios01.scn b/testsuites/libtests/termios01/termios01.scn
index 47fc053..c1c5470 100644
--- a/testsuites/libtests/termios01/termios01.scn
+++ b/testsuites/libtests/termios01/termios01.scn
@@ -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




More information about the vc mailing list