summaryrefslogtreecommitdiffstats
path: root/testsuites/libtests/termios01
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2012-07-17 10:45:17 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2012-07-17 10:52:13 +0200
commitc8615dcf262da168b44c478a76d0b831cdf4286a (patch)
tree0327ab1d625cad9de4195ba7bd199d7625deddc5 /testsuites/libtests/termios01
parentscore: Change greedy allocation API (diff)
downloadrtems-c8615dcf262da168b44c478a76d0b831cdf4286a.tar.bz2
libtests/termios01: Use greedy allocation API
Diffstat (limited to 'testsuites/libtests/termios01')
-rw-r--r--testsuites/libtests/termios01/init.c2
-rw-r--r--testsuites/libtests/termios01/termios_testdriver.c56
2 files changed, 22 insertions, 36 deletions
diff --git a/testsuites/libtests/termios01/init.c b/testsuites/libtests/termios01/init.c
index 0b5d01accf..9649ffa762 100644
--- a/testsuites/libtests/termios01/init.c
+++ b/testsuites/libtests/termios01/init.c
@@ -473,7 +473,7 @@ static rtems_task Init(
test_termios_baud2number();
test_termios_number_to_baud();
- sc = rtems_termios_bufsize( 256, 138, 64 );
+ sc = rtems_termios_bufsize( 256, 128, 64 );
directive_failed( sc, "rtems_termios_bufsize" );
/*
diff --git a/testsuites/libtests/termios01/termios_testdriver.c b/testsuites/libtests/termios01/termios_testdriver.c
index 70e0d491af..c53b5b4c7a 100644
--- a/testsuites/libtests/termios01/termios_testdriver.c
+++ b/testsuites/libtests/termios01/termios_testdriver.c
@@ -23,6 +23,7 @@
#include <termios.h>
#include <rtems/termiostypes.h>
#include <rtems/libcsupport.h>
+#include <rtems/malloc.h>
#include "termios_testdriver.h"
/* forward declarations to avoid warnings */
@@ -162,9 +163,7 @@ 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 bool firstCall = true;
static const rtems_termios_callbacks Callbacks = {
NULL, /* firstOpen */
@@ -182,39 +181,26 @@ 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 );
+ if( firstCall ) {
+ static const uintptr_t allocSizes [] = {
+ sizeof( struct rtems_termios_tty ),
+ 128,
+ 64,
+ 256
+ };
+
+ size_t i;
+
+ firstCall = false;
- free( alloc_ptr );
- test = 1;
+ for (i = 0; i < sizeof( allocSizes ) / sizeof( allocSizes [0] ); ++i) {
+ void *opaque = rtems_heap_greedy_allocate( allocSizes, i );
+
+ sc = rtems_termios_open( major, minor, arg, &Callbacks );
+ rtems_test_assert( sc == RTEMS_NO_MEMORY );
+
+ rtems_heap_greedy_free( opaque );
+ }
}
sc = rtems_termios_open (major, minor, arg, &Callbacks);