summaryrefslogtreecommitdiffstats
path: root/testsuites/psxtests
diff options
context:
space:
mode:
authorZhongwei Yao <ashi08104@gmail.com>2013-08-05 09:20:45 -0400
committerSebastian Huber <sebastian.huber@embedded-brains.de>2013-08-06 14:11:38 +0200
commitb5c906429f6e67452eec1b0089ac7a204ff998ee (patch)
tree5e24aed5499922f6d3fa6e1559f5bc7e83fba4b2 /testsuites/psxtests
parentbsp/realview-pbx-a9: Enable fast idle clock (diff)
downloadrtems-b5c906429f6e67452eec1b0089ac7a204ff998ee.tar.bz2
Unlimited objects support for POSIX keys
This patch enables unlimited model in POSIX key manger and have a decent runtime on POSIX key searching, adding and deleting operations. Memory overhead is lower than current implementation when the size of key and key value becomes big.
Diffstat (limited to 'testsuites/psxtests')
-rw-r--r--testsuites/psxtests/Makefile.am3
-rw-r--r--testsuites/psxtests/configure.ac7
-rw-r--r--testsuites/psxtests/psxkey01/init.c4
-rw-r--r--testsuites/psxtests/psxkey01/psxkey01.scn4
-rw-r--r--testsuites/psxtests/psxkey04/Makefile.am23
-rw-r--r--testsuites/psxtests/psxkey04/init.c128
-rw-r--r--testsuites/psxtests/psxkey04/psxkey04.doc22
-rw-r--r--testsuites/psxtests/psxkey04/psxkey04.scn11
-rw-r--r--testsuites/psxtests/psxkey05/Makefile.am23
-rw-r--r--testsuites/psxtests/psxkey05/init.c82
-rw-r--r--testsuites/psxtests/psxkey05/psxkey05.doc22
-rw-r--r--testsuites/psxtests/psxkey05/psxkey05.scn10
-rw-r--r--testsuites/psxtests/psxkey06/Makefile.am23
-rw-r--r--testsuites/psxtests/psxkey06/init.c153
-rw-r--r--testsuites/psxtests/psxkey06/psxkey06.doc23
-rw-r--r--testsuites/psxtests/psxkey06/psxkey06.scn18
-rw-r--r--testsuites/psxtests/psxkey07/Makefile.am23
-rw-r--r--testsuites/psxtests/psxkey07/init.c173
-rw-r--r--testsuites/psxtests/psxkey07/psxkey07.doc26
-rw-r--r--testsuites/psxtests/psxkey07/psxkey07.scn18
-rw-r--r--testsuites/psxtests/psxkey08/Makefile.am23
-rw-r--r--testsuites/psxtests/psxkey08/init.c165
-rw-r--r--testsuites/psxtests/psxkey08/psxkey08.doc25
-rw-r--r--testsuites/psxtests/psxkey08/psxkey08.scn15
-rw-r--r--testsuites/psxtests/psxkey09/Makefile.am23
-rw-r--r--testsuites/psxtests/psxkey09/init.c103
-rw-r--r--testsuites/psxtests/psxkey09/psxkey09.doc22
-rw-r--r--testsuites/psxtests/psxkey09/psxkey09.scn9
-rw-r--r--testsuites/psxtests/psxkey10/Makefile.am23
-rw-r--r--testsuites/psxtests/psxkey10/init.c106
-rw-r--r--testsuites/psxtests/psxkey10/psxkey10.doc22
-rw-r--r--testsuites/psxtests/psxkey10/psxkey10.scn10
32 files changed, 1337 insertions, 5 deletions
diff --git a/testsuites/psxtests/Makefile.am b/testsuites/psxtests/Makefile.am
index 0e8a3e805b..423cf07043 100644
--- a/testsuites/psxtests/Makefile.am
+++ b/testsuites/psxtests/Makefile.am
@@ -7,7 +7,8 @@ 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 psxkey01 psxkey02 psxkey03 \
+ psxcond01 psxconfig01 psxenosys psxkey01 psxkey02 psxkey03 psxkey04 \
+ psxkey05 psxkey06 psxkey07 psxkey08 psxkey09 psxkey10 \
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 a04fc5ec65..8e0a2384cd 100644
--- a/testsuites/psxtests/configure.ac
+++ b/testsuites/psxtests/configure.ac
@@ -122,6 +122,13 @@ psxitimer/Makefile
psxkey01/Makefile
psxkey02/Makefile
psxkey03/Makefile
+psxkey04/Makefile
+psxkey05/Makefile
+psxkey06/Makefile
+psxkey07/Makefile
+psxkey08/Makefile
+psxkey09/Makefile
+psxkey10/Makefile
psxmount/Makefile
psxmsgq01/Makefile
psxmsgq02/Makefile
diff --git a/testsuites/psxtests/psxkey01/init.c b/testsuites/psxtests/psxkey01/init.c
index 3383c8da3c..e63407cda8 100644
--- a/testsuites/psxtests/psxkey01/init.c
+++ b/testsuites/psxtests/psxkey01/init.c
@@ -43,10 +43,10 @@ void *POSIX_Init(
rtems_workspace_greedy_allocate( NULL, 0 );
- puts("Init: pthread_key_create - ENOMEM (Workspace not available)");
+ puts("Init: pthread_key_create - OK");
empty_line();
status = pthread_key_create( &Key_id[0], Key_destructor );
- fatal_directive_check_status_only( status, ENOMEM, "no workspace available" );
+ fatal_directive_check_status_only( status, 0, "OK" );
puts( "*** END OF POSIX KEY 01 TEST ***" );
rtems_test_exit( 0 );
diff --git a/testsuites/psxtests/psxkey01/psxkey01.scn b/testsuites/psxtests/psxkey01/psxkey01.scn
index 597b0f8e23..e1a747c8ab 100644
--- a/testsuites/psxtests/psxkey01/psxkey01.scn
+++ b/testsuites/psxtests/psxkey01/psxkey01.scn
@@ -1,5 +1,5 @@
*** POSIX KEY 01 TEST ***
Init's ID is 0x0b010001
-Allocate_majority_of_workspace:
-Init: pthread_key_create - ENOMEM (Workspace not available)
+Init: pthread_key_create - OK
+
*** END OF POSIX KEY 01 TEST ***
diff --git a/testsuites/psxtests/psxkey04/Makefile.am b/testsuites/psxtests/psxkey04/Makefile.am
new file mode 100644
index 0000000000..cd5f2bb8c1
--- /dev/null
+++ b/testsuites/psxtests/psxkey04/Makefile.am
@@ -0,0 +1,23 @@
+
+rtems_tests_PROGRAMS = psxkey04
+psxkey04_SOURCES = init.c
+
+dist_rtems_tests_DATA = psxkey04.scn
+dist_rtems_tests_DATA += psxkey04.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 = $(psxkey04_OBJECTS)
+LINK_LIBS = $(psxkey04_LDLIBS)
+
+psxkey04$(EXEEXT): $(psxkey04_OBJECTS) $(psxkey04_DEPENDENCIES)
+ @rm -f psxkey04$(EXEEXT)
+ $(make-exe)
+
+include $(top_srcdir)/../automake/local.am
diff --git a/testsuites/psxtests/psxkey04/init.c b/testsuites/psxtests/psxkey04/init.c
new file mode 100644
index 0000000000..76540dd76f
--- /dev/null
+++ b/testsuites/psxtests/psxkey04/init.c
@@ -0,0 +1,128 @@
+/*
+ * Copyright (c) 2012 Zhongwei Yao.
+ * 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <pthread.h>
+#include <errno.h>
+#include "tmacros.h"
+#include "pmacros.h"
+
+/* forward declarations to avoid warnings */
+void *POSIX_Init(void *argument);
+void *Test_Thread1(void *argument);
+void *Test_Thread2(void *argument);
+
+int Data_array[2] = {1, 2};
+pthread_t thread1, thread2;
+
+pthread_key_t Key;
+
+void *Test_Thread1(
+ void *argument
+)
+{
+ int sc;
+ int *value;
+ struct timespec delay_request;
+ /*
+ * Detach ourselves so we don't wait for a join that won't happen.
+ */
+ pthread_detach( pthread_self() );
+
+ puts( "Test_Thread 1 - pthread_setspecific - OK" );
+ sc = pthread_setspecific( Key, &Data_array[0] );
+ rtems_test_assert( !sc );
+
+ puts( "Test_Thread 1 - sleep - let thread 2 run - OK" );
+ delay_request.tv_sec = 0;
+ delay_request.tv_nsec = 4 * 100000000;
+ sc = nanosleep( &delay_request, NULL );
+ rtems_test_assert( !sc );
+
+ puts( "Test_Thread 1 - pthread_getspecific - OK" );
+ value = pthread_getspecific( Key );
+ rtems_test_assert( *value == Data_array[0] );
+
+ return NULL;
+}
+
+void *Test_Thread2(
+ void *argument
+)
+{
+ int sc;
+ int *value;
+ /*
+ * Detach ourselves so we don't wait for a join that won't happen.
+ */
+ pthread_detach( pthread_self() );
+
+ puts( "Test_Thread 2 - pthread_setspecific - OK" );
+ sc = pthread_setspecific( Key, &Data_array[1] );
+ rtems_test_assert( !sc );
+
+ puts( "Test_Thread 2 - pthread_getspecific - OK" );
+ value = pthread_getspecific( Key );
+ rtems_test_assert( *value == Data_array[1] );
+
+ return NULL;
+}
+
+void *POSIX_Init(
+ void *ignored
+)
+{
+ int sc;
+ struct timespec delay_request;
+
+ puts( "\n\n*** TEST KEY 04 ***" );
+
+ puts( "Init - pthread_key_create - OK" );
+ sc = pthread_key_create( &Key, NULL );
+ rtems_test_assert( !sc );
+
+ puts( "Init - pthread_create - OK" );
+ sc = pthread_create( &thread1, NULL, Test_Thread1, NULL );
+ rtems_test_assert( !sc );
+
+ sc = pthread_create( &thread2, NULL, Test_Thread2, NULL );
+ rtems_test_assert( !sc );
+
+ puts( "Init - sleep - let thread run - OK" );
+ delay_request.tv_sec = 0;
+ delay_request.tv_nsec = 8 * 100000000;
+ sc = nanosleep( &delay_request, NULL );
+ rtems_test_assert( !sc );
+
+ puts( "Init - pthread_key_delete - OK" );
+ sc = pthread_key_delete( Key );
+ rtems_test_assert( sc == 0 );
+
+ puts( "*** END OF TEST KEY 04 ***" );
+ rtems_test_exit(0);
+}
+
+/* configuration information */
+
+#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
+#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
+
+#define CONFIGURE_MAXIMUM_POSIX_THREADS 3
+#define CONFIGURE_MAXIMUM_POSIX_KEYS 1
+
+#define CONFIGURE_POSIX_INIT_THREAD_TABLE
+
+#define CONFIGURE_INIT
+#include <rtems/confdefs.h>
+
+/* global variables */
diff --git a/testsuites/psxtests/psxkey04/psxkey04.doc b/testsuites/psxtests/psxkey04/psxkey04.doc
new file mode 100644
index 0000000000..6438d4e501
--- /dev/null
+++ b/testsuites/psxtests/psxkey04/psxkey04.doc
@@ -0,0 +1,22 @@
+# COPYRIGHT (c) 1989-2009.
+# 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 file describes the directives and concepts tested by this test set.
+
+test set name: psxkey04
+
+directives:
+
+ pthread_key_create
+ pthread_setspecific
+ pthread_getspecific
+ pthread_key_delete
+
+concepts:
+
++ Ensure that key data's operation(set and get) under multithreads work.
diff --git a/testsuites/psxtests/psxkey04/psxkey04.scn b/testsuites/psxtests/psxkey04/psxkey04.scn
new file mode 100644
index 0000000000..aa0500fcba
--- /dev/null
+++ b/testsuites/psxtests/psxkey04/psxkey04.scn
@@ -0,0 +1,11 @@
+*** TEST KEY 04 ***
+Init - pthread_key_create - OK
+Init - pthread_create - OK
+Init - sleep - let thread run - OK
+Test_Thread 1 - pthread_setspecific - OK
+Test_Thread 1 - sleep - let thread 2 run - OK
+Test_Thread 2 - pthread_setspecific - OK
+Test_Thread 2 - pthread_getspecific - OK
+Test_Thread 1 - pthread_getspecific - OK
+Init - pthread_key_delete - OK
+*** END OF TEST KEY 04 ***
diff --git a/testsuites/psxtests/psxkey05/Makefile.am b/testsuites/psxtests/psxkey05/Makefile.am
new file mode 100644
index 0000000000..c253900c06
--- /dev/null
+++ b/testsuites/psxtests/psxkey05/Makefile.am
@@ -0,0 +1,23 @@
+
+rtems_tests_PROGRAMS = psxkey05
+psxkey05_SOURCES = init.c
+
+dist_rtems_tests_DATA = psxkey05.scn
+dist_rtems_tests_DATA += psxkey05.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 = $(psxkey05_OBJECTS)
+LINK_LIBS = $(psxkey05_LDLIBS)
+
+psxkey05$(EXEEXT): $(psxkey05_OBJECTS) $(psxkey05_DEPENDENCIES)
+ @rm -f psxkey05$(EXEEXT)
+ $(make-exe)
+
+include $(top_srcdir)/../automake/local.am
diff --git a/testsuites/psxtests/psxkey05/init.c b/testsuites/psxtests/psxkey05/init.c
new file mode 100644
index 0000000000..08d22b0cbd
--- /dev/null
+++ b/testsuites/psxtests/psxkey05/init.c
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2012 Zhongwei Yao.
+ * 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <pthread.h>
+#include <errno.h>
+#include "tmacros.h"
+#include "pmacros.h"
+
+/* forward declarations to avoid warnings */
+void *POSIX_Init(void *argument);
+
+void *POSIX_Init(
+ void *ignored
+)
+{
+ pthread_key_t key1, key2;
+ int sc, *value;
+ int Data_array[2] = {1, 2};
+
+ puts( "\n\n*** TEST KEY 05 ***" );
+
+ puts( "Init - pthread key1 create - OK" );
+ sc = pthread_key_create( &key1, NULL );
+ rtems_test_assert( !sc );
+
+ puts( "Init - pthread key2 create - OK" );
+ sc = pthread_key_create( &key2, NULL );
+ rtems_test_assert( !sc );
+
+ puts( "Init - key1 pthread_setspecific - OK" );
+ sc = pthread_setspecific( key1, &Data_array[0] );
+ rtems_test_assert( !sc );
+
+ puts( "Init - key2 pthread_setspecific - OK" );
+ sc = pthread_setspecific( key2, &Data_array[1] );
+ rtems_test_assert( !sc );
+
+ puts( "Init - key1 pthread_getspecific - OK" );
+ value = pthread_getspecific( key1 );
+ rtems_test_assert( *value == Data_array[0] );
+
+ puts( "Init - key2 pthread_getspecific - OK" );
+ value = pthread_getspecific( key2 );
+ rtems_test_assert( *value == Data_array[1] );
+
+ puts( "Init - pthread key1 delete - OK" );
+ sc = pthread_key_delete( key1 );
+ rtems_test_assert( sc == 0 );
+
+ puts( "Init - pthread key2 delete - OK" );
+ sc = pthread_key_delete( key2 );
+ rtems_test_assert( sc == 0 );
+
+ puts( "*** END OF TEST KEY 05 ***" );
+ rtems_test_exit(0);
+}
+
+/* configuration information */
+
+#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
+#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
+
+#define CONFIGURE_MAXIMUM_POSIX_THREADS 1
+#define CONFIGURE_MAXIMUM_POSIX_KEYS 2
+
+#define CONFIGURE_POSIX_INIT_THREAD_TABLE
+
+#define CONFIGURE_INIT
+#include <rtems/confdefs.h>
+
+/* global variables */
diff --git a/testsuites/psxtests/psxkey05/psxkey05.doc b/testsuites/psxtests/psxkey05/psxkey05.doc
new file mode 100644
index 0000000000..f4359d64c7
--- /dev/null
+++ b/testsuites/psxtests/psxkey05/psxkey05.doc
@@ -0,0 +1,22 @@
+# COPYRIGHT (c) 1989-2009.
+# 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 file describes the directives and concepts tested by this test set.
+
+test set name: psxkey05
+
+directives:
+
+ pthread_key_create
+ pthread_setspecific
+ pthread_getspecific
+ pthread_key_delete
+
+concepts:
+
++ Ensure that key data's operation(create, set, get and delete) under multikeys work.
diff --git a/testsuites/psxtests/psxkey05/psxkey05.scn b/testsuites/psxtests/psxkey05/psxkey05.scn
new file mode 100644
index 0000000000..f352a36785
--- /dev/null
+++ b/testsuites/psxtests/psxkey05/psxkey05.scn
@@ -0,0 +1,10 @@
+*** TEST KEY 05 ***
+Init - pthread key1 create - OK
+Init - pthread key2 create - OK
+Init - key1 pthread_setspecific - OK
+Init - key1 pthread_getspecific - OK
+Init - key2 pthread_setspecific - OK
+Init - key2 pthread_getspecific - OK
+Init - pthread key1 delete - OK
+Init - pthread key2 delete - OK
+*** END OF TEST KEY 05 *** \ No newline at end of file
diff --git a/testsuites/psxtests/psxkey06/Makefile.am b/testsuites/psxtests/psxkey06/Makefile.am
new file mode 100644
index 0000000000..9815baf4eb
--- /dev/null
+++ b/testsuites/psxtests/psxkey06/Makefile.am
@@ -0,0 +1,23 @@
+
+rtems_tests_PROGRAMS = psxkey06
+psxkey06_SOURCES = init.c
+
+dist_rtems_tests_DATA = psxkey06.scn
+dist_rtems_tests_DATA += psxkey06.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 = $(psxkey06_OBJECTS)
+LINK_LIBS = $(psxkey06_LDLIBS)
+
+psxkey06$(EXEEXT): $(psxkey06_OBJECTS) $(psxkey06_DEPENDENCIES)
+ @rm -f psxkey06$(EXEEXT)
+ $(make-exe)
+
+include $(top_srcdir)/../automake/local.am
diff --git a/testsuites/psxtests/psxkey06/init.c b/testsuites/psxtests/psxkey06/init.c
new file mode 100644
index 0000000000..98b46a42be
--- /dev/null
+++ b/testsuites/psxtests/psxkey06/init.c
@@ -0,0 +1,153 @@
+/*
+ * Copyright (c) 2012 Zhongwei Yao.
+ * 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <pthread.h>
+#include <errno.h>
+#include "tmacros.h"
+#include "pmacros.h"
+
+/* forward declarations to avoid warnings */
+void *POSIX_Init(void *argument);
+void *Test_Thread1(void *argument);
+void *Test_Thread2(void *argument);
+
+int Data_array[4] = {1, 2, 3, 4};
+
+pthread_key_t key1, key2;
+
+void *Test_Thread1(
+ void *argument
+)
+{
+ int sc;
+ int *value;
+ struct timespec delay_request;
+ /*
+ * Detach ourselves so we don't wait for a join that won't happen.
+ */
+ pthread_detach( pthread_self() );
+
+ puts( "Test_Thread 1 - key1 pthread_setspecific - OK" );
+ sc = pthread_setspecific( key1, &Data_array[0] );
+ rtems_test_assert( !sc );
+
+ puts( "Test_Thread 1 - key2 pthread_setspecific - OK" );
+ sc = pthread_setspecific( key2, &Data_array[1] );
+ rtems_test_assert( !sc );
+
+ puts( "Test_Thread 1 - sleep - let thread2 run - OK" );
+ delay_request.tv_sec = 0;
+ delay_request.tv_nsec = 4 * 100000000;
+ sc = nanosleep( &delay_request, NULL );
+ rtems_test_assert( !sc );
+
+ puts( "Test_Thread 1 - key1 pthread_getspecific - OK" );
+ value = pthread_getspecific( key1 );
+ rtems_test_assert( *value == Data_array[0] );
+
+ puts( "Test_Thread 1 - key2 pthread_getspecific - OK" );
+ value = pthread_getspecific( key2 );
+ rtems_test_assert( *value == Data_array[1] );
+
+ return NULL;
+}
+
+void *Test_Thread2(
+ void *argument
+)
+{
+ int sc;
+ int *value;
+ /*
+ * Detach ourselves so we don't wait for a join that won't happen.
+ */
+ pthread_detach( pthread_self() );
+
+ puts( "Test_Thread 2 - key1 pthread_setspecific - OK" );
+ sc = pthread_setspecific( key1, &Data_array[2] );
+ rtems_test_assert( !sc );
+
+ puts( "Test_Thread 2 - key2 pthread_setspecific - OK" );
+ sc = pthread_setspecific( key2, &Data_array[3] );
+ rtems_test_assert( !sc );
+
+ puts( "Test_Thread 2 - key1 pthread_getspecific - OK" );
+ value = pthread_getspecific( key1 );
+ rtems_test_assert( *value == Data_array[2] );
+
+ puts( "Test_Thread 2 - key2 pthread_getspecific - OK" );
+ value = pthread_getspecific( key2 );
+ rtems_test_assert( *value == Data_array[3] );
+
+ return NULL;
+}
+
+void *POSIX_Init(
+ void *ignored
+)
+{
+ pthread_t thread1, thread2;
+ int sc;
+ struct timespec delay_request;
+
+ puts( "\n\n*** TEST KEY 06 ***" );
+
+ puts( "Init - pthread key1 create - OK" );
+ sc = pthread_key_create( &key1, NULL );
+ rtems_test_assert( !sc );
+
+ puts( "Init - pthread key2 create - OK" );
+ sc = pthread_key_create( &key2, NULL );
+ rtems_test_assert( !sc );
+
+ puts( "Init - pthread1 create - OK" );
+ sc = pthread_create( &thread1, NULL, Test_Thread1, NULL );
+ rtems_test_assert( !sc );
+
+ puts( "Init - pthread2 create - OK" );
+ sc = pthread_create( &thread2, NULL, Test_Thread2, NULL );
+ rtems_test_assert( !sc );
+
+ puts( "Init - sleep - let thread run - OK" );
+ delay_request.tv_sec = 0;
+ delay_request.tv_nsec = 8 * 100000000;
+ sc = nanosleep( &delay_request, NULL );
+ rtems_test_assert( !sc );
+
+ puts( "Init - pthread key1 delete - OK" );
+ sc = pthread_key_delete( key1 );
+ rtems_test_assert( sc == 0 );
+
+ puts( "Init - pthread key2 delete - OK" );
+ sc = pthread_key_delete( key2 );
+ rtems_test_assert( sc == 0 );
+
+ puts( "*** END OF TEST KEY 06 ***" );
+ rtems_test_exit(0);
+}
+
+/* configuration information */
+
+#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
+#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
+
+#define CONFIGURE_MAXIMUM_POSIX_THREADS 3
+#define CONFIGURE_MAXIMUM_POSIX_KEYS 2
+
+#define CONFIGURE_POSIX_INIT_THREAD_TABLE
+
+#define CONFIGURE_INIT
+#include <rtems/confdefs.h>
+
+/* global variables */
diff --git a/testsuites/psxtests/psxkey06/psxkey06.doc b/testsuites/psxtests/psxkey06/psxkey06.doc
new file mode 100644
index 0000000000..6becdb9e66
--- /dev/null
+++ b/testsuites/psxtests/psxkey06/psxkey06.doc
@@ -0,0 +1,23 @@
+# COPYRIGHT (c) 1989-2009.
+# 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 file describes the directives and concepts tested by this test set.
+
+test set name: psxkey06
+
+directives:
+
+ pthread_key_create
+ pthread_setspecific
+ pthread_getspecific
+ pthread_key_delete
+
+concepts:
+
++ Ensure that key data's operation(create, set, get and delete) under
+ multikeys and multi threads work.
diff --git a/testsuites/psxtests/psxkey06/psxkey06.scn b/testsuites/psxtests/psxkey06/psxkey06.scn
new file mode 100644
index 0000000000..a105b6fd8f
--- /dev/null
+++ b/testsuites/psxtests/psxkey06/psxkey06.scn
@@ -0,0 +1,18 @@
+*** TEST KEY 06 ***
+Init - pthread key1 create - OK
+Init - pthread key2 create - OK
+Init - pthread1 create - OK
+Init - pthread2 create - OK
+Init - sleep - let thread run - OK
+Test_Thread 1 - key1 pthread_setspecific - OK
+Test_Thread 1 - key2 pthread_setspecific - OK
+Test_Thread 1 - sleep - let thread2 run - OK
+Test_Thread 2 - key1 pthread_setspecific - OK
+Test_Thread 2 - key2 pthread_setspecific - OK
+Test_Thread 2 - key1 pthread_getspecific - OK
+Test_Thread 2 - key2 pthread_getspecific - OK
+Test_Thread 1 - key1 pthread_getspecific - OK
+Test_Thread 1 - key2 pthread_getspecific - OK
+Init - pthread key1 delete - OK
+Init - pthread key2 delete - OK
+*** END OF TEST KEY 06 ***
diff --git a/testsuites/psxtests/psxkey07/Makefile.am b/testsuites/psxtests/psxkey07/Makefile.am
new file mode 100644
index 0000000000..a701f309b2
--- /dev/null
+++ b/testsuites/psxtests/psxkey07/Makefile.am
@@ -0,0 +1,23 @@
+
+rtems_tests_PROGRAMS = psxkey07
+psxkey07_SOURCES = init.c
+
+dist_rtems_tests_DATA = psxkey07.scn
+dist_rtems_tests_DATA += psxkey07.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 = $(psxkey07_OBJECTS)
+LINK_LIBS = $(psxkey07_LDLIBS)
+
+psxkey07$(EXEEXT): $(psxkey07_OBJECTS) $(psxkey07_DEPENDENCIES)
+ @rm -f psxkey07$(EXEEXT)
+ $(make-exe)
+
+include $(top_srcdir)/../automake/local.am
diff --git a/testsuites/psxtests/psxkey07/init.c b/testsuites/psxtests/psxkey07/init.c
new file mode 100644
index 0000000000..e911dc77d9
--- /dev/null
+++ b/testsuites/psxtests/psxkey07/init.c
@@ -0,0 +1,173 @@
+/*
+ * Copyright (c) 2012 Zhongwei Yao.
+ * 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <pthread.h>
+#include <sched.h>
+#include <errno.h>
+#include "tmacros.h"
+#include "pmacros.h"
+
+/* forward declarations to avoid warnings */
+void *POSIX_Init(void *argument);
+void *Test_Thread(void *argument);
+
+pthread_key_t Key;
+int created_thread_count, setted_thread_count, got_thread_count;
+int all_thread_created;
+pthread_mutex_t mutex1, mutex2;
+pthread_cond_t create_condition_var, set_condition_var;
+
+void *Test_Thread(
+ void *argument
+)
+{
+ int sc;
+ int *value_p, *value_p2;
+
+ value_p = malloc( sizeof( int ) );
+ //printf( "Test_Thread%d - Key pthread_setspecific - OK\n", (int)pthread_self() );
+ sc = pthread_setspecific( Key, value_p );
+ rtems_test_assert( !sc );
+ pthread_mutex_lock( &mutex1 );
+ ++setted_thread_count;
+ pthread_cond_signal( &set_condition_var );
+ pthread_mutex_unlock( &mutex1 );
+
+ /**
+ * blocked untill all threads have been created.
+ */
+ pthread_mutex_lock( &mutex2 );
+ while( !all_thread_created )
+ pthread_cond_wait( &create_condition_var, &mutex2 );
+ pthread_mutex_unlock( &mutex2 );
+
+ //printf( "Test_Thread%d - Key pthread_getspecific - OK\n", (int)pthread_self() );
+ value_p2 = pthread_getspecific( Key );
+ rtems_test_assert( value_p == value_p2 );
+ ++got_thread_count;
+
+ return NULL;
+}
+
+void *POSIX_Init(
+ void *ignored
+)
+{
+ pthread_t *thread_p;
+ int sc;
+ struct timespec delay_request;
+ all_thread_created = 0;
+
+ puts( "\n\n*** TEST KEY 07 ***" );
+
+ puts( "Init - Mutex 1 create - OK" );
+ sc = pthread_mutex_init( &mutex1, NULL );
+ rtems_test_assert( !sc );
+ puts( "Init - Mutex 2 create - OK" );
+ sc = pthread_mutex_init( &mutex2, NULL );
+ rtems_test_assert( !sc );
+ puts( "Init - Condition variable 1 create - OK" );
+ sc = pthread_cond_init( &create_condition_var, NULL );
+ rtems_test_assert( !sc );
+ puts( "Init - Condition variable 2 create - OK" );
+ sc = pthread_cond_init( &set_condition_var, NULL );
+ rtems_test_assert( !sc );
+
+ puts( "Init - pthread Key create - OK" );
+ sc = pthread_key_create( &Key, NULL );
+ rtems_test_assert( !sc );
+
+ for( ; ; )
+ {
+ thread_p = malloc( sizeof( pthread_t ) );
+ rtems_test_assert( thread_p );
+ pthread_mutex_lock( &mutex1 );
+ sc = pthread_create( thread_p, NULL, Test_Thread, NULL );
+ rtems_test_assert( ( sc == 0 ) || ( sc == EAGAIN ) );
+ /**
+ * check if return is EAGAIN, it means RTEMS Workspace RAM
+ * have been exhausted.
+ */
+ if ( sc == EAGAIN )
+ {
+ pthread_mutex_unlock( &mutex1 );
+ break;
+ }
+ ++created_thread_count;
+ /**
+ * wait for test thread set key, the while loop here is used to
+ * avoid suprious wakeup.
+ */
+ while( created_thread_count > setted_thread_count )
+ pthread_cond_wait( &set_condition_var, &mutex1 );
+ pthread_mutex_unlock( &mutex1 );
+ }
+ printf( "Init - %d pthreads have been created - OK\n", created_thread_count );
+ printf( "Init - %d pthreads have been setted key data - OK\n", setted_thread_count );
+ rtems_test_assert( created_thread_count == setted_thread_count );
+ /* unblock all created pthread to let them set key data.*/
+ pthread_mutex_lock( &mutex2 );
+ all_thread_created = 1;
+ pthread_cond_broadcast( &create_condition_var );
+ pthread_mutex_unlock( &mutex2 );
+
+ puts( "Init - sleep - let threads run - OK" );
+ delay_request.tv_sec = 0;
+ delay_request.tv_nsec = 8 * 100000000;
+ sc = nanosleep( &delay_request, NULL );
+ rtems_test_assert( !sc );
+
+ printf( "Init - %d pthreads have been got key data - OK\n", got_thread_count );
+ rtems_test_assert( created_thread_count == got_thread_count );
+ puts( "Init - pthread Key delete - OK" );
+ sc = pthread_key_delete( Key );
+ rtems_test_assert( sc == 0 );
+
+ puts( "Init - Mutex1 delete - OK" );
+ sc = pthread_mutex_destroy( &mutex1 );
+ rtems_test_assert( !sc );
+ puts( "Init - Mutex2 delete - OK" );
+ sc = pthread_mutex_destroy( &mutex2 );
+ rtems_test_assert( !sc );
+ puts( "Init - Condition variable 1 delete - OK" );
+ sc = pthread_cond_destroy( &create_condition_var );
+ rtems_test_assert( !sc );
+ puts( "Init - Condition variable 2 delete - OK" );
+ sc = pthread_cond_destroy( &set_condition_var );
+ rtems_test_assert( !sc );
+
+ puts( "*** END OF TEST KEY 07 ***" );
+ rtems_test_exit(0);
+}
+
+/* configuration information */
+
+#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
+#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
+
+
+#define CONFIGURE_MAXIMUM_POSIX_THREADS rtems_resource_unlimited(10)
+#define CONFIGURE_MAXIMUM_POSIX_MUTEXES 2
+#define CONFIGURE_MAXIMUM_POSIX_KEYS 1
+#define CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES 2
+#define CONFIGURE_UNIFIED_WORK_AREAS
+
+
+
+#define CONFIGURE_POSIX_INIT_THREAD_TABLE
+
+#define CONFIGURE_INIT
+#include <rtems/confdefs.h>
+
+/* global variables */
diff --git a/testsuites/psxtests/psxkey07/psxkey07.doc b/testsuites/psxtests/psxkey07/psxkey07.doc
new file mode 100644
index 0000000000..16d93de78c
--- /dev/null
+++ b/testsuites/psxtests/psxkey07/psxkey07.doc
@@ -0,0 +1,26 @@
+# COPYRIGHT (c) 1989-2009.
+# 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 file describes the directives and concepts tested by this test set.
+
+test set name: psxkey07
+
+directives:
+
+ pthread_key_create
+ pthread_setspecific
+ pthread_getspecific
+ pthread_key_delete
+
+concepts:
+
++ Ensure that key data's operation(create, set, get and delete) under unlimited configuration in POSIX API.
++ this test workflow is:
+ 1. create thread and set thread's key data one by one until exhausting workspace RAM
+ 2. when step 1 finished, let all thread created thread run the getspecific function to
+test if key set and get works correctly.
diff --git a/testsuites/psxtests/psxkey07/psxkey07.scn b/testsuites/psxtests/psxkey07/psxkey07.scn
new file mode 100644
index 0000000000..851876fce1
--- /dev/null
+++ b/testsuites/psxtests/psxkey07/psxkey07.scn
@@ -0,0 +1,18 @@
+
+
+*** TEST KEY 07 ***
+Init - Mutex 1 create - OK
+Init - Mutex 2 create - OK
+Init - Condition variable 1 create - OK
+Init - Condition variable 2 create - OK
+Init - pthread Key create - OK
+Init - 380 pthreads have been created - OK
+Init - 380 pthreads have been setted key data - OK
+Init - sleep - let threads run - OK
+Init - 380 pthreads have been got key data - OK
+Init - pthread Key delete - OK
+Init - Mutex1 delete - OK
+Init - Mutex2 delete - OK
+Init - Condition variable 1 delete - OK
+Init - Condition variable 2 delete - OK
+*** END OF TEST KEY 07 ***
diff --git a/testsuites/psxtests/psxkey08/Makefile.am b/testsuites/psxtests/psxkey08/Makefile.am
new file mode 100644
index 0000000000..e5bf7873ee
--- /dev/null
+++ b/testsuites/psxtests/psxkey08/Makefile.am
@@ -0,0 +1,23 @@
+
+rtems_tests_PROGRAMS = psxkey08
+psxkey08_SOURCES = init.c
+
+dist_rtems_tests_DATA = psxkey08.scn
+dist_rtems_tests_DATA += psxkey08.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 = $(psxkey08_OBJECTS)
+LINK_LIBS = $(psxkey08_LDLIBS)
+
+psxkey08$(EXEEXT): $(psxkey08_OBJECTS) $(psxkey08_DEPENDENCIES)
+ @rm -f psxkey08$(EXEEXT)
+ $(make-exe)
+
+include $(top_srcdir)/../automake/local.am
diff --git a/testsuites/psxtests/psxkey08/init.c b/testsuites/psxtests/psxkey08/init.c
new file mode 100644
index 0000000000..81f4378828
--- /dev/null
+++ b/testsuites/psxtests/psxkey08/init.c
@@ -0,0 +1,165 @@
+/*
+ * Copyright (c) 2012 Zhongwei Yao.
+ * 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "tmacros.h"
+
+#include <stdio.h>
+#include <rtems.h>
+#include <pthread.h>
+#include <unistd.h>
+#include <errno.h>
+
+pthread_key_t Key;
+int created_task_count, setted_task_count, got_task_count;
+int all_thread_created;
+rtems_id sema1, sema2;
+rtems_name name1, name2;
+
+/* forward declarations to avoid warnings */
+rtems_task Init(rtems_task_argument arg);
+rtems_task test_task(rtems_task_argument arg);
+
+rtems_task test_task(rtems_task_argument arg)
+{
+ int sc;
+ int *value_p, *value_p2;
+
+ value_p = malloc( sizeof( int ) );
+ //printf( "Test_Task%d - Key pthread_setspecific - OK\n", (int)rtems_task_self() );
+ sc = pthread_setspecific( Key, value_p );
+ rtems_test_assert( !sc );
+ ++setted_task_count;
+ sc = rtems_semaphore_release( sema1 );
+
+ /**
+ * blocked untill all tasks have been created.
+ */
+ rtems_semaphore_obtain( sema2 , RTEMS_WAIT, 0 );
+
+ //printf( "Test_Task%d - Key pthread_getspecific - OK\n", (int)rtems_task_self() );
+ value_p2 = pthread_getspecific( Key );
+ rtems_test_assert( value_p == value_p2 );
+ ++got_task_count;
+
+ pthread_exit( 0 );
+}
+
+rtems_task Init(rtems_task_argument arg)
+{
+ rtems_status_code status;
+ int sc;
+ rtems_id *task_id_p;
+
+ all_thread_created = 0;
+
+ puts( "\n\n*** TEST KEY 08 ***" );
+
+ puts( "Init - Semaphore 1 create - OK" );
+ name1 = rtems_build_name('S', 'E', 'M', '1');
+ sc = rtems_semaphore_create( name1, 0,
+ RTEMS_SIMPLE_BINARY_SEMAPHORE |
+ RTEMS_FIFO,
+ 0, &sema1 );
+ rtems_test_assert( sc == RTEMS_SUCCESSFUL );
+
+ puts( "Init - Semaphore 2 create - OK" );
+ name2 = rtems_build_name('S', 'E', 'M', '2');
+ sc = rtems_semaphore_create( name2, 0,
+ RTEMS_SIMPLE_BINARY_SEMAPHORE |
+ RTEMS_FIFO,
+ 0, &sema2 );
+ rtems_test_assert( sc == RTEMS_SUCCESSFUL );
+
+ puts( "Init - pthread Key create - OK" );
+ sc = pthread_key_create( &Key, NULL );
+ rtems_test_assert( !sc );
+
+ for( ; ; )
+ {
+ task_id_p = malloc( sizeof( rtems_id ) );
+ rtems_test_assert( task_id_p );
+ sc = rtems_task_create(
+ rtems_build_name('T','A',created_task_count, ' '),
+ 1,
+ RTEMS_MINIMUM_STACK_SIZE,
+ RTEMS_DEFAULT_MODES,
+ RTEMS_DEFAULT_ATTRIBUTES,
+ task_id_p
+ );
+ rtems_test_assert( (sc == RTEMS_UNSATISFIED) || (sc == RTEMS_TOO_MANY) || (sc == RTEMS_SUCCESSFUL) );
+ /**
+ * when return is RTEMS_TOO_MANY or RTEMS_UNSATISFIED, there is not
+ * enough source to create task.
+ */
+ if ( (sc == RTEMS_TOO_MANY) || (sc == RTEMS_UNSATISFIED) )
+ {
+ break;
+ }
+ ++created_task_count;
+ sc = rtems_task_start( *task_id_p, test_task, 0 );
+ rtems_test_assert( sc == RTEMS_SUCCESSFUL );
+ sc = rtems_semaphore_obtain( sema1, RTEMS_WAIT, 0 );
+ rtems_test_assert( sc == RTEMS_SUCCESSFUL );
+ }
+
+ printf( "Init - %d tasks have been created - OK\n", created_task_count );
+ printf( "Init - %d tasks have been setted key data - OK\n", setted_task_count );
+ rtems_test_assert( created_task_count == setted_task_count );
+
+ /* unblock all created tasks to let them set key data.*/
+ puts( "Init - flush semaphore 2 - OK" );
+ sc = rtems_semaphore_flush( sema2 );
+ rtems_test_assert( sc == RTEMS_SUCCESSFUL );
+
+ puts( "Init - sleep to yield processor - OK" );
+ status = rtems_task_wake_after( RTEMS_YIELD_PROCESSOR );
+ directive_failed( status, "rtems_task_wake_after" );
+
+ printf( "Init - %d Tasks have been got key data - OK\n", got_task_count );
+ rtems_test_assert( created_task_count == got_task_count );
+ puts( "Init - pthread Key delete - OK" );
+ sc = pthread_key_delete( Key );
+ rtems_test_assert( sc == 0 );
+
+ puts( "Init - semaphore 1 delete - OK" );
+ sc = rtems_semaphore_delete( sema1 );
+ rtems_test_assert( !sc );
+
+ puts( "Init - semaphore 2 delete - OK" );
+ sc = rtems_semaphore_delete( sema2 );
+ rtems_test_assert( !sc );
+
+ puts( "*** END OF TEST KEY 08***" );
+ exit(0);
+}
+
+/* configuration information */
+#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
+#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
+
+#define CONFIGURE_MAXIMUM_TASKS rtems_resource_unlimited(5)
+#define CONFIGURE_MAXIMUM_SEMAPHORES 2
+#define CONFIGURE_MAXIMUM_POSIX_KEYS 1
+
+#define CONFIGURE_INIT_TASK_INITIAL_MODES \
+ (RTEMS_PREEMPT | RTEMS_NO_TIMESLICE | RTEMS_ASR | RTEMS_INTERRUPT_LEVEL(0))
+
+#define CONFIGURE_INIT_TASK_PRIORITY 4
+#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
+
+#define CONFIGURE_UNIFIED_WORK_AREAS
+
+#define CONFIGURE_INIT
+#include <rtems/confdefs.h>
+/* end of file */
diff --git a/testsuites/psxtests/psxkey08/psxkey08.doc b/testsuites/psxtests/psxkey08/psxkey08.doc
new file mode 100644
index 0000000000..5d0b1711c4
--- /dev/null
+++ b/testsuites/psxtests/psxkey08/psxkey08.doc
@@ -0,0 +1,25 @@
+# COPYRIGHT (c) 1989-2009.
+# 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 file describes the directives and concepts tested by this test set.
+
+test set name: psxkey08
+
+directives:
+
+ pthread_key_create
+ pthread_setspecific
+ pthread_getspecific
+ pthread_key_delete
+
+concepts:
+
++ Ensure that key data's operation(create, set, get and delete) under unlimited configuration in RTEMS classic API. Note: posix key is allowed to be called by RTEMS classic API.
++ this test workflow is:
+ 1. create thread and set thread's key data one by one until exhausting workspace RAM
+ 2. when step 1 finished, let all thread created thread run the getspecific function to test if key set and get works correctly.
diff --git a/testsuites/psxtests/psxkey08/psxkey08.scn b/testsuites/psxtests/psxkey08/psxkey08.scn
new file mode 100644
index 0000000000..a4f1be4959
--- /dev/null
+++ b/testsuites/psxtests/psxkey08/psxkey08.scn
@@ -0,0 +1,15 @@
+
+
+*** TEST KEY 08 ***
+Init - Semaphore 1 create - OK
+Init - Semaphore 2 create - OK
+Init - pthread Key create - OK
+Init - 651 tasks have been created - OK
+Init - 651 tasks have been setted key data - OK
+Init - flush semaphore 2 - OK
+Init - sleep to yield processor - OK
+Init - 651 Tasks have been got key data - OK
+Init - pthread Key delete - OK
+Init - semaphore 1 delete - OK
+Init - semaphore 2 delete - OK
+*** END OF TEST KEY 08***
diff --git a/testsuites/psxtests/psxkey09/Makefile.am b/testsuites/psxtests/psxkey09/Makefile.am
new file mode 100644
index 0000000000..ed3ee0045d
--- /dev/null
+++ b/testsuites/psxtests/psxkey09/Makefile.am
@@ -0,0 +1,23 @@
+
+rtems_tests_PROGRAMS = psxkey09
+psxkey09_SOURCES = init.c
+
+dist_rtems_tests_DATA = psxkey09.scn
+dist_rtems_tests_DATA += psxkey09.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 = $(psxkey09_OBJECTS)
+LINK_LIBS = $(psxkey09_LDLIBS)
+
+psxkey09$(EXEEXT): $(psxkey09_OBJECTS) $(psxkey09_DEPENDENCIES)
+ @rm -f psxkey09$(EXEEXT)
+ $(make-exe)
+
+include $(top_srcdir)/../automake/local.am
diff --git a/testsuites/psxtests/psxkey09/init.c b/testsuites/psxtests/psxkey09/init.c
new file mode 100644
index 0000000000..a44f0e36ca
--- /dev/null
+++ b/testsuites/psxtests/psxkey09/init.c
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 2012 Zhongwei Yao.
+ * 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <pthread.h>
+#include <errno.h>
+#include "tmacros.h"
+#include "pmacros.h"
+
+
+/* forward declarations to avoid warnings */
+void *POSIX_Init(void *argument);
+void destructor(void *value);
+void *Test_Thread(void *argument);
+
+int Data_array[1] = {1};
+
+pthread_key_t key;
+volatile bool destructor_ran;
+
+void destructor(void *value)
+{
+ destructor_ran = true;
+}
+
+void *Test_Thread(
+ void *argument
+)
+{
+ int sc;
+
+ /**
+ * Detach ourselves to release test thread's resource after thread exit.
+ */
+ pthread_detach( pthread_self() );
+
+ puts( "Test_Thread - key pthread_setspecific - OK" );
+ sc = pthread_setspecific( key, argument );
+ rtems_test_assert( !sc );
+
+ puts( "Test_Thread - pthread_exit to run key destructors - OK" );
+ return NULL;
+}
+
+void *POSIX_Init(
+ void *ignored
+)
+{
+ pthread_t thread;
+ int sc;
+ struct timespec delay_request;
+
+ puts( "\n\n*** TEST KEY 09 ***" );
+
+ puts( "Init - pthread key create with destructor - OK" );
+ sc = pthread_key_create( &key, destructor );
+ rtems_test_assert( !sc );
+
+ puts( "Init - pthread create - OK" );
+ sc = pthread_create( &thread, NULL, Test_Thread, &sc );
+ rtems_test_assert( !sc );
+
+ puts( "Init - sleep - let thread run - OK" );
+ delay_request.tv_sec = 0;
+ delay_request.tv_nsec = 8 * 100000000;
+ sc = nanosleep( &delay_request, NULL );
+ rtems_test_assert( !sc );
+
+ puts( "Init - verify destructor run - OK" );
+ rtems_test_assert( destructor_ran == true );
+
+ puts( "Init - pthread key delete - OK" );
+ sc = pthread_key_delete( key );
+ rtems_test_assert( sc == 0 );
+
+ puts( "*** END OF TEST KEY 09 ***" );
+ rtems_test_exit(0);
+}
+
+/* configuration information */
+
+#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
+#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
+
+#define CONFIGURE_MAXIMUM_POSIX_THREADS 2
+#define CONFIGURE_MAXIMUM_POSIX_KEYS 1
+
+#define CONFIGURE_POSIX_INIT_THREAD_TABLE
+
+#define CONFIGURE_INIT
+#include <rtems/confdefs.h>
+
+/* global variables */
diff --git a/testsuites/psxtests/psxkey09/psxkey09.doc b/testsuites/psxtests/psxkey09/psxkey09.doc
new file mode 100644
index 0000000000..ecb9b742be
--- /dev/null
+++ b/testsuites/psxtests/psxkey09/psxkey09.doc
@@ -0,0 +1,22 @@
+# COPYRIGHT (c) 1989-2009.
+# 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 file describes the directives and concepts tested by this test set.
+
+test set name: psxkey09
+
+directives:
+
+ pthread_key_create
+ pthread_setspecific
+ pthread_key_delete
+ _POSIX_Keys_Run_destructors
+
+concepts:
+
++ Ensure that POSIX Key works when thread deleted first and then deleted key self.
diff --git a/testsuites/psxtests/psxkey09/psxkey09.scn b/testsuites/psxtests/psxkey09/psxkey09.scn
new file mode 100644
index 0000000000..707c7d63b1
--- /dev/null
+++ b/testsuites/psxtests/psxkey09/psxkey09.scn
@@ -0,0 +1,9 @@
+*** TEST KEY 09 ***
+Init - pthread key create with destructor - OK
+Init - pthread create - OK
+Init - sleep - let thread run - OK
+Test_Thread - key pthread_setspecific - OK
+Test_Thread - pthread_exit to run key destructors - OK
+Init - verify destructor run - OK
+Init - pthread key delete - OK
+*** END OF TEST KEY 09 ***
diff --git a/testsuites/psxtests/psxkey10/Makefile.am b/testsuites/psxtests/psxkey10/Makefile.am
new file mode 100644
index 0000000000..8e4f2f409b
--- /dev/null
+++ b/testsuites/psxtests/psxkey10/Makefile.am
@@ -0,0 +1,23 @@
+
+rtems_tests_PROGRAMS = psxkey10
+psxkey10_SOURCES = init.c
+
+dist_rtems_tests_DATA = psxkey10.scn
+dist_rtems_tests_DATA += psxkey10.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 = $(psxkey10_OBJECTS)
+LINK_LIBS = $(psxkey10_LDLIBS)
+
+psxkey10$(EXEEXT): $(psxkey10_OBJECTS) $(psxkey10_DEPENDENCIES)
+ @rm -f psxkey10$(EXEEXT)
+ $(make-exe)
+
+include $(top_srcdir)/../automake/local.am
diff --git a/testsuites/psxtests/psxkey10/init.c b/testsuites/psxtests/psxkey10/init.c
new file mode 100644
index 0000000000..eee0c18d8d
--- /dev/null
+++ b/testsuites/psxtests/psxkey10/init.c
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2012 Zhongwei Yao.
+ * 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <pthread.h>
+#include <errno.h>
+#include "tmacros.h"
+#include "pmacros.h"
+
+/* forward declarations to avoid warnings */
+void *POSIX_Init(void *argument);
+void destructor(void *value);
+void *Test_Thread(void *argument);
+
+int Data_array[1] = {1};
+
+pthread_key_t key;
+volatile bool destructor_ran;
+
+void destructor(void *value)
+{
+ destructor_ran = true;
+}
+
+void *Test_Thread(
+ void *argument
+)
+{
+ int sc;
+
+ /**
+ * Detach ourselves to release test thread's resource after thread exit.
+ */
+ pthread_detach( pthread_self() );
+
+ puts( "Test_Thread - key pthread_setspecific - OK" );
+ sc = pthread_setspecific( key, argument );
+ rtems_test_assert( !sc );
+
+ puts( "Test_Thread - pthread key delete - OK" );
+ sc = pthread_key_delete( key );
+ rtems_test_assert( sc == 0 );
+
+ puts( "Test_Thread - pthread exit, but don't run key destructors - OK" );
+ return NULL;
+}
+
+void *POSIX_Init(
+ void *ignored
+)
+{
+ pthread_t thread;
+ int sc;
+ struct timespec delay_request;
+
+ puts( "\n\n*** TEST KEY 10 ***" );
+
+ puts( "Init - pthread key create with destructor - OK" );
+ sc = pthread_key_create( &key, destructor );
+ rtems_test_assert( !sc );
+
+ puts( "Init - pthread create - OK" );
+ sc = pthread_create( &thread, NULL, Test_Thread, &sc );
+ rtems_test_assert( !sc );
+
+ puts( "Init - sleep - let thread run - OK" );
+ delay_request.tv_sec = 0;
+ delay_request.tv_nsec = 8 * 100000000;
+ sc = nanosleep( &delay_request, NULL );
+ rtems_test_assert( !sc );
+
+ puts( "Init - verify destructor did NOT run - OK" );
+ rtems_test_assert( destructor_ran == false );
+
+ /* puts( "Init - pthread key delete - OK" ); */
+ /* sc = pthread_key_delete( key ); */
+ /* rtems_test_assert( sc == 0 ); */
+
+ puts( "*** END OF TEST KEY 10 ***" );
+ rtems_test_exit(0);
+}
+
+/* configuration information */
+
+#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
+#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
+
+#define CONFIGURE_MAXIMUM_POSIX_THREADS 2
+#define CONFIGURE_MAXIMUM_POSIX_KEYS 1
+
+#define CONFIGURE_POSIX_INIT_THREAD_TABLE
+
+#define CONFIGURE_INIT
+#include <rtems/confdefs.h>
+
+/* global variables */
diff --git a/testsuites/psxtests/psxkey10/psxkey10.doc b/testsuites/psxtests/psxkey10/psxkey10.doc
new file mode 100644
index 0000000000..75c35c85c2
--- /dev/null
+++ b/testsuites/psxtests/psxkey10/psxkey10.doc
@@ -0,0 +1,22 @@
+# COPYRIGHT (c) 1989-2009.
+# 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 file describes the directives and concepts tested by this test set.
+
+test set name: psxkey10
+
+directives:
+
+ pthread_key_create
+ pthread_setspecific
+ pthread_key_delete
+ _POSIX_Keys_Run_destructors
+
+concepts:
+
++ Ensure that POSIX Key works when key first and then deleted thread self.
diff --git a/testsuites/psxtests/psxkey10/psxkey10.scn b/testsuites/psxtests/psxkey10/psxkey10.scn
new file mode 100644
index 0000000000..98940e24ad
--- /dev/null
+++ b/testsuites/psxtests/psxkey10/psxkey10.scn
@@ -0,0 +1,10 @@
+
+*** TEST KEY 10 ***
+Init - pthread key create with destructor - OK
+Init - pthread create - OK
+Init - sleep - let thread run - OK
+Test_Thread - key pthread_setspecific - OK
+Test_Thread - pthread key delete - OK
+Test_Thread - pthread exit, but don't run key destructors - OK
+Init - verify destructor did NOT run - OK
+*** END OF TEST KEY 10 ***