diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2011-07-22 17:05:46 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2011-07-22 17:05:46 +0000 |
commit | f31fcd44e48705e638e1acb9e975ceec8a37b187 (patch) | |
tree | 17d6a6a374ef0625010580ae86c5007e75b48e72 /testsuites | |
parent | 2011-07-22 Joel Sherrill <joel.sherrilL@OARcorp.com> (diff) | |
download | rtems-f31fcd44e48705e638e1acb9e975ceec8a37b187.tar.bz2 |
2011-07-22 Ricardo Aguirre <el.mastin@ymail.com>
PR 1846/tests
* Makefile.am, configure.ac, psxtmtests_plan.csv: Add benchmark of
various sem_open(), sem_close(), sem_unlink(), sem_init(), and
sem_destroy() cases.
* psxtmsem01/.cvsignore, psxtmsem01/Makefile.am, psxtmsem01/init.c,
psxtmsem01/psxtmsem01.doc: New files.
Diffstat (limited to 'testsuites')
-rw-r--r-- | testsuites/psxtmtests/ChangeLog | 9 | ||||
-rw-r--r-- | testsuites/psxtmtests/Makefile.am | 1 | ||||
-rw-r--r-- | testsuites/psxtmtests/configure.ac | 1 | ||||
-rw-r--r-- | testsuites/psxtmtests/psxtmsem01/.cvsignore | 2 | ||||
-rw-r--r-- | testsuites/psxtmtests/psxtmsem01/Makefile.am | 30 | ||||
-rw-r--r-- | testsuites/psxtmtests/psxtmsem01/init.c | 206 | ||||
-rw-r--r-- | testsuites/psxtmtests/psxtmsem01/psxtmsem01.doc | 20 | ||||
-rw-r--r-- | testsuites/psxtmtests/psxtmtests_plan.csv | 18 |
8 files changed, 279 insertions, 8 deletions
diff --git a/testsuites/psxtmtests/ChangeLog b/testsuites/psxtmtests/ChangeLog index d46ba86942..85eed7650b 100644 --- a/testsuites/psxtmtests/ChangeLog +++ b/testsuites/psxtmtests/ChangeLog @@ -1,3 +1,12 @@ +2011-07-22 Ricardo Aguirre <el.mastin@ymail.com> + + PR 1846/tests + * Makefile.am, configure.ac, psxtmtests_plan.csv: Add benchmark of + various sem_open(), sem_close(), sem_unlink(), sem_init(), and + sem_destroy() cases. + * psxtmsem01/.cvsignore, psxtmsem01/Makefile.am, psxtmsem01/init.c, + psxtmsem01/psxtmsem01.doc: New files. + 2011-07-21 Ricardo Aguirre <el.mastin@ymail.com> PR 1835/tests diff --git a/testsuites/psxtmtests/Makefile.am b/testsuites/psxtmtests/Makefile.am index 63fe7b1a6b..5f905b6361 100644 --- a/testsuites/psxtmtests/Makefile.am +++ b/testsuites/psxtmtests/Makefile.am @@ -18,6 +18,7 @@ SUBDIRS += psxtmmutex06 SUBDIRS += psxtmmutex07 SUBDIRS += psxtmnanosleep01 SUBDIRS += psxtmnanosleep02 +SUBDIRS += psxtmsem01 SUBDIRS += psxtmsleep01 SUBDIRS += psxtmsleep02 SUBDIRS += psxtmthread01 diff --git a/testsuites/psxtmtests/configure.ac b/testsuites/psxtmtests/configure.ac index 8ee9062d00..8122260139 100644 --- a/testsuites/psxtmtests/configure.ac +++ b/testsuites/psxtmtests/configure.ac @@ -90,6 +90,7 @@ psxtmmutex06/Makefile psxtmmutex07/Makefile psxtmnanosleep01/Makefile psxtmnanosleep02/Makefile +psxtmsem01/Makefile psxtmsleep01/Makefile psxtmsleep02/Makefile psxtmthread01/Makefile diff --git a/testsuites/psxtmtests/psxtmsem01/.cvsignore b/testsuites/psxtmtests/psxtmsem01/.cvsignore new file mode 100644 index 0000000000..282522db03 --- /dev/null +++ b/testsuites/psxtmtests/psxtmsem01/.cvsignore @@ -0,0 +1,2 @@ +Makefile +Makefile.in diff --git a/testsuites/psxtmtests/psxtmsem01/Makefile.am b/testsuites/psxtmtests/psxtmsem01/Makefile.am new file mode 100644 index 0000000000..23f58aa70b --- /dev/null +++ b/testsuites/psxtmtests/psxtmsem01/Makefile.am @@ -0,0 +1,30 @@ +## +## $Id$ +## + +MANAGERS = all + +rtems_tests_PROGRAMS = psxtmsem01 +psxtmsem01_SOURCES = init.c ../../tmtests/include/timesys.h \ + ../../support/src/tmtests_empty_function.c \ + ../../support/src/tmtests_support.c + +dist_rtems_tests_DATA = psxtmsem01.doc + +include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg +include $(top_srcdir)/../automake/compile.am +include $(top_srcdir)/../automake/leaf.am + +OPERATION_COUNT = @OPERATION_COUNT@ +AM_CPPFLAGS += -I$(top_srcdir)/../tmtests/include +AM_CPPFLAGS += -DOPERATION_COUNT=$(OPERATION_COUNT) +AM_CPPFLAGS += -I$(top_srcdir)/../support/include + +LINK_OBJS = $(psxtmsem01_OBJECTS) $(psxtmsem01_LDADD) +LINK_LIBS = $(psxtmsem01_LDLIBS) + +psxtmsem01$(EXEEXT): $(psxtmsem01_OBJECTS) $(psxtmsem01_DEPENDENCIES) + @rm -f psxtmsem01$(EXEEXT) + $(make-exe) + +include $(top_srcdir)/../automake/local.am diff --git a/testsuites/psxtmtests/psxtmsem01/init.c b/testsuites/psxtmtests/psxtmsem01/init.c new file mode 100644 index 0000000000..d3c489cd3f --- /dev/null +++ b/testsuites/psxtmtests/psxtmsem01/init.c @@ -0,0 +1,206 @@ +/* + * COPYRIGHT (c) 1989-2011. + * 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$ + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <errno.h> +#include <fcntl.h> +#include <semaphore.h> +#include <tmacros.h> +#include <timesys.h> +#include <rtems/timerdrv.h> +#include "test_support.h" + +#define MAX_SEMS 2 + +sem_t sem1; +sem_t *n_sem1; +sem_t *n_sem2; + +void benchmark_sem_init(void) +{ + long end_time; + int status; + + benchmark_timer_initialize(); + status = sem_init( &sem1, 0, 1 ); + end_time = benchmark_timer_read(); + rtems_test_assert( status == 0 ); + + put_time( + "sem_init", + end_time, + 1, /* Only executed once */ + 0, + 0 + ); +} + +void benchmark_sem_destroy(void) +{ + long end_time; + int status; + + benchmark_timer_initialize(); + status = sem_destroy( &sem1 ); + end_time = benchmark_timer_read(); + rtems_test_assert( status == 0 ); + + put_time( + "sem_destroy", + end_time, + 1, /* Only executed once */ + 0, + 0 + ); +} + +void benchmark_sem_open(bool report_time) +{ + long end_time; + + benchmark_timer_initialize(); + n_sem1 = sem_open( "sem1", O_CREAT, 0777, 1 ); + end_time = benchmark_timer_read(); + + if ( report_time ) { + put_time( + "sem_open (first open 'O_CREAT')", + end_time, + 1, /* Only executed once */ + 0, + 0 + ); + } +} + +void benchmark_sem_close(bool report_time) +{ + long end_time; + int status; + + benchmark_timer_initialize(); + status = sem_close( n_sem1 ); + end_time = benchmark_timer_read(); + rtems_test_assert( status == 0 ); + + if ( report_time ) { + put_time( + "sem_close (named first/nested close)", + end_time, + 1, /* Only executed once */ + 0, + 0 + ); + } +} + +void benchmark_sem_unlink(const char *message) +{ + long end_time; + int status; + + benchmark_timer_initialize(); + status = sem_unlink( "sem1" ); + end_time = benchmark_timer_read(); + rtems_test_assert( status == 0 ); + + put_time( + message, + end_time, + 1, /* Only executed once */ + 0, + 0 + ); +} + +void benchmark_sem_open_second(void) +{ + long end_time; + + benchmark_timer_initialize(); + n_sem2 = sem_open( "sem1", O_EXCL, 0777, 1 ); + end_time = benchmark_timer_read(); + + put_time( + "sem_open (second open 'O_EXCL')", + end_time, + 1, /* Only executed once */ + 0, + 0 + ); +} + +void benchmark_sem_close_second(void) +{ + long end_time; + int status; + + benchmark_timer_initialize(); + status = sem_close( n_sem2 ); + end_time = benchmark_timer_read(); + rtems_test_assert( status == 0 ); + + put_time( + "sem_close (named second close)", + end_time, + 1, /* Only executed once */ + 0, + 0 + ); +} + +void *POSIX_Init(void *argument) +{ + + puts( "\n\n*** POSIX TIME TEST PSXTMSEM01 ***" ); + + /* creating unnamed semaphore */ + benchmark_sem_init(); + /* destroying unnamed semaphore */ + benchmark_sem_destroy(); + + /* opening named semaphore first time o_flag = O_CREAT */ + benchmark_sem_open(true); + /* opening named semaphore second time o_flag = O_EXCL */ + benchmark_sem_open_second(); + /* close named semaphore first time -- does not delete */ + benchmark_sem_close(true); + /* unlink named semaphore -- does not delete */ + benchmark_sem_unlink("sem_unlink (does not delete)"); + /* close semaphore the second time, this actually deletes it */ + benchmark_sem_close_second(); + + /* recrate named semaphore first time o_flag = O_CREAT */ + benchmark_sem_open(false); + benchmark_sem_close(false); + benchmark_sem_unlink("sem_unlink (deletes semaphore)"); + + puts( "*** END OF POSIX TIME TEST PSXTMSEM01 ***" ); + + rtems_test_exit(0); +} + +/* configuration information */ + +#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER +#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER + +#define CONFIGURE_MAXIMUM_POSIX_THREADS 1 +#define CONFIGURE_MAXIMUM_POSIX_SEMAPHORES MAX_SEMS +#define CONFIGURE_POSIX_INIT_THREAD_TABLE + +#define CONFIGURE_INIT + +#include <rtems/confdefs.h> +/* end of file */ diff --git a/testsuites/psxtmtests/psxtmsem01/psxtmsem01.doc b/testsuites/psxtmtests/psxtmsem01/psxtmsem01.doc new file mode 100644 index 0000000000..83d45b0fc7 --- /dev/null +++ b/testsuites/psxtmtests/psxtmsem01/psxtmsem01.doc @@ -0,0 +1,20 @@ +# +# $Id$ +# +# COPYRIGHT (c) 1989-2011. +# 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 test benchmarks the following operations: + ++ sem_init ++ sem_open (first 'O_CREAT') ++ sem_close (first) ++ sem_open (second 'O_EXCL') ++ sem_close (second) ++ sem_destroy + diff --git a/testsuites/psxtmtests/psxtmtests_plan.csv b/testsuites/psxtmtests/psxtmtests_plan.csv index cddf0f4b6d..5825aa767d 100644 --- a/testsuites/psxtmtests/psxtmtests_plan.csv +++ b/testsuites/psxtmtests/psxtmtests_plan.csv @@ -86,7 +86,7 @@ "mq_open (second open)","psxtmsem03","psxtmtest_init_destroy", "mq_close (close of second)","psxtmsem03","psxtmtest_init_destroy", "mq_unlink",,, -"mq_receive – available",,"psxtmtest_single", +"mq_receive - available",,"psxtmtest_single", "mq_receive - not available, block",,"psxtmtest_blocking", "mq_timedreceive - available",,"psxtmtest_single", "mq_timedreceive - not available, blocks",,"psxtmtest_single", @@ -98,13 +98,15 @@ "mq_timedsend - thread waiting, preemption",,"psxtmtest_unblocking_preempt", "mq_notify ",,"psxtmtest_single", ,,, -"sem_init","psxtmsem01","psxtmtest_init_destroy", -"sem_destroy","psxtmsem01","psxtmtest_init_destroy", -"sem_open (first open)","psxtmsem01","psxtmtest_init_destroy", -"sem_close (close of first)","psxtmsem01","psxtmtest_init_destroy", -"sem_open (second open)","psxtmsem01","psxtmtest_init_destroy", -"sem_close (close of second)","psxtmsem01","psxtmtest_init_destroy", -"sem_wait – available",,"psxtmtest_single", +"sem_init","psxtmsem01","psxtmtest_single","Yes" +"sem_destroy","psxtmsem01","psxtmtest_single","Yes" +"sem_open (first open named)","psxtmsem01","psxtmtest_single","Yes" +"sem_open (second open named)","psxtmsem01","psxtmtest_single","Yes" +"sem_close (named first/nested close)","psxtmsem01","psxtmtest_single","Yes" +"sem_unlink (does not delete)","psxtmsem01","psxtmtest_single","Yes" +"sem_close (named second close - removes)","psxtmsem01","psxtmtest_single","Yes" +"sem_unlink (deletes)","psxtmsem01","psxtmtest_single","Yes" +"sem_wait - available",,"psxtmtest_single", "sem_wait - not available, block",,"psxtmtest_blocking", "sem_trywait - available",,"psxtmtest_single", "sem_trywait - not available",,"psxtmtest_single", |