From 91b38c632a097596bf0fb7c58b4a5a28bee84236 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Tue, 12 Jul 2011 13:22:24 +0000 Subject: 2011-07-12 Ricardo Aguirre * Makefile.am, configure.ac, psxtmtests_plan.csv: Add psxtmmutex03. * psxtmmutex03/.cvsignore, psxtmmutex03/Makefile.am, psxtmmutex03/init.c, psxtmmutex03/psxtmmutex03.doc: New files. --- testsuites/psxtmtests/ChangeLog | 6 + testsuites/psxtmtests/Makefile.am | 1 + testsuites/psxtmtests/configure.ac | 1 + testsuites/psxtmtests/psxtmmutex03/.cvsignore | 2 + testsuites/psxtmtests/psxtmmutex03/Makefile.am | 30 ++++ testsuites/psxtmtests/psxtmmutex03/init.c | 175 +++++++++++++++++++++ .../psxtmtests/psxtmmutex03/psxtmmutex03.doc | 20 +++ testsuites/psxtmtests/psxtmtests_plan.csv | 10 +- 8 files changed, 240 insertions(+), 5 deletions(-) create mode 100644 testsuites/psxtmtests/psxtmmutex03/.cvsignore create mode 100644 testsuites/psxtmtests/psxtmmutex03/Makefile.am create mode 100644 testsuites/psxtmtests/psxtmmutex03/init.c create mode 100644 testsuites/psxtmtests/psxtmmutex03/psxtmmutex03.doc (limited to 'testsuites') diff --git a/testsuites/psxtmtests/ChangeLog b/testsuites/psxtmtests/ChangeLog index 755278b9c4..9bdd556297 100644 --- a/testsuites/psxtmtests/ChangeLog +++ b/testsuites/psxtmtests/ChangeLog @@ -1,3 +1,9 @@ +2011-07-12 Ricardo Aguirre + + * Makefile.am, configure.ac, psxtmtests_plan.csv: Add psxtmmutex03. + * psxtmmutex03/.cvsignore, psxtmmutex03/Makefile.am, + psxtmmutex03/init.c, psxtmmutex03/psxtmmutex03.doc: New files. + 2011-06-29 Ricardo Aguirre * psxtmtests/Makefile.am, psxtmtests/configure.ac, diff --git a/testsuites/psxtmtests/Makefile.am b/testsuites/psxtmtests/Makefile.am index 89b5275ab7..1bad66682c 100644 --- a/testsuites/psxtmtests/Makefile.am +++ b/testsuites/psxtmtests/Makefile.am @@ -12,6 +12,7 @@ SUBDIRS += psxtmthread01 SUBDIRS += psxtmthread03 SUBDIRS += psxtmnanosleep01 SUBDIRS += psxtmnanosleep02 +SUBDIRS += psxtmmutex03 endif DIST_SUBDIRS = $(SUBDIRS) diff --git a/testsuites/psxtmtests/configure.ac b/testsuites/psxtmtests/configure.ac index 6bf3484e32..aca7324ca4 100644 --- a/testsuites/psxtmtests/configure.ac +++ b/testsuites/psxtmtests/configure.ac @@ -80,6 +80,7 @@ AC_SUBST(OPERATION_COUNT) # Explicitly list all Makefiles here AC_CONFIG_FILES([Makefile psxtmmutex02/Makefile +psxtmmutex03/Makefile psxtmsleep01/Makefile psxtmsleep02/Makefile psxtmthread01/Makefile diff --git a/testsuites/psxtmtests/psxtmmutex03/.cvsignore b/testsuites/psxtmtests/psxtmmutex03/.cvsignore new file mode 100644 index 0000000000..282522db03 --- /dev/null +++ b/testsuites/psxtmtests/psxtmmutex03/.cvsignore @@ -0,0 +1,2 @@ +Makefile +Makefile.in diff --git a/testsuites/psxtmtests/psxtmmutex03/Makefile.am b/testsuites/psxtmtests/psxtmmutex03/Makefile.am new file mode 100644 index 0000000000..5a4a1d3a4e --- /dev/null +++ b/testsuites/psxtmtests/psxtmmutex03/Makefile.am @@ -0,0 +1,30 @@ +## +## $Id$ +## + +MANAGERS = all + +rtems_tests_PROGRAMS = psxtmmutex03 +psxtmmutex03_SOURCES = init.c ../../tmtests/include/timesys.h \ + ../../support/src/tmtests_empty_function.c \ + ../../support/src/tmtests_support.c + +dist_rtems_tests_DATA = psxtmmutex03.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 = $(psxtmmutex03_OBJECTS) $(psxtmmutex03_LDADD) +LINK_LIBS = $(psxtmmutex03_LDLIBS) + +psxtmmutex03$(EXEEXT): $(psxtmmutex03_OBJECTS) $(psxtmmutex03_DEPENDENCIES) + @rm -f psxtmmutex03$(EXEEXT) + $(make-exe) + +include $(top_srcdir)/../automake/local.am diff --git a/testsuites/psxtmtests/psxtmmutex03/init.c b/testsuites/psxtmtests/psxtmmutex03/init.c new file mode 100644 index 0000000000..e65761b7d6 --- /dev/null +++ b/testsuites/psxtmtests/psxtmmutex03/init.c @@ -0,0 +1,175 @@ +/* + * 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 +#include +#include +#include +#include "test_support.h" + +pthread_mutex_t MutexId; + +void benchmark_mutex_lock_available(void) +{ + long end_time; + int status; + + benchmark_timer_initialize(); + status = pthread_mutex_lock( &MutexId ); + end_time = benchmark_timer_read(); + rtems_test_assert( !status ); + + put_time( + "pthread_mutex_lock - available", + end_time, + 1, + 0, + 0 + ); +} + +void benchmark_mutex_unlock_no_threads_waiting(void) +{ + long end_time; + int status; + + benchmark_timer_initialize(); + status = pthread_mutex_unlock( &MutexId ); + end_time = benchmark_timer_read(); + rtems_test_assert( !status ); + + put_time( + "pthread_mutex_unlock - no threads waiting", + end_time, + 1, + 0, + 0 + ); +} + +void benchmark_mutex_trylock_available(void) +{ + long end_time; + int status; + + benchmark_timer_initialize(); + status = pthread_mutex_trylock( &MutexId ); + end_time = benchmark_timer_read(); + rtems_test_assert( !status ); + + put_time( + "pthread_mutex_trylock - available", + end_time, + 1, + 0, + 0 + ); +} + + +void benchmark_mutex_trylock_not_available(void) +{ + long end_time; + int status; + + benchmark_timer_initialize(); + status = pthread_mutex_trylock( &MutexId ); + /* + * it has to return a negative value + * because it try to lock a not available mutex + * so the assert call is make with status instead !status + */ + end_time = benchmark_timer_read(); + rtems_test_assert( status ); + + put_time( + "pthread_mutex_trylock - not available", + end_time, + 1, + 0, + 0 + ); +} + +void benchmark_mutex_timedlock_available(void) +{ + long end_time; + int status; + + benchmark_timer_initialize(); + status = pthread_mutex_timedlock( &MutexId, 0 ); + end_time = benchmark_timer_read(); + rtems_test_assert( !status ); + + put_time( + "pthread_mutex_timedlock - available", + end_time, + 1, + 0, + 0 + ); +} + +void *POSIX_Init( + void *argument +) +{ + int status; + + puts( "\n\n*** POSIX TIME TEST PSXTMMUTEX03 ***" ); + + /* + * Create the single Mutex used in all the test case + */ + status = pthread_mutex_init( &MutexId, NULL ); + rtems_test_assert( !status ); + + /* + * Now invoke subroutines to time each test case + * get the goal depends of its order + */ + benchmark_mutex_lock_available(); + benchmark_mutex_unlock_no_threads_waiting(); + benchmark_mutex_trylock_available(); + benchmark_mutex_trylock_not_available(); + benchmark_mutex_unlock_no_threads_waiting(); + benchmark_mutex_timedlock_available(); + benchmark_mutex_unlock_no_threads_waiting(); + + + /* + * Destroy the mutex used in the tests + */ + status = pthread_mutex_destroy( &MutexId ); + rtems_test_assert( !status ); + + puts( "*** END OF POSIX TIME TEST PSXTMMUTEX03 ***" ); + + 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_MUTEXES 1 +#define CONFIGURE_POSIX_INIT_THREAD_TABLE + +#define CONFIGURE_INIT + +#include +/* end of file */ diff --git a/testsuites/psxtmtests/psxtmmutex03/psxtmmutex03.doc b/testsuites/psxtmtests/psxtmmutex03/psxtmmutex03.doc new file mode 100644 index 0000000000..abda014d14 --- /dev/null +++ b/testsuites/psxtmtests/psxtmmutex03/psxtmmutex03.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: + ++ pthread_mutex_lock - available ++ pthread_mutex_unlock - no threads waiting ++ pthread_mutex_trylock - available ++ pthread_mutex_trylock - not available ++ pthread_mutex_unlock - no threads waiting ++ pthread_mutex_timedlock - available ++ pthread_mutex_unlock - no threads waiting diff --git a/testsuites/psxtmtests/psxtmtests_plan.csv b/testsuites/psxtmtests/psxtmtests_plan.csv index f0c6fff347..edf096babf 100644 --- a/testsuites/psxtmtests/psxtmtests_plan.csv +++ b/testsuites/psxtmtests/psxtmtests_plan.csv @@ -2,13 +2,13 @@ "pthread_mutex_init","psxtmmutex01","psxtmtest_init_destroy", "pthread_mutex_destroy","psxtmmutex01","psxtmtest_init_destroy", "pthread_mutex_lock - not available, block","psxtmmutex02","psxtmtest_blocking","Yes" -"pthread_mutex_lock - available","psxtmmutex03","psxtmtest_single", -"pthread_mutex_trylock - available","psxtmmutex04","psxtmtest_single", -"pthread_mutex_trylock - not available","psxtmmutex05","psxtmtest_single", -"pthread_mutex_unlock - no threads waiting","psxtmmutex06","psxtmtest_single", +"pthread_mutex_lock - available","psxtmmutex03","psxtmtest_single","Yes" +"pthread_mutex_trylock - available","psxtmmutex03","psxtmtest_single","Yes" +"pthread_mutex_trylock - not available","psxtmmutex03","psxtmtest_single","Yes" +"pthread_mutex_unlock - no threads waiting","psxtmmutex03","psxtmtest_single","Yes" "pthread_mutex_unlock - thread waiting, no preempt","psxtmmutex07","psxtmtest_unblocking_nopreempt", "pthread_mutex_unlock - thread waiting, preempt","psxtmmutex08","psxtmtest_unblocking_preempt", -"pthread_mutex_timedlock - available","psxtmmutex09","psxtmtest_single", +"pthread_mutex_timedlock - available","psxtmmutex03","psxtmtest_single","Yes" "pthread_mutex_timedlock - not available, block","psxtmmutex10","psxtmtest_blocking", "pthread_mutex_setprioceiling","psxtmmutex11","psxtmtest_single", "pthread_mutex_getprioceiling","psxtmmutex12","psxtmtest_single", -- cgit v1.2.3