summaryrefslogtreecommitdiffstats
path: root/testsuites/psxtmtests
diff options
context:
space:
mode:
authorDaniel Ramirez <javamonn@gmail.com>2013-11-30 20:27:44 -0600
committerGedare Bloom <gedare@rtems.org>2013-11-30 21:31:30 -0500
commit72ff7569b096457332cd8de7fe0f00c16b87fb1b (patch)
tree19e10619f87748ee153e3b38e00ad1d7c253144c /testsuites/psxtmtests
parentpsx07.doc: New file (diff)
downloadrtems-72ff7569b096457332cd8de7fe0f00c16b87fb1b.tar.bz2
psxtmtests: added new psxtmcond04 test, fixed psxtmcond03
Diffstat (limited to 'testsuites/psxtmtests')
-rw-r--r--testsuites/psxtmtests/Makefile.am1
-rw-r--r--testsuites/psxtmtests/configure.ac1
-rw-r--r--testsuites/psxtmtests/psxtmcond03/init.c24
-rw-r--r--testsuites/psxtmtests/psxtmcond04/Makefile.am27
-rw-r--r--testsuites/psxtmtests/psxtmcond04/init.c107
-rw-r--r--testsuites/psxtmtests/psxtmcond04/psxtmcond04.doc25
-rw-r--r--testsuites/psxtmtests/psxtmtests_plan.csv2
7 files changed, 179 insertions, 8 deletions
diff --git a/testsuites/psxtmtests/Makefile.am b/testsuites/psxtmtests/Makefile.am
index b920047bef..15b97144c7 100644
--- a/testsuites/psxtmtests/Makefile.am
+++ b/testsuites/psxtmtests/Makefile.am
@@ -10,6 +10,7 @@ SUBDIRS += psxtmbarrier04
SUBDIRS += psxtmcond01
SUBDIRS += psxtmcond02
SUBDIRS += psxtmcond03
+SUBDIRS += psxtmcond04
SUBDIRS += psxtmcond05
SUBDIRS += psxtmcond08
SUBDIRS += psxtmcond09
diff --git a/testsuites/psxtmtests/configure.ac b/testsuites/psxtmtests/configure.ac
index 42be4bdc04..6cfc73c633 100644
--- a/testsuites/psxtmtests/configure.ac
+++ b/testsuites/psxtmtests/configure.ac
@@ -84,6 +84,7 @@ psxtmbarrier04/Makefile
psxtmcond01/Makefile
psxtmcond02/Makefile
psxtmcond03/Makefile
+psxtmcond04/Makefile
psxtmcond05/Makefile
psxtmcond08/Makefile
psxtmcond09/Makefile
diff --git a/testsuites/psxtmtests/psxtmcond03/init.c b/testsuites/psxtmtests/psxtmcond03/init.c
index 4c1b9ad6d3..f2228b7378 100644
--- a/testsuites/psxtmtests/psxtmcond03/init.c
+++ b/testsuites/psxtmtests/psxtmcond03/init.c
@@ -30,8 +30,15 @@ void *Blocker(
void *argument
)
{
+ int status;
+
+ status = pthread_mutex_lock(&MutexID);
+ rtems_test_assert( status == 0 );
+
+ /* Unlock mutex, block, wait for CondID to be signaled */
pthread_cond_wait(&CondID,&MutexID);
- /* should never return */
+
+ /* should never return */
rtems_test_assert( FALSE );
return NULL;
@@ -44,6 +51,8 @@ void *POSIX_Init(
int status;
pthread_t threadId;
long end_time;
+ struct sched_param param;
+ int policy;
puts( "\n\n*** POSIX TIME TEST PSXTMCOND03 ***" );
@@ -57,18 +66,19 @@ void *POSIX_Init(
rtems_test_assert( status == 0 );
/*
- * Ensure the mutex is unavailable so the other threads block.
- */
- status = pthread_mutex_lock(&MutexID);
- rtems_test_assert( status == 0 );
-
- /*
* Let the other thread start so the thread startup overhead,
* is accounted for. When we return, we can start the benchmark.
*/
sched_yield();
/* let other thread run */
+ /* To be extra sure we don't get preempted on the signal */
+ status = pthread_getschedparam(pthread_self(), &policy, &param);
+ rtems_test_assert( status == 0);
+ param.sched_priority = sched_get_priority_max(policy) - 1;
+ status = pthread_setschedparam(pthread_self(), policy, &param);
+ rtems_test_assert( status == 0);
+
benchmark_timer_initialize();
status = pthread_cond_signal(&CondID);
end_time = benchmark_timer_read();
diff --git a/testsuites/psxtmtests/psxtmcond04/Makefile.am b/testsuites/psxtmtests/psxtmcond04/Makefile.am
new file mode 100644
index 0000000000..875b08c576
--- /dev/null
+++ b/testsuites/psxtmtests/psxtmcond04/Makefile.am
@@ -0,0 +1,27 @@
+MANAGERS = all
+
+rtems_tests_PROGRAMS = psxtmcond04
+psxtmcond04_SOURCES = init.c
+psxtmcond04_SOURCES += ../../tmtests/include/timesys.h
+psxtmcond04_SOURCES += ../../support/src/tmtests_empty_function.c
+psxtmcond04_SOURCES += ../../support/src/tmtests_support.c
+
+dist_rtems_tests_DATA = psxtmcond04.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 = $(psxtmcond04_OBJECTS) $(psxtmcond04_LDADD)
+LINK_LIBS = $(psxtmcond04_LDLIBS)
+
+psxtmcond04$(EXEEXT): $(psxtmcond04_OBJECTS) $(psxtmcond04_DEPENDENCIES)
+ @rm -f psxtmcond04$(EXEEXT)
+ $(make-exe)
+
+include $(top_srcdir)/../automake/local.am
diff --git a/testsuites/psxtmtests/psxtmcond04/init.c b/testsuites/psxtmtests/psxtmcond04/init.c
new file mode 100644
index 0000000000..676a3c84a8
--- /dev/null
+++ b/testsuites/psxtmtests/psxtmcond04/init.c
@@ -0,0 +1,107 @@
+/*
+ * COPYRIGHT (c) 2013.
+ * 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <coverhd.h>
+#include <tmacros.h>
+#include <timesys.h>
+#include "test_support.h"
+#include <pthread.h>
+#include <sched.h>
+#include <rtems/timerdrv.h>
+
+/* forward declarations to avoid warnings */
+void *POSIX_Init(void *argument);
+void *Blocker(void *argument);
+
+pthread_mutex_t MutexID;
+pthread_cond_t CondID;
+
+void *Blocker(
+ void *argument
+)
+{
+
+ long end_time;
+ struct sched_param param;
+ int policy;
+ int status;
+
+ status = pthread_mutex_lock(&MutexID);
+ rtems_test_assert( status == 0 );
+ status = pthread_getschedparam(pthread_self(), &policy, &param);
+ rtems_test_assert( status == 0 );
+ param.sched_priority = sched_get_priority_max(policy) - 1;
+ status = pthread_setschedparam(pthread_self(), policy, &param);
+ /* Thread blocks, unlocks mutex, waits for CondID to be signaled */
+ pthread_cond_wait(&CondID,&MutexID);
+
+ /* Once signaled, this thread preempts POSIX_Init thread */
+ end_time = benchmark_timer_read();
+ put_time(
+ "pthread_cond_signal - thread waiting, preempt",
+ end_time,
+ 1,
+ 0,
+ 0
+ );
+ puts( "*** END OF POSIX TIME TEST PSXTMCOND04 ***" );
+ rtems_test_exit( 0 );
+ return NULL;
+}
+
+void *POSIX_Init(
+ void *argument
+)
+{
+ int status;
+ pthread_t threadId;
+
+ puts( "\n\n*** POSIX TIME TEST PSXTMCOND04 ***" );
+
+ status = pthread_create( &threadId, NULL, Blocker, NULL );
+ rtems_test_assert( status == 0 );
+
+ status = pthread_mutex_init(&MutexID, NULL);
+ rtems_test_assert( status == 0 );
+
+ status = pthread_cond_init(&CondID, NULL); /* Create condition variable */
+ rtems_test_assert( status == 0 );
+
+ /*
+ * Let the other thread start so the thread startup overhead,
+ * is accounted for. When we return, we can start the benchmark.
+ */
+ sched_yield();
+ /* let other thread run */
+
+ /* Other thread is blocked and waiting on condition to be signaled */
+ benchmark_timer_initialize();
+ status = pthread_cond_signal(&CondID);
+ rtems_test_assert ( status == 0 );
+ return NULL;
+}
+
+/* configuration information */
+
+#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
+#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
+
+#define CONFIGURE_MAXIMUM_POSIX_THREADS 2
+#define CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES 2
+#define CONFIGURE_MAXIMUM_POSIX_MUTEXES 2
+#define CONFIGURE_POSIX_INIT_THREAD_TABLE
+
+#define CONFIGURE_INIT
+
+#include <rtems/confdefs.h>
+ /* end of file */
diff --git a/testsuites/psxtmtests/psxtmcond04/psxtmcond04.doc b/testsuites/psxtmtests/psxtmcond04/psxtmcond04.doc
new file mode 100644
index 0000000000..eb260805a3
--- /dev/null
+++ b/testsuites/psxtmtests/psxtmcond04/psxtmcond04.doc
@@ -0,0 +1,25 @@
+# COPYRIGHT (c) 2013
+# 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_cond_signal - thread waiting: preempt
+
+This file describes the directives and concepts tested by this test set.
+
+test set name: psxtmcond
+
+directives:
++ pthread_cond_signal
++ pthread_mutex_lock
++ pthread_mutex_init
++ pthread_cond_init
++ pthread_create
+
+concepts:
++ Benchmark the call pthread_cond_signal to unlock a mutex, with a preempt.
diff --git a/testsuites/psxtmtests/psxtmtests_plan.csv b/testsuites/psxtmtests/psxtmtests_plan.csv
index c89fbcc69f..b21f50be93 100644
--- a/testsuites/psxtmtests/psxtmtests_plan.csv
+++ b/testsuites/psxtmtests/psxtmtests_plan.csv
@@ -17,7 +17,7 @@
"pthread_cond_destroy","psxtmcond01","psxtmtest_init_destroy","Yes"
"pthread_cond_signal - no threads waiting","psxtmcond02","psxtmtest_single","Yes"
"pthread_cond_signal - thread waiting: no preempt","psxtmcond03","psxtmtest_unblocking_nopreempt","Yes"
-"pthread_cond_signal - thread waiting: preempt","psxtmcond04","psxtmtest_unblocking_preempt","No"
+"pthread_cond_signal - thread waiting: preempt","psxtmcond04","psxtmtest_unblocking_preempt","Yes"
"pthread_cond_broadcast - no threads waiting","psxtmcond05","psxtmtest_single","Yes"
"pthread_cond_broadcast - threads waiting: no preempt","psxtmcond06","psxtmtest_unblocking_nopreempt","No"
"pthread_cond_broadcast - threads waiting: preempt","psxtmcond07","psxtmtest_unblocking_preempt","No"