From e247b1af43f651b822fc524fb98d050b47dd7e8a Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Mon, 21 Jun 2010 20:05:46 +0000 Subject: 2010-06-21 Joel Sherrill * Makefile.am, configure.ac: Add test for deferring free() from ISR and for deferred free() processing. * malloc02/.cvsignore, malloc02/Makefile.am, malloc02/init.c, malloc02/malloc02.doc, malloc02/malloc02.scn: New files. --- testsuites/libtests/ChangeLog | 7 +++ testsuites/libtests/Makefile.am | 2 +- testsuites/libtests/configure.ac | 1 + testsuites/libtests/malloc02/.cvsignore | 2 + testsuites/libtests/malloc02/Makefile.am | 26 +++++++++ testsuites/libtests/malloc02/init.c | 95 +++++++++++++++++++++++++++++++ testsuites/libtests/malloc02/malloc02.doc | 24 ++++++++ testsuites/libtests/malloc02/malloc02.scn | 5 ++ 8 files changed, 161 insertions(+), 1 deletion(-) create mode 100644 testsuites/libtests/malloc02/.cvsignore create mode 100644 testsuites/libtests/malloc02/Makefile.am create mode 100644 testsuites/libtests/malloc02/init.c create mode 100644 testsuites/libtests/malloc02/malloc02.doc create mode 100644 testsuites/libtests/malloc02/malloc02.scn (limited to 'testsuites/libtests') diff --git a/testsuites/libtests/ChangeLog b/testsuites/libtests/ChangeLog index 78618991bd..8f53539d46 100644 --- a/testsuites/libtests/ChangeLog +++ b/testsuites/libtests/ChangeLog @@ -1,3 +1,10 @@ +2010-06-21 Joel Sherrill + + * Makefile.am, configure.ac: Add test for deferring free() from ISR and + for deferred free() processing. + * malloc02/.cvsignore, malloc02/Makefile.am, malloc02/init.c, + malloc02/malloc02.doc, malloc02/malloc02.scn: New files. + 2010-06-07 Joel Sherrill * termios01/init.c, termios01/termios01.scn, termios02/init.c, diff --git a/testsuites/libtests/Makefile.am b/testsuites/libtests/Makefile.am index 705f69058e..36eb7a2507 100644 --- a/testsuites/libtests/Makefile.am +++ b/testsuites/libtests/Makefile.am @@ -6,7 +6,7 @@ ACLOCAL_AMFLAGS = -I ../aclocal SUBDIRS = POSIX -SUBDIRS += bspcmdline01 cpuuse malloctest heapwalk putenvtest monitor \ +SUBDIRS += bspcmdline01 cpuuse malloctest malloc02 heapwalk putenvtest monitor \ monitor02 rtmonuse stackchk stackchk01 termios termios01 termios02 \ rtems++ tztest block01 block02 block03 block04 block05 block06 block07 \ block08 block09 block10 stringto01 diff --git a/testsuites/libtests/configure.ac b/testsuites/libtests/configure.ac index d1d472c598..e2ec4a25b2 100644 --- a/testsuites/libtests/configure.ac +++ b/testsuites/libtests/configure.ac @@ -47,6 +47,7 @@ bspcmdline01/Makefile cpuuse/Makefile heapwalk/Makefile malloctest/Makefile +malloc02/Makefile monitor/Makefile monitor02/Makefile putenvtest/Makefile diff --git a/testsuites/libtests/malloc02/.cvsignore b/testsuites/libtests/malloc02/.cvsignore new file mode 100644 index 0000000000..282522db03 --- /dev/null +++ b/testsuites/libtests/malloc02/.cvsignore @@ -0,0 +1,2 @@ +Makefile +Makefile.in diff --git a/testsuites/libtests/malloc02/Makefile.am b/testsuites/libtests/malloc02/Makefile.am new file mode 100644 index 0000000000..dcfacc697c --- /dev/null +++ b/testsuites/libtests/malloc02/Makefile.am @@ -0,0 +1,26 @@ +## +## $Id$ +## + +MANAGERS = all + +rtems_tests_PROGRAMS = malloc02 +malloc02_SOURCES = init.c ../../support/src/spin.c + +dist_rtems_tests_DATA = malloc02.scn +dist_rtems_tests_DATA += malloc02.doc + +include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg +include $(top_srcdir)/../automake/compile.am +include $(top_srcdir)/../automake/leaf.am + +AM_CPPFLAGS += -I$(top_srcdir)/../support/include + +LINK_OBJS = $(malloc02_OBJECTS) $(malloc02_LDADD) +LINK_LIBS = $(malloc02_LDLIBS) + +malloc02$(EXEEXT): $(malloc02_OBJECTS) $(malloc02_DEPENDENCIES) + @rm -f malloc02$(EXEEXT) + $(make-exe) + +include $(top_srcdir)/../automake/local.am diff --git a/testsuites/libtests/malloc02/init.c b/testsuites/libtests/malloc02/init.c new file mode 100644 index 0000000000..939fdcd748 --- /dev/null +++ b/testsuites/libtests/malloc02/init.c @@ -0,0 +1,95 @@ +/* + * COPYRIGHT (c) 1989-2009. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + * + * $Id$ + */ + +#include + +volatile bool operation_performed_from_tsr; + +void *Pointer1; + +rtems_timer_service_routine test_operation_from_isr( + rtems_id timer, + void *arg +) +{ + /* free memory from ISR so it is deferred */ + free( Pointer1 ); + + operation_performed_from_tsr = true; +} + +rtems_task Init( + rtems_task_argument argument +) +{ + rtems_status_code status; + rtems_id timer; + void *pointer2; + + puts( "\n\n*** TEST MALLOC 02 ***" ); + + puts( "malloc memory to free from ISR" ); + Pointer1 = malloc( 20 ); + + /* + * Timer used in multiple ways + */ + status = rtems_timer_create( rtems_build_name('T', 'M', 'R', '0'), &timer ); + directive_failed( status, "rtems_timer_create" ); + + operation_performed_from_tsr = false; + + /* + * Test Operation from ISR + */ + status = rtems_timer_fire_after( timer, 10, test_operation_from_isr, NULL ); + directive_failed( status, "timer_fire_after failed" ); + + /* XXX pick a delay method */ +#if 0 + status = rtems_task_wake_after( 20 ); +#else + { + rtems_interval start; + rtems_interval now; + start = rtems_clock_get_ticks_since_boot(); + do { + now = rtems_clock_get_ticks_since_boot(); + } while ( (now-start) < 100 ); + } +#endif + if ( !operation_performed_from_tsr ) { + puts( "Operation from ISR did not get processed\n" ); + rtems_test_exit( 0 ); + } + + puts( "Free from ISR successfully processed" ); + puts( "Now malloc'ing more memory to process the free" ); + pointer2 = malloc(20); + + puts( "*** END OF TEST MALLOC 02 ***" ); + rtems_test_exit( 0 ); +} + +/* configuration information */ + +#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER +#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER + +#define CONFIGURE_RTEMS_INIT_TASKS_TABLE + +#define CONFIGURE_MAXIMUM_TASKS 1 +#define CONFIGURE_MAXIMUM_TIMERS 1 + +#define CONFIGURE_INIT +#include +/* end of file */ + diff --git a/testsuites/libtests/malloc02/malloc02.doc b/testsuites/libtests/malloc02/malloc02.doc new file mode 100644 index 0000000000..35ce0d340b --- /dev/null +++ b/testsuites/libtests/malloc02/malloc02.doc @@ -0,0 +1,24 @@ +# +# $Id$ +# +# COPYRIGHT (c) 1989-2010. +# On-Line Applications Research Corporation (OAR). +# +# The license and distribution terms for this file may be +# found in the file LICENSE in this distribution or at +# http://www.rtems.com/license/LICENSE. +# + +This file describes the directives and concepts tested by this test set. + +test set name: malloc02 + +directives: + + + free from ISR which is deferred + + malloc - deferred reclamation + +concepts: + ++ adding to the deferred free operation chain ++ processing the deferred free operation chain diff --git a/testsuites/libtests/malloc02/malloc02.scn b/testsuites/libtests/malloc02/malloc02.scn new file mode 100644 index 0000000000..fa8636337b --- /dev/null +++ b/testsuites/libtests/malloc02/malloc02.scn @@ -0,0 +1,5 @@ +*** TEST MALLOC 02 *** +malloc memory to free from ISR +Free from ISR successfully processed +Now malloc'ing more memory to process the free +*** END OF TEST MALLOC 02 *** -- cgit v1.2.3