[rtems commit] psxtmtests: added psxtmcond06 test

Joel Sherrill joel at rtems.org
Sun Dec 1 12:44:23 UTC 2013


Module:    rtems
Branch:    master
Commit:    972579d32b588e947c4a78e18d1814e17946e3f8
Changeset: http://git.rtems.org/rtems/commit/?id=972579d32b588e947c4a78e18d1814e17946e3f8

Author:    Daniel Ramirez <javamonn at gmail.com>
Date:      Sat Nov 30 22:04:51 2013 -0600

psxtmtests: added psxtmcond06 test

---

 testsuites/psxtmtests/Makefile.am                 |    1 +
 testsuites/psxtmtests/configure.ac                |    1 +
 testsuites/psxtmtests/psxtmcond06/Makefile.am     |   27 +++++
 testsuites/psxtmtests/psxtmcond06/init.c          |  131 +++++++++++++++++++++
 testsuites/psxtmtests/psxtmcond06/psxtmcond06.doc |   26 ++++
 testsuites/psxtmtests/psxtmtests_plan.csv         |    2 +-
 6 files changed, 187 insertions(+), 1 deletions(-)

diff --git a/testsuites/psxtmtests/Makefile.am b/testsuites/psxtmtests/Makefile.am
index 15b9714..e5ca7b5 100644
--- a/testsuites/psxtmtests/Makefile.am
+++ b/testsuites/psxtmtests/Makefile.am
@@ -12,6 +12,7 @@ SUBDIRS += psxtmcond02
 SUBDIRS += psxtmcond03
 SUBDIRS += psxtmcond04
 SUBDIRS += psxtmcond05
+SUBDIRS += psxtmcond06
 SUBDIRS += psxtmcond08
 SUBDIRS += psxtmcond09
 SUBDIRS += psxtmcond10
diff --git a/testsuites/psxtmtests/configure.ac b/testsuites/psxtmtests/configure.ac
index 6cfc73c..5f0a503 100644
--- a/testsuites/psxtmtests/configure.ac
+++ b/testsuites/psxtmtests/configure.ac
@@ -86,6 +86,7 @@ psxtmcond02/Makefile
 psxtmcond03/Makefile
 psxtmcond04/Makefile
 psxtmcond05/Makefile
+psxtmcond06/Makefile
 psxtmcond08/Makefile
 psxtmcond09/Makefile
 psxtmcond10/Makefile
diff --git a/testsuites/psxtmtests/psxtmcond06/Makefile.am b/testsuites/psxtmtests/psxtmcond06/Makefile.am
new file mode 100644
index 0000000..37d54e6
--- /dev/null
+++ b/testsuites/psxtmtests/psxtmcond06/Makefile.am
@@ -0,0 +1,27 @@
+MANAGERS = all
+
+rtems_tests_PROGRAMS = psxtmcond06
+psxtmcond06_SOURCES  = init.c
+psxtmcond06_SOURCES += ../../tmtests/include/timesys.h
+psxtmcond06_SOURCES += ../../support/src/tmtests_empty_function.c
+psxtmcond06_SOURCES += ../../support/src/tmtests_support.c
+
+dist_rtems_tests_DATA = psxtmcond06.doc
+
+include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP at .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 = $(psxtmcond06_OBJECTS) $(psxtmcond06_LDADD)
+LINK_LIBS = $(psxtmcond06_LDLIBS)
+
+psxtmcond06$(EXEEXT): $(psxtmcond06_OBJECTS) $(psxtmcond06_DEPENDENCIES)
+	@rm -f psxtmcond06$(EXEEXT)
+	$(make-exe)
+
+include $(top_srcdir)/../automake/local.am
diff --git a/testsuites/psxtmtests/psxtmcond06/init.c b/testsuites/psxtmtests/psxtmcond06/init.c
new file mode 100644
index 0000000..13a1667
--- /dev/null
+++ b/testsuites/psxtmtests/psxtmcond06/init.c
@@ -0,0 +1,131 @@
+/*
+ *  COPYRIGHT (c) 1989-2012.
+ *  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>
+
+#define N 5
+
+/* 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
+)
+{
+  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 */
+  rtems_test_assert( FALSE );
+
+  return NULL;
+}
+
+void *POSIX_Init(
+  void *argument
+)
+{
+  long                end_time;
+  int                 status;
+  int                 i;
+  pthread_t           threadId;
+  pthread_attr_t      attr;
+  struct sched_param  param;
+  int                 policy;
+
+  puts( "\n\n*** POSIX TIME TEST PSXTMCOND06 ***" );
+
+  /* Setup variables */
+  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);
+  rtems_test_assert( status == 0 );
+
+  /* Setup so threads are created with a high enough priority to preempt
+   * as they get created.
+   */
+  status = pthread_attr_init( &attr );
+  rtems_test_assert( status == 0 );
+  status = pthread_attr_setinheritsched( &attr, PTHREAD_EXPLICIT_SCHED );
+  rtems_test_assert( status == 0 );
+  status = pthread_attr_setschedpolicy( &attr, SCHED_FIFO );
+  rtems_test_assert( status == 0 );
+  param.sched_priority = sched_get_priority_max(SCHED_FIFO) / 2;
+  status = pthread_attr_setschedparam( &attr, &param );
+  rtems_test_assert( status == 0 );
+
+  for ( i=0 ; i < N ; i++) {
+    /* Threads will preempt as they are created, start up, and block */
+    status = pthread_create(&threadId, &attr, Blocker, NULL);
+    rtems_test_assert( status == 0 );
+  }
+
+  /* Now that all the threads have been created, adjust our priority
+   * so we don't get preempted on broadcast.
+   */
+  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_broadcast(&CondID);
+  end_time = benchmark_timer_read();
+  rtems_test_assert( status == 0 );
+
+  put_time(
+    "pthread_cond_broadcast - threads waiting, no preempt",
+    end_time,
+    1,
+    0,
+    0
+  );
+
+  puts( "*** END OF POSIX TIME TEST PSXTMCOND06 ***" );
+  rtems_test_exit( 0 );
+
+  return NULL;
+}
+
+/* configuration information */
+
+#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
+#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
+
+#define CONFIGURE_MAXIMUM_POSIX_THREADS  2 + N
+#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/psxtmcond06/psxtmcond06.doc b/testsuites/psxtmtests/psxtmcond06/psxtmcond06.doc
new file mode 100644
index 0000000..c968748
--- /dev/null
+++ b/testsuites/psxtmtests/psxtmcond06/psxtmcond06.doc
@@ -0,0 +1,26 @@
+#  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_broadcast - threads waiting, no preempt
+
+This file describes the directives and concepts tested by this test set.
+
+test set name: psxtmcond
+
+directives:
++ pthread_cond_broadcast
++ pthread_mutex_lock
++ pthread_mutex_init
++ pthread_cond_init
++ pthread_create
+
+concepts:
++ Benchmark the call pthread_cond_broadcast to wake all other threads, with no
+  resulting preempt.
diff --git a/testsuites/psxtmtests/psxtmtests_plan.csv b/testsuites/psxtmtests/psxtmtests_plan.csv
index b21f50b..8f954af 100644
--- a/testsuites/psxtmtests/psxtmtests_plan.csv
+++ b/testsuites/psxtmtests/psxtmtests_plan.csv
@@ -19,7 +19,7 @@
 "pthread_cond_signal - thread waiting: no preempt","psxtmcond03","psxtmtest_unblocking_nopreempt","Yes"
 "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: no preempt","psxtmcond06","psxtmtest_unblocking_nopreempt","Yes"
 "pthread_cond_broadcast -  threads waiting: preempt","psxtmcond07","psxtmtest_unblocking_preempt","No"
 
 "pthread_cond_wait - blocks (mutex+condvar pattern)","psxtmcond08","psxtmtest_blocking","Yes"




More information about the vc mailing list