summaryrefslogtreecommitdiffstats
path: root/testsuites
diff options
context:
space:
mode:
authorJoel Sherrill <joel@rtems.org>2016-02-19 16:00:48 -0600
committerJoel Sherrill <joel@rtems.org>2016-04-14 16:28:10 -0500
commit8228548d127dd73439615f45f38f92b8a42bcfed (patch)
treeb7a48c833e30bcbd736f649815129c8aff2201f4 /testsuites
parent6efa3498504bffde166b4663319bd7d94ea42a08 (diff)
downloadrtems-8228548d127dd73439615f45f38f92b8a42bcfed.tar.bz2
Add pthread_getconcurrency() and pthread_setconcurrency()
This is the very simple implementation specified by the Open Group for implementations with 1:1 kernel thread to user thread mappings. http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_getconcurrency.html updates #2680.
Diffstat (limited to 'testsuites')
-rw-r--r--testsuites/psxtests/Makefile.am2
-rw-r--r--testsuites/psxtests/configure.ac1
-rw-r--r--testsuites/psxtests/psxconcurrency01/Makefile.am23
-rw-r--r--testsuites/psxtests/psxconcurrency01/init.c58
-rw-r--r--testsuites/psxtests/psxconcurrency01/psxconcurrency01.doc25
-rw-r--r--testsuites/psxtests/psxconcurrency01/psxconcurrency01.scn5
-rw-r--r--testsuites/psxtests/psxhdrs/Makefile.am2
-rw-r--r--testsuites/psxtests/psxhdrs/pthread/pthread_getconcurrency.c34
-rw-r--r--testsuites/psxtests/psxhdrs/pthread/pthread_setconcurrency.c37
9 files changed, 186 insertions, 1 deletions
diff --git a/testsuites/psxtests/Makefile.am b/testsuites/psxtests/Makefile.am
index bb89cdec04..6dd5649a34 100644
--- a/testsuites/psxtests/Makefile.am
+++ b/testsuites/psxtests/Makefile.am
@@ -7,7 +7,7 @@ _SUBDIRS += psxhdrs psx01 psx02 psx03 psx04 psx05 psx06 psx07 psx08 psx09 \
psxaio01 psxaio02 psxaio03 \
psxalarm01 psxautoinit01 psxautoinit02 psxbarrier01 \
psxcancel psxcancel01 psxclassic01 psxcleanup psxcleanup01 \
- psxcond01 psxconfig01 psxenosys \
+ psxconcurrency01 psxcond01 psxconfig01 psxenosys \
psxitimer psxmsgq01 psxmsgq02 psxmsgq03 psxmsgq04 \
psxmutexattr01 psxobj01 psxrwlock01 psxsem01 psxsignal01 psxsignal02 \
psxsignal03 psxsignal04 psxsignal05 psxsignal06 \
diff --git a/testsuites/psxtests/configure.ac b/testsuites/psxtests/configure.ac
index 67ef83e302..779e0b5d15 100644
--- a/testsuites/psxtests/configure.ac
+++ b/testsuites/psxtests/configure.ac
@@ -143,6 +143,7 @@ psxcleanup01/Makefile
psxcleanup02/Makefile
psxclock/Makefile
psxclock01/Makefile
+psxconcurrency01/Makefile
psxcond01/Makefile
psxconfig01/Makefile
psxeintr_join/Makefile
diff --git a/testsuites/psxtests/psxconcurrency01/Makefile.am b/testsuites/psxtests/psxconcurrency01/Makefile.am
new file mode 100644
index 0000000000..2be4ebb989
--- /dev/null
+++ b/testsuites/psxtests/psxconcurrency01/Makefile.am
@@ -0,0 +1,23 @@
+
+rtems_tests_PROGRAMS = psxconcurrency01
+psxconcurrency01_SOURCES = init.c ../include/pmacros.h
+
+dist_rtems_tests_DATA = psxconcurrency01.scn
+dist_rtems_tests_DATA += psxconcurrency01.doc
+
+include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
+include $(top_srcdir)/../automake/compile.am
+include $(top_srcdir)/../automake/leaf.am
+
+
+AM_CPPFLAGS += -I$(top_srcdir)/include
+AM_CPPFLAGS += -I$(top_srcdir)/../support/include
+
+LINK_OBJS = $(psxconcurrency01_OBJECTS)
+LINK_LIBS = $(psxconcurrency01_LDLIBS)
+
+psxconcurrency01$(EXEEXT): $(psxconcurrency01_OBJECTS) $(psxconcurrency01_DEPENDENCIES)
+ @rm -f psxconcurrency01$(EXEEXT)
+ $(make-exe)
+
+include $(top_srcdir)/../automake/local.am
diff --git a/testsuites/psxtests/psxconcurrency01/init.c b/testsuites/psxtests/psxconcurrency01/init.c
new file mode 100644
index 0000000000..60aef9230d
--- /dev/null
+++ b/testsuites/psxtests/psxconcurrency01/init.c
@@ -0,0 +1,58 @@
+/*
+ * COPYRIGHT (c) 2016
+ * 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.org/license/LICENSE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <pmacros.h>
+#include <pthread.h>
+#include <errno.h>
+
+const char rtems_test_name[] = "PSXCONCURRENCY01";
+
+/* forward declarations to avoid warnings */
+void *POSIX_Init(void *argument);
+
+void *POSIX_Init(
+ void *argument
+)
+{
+ int sc;
+
+ TEST_BEGIN();
+
+ puts( "Init: pthread_getconcurrency - initial value of 0" );
+ sc = pthread_getconcurrency();
+ rtems_test_assert( sc == 0 );
+
+ puts( "Init: pthread_setconcurrency - set value to 2" );
+ sc = pthread_setconcurrency( 2 );
+ rtems_test_assert( sc == 0 );
+
+ puts( "Init: pthread_getconcurrency - confirm new value of 2" );
+ sc = pthread_getconcurrency();
+ rtems_test_assert( sc == 2 );
+
+ TEST_END();
+ rtems_test_exit(0);
+}
+
+
+/* configuration information */
+#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
+#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
+
+#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
+
+#define CONFIGURE_MAXIMUM_POSIX_THREADS 1
+#define CONFIGURE_POSIX_INIT_THREAD_TABLE
+
+#define CONFIGURE_INIT
+#include <rtems/confdefs.h>
diff --git a/testsuites/psxtests/psxconcurrency01/psxconcurrency01.doc b/testsuites/psxtests/psxconcurrency01/psxconcurrency01.doc
new file mode 100644
index 0000000000..62492adfc9
--- /dev/null
+++ b/testsuites/psxtests/psxconcurrency01/psxconcurrency01.doc
@@ -0,0 +1,25 @@
+# COPYRIGHT (c) 2016.
+# 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.org/license/LICENSE.
+#
+
+This file describes the directives and concepts tested by this test set.
+
+test set name: psxconcurrency01
+
+directives:
+ pthread_getconcurrency
+ pthread_setconcurrency
+
+concepts:
+
++ This test exercises the pthread_getconcurrency() method.
++ This test exercises the pthread_setconcurrency() method.
+
+NOTE: These methods are of limited utility with any threading implementation
+ in which kernel threads and user threads are mapped 1:1. As of POSIX
+ Issue 7 (POSIX 2013), these are marked obsolete. But they are still
+ required for 2008 and Open Group FACE conformance.
diff --git a/testsuites/psxtests/psxconcurrency01/psxconcurrency01.scn b/testsuites/psxtests/psxconcurrency01/psxconcurrency01.scn
new file mode 100644
index 0000000000..53eca04917
--- /dev/null
+++ b/testsuites/psxtests/psxconcurrency01/psxconcurrency01.scn
@@ -0,0 +1,5 @@
+*** BEGIN OF TEST PSXCONCURRENCY01 ***
+Init: pthread_getconcurrency - initial value of 0
+Init: pthread_setconcurrency - set value to 2
+Init: pthread_getconcurrency - confirm new value of 2
+*** END OF TEST PSXCONCURRENCY01 ***
diff --git a/testsuites/psxtests/psxhdrs/Makefile.am b/testsuites/psxtests/psxhdrs/Makefile.am
index 8dc13e17cf..3eecd84dbd 100644
--- a/testsuites/psxtests/psxhdrs/Makefile.am
+++ b/testsuites/psxtests/psxhdrs/Makefile.am
@@ -38,6 +38,7 @@ lib_a_SOURCES += pthread/pthread_create.c
lib_a_SOURCES += pthread/pthread_detach.c
lib_a_SOURCES += pthread/pthread_equal.c
lib_a_SOURCES += pthread/pthread_exit.c
+lib_a_SOURCES += pthread/pthread_getconcurrency.c
lib_a_SOURCES += pthread/pthread_getcpuclockid.c
lib_a_SOURCES += pthread/pthread_getschedparam.c
lib_a_SOURCES += pthread/pthread_getspecific.c
@@ -64,6 +65,7 @@ lib_a_SOURCES += pthread/pthread_once.c
lib_a_SOURCES += pthread/pthread_self.c
lib_a_SOURCES += pthread/pthread_setcancelstate.c
lib_a_SOURCES += pthread/pthread_setcanceltype.c
+lib_a_SOURCES += pthread/pthread_setconcurrency.c
lib_a_SOURCES += pthread/pthread_setschedparam.c
lib_a_SOURCES += pthread/pthread_setspecific.c
lib_a_SOURCES += pthread/pthread_testcancel.c
diff --git a/testsuites/psxtests/psxhdrs/pthread/pthread_getconcurrency.c b/testsuites/psxtests/psxhdrs/pthread/pthread_getconcurrency.c
new file mode 100644
index 0000000000..dda472030e
--- /dev/null
+++ b/testsuites/psxtests/psxhdrs/pthread/pthread_getconcurrency.c
@@ -0,0 +1,34 @@
+/**
+ * @file
+ * @brief pthread_getconcurrency() API Conformance Test
+ */
+
+/*
+ * COPYRIGHT (c) 2016.
+ * 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.org/license/LICENSE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <pthread.h>
+
+#ifndef _POSIX_THREADS
+#error "rtems is supposed to have pthread_getconcurrency"
+#endif
+
+int test( void );
+
+int test( void )
+{
+ int level;
+
+ level = pthread_getconcurrency();
+
+ return (level == 0);
+}
diff --git a/testsuites/psxtests/psxhdrs/pthread/pthread_setconcurrency.c b/testsuites/psxtests/psxhdrs/pthread/pthread_setconcurrency.c
new file mode 100644
index 0000000000..91b1889f10
--- /dev/null
+++ b/testsuites/psxtests/psxhdrs/pthread/pthread_setconcurrency.c
@@ -0,0 +1,37 @@
+/**
+ * @file
+ * @brief pthread_setconcurrency() API Conformance Test
+ */
+
+/*
+ * COPYRIGHT (c) 2016.
+ * 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.org/license/LICENSE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <pthread.h>
+
+#ifndef _POSIX_THREADS
+#error "rtems is supposed to have pthread_setconcurrency"
+#endif
+
+int test( void );
+
+int test( void )
+{
+ int level;
+ int rc;
+
+ level = 42;
+
+ rc = pthread_setconcurrency( level );
+
+ return (rc == 0);
+}