[rtems commit] Create POSIX Timing Test psxtmcond09

Jennifer Averett jennifer at rtems.org
Fri Jan 11 20:33:51 UTC 2013


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

Author:    Christopher Kerl <zargyyoyo at gmail.com>
Date:      Fri Jan 11 14:33:37 2013 -0600

Create POSIX Timing Test psxtmcond09

Modifications were made to this submission allow the same init.c
file to be ran by three tests that were very similar using posix
pthread_cond_timedwait and pthread_cond_wait.

---

 testsuites/psxtmtests/Makefile.am                 |    3 +
 testsuites/psxtmtests/configure.ac                |    3 +
 testsuites/psxtmtests/psxtmcond08/Makefile.am     |   28 ++++
 testsuites/psxtmtests/psxtmcond08/init.c          |  178 +++++++++++++++++++++
 testsuites/psxtmtests/psxtmcond08/psxtmcond08.doc |   11 ++
 testsuites/psxtmtests/psxtmcond09/Makefile.am     |   28 ++++
 testsuites/psxtmtests/psxtmcond09/psxtmcond09.doc |   11 ++
 testsuites/psxtmtests/psxtmcond10/Makefile.am     |   28 ++++
 8 files changed, 290 insertions(+), 0 deletions(-)

diff --git a/testsuites/psxtmtests/Makefile.am b/testsuites/psxtmtests/Makefile.am
index db10965..3530eaf 100644
--- a/testsuites/psxtmtests/Makefile.am
+++ b/testsuites/psxtmtests/Makefile.am
@@ -10,6 +10,9 @@ SUBDIRS += psxtmcond01
 SUBDIRS += psxtmcond02
 SUBDIRS += psxtmcond03
 SUBDIRS += psxtmcond05
+SUBDIRS += psxtmcond08
+SUBDIRS += psxtmcond09
+SUBDIRS += psxtmcond10
 SUBDIRS += psxtmkey01
 SUBDIRS += psxtmkey02
 SUBDIRS += psxtmmq01
diff --git a/testsuites/psxtmtests/configure.ac b/testsuites/psxtmtests/configure.ac
index 1972b84..ab01acb 100644
--- a/testsuites/psxtmtests/configure.ac
+++ b/testsuites/psxtmtests/configure.ac
@@ -84,6 +84,9 @@ psxtmcond01/Makefile
 psxtmcond02/Makefile
 psxtmcond03/Makefile
 psxtmcond05/Makefile
+psxtmcond08/Makefile
+psxtmcond09/Makefile
+psxtmcond10/Makefile
 psxtmkey01/Makefile
 psxtmkey02/Makefile
 psxtmmq01/Makefile
diff --git a/testsuites/psxtmtests/psxtmcond08/Makefile.am b/testsuites/psxtmtests/psxtmcond08/Makefile.am
new file mode 100644
index 0000000..6207972
--- /dev/null
+++ b/testsuites/psxtmtests/psxtmcond08/Makefile.am
@@ -0,0 +1,28 @@
+MANAGERS = all
+
+rtems_tests_PROGRAMS = psxtmcond08
+psxtmcond08_SOURCES  = init.c
+psxtmcond08_SOURCES += ../../tmtests/include/timesys.h
+psxtmcond08_SOURCES += ../../support/src/tmtests_empty_function.c
+psxtmcond08_SOURCES += ../../support/src/tmtests_support.c
+
+dist_rtems_tests_DATA = psxtmcond08.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
+AM_CPPFLAGS += -DUSE_WAIT
+
+LINK_OBJS = $(psxtmcond08_OBJECTS) $(psxtmcond08_LDADD)
+LINK_LIBS = $(psxtmcond08_LDLIBS)
+
+psxtmcond08$(EXEEXT): $(psxtmcond08_OBJECTS) $(psxtmcond08_DEPENDENCIES)
+	@rm -f psxtmcond08$(EXEEXT)
+	$(make-exe)
+
+include $(top_srcdir)/../automake/local.am
diff --git a/testsuites/psxtmtests/psxtmcond08/init.c b/testsuites/psxtmtests/psxtmcond08/init.c
new file mode 100644
index 0000000..af97036
--- /dev/null
+++ b/testsuites/psxtmtests/psxtmcond08/init.c
@@ -0,0 +1,178 @@
+/*
+ *  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.
+ */
+
+#if   defined(USE_WAIT)
+  #define TEST_NUMBER "08"
+  #define TEST_CASE "pthread_cond_wait - blocking"
+#elif defined(USE_TIMEDWAIT_WITH_VALUE)
+  #define TEST_NUMBER "09"
+  #define TEST_CASE "pthread_cond_timedwait - blocking"
+#elif defined(USE_TIMEDWAIT_WAIT_VALUE_IN_PAST)
+  #define TEST_NUMBER "10"
+  #define TEST_CASE "pthread_cond_timedwait - time in past error"
+#else
+  #error "How am I being compiled?"
+#endif
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdio.h>
+#include <time.h>
+#include <errno.h>
+#include <timesys.h>
+#include <tmacros.h>
+#include <rtems/timerdrv.h>
+#include "test_support.h"
+
+#include <pthread.h>
+
+/* forward declarations to avoid warnings */
+void *POSIX_Init(void *argument);
+void *Middle(void *argument);
+void *Low(void *argument);
+
+pthread_cond_t  CondID;
+pthread_mutex_t MutexID;
+struct timespec sleepTime;
+
+void *Low(
+  void *argument
+)
+{
+  long end_time;
+
+  end_time = benchmark_timer_read();
+
+  put_time(
+    TEST_CASE,
+    end_time,
+    OPERATION_COUNT,
+    0,
+    0
+  );
+
+  puts( "*** END OF POSIX TIME TEST PSXTMCOND" TEST_NUMBER " ***" );
+
+  rtems_test_exit( 0 );
+  return NULL;
+}
+
+void *Middle(
+  void *argument
+)
+{
+  int             rc;
+
+
+  rc = pthread_mutex_lock(&MutexID);
+  rtems_test_assert( rc == 0 );
+
+  /* block and switch to another task here */
+
+  #if   defined(USE_WAIT)
+    rc = pthread_cond_wait( &CondID, &MutexID );
+    rtems_test_assert( rc == 0 );
+
+  #elif defined(USE_TIMEDWAIT_WITH_VALUE)
+   
+    rc = pthread_cond_timedwait( &CondID, &MutexID, &sleepTime );
+    rtems_test_assert( rc == 0 );
+
+  #elif defined(USE_TIMEDWAIT_WAIT_VALUE_IN_PAST)
+    {
+      long end_time;
+
+      /* override sleepTime with something obviously in the past */
+      sleepTime.tv_sec = 0;
+      sleepTime.tv_nsec = 5;
+
+      /* this does all the work of timedwait but immediately returns */
+      rc = pthread_cond_timedwait( &CondID, &MutexID, &sleepTime );
+      end_time = benchmark_timer_read();
+      rtems_test_assert(rc == ETIMEDOUT);
+    }
+  #endif
+
+  pthread_mutex_unlock(&MutexID);
+  #if defined(USE_TIMEDWAIT_WAIT_VALUE_IN_PAST)
+    /*
+     * In this case, unlock does not switch to another thread. so we need
+     * to explicitly yield. If we do not yield, then we will measure the
+     * time required to do an implicit pthread_exit() which is undesirable
+     * from a measurement viewpoint.
+     */
+    sched_yield();
+  #endif
+  return NULL;
+}
+
+void *POSIX_Init(
+  void *argument
+)
+{
+  int             i;
+  int             status;
+  pthread_t       threadId;
+  int             rc;
+  struct timeval  tp;
+
+  puts( "\n\n*** POSIX TIME TEST PSXTMCOND" TEST_NUMBER " ***" );
+
+  rc =  gettimeofday(&tp, NULL);
+  rtems_test_assert( rc == 0 );
+
+  /* Convert from timeval to timespec */
+  sleepTime.tv_sec  = tp.tv_sec;
+  sleepTime.tv_nsec = tp.tv_usec * 1000;
+  sleepTime.tv_nsec += 1;
+
+  rc = pthread_cond_init(&CondID, NULL);
+  rtems_test_assert( rc == 0 );
+
+  rc = pthread_mutex_init(&MutexID, NULL);
+  rtems_test_assert( rc == 0 );
+
+  rc = pthread_mutex_lock(&MutexID);
+  rtems_test_assert( rc == 0 );
+
+  for ( i=0 ; i < OPERATION_COUNT - 1 ; i++ ) {
+    status = pthread_create( &threadId, NULL, Middle, NULL );
+    rtems_test_assert( !status );
+  }
+
+  status = pthread_create( &threadId, NULL, Low, NULL );
+  rtems_test_assert( !status );
+
+  /* start the timer and switch through all the other tasks */
+  benchmark_timer_initialize();
+
+  rc = pthread_mutex_unlock(&MutexID);
+  rtems_test_assert( rc == 0 );
+
+  /* Should never return. */
+  return NULL;
+}
+
+/* configuration information */
+
+#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
+#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
+
+#define CONFIGURE_MAXIMUM_POSIX_THREADS     OPERATION_COUNT + 2
+#define CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES 2
+#define CONFIGURE_POSIX_INIT_THREAD_TABLE
+#define CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES 2
+#define CONFIGURE_MAXIMUM_POSIX_MUTEXES 2
+
+#define CONFIGURE_INIT
+
+#include <rtems/confdefs.h>
+  /* end of file */
diff --git a/testsuites/psxtmtests/psxtmcond08/psxtmcond08.doc b/testsuites/psxtmtests/psxtmcond08/psxtmcond08.doc
new file mode 100644
index 0000000..865fc07
--- /dev/null
+++ b/testsuites/psxtmtests/psxtmcond08/psxtmcond08.doc
@@ -0,0 +1,11 @@
+#  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:
+
++ 
diff --git a/testsuites/psxtmtests/psxtmcond09/Makefile.am b/testsuites/psxtmtests/psxtmcond09/Makefile.am
new file mode 100644
index 0000000..c5b4edd
--- /dev/null
+++ b/testsuites/psxtmtests/psxtmcond09/Makefile.am
@@ -0,0 +1,28 @@
+MANAGERS = all
+
+rtems_tests_PROGRAMS = psxtmcond09
+psxtmcond09_SOURCES  = ../psxtmcond08/init.c
+psxtmcond09_SOURCES += ../../tmtests/include/timesys.h
+psxtmcond09_SOURCES += ../../support/src/tmtests_empty_function.c
+psxtmcond09_SOURCES += ../../support/src/tmtests_support.c
+
+dist_rtems_tests_DATA = psxtmcond09.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
+AM_CPPFLAGS += -DUSE_TIMEDWAIT_WITH_VALUE
+
+LINK_OBJS = $(psxtmcond09_OBJECTS) $(psxtmcond09_LDADD)
+LINK_LIBS = $(psxtmcond09_LDLIBS)
+
+psxtmcond09$(EXEEXT): $(psxtmcond09_OBJECTS) $(psxtmcond09_DEPENDENCIES)
+	@rm -f psxtmcond09$(EXEEXT)
+	$(make-exe)
+
+include $(top_srcdir)/../automake/local.am
diff --git a/testsuites/psxtmtests/psxtmcond09/psxtmcond09.doc b/testsuites/psxtmtests/psxtmcond09/psxtmcond09.doc
new file mode 100644
index 0000000..865fc07
--- /dev/null
+++ b/testsuites/psxtmtests/psxtmcond09/psxtmcond09.doc
@@ -0,0 +1,11 @@
+#  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:
+
++ 
diff --git a/testsuites/psxtmtests/psxtmcond10/Makefile.am b/testsuites/psxtmtests/psxtmcond10/Makefile.am
new file mode 100644
index 0000000..19222c8
--- /dev/null
+++ b/testsuites/psxtmtests/psxtmcond10/Makefile.am
@@ -0,0 +1,28 @@
+MANAGERS = all
+
+rtems_tests_PROGRAMS = psxtmcond10
+psxtmcond10_SOURCES  = ../psxtmcond08/init.c
+psxtmcond10_SOURCES += ../../tmtests/include/timesys.h
+psxtmcond10_SOURCES += ../../support/src/tmtests_empty_function.c
+psxtmcond10_SOURCES += ../../support/src/tmtests_support.c
+
+dist_rtems_tests_DATA = psxtmcond10.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
+AM_CPPFLAGS += -DUSE_TIMEDWAIT_WAIT_VALUE_IN_PAST
+
+LINK_OBJS = $(psxtmcond10_OBJECTS) $(psxtmcond10_LDADD)
+LINK_LIBS = $(psxtmcond10_LDLIBS)
+
+psxtmcond10$(EXEEXT): $(psxtmcond10_OBJECTS) $(psxtmcond10_DEPENDENCIES)
+	@rm -f psxtmcond10$(EXEEXT)
+	$(make-exe)
+
+include $(top_srcdir)/../automake/local.am
diff --git a/testsuites/psxtmtests/psxtmcond10/psxtmcond10.doc b/testsuites/psxtmtests/psxtmcond10/psxtmcond10.doc
new file mode 100644
index 0000000..e69de29




More information about the vc mailing list