summaryrefslogtreecommitdiffstats
path: root/testsuites/libtests/termios01/termios_testdriver.c
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2010-08-09 14:36:47 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2010-08-09 14:36:47 +0000
commit2e54cdc4d85a3b5d8d98ddcee2c3de6322e6af2c (patch)
tree56decc236f29385af6f03be21f8f2cc8f88f8490 /testsuites/libtests/termios01/termios_testdriver.c
parent2010-08-09 Joel Sherrill <joel.sherrill@oarcorp.com> (diff)
downloadrtems-2e54cdc4d85a3b5d8d98ddcee2c3de6322e6af2c.tar.bz2
2010-08-09 Bharath Suri <bharath.s.jois@gmail.com>
PR 1661/testing * termios01/init.c, termios01/termios_testdriver.c, termios01/termios01.scn: Changes to improve coverage of rtems_termios_open routine.
Diffstat (limited to 'testsuites/libtests/termios01/termios_testdriver.c')
-rw-r--r--testsuites/libtests/termios01/termios_testdriver.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/testsuites/libtests/termios01/termios_testdriver.c b/testsuites/libtests/termios01/termios_testdriver.c
index 699e0a9e89..4b46af51a5 100644
--- a/testsuites/libtests/termios01/termios_testdriver.c
+++ b/testsuites/libtests/termios01/termios_testdriver.c
@@ -16,6 +16,7 @@
#include <stdlib.h>
#include <termios.h>
#include <rtems/termiostypes.h>
+#include <rtems/libcsupport.h>
#include "termios_testdriver.h"
int termios_test_driver_inbyte_nonblocking( int port )
@@ -138,6 +139,10 @@ rtems_device_driver termios_test_driver_open(
rtems_status_code sc;
int rc;
rtems_libio_open_close_args_t *args = arg;
+ void *alloc_ptr = (void *)0;
+ static int test = 0;
+ size_t freeMemory;
+
static const rtems_termios_callbacks Callbacks = {
NULL, /* firstOpen */
NULL, /* lastClose */
@@ -154,6 +159,41 @@ rtems_device_driver termios_test_driver_open(
rtems_test_exit(0);
}
+ freeMemory = malloc_free_space();
+ if( test == 0 ) {
+ alloc_ptr = malloc( freeMemory - 4 );
+
+ sc = rtems_termios_open (major, minor, arg, &Callbacks);
+ rtems_test_assert( sc == RTEMS_NO_MEMORY );
+
+ free( alloc_ptr );
+ alloc_ptr = malloc( freeMemory - 4 - 10 -
+ sizeof( struct rtems_termios_tty ) );
+
+ sc = rtems_termios_open (major, minor, arg, &Callbacks);
+ rtems_test_assert( sc == RTEMS_NO_MEMORY );
+
+ free( alloc_ptr );
+ alloc_ptr = malloc( freeMemory - 4 - 20 -
+ sizeof( struct rtems_termios_tty ) -
+ 128 );
+
+ sc = rtems_termios_open (major, minor, arg, &Callbacks);
+ rtems_test_assert( sc == RTEMS_NO_MEMORY );
+
+ free( alloc_ptr );
+ alloc_ptr = malloc( freeMemory - 4 - 20 -
+ sizeof( struct rtems_termios_tty ) -
+ 128 -
+ 80 );
+
+ sc = rtems_termios_open (major, minor, arg, &Callbacks);
+ rtems_test_assert( sc == RTEMS_NO_MEMORY );
+
+ free( alloc_ptr );
+ test = 1;
+ }
+
sc = rtems_termios_open (major, minor, arg, &Callbacks);
directive_failed( sc, "rtems_termios_open" );