summaryrefslogtreecommitdiffstats
path: root/testsuites/psxtests/psxconcurrency01
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/psxtests/psxconcurrency01
parentposix: Run key destructors during thread restart (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/psxtests/psxconcurrency01')
-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
4 files changed, 111 insertions, 0 deletions
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 ***