summaryrefslogtreecommitdiffstats
path: root/testsuites/psxtmtests
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2011-07-22 17:22:10 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2011-07-22 17:22:10 +0000
commit8f376951c55621103a15ff78f87919950d3ce16a (patch)
tree0cbe45ebeade48f424f1c8fa83886bf68cb570bc /testsuites/psxtmtests
parent2011-07-22 Ricardo Aguirre <el.mastin@ymail.com> (diff)
downloadrtems-8f376951c55621103a15ff78f87919950d3ce16a.tar.bz2
2011-07-22 Ricardo Aguirre <el.mastin@ymail.com>
PR 1847/tests * Makefile.am, configure.ac, psxtmtests_plan.csv: Add benchmark of various non-blocking semaphore operations. * psxtmsem02/.cvsignore, psxtmsem02/Makefile.am, psxtmsem02/init.c, psxtmsem02/psxtmsem02.doc: New files.
Diffstat (limited to 'testsuites/psxtmtests')
-rw-r--r--testsuites/psxtmtests/ChangeLog8
-rw-r--r--testsuites/psxtmtests/Makefile.am1
-rw-r--r--testsuites/psxtmtests/configure.ac1
-rw-r--r--testsuites/psxtmtests/psxtmsem02/.cvsignore2
-rw-r--r--testsuites/psxtmtests/psxtmsem02/Makefile.am30
-rw-r--r--testsuites/psxtmtests/psxtmsem02/init.c164
-rw-r--r--testsuites/psxtmtests/psxtmsem02/psxtmsem02.doc19
-rw-r--r--testsuites/psxtmtests/psxtmtests_plan.csv10
8 files changed, 230 insertions, 5 deletions
diff --git a/testsuites/psxtmtests/ChangeLog b/testsuites/psxtmtests/ChangeLog
index 85eed7650b..1f006b279a 100644
--- a/testsuites/psxtmtests/ChangeLog
+++ b/testsuites/psxtmtests/ChangeLog
@@ -1,5 +1,13 @@
2011-07-22 Ricardo Aguirre <el.mastin@ymail.com>
+ PR 1847/tests
+ * Makefile.am, configure.ac, psxtmtests_plan.csv: Add benchmark of
+ various non-blocking semaphore operations.
+ * psxtmsem02/.cvsignore, psxtmsem02/Makefile.am, psxtmsem02/init.c,
+ psxtmsem02/psxtmsem02.doc: New files.
+
+2011-07-22 Ricardo Aguirre <el.mastin@ymail.com>
+
PR 1846/tests
* Makefile.am, configure.ac, psxtmtests_plan.csv: Add benchmark of
various sem_open(), sem_close(), sem_unlink(), sem_init(), and
diff --git a/testsuites/psxtmtests/Makefile.am b/testsuites/psxtmtests/Makefile.am
index 5f905b6361..2f1f01ee06 100644
--- a/testsuites/psxtmtests/Makefile.am
+++ b/testsuites/psxtmtests/Makefile.am
@@ -19,6 +19,7 @@ SUBDIRS += psxtmmutex07
SUBDIRS += psxtmnanosleep01
SUBDIRS += psxtmnanosleep02
SUBDIRS += psxtmsem01
+SUBDIRS += psxtmsem02
SUBDIRS += psxtmsleep01
SUBDIRS += psxtmsleep02
SUBDIRS += psxtmthread01
diff --git a/testsuites/psxtmtests/configure.ac b/testsuites/psxtmtests/configure.ac
index 8122260139..4878dcddd1 100644
--- a/testsuites/psxtmtests/configure.ac
+++ b/testsuites/psxtmtests/configure.ac
@@ -91,6 +91,7 @@ psxtmmutex07/Makefile
psxtmnanosleep01/Makefile
psxtmnanosleep02/Makefile
psxtmsem01/Makefile
+psxtmsem02/Makefile
psxtmsleep01/Makefile
psxtmsleep02/Makefile
psxtmthread01/Makefile
diff --git a/testsuites/psxtmtests/psxtmsem02/.cvsignore b/testsuites/psxtmtests/psxtmsem02/.cvsignore
new file mode 100644
index 0000000000..282522db03
--- /dev/null
+++ b/testsuites/psxtmtests/psxtmsem02/.cvsignore
@@ -0,0 +1,2 @@
+Makefile
+Makefile.in
diff --git a/testsuites/psxtmtests/psxtmsem02/Makefile.am b/testsuites/psxtmtests/psxtmsem02/Makefile.am
new file mode 100644
index 0000000000..7147dc3b79
--- /dev/null
+++ b/testsuites/psxtmtests/psxtmsem02/Makefile.am
@@ -0,0 +1,30 @@
+##
+## $Id$
+##
+
+MANAGERS = all
+
+rtems_tests_PROGRAMS = psxtmsem02
+psxtmsem02_SOURCES = init.c ../../tmtests/include/timesys.h \
+ ../../support/src/tmtests_empty_function.c \
+ ../../support/src/tmtests_support.c
+
+dist_rtems_tests_DATA = psxtmsem02.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 = $(psxtmsem02_OBJECTS) $(psxtmsem02_LDADD)
+LINK_LIBS = $(psxtmsem02_LDLIBS)
+
+psxtmsem02$(EXEEXT): $(psxtmsem02_OBJECTS) $(psxtmsem02_DEPENDENCIES)
+ @rm -f psxtmsem02$(EXEEXT)
+ $(make-exe)
+
+include $(top_srcdir)/../automake/local.am
diff --git a/testsuites/psxtmtests/psxtmsem02/init.c b/testsuites/psxtmtests/psxtmsem02/init.c
new file mode 100644
index 0000000000..8aedde2757
--- /dev/null
+++ b/testsuites/psxtmtests/psxtmsem02/init.c
@@ -0,0 +1,164 @@
+/*
+ * 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 <errno.h>
+#include <fcntl.h>
+#include <semaphore.h>
+#include <tmacros.h>
+#include <timesys.h>
+#include <rtems/timerdrv.h>
+#include "test_support.h"
+
+sem_t sem1;
+sem_t *n_sem1;
+
+void benchmark_sem_getvalue(void)
+{
+ long end_time;
+ int status;
+ int value;
+
+ benchmark_timer_initialize();
+ status = sem_getvalue(&sem1, &value);
+ end_time = benchmark_timer_read();
+ rtems_test_assert( status == 0 );
+
+ put_time(
+ "sem_getvalue",
+ end_time,
+ 1, /* Only executed once */
+ 0,
+ 0
+ );
+}
+
+void benchmark_sem_wait(void)
+{
+ long end_time;
+ int status;
+
+ benchmark_timer_initialize();
+ status = sem_wait(&sem1);
+ end_time = benchmark_timer_read();
+ rtems_test_assert( status == 0 );
+
+ put_time(
+ "sem_wait – available",
+ end_time,
+ 1, /* Only executed once */
+ 0,
+ 0
+ );
+}
+
+void benchmark_sem_post(void)
+{
+ long end_time;
+ int status;
+
+ benchmark_timer_initialize();
+ status = sem_post(&sem1);
+ end_time = benchmark_timer_read();
+ rtems_test_assert( status == 0 );
+
+ put_time(
+ "sem_post - no threads waiting",
+ end_time,
+ 1, /* Only executed once */
+ 0,
+ 0
+ );
+}
+
+void benchmark_sem_trywait_available(void)
+{
+ long end_time;
+ int status;
+
+ benchmark_timer_initialize();
+ status = sem_trywait(&sem1);
+ end_time = benchmark_timer_read();
+ rtems_test_assert( status == 0 );
+
+ put_time(
+ "sem_trywait - available",
+ end_time,
+ 1, /* Only executed once */
+ 0,
+ 0
+ );
+}
+
+void benchmark_sem_trywait_not_available(void)
+{
+ long end_time;
+ int status;
+
+ benchmark_timer_initialize();
+ status = sem_trywait(&sem1);
+ end_time = benchmark_timer_read();
+ /*it must be non avalible, so status should be non zero*/
+ rtems_test_assert( status != 0 );
+
+ put_time(
+ "sem_trywait - not available",
+ end_time,
+ 1, /* Only executed once */
+ 0,
+ 0
+ );
+}
+
+void *POSIX_Init(void *argument)
+{
+ int status;
+ puts( "\n\n*** POSIX TIME TEST PSXTMSEM02 ***" );
+
+ /* create the semaphore */
+ status = sem_init( &sem1, 0, 1 );
+ rtems_test_assert( status == 0 );
+
+ /* obtain the actual semaphore value */
+ benchmark_sem_getvalue();
+ /* lock the semaphore */
+ benchmark_sem_wait();
+ /* unlock the semaphore */
+ benchmark_sem_post();
+ /* try to lock the semaphore - available */
+ benchmark_sem_trywait_available();
+ /* try to lock the semaphore, not available */
+ benchmark_sem_trywait_not_available();
+
+ puts( "*** END OF POSIX TIME TEST PSXTMSEM02 ***" );
+
+ /*Destroying the semaphore*/
+ status = sem_destroy(&sem1);
+ rtems_test_assert( status == 0 );
+
+ 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_SEMAPHORES 2
+#define CONFIGURE_POSIX_INIT_THREAD_TABLE
+
+#define CONFIGURE_INIT
+#include <rtems/confdefs.h>
+/* end of file */
diff --git a/testsuites/psxtmtests/psxtmsem02/psxtmsem02.doc b/testsuites/psxtmtests/psxtmsem02/psxtmsem02.doc
new file mode 100644
index 0000000000..bbcc50903a
--- /dev/null
+++ b/testsuites/psxtmtests/psxtmsem02/psxtmsem02.doc
@@ -0,0 +1,19 @@
+#
+# $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:
+
++ sem_getvalue
++ sem_wait – available
++ sem_post - no threads waiting
++ sem_trywait - available_
++ sem_trywait - not available
+
diff --git a/testsuites/psxtmtests/psxtmtests_plan.csv b/testsuites/psxtmtests/psxtmtests_plan.csv
index 5825aa767d..b62fdde052 100644
--- a/testsuites/psxtmtests/psxtmtests_plan.csv
+++ b/testsuites/psxtmtests/psxtmtests_plan.csv
@@ -106,14 +106,14 @@
"sem_unlink (does not delete)","psxtmsem01","psxtmtest_single","Yes"
"sem_close (named second close - removes)","psxtmsem01","psxtmtest_single","Yes"
"sem_unlink (deletes)","psxtmsem01","psxtmtest_single","Yes"
-"sem_wait - available",,"psxtmtest_single",
+"sem_wait - available","psxtmsem02","psxtmtest_single","Yes"
"sem_wait - not available, block",,"psxtmtest_blocking",
-"sem_trywait - available",,"psxtmtest_single",
-"sem_trywait - not available",,"psxtmtest_single",
-"sem_post - no threads waiting",,"psxtmtest_single",
+"sem_trywait - available","psxtmsem02","psxtmtest_single","Yes"
+"sem_trywait - not available","psxtmsem02","psxtmtest_single","Yes"
+"sem_post - no threads waiting","psxtmsem02","psxtmtest_single","Yes"
"sem_post - thread waiting, no preempt",,"psxtmtest_unblocking_nopreempt",
"sem_post - thread waiting, preempt",,"psxtmtest_unblocking_preempt",
-"sem_getvalue",,"psxtmtest_single",
+"sem_getvalue","psxtmsem02","psxtmtest_single","Yes"
,,,
"sleep - yield","psxtmsleep01","psxtmtest_single","Yes"
"sleep - blocking","psxtmsleep02","psxtmtest_blocking","Yes"