[rtems commit] psxtmtests: added psxtmcond07 test

Joel Sherrill joel at rtems.org
Tue Dec 10 05:20:03 UTC 2013


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

Author:    Daniel Ramirez <javamonn at gmail.com>
Date:      Mon Dec  9 23:16:17 2013 -0600

psxtmtests: added psxtmcond07 test

---

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

diff --git a/testsuites/psxtmtests/Makefile.am b/testsuites/psxtmtests/Makefile.am
index 4474cbe..c4276a4 100644
--- a/testsuites/psxtmtests/Makefile.am
+++ b/testsuites/psxtmtests/Makefile.am
@@ -13,6 +13,7 @@ SUBDIRS += psxtmcond03
 SUBDIRS += psxtmcond04
 SUBDIRS += psxtmcond05
 SUBDIRS += psxtmcond06
+SUBDIRS += psxtmcond07
 SUBDIRS += psxtmcond08
 SUBDIRS += psxtmcond09
 SUBDIRS += psxtmcond10
diff --git a/testsuites/psxtmtests/configure.ac b/testsuites/psxtmtests/configure.ac
index 8b720f1..7882321 100644
--- a/testsuites/psxtmtests/configure.ac
+++ b/testsuites/psxtmtests/configure.ac
@@ -87,6 +87,7 @@ psxtmcond03/Makefile
 psxtmcond04/Makefile
 psxtmcond05/Makefile
 psxtmcond06/Makefile
+psxtmcond07/Makefile
 psxtmcond08/Makefile
 psxtmcond09/Makefile
 psxtmcond10/Makefile
diff --git a/testsuites/psxtmtests/psxtmcond07/Makefile.am b/testsuites/psxtmtests/psxtmcond07/Makefile.am
new file mode 100644
index 0000000..d266770
--- /dev/null
+++ b/testsuites/psxtmtests/psxtmcond07/Makefile.am
@@ -0,0 +1,27 @@
+MANAGERS = all
+
+rtems_tests_PROGRAMS = psxtmcond07
+psxtmcond07_SOURCES  = init.c
+psxtmcond07_SOURCES += ../../tmtests/include/timesys.h
+psxtmcond07_SOURCES += ../../support/src/tmtests_empty_function.c
+psxtmcond07_SOURCES += ../../support/src/tmtests_support.c
+
+dist_rtems_tests_DATA = psxtmcond07.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 = $(psxtmcond07_OBJECTS) $(psxtmcond07_LDADD)
+LINK_LIBS = $(psxtmcond07_LDLIBS)
+
+psxtmcond07$(EXEEXT): $(psxtmcond07_OBJECTS) $(psxtmcond07_DEPENDENCIES)
+	@rm -f psxtmcond07$(EXEEXT)
+	$(make-exe)
+
+include $(top_srcdir)/../automake/local.am
diff --git a/testsuites/psxtmtests/psxtmcond07/init.c b/testsuites/psxtmtests/psxtmcond07/init.c
new file mode 100644
index 0000000..523d9ae
--- /dev/null
+++ b/testsuites/psxtmtests/psxtmcond07/init.c
@@ -0,0 +1,127 @@
+/*
+ *  COPYRIGHT (c) 1989-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>
+
+#define N 1
+
+/* 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;
+  benchmark_timer_t  end_time;
+
+  status = pthread_mutex_lock(&MutexID);
+  rtems_test_assert( status == 0 );
+
+  /* Unlock mutex, block, wait for CondID to be signaled */
+  pthread_cond_wait(&CondID,&MutexID);
+
+  end_time = benchmark_timer_read();
+  put_time(
+    "pthread_cond_broadcast: threads waiting, preempt",
+    end_time,
+    1,
+    0,
+    0
+  );
+
+  puts( "*** END OF POSIX TIME TEST PSXTMCOND07 ***" );
+  rtems_test_exit( 0 );
+  return NULL;
+
+}
+
+void *POSIX_Init(
+  void *argument
+)
+{
+  int                 status;
+  int                 i;
+  pthread_t           threadId;
+  pthread_attr_t      attr;
+  struct sched_param  param;
+
+  puts( "\n\n*** POSIX TIME TEST PSXTMCOND07 ***" );
+
+  /* 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);
+  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 );
+  }
+
+  /* broadcast will awaken all threads and one will preempt us, end time
+   * in other thread
+   */
+  benchmark_timer_initialize();
+  status = pthread_cond_broadcast(&CondID);
+
+  /* Should never reach this point */
+  rtems_test_assert( FALSE );
+  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 1
+#define CONFIGURE_MAXIMUM_POSIX_MUTEXES 1
+#define CONFIGURE_POSIX_INIT_THREAD_TABLE
+
+#define CONFIGURE_INIT
+
+#include <rtems/confdefs.h>
+  /* end of file */
diff --git a/testsuites/psxtmtests/psxtmcond07/psxtmcond07.doc b/testsuites/psxtmtests/psxtmcond07/psxtmcond07.doc
new file mode 100644
index 0000000..599ee03
--- /dev/null
+++ b/testsuites/psxtmtests/psxtmcond07/psxtmcond07.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, 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 a
+  resulting preempt.
diff --git a/testsuites/psxtmtests/psxtmtests_plan.csv b/testsuites/psxtmtests/psxtmtests_plan.csv
index e94de3f..190ae9b 100644
--- a/testsuites/psxtmtests/psxtmtests_plan.csv
+++ b/testsuites/psxtmtests/psxtmtests_plan.csv
@@ -20,7 +20,7 @@
 "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","Yes"
-"pthread_cond_broadcast:  threads waiting: preempt","psxtmcond07","psxtmtest_unblocking_preempt","No"
+"pthread_cond_broadcast:  threads waiting: preempt","psxtmcond07","psxtmtest_unblocking_preempt","Yes"
 
 "pthread_cond_wait: blocks","psxtmcond08","psxtmtest_blocking","Yes"
 "pthread_cond_timedwait: blocks,"psxtmcond09","psxtmtest_blocking","yes"




More information about the vc mailing list