[PATCH 2/2] psxtests: Add tests for POSIX Keys.

Gedare Bloom gedare at rtems.org
Sat Feb 23 14:38:27 UTC 2013


From: Zhongwei Yao <ashi08104 at gmail.com>

These are test cases added to exercise the POSIX Keys implementation.
This code was contributed during GSOC 2012.
---
 testsuites/psxtests/Makefile.am           |    3 +-
 testsuites/psxtests/configure.ac          |    7 +
 testsuites/psxtests/psxkey01/init.c       |    4 +-
 testsuites/psxtests/psxkey01/psxkey01.scn |    4 +-
 testsuites/psxtests/psxkey04/Makefile.am  |   23 ++++
 testsuites/psxtests/psxkey04/init.c       |  128 +++++++++++++++++++++
 testsuites/psxtests/psxkey04/psxkey04.doc |   22 ++++
 testsuites/psxtests/psxkey04/psxkey04.scn |   11 ++
 testsuites/psxtests/psxkey05/Makefile.am  |   23 ++++
 testsuites/psxtests/psxkey05/init.c       |   82 ++++++++++++++
 testsuites/psxtests/psxkey05/psxkey05.doc |   22 ++++
 testsuites/psxtests/psxkey05/psxkey05.scn |   10 ++
 testsuites/psxtests/psxkey06/Makefile.am  |   23 ++++
 testsuites/psxtests/psxkey06/init.c       |  153 +++++++++++++++++++++++++
 testsuites/psxtests/psxkey06/psxkey06.doc |   23 ++++
 testsuites/psxtests/psxkey06/psxkey06.scn |   18 +++
 testsuites/psxtests/psxkey07/Makefile.am  |   23 ++++
 testsuites/psxtests/psxkey07/init.c       |  174 +++++++++++++++++++++++++++++
 testsuites/psxtests/psxkey07/psxkey07.doc |   27 +++++
 testsuites/psxtests/psxkey07/psxkey07.scn |   18 +++
 testsuites/psxtests/psxkey08/Makefile.am  |   23 ++++
 testsuites/psxtests/psxkey08/init.c       |  166 +++++++++++++++++++++++++++
 testsuites/psxtests/psxkey08/psxkey08.doc |   29 +++++
 testsuites/psxtests/psxkey08/psxkey08.scn |   15 +++
 testsuites/psxtests/psxkey09/Makefile.am  |   23 ++++
 testsuites/psxtests/psxkey09/init.c       |  103 +++++++++++++++++
 testsuites/psxtests/psxkey09/psxkey09.doc |   23 ++++
 testsuites/psxtests/psxkey09/psxkey09.scn |    9 ++
 testsuites/psxtests/psxkey10/Makefile.am  |   23 ++++
 testsuites/psxtests/psxkey10/init.c       |  106 +++++++++++++++++
 testsuites/psxtests/psxkey10/psxkey10.doc |   22 ++++
 testsuites/psxtests/psxkey10/psxkey10.scn |   10 ++
 32 files changed, 1345 insertions(+), 5 deletions(-)
 create mode 100644 testsuites/psxtests/psxkey04/Makefile.am
 create mode 100644 testsuites/psxtests/psxkey04/init.c
 create mode 100644 testsuites/psxtests/psxkey04/psxkey04.doc
 create mode 100644 testsuites/psxtests/psxkey04/psxkey04.scn
 create mode 100644 testsuites/psxtests/psxkey05/Makefile.am
 create mode 100644 testsuites/psxtests/psxkey05/init.c
 create mode 100644 testsuites/psxtests/psxkey05/psxkey05.doc
 create mode 100644 testsuites/psxtests/psxkey05/psxkey05.scn
 create mode 100644 testsuites/psxtests/psxkey06/Makefile.am
 create mode 100644 testsuites/psxtests/psxkey06/init.c
 create mode 100644 testsuites/psxtests/psxkey06/psxkey06.doc
 create mode 100644 testsuites/psxtests/psxkey06/psxkey06.scn
 create mode 100644 testsuites/psxtests/psxkey07/Makefile.am
 create mode 100644 testsuites/psxtests/psxkey07/init.c
 create mode 100644 testsuites/psxtests/psxkey07/psxkey07.doc
 create mode 100644 testsuites/psxtests/psxkey07/psxkey07.scn
 create mode 100644 testsuites/psxtests/psxkey08/Makefile.am
 create mode 100644 testsuites/psxtests/psxkey08/init.c
 create mode 100644 testsuites/psxtests/psxkey08/psxkey08.doc
 create mode 100644 testsuites/psxtests/psxkey08/psxkey08.scn
 create mode 100644 testsuites/psxtests/psxkey09/Makefile.am
 create mode 100644 testsuites/psxtests/psxkey09/init.c
 create mode 100644 testsuites/psxtests/psxkey09/psxkey09.doc
 create mode 100644 testsuites/psxtests/psxkey09/psxkey09.scn
 create mode 100644 testsuites/psxtests/psxkey10/Makefile.am
 create mode 100644 testsuites/psxtests/psxkey10/init.c
 create mode 100644 testsuites/psxtests/psxkey10/psxkey10.doc
 create mode 100644 testsuites/psxtests/psxkey10/psxkey10.scn

diff --git a/testsuites/psxtests/Makefile.am b/testsuites/psxtests/Makefile.am
index 0e8a3e8..423cf07 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 a04fc5e..8e0a238 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 3383c8d..e63407c 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 597b0f8..e1a747c 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 0000000..8072acd
--- /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 at .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 0000000..76540dd
--- /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 0000000..6438d4e
--- /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 0000000..aa0500f
--- /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 0000000..52bbcce
--- /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 at .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 0000000..1d866c7
--- /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  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/psxkey05/psxkey05.doc b/testsuites/psxtests/psxkey05/psxkey05.doc
new file mode 100644
index 0000000..f4359d6
--- /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 0000000..f352a36
--- /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 0000000..7db7582
--- /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 at .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 0000000..98b46a4
--- /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 0000000..6becdb9
--- /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 0000000..a105b6f
--- /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 0000000..cadc441
--- /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 at .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 0000000..0a77b83
--- /dev/null
+++ b/testsuites/psxtests/psxkey07/init.c
@@ -0,0 +1,174 @@
+/*
+ *  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 );
+
+  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(5)
+#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 0000000..6de164f
--- /dev/null
+++ b/testsuites/psxtests/psxkey07/psxkey07.doc
@@ -0,0 +1,27 @@
+#  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
diff --git a/testsuites/psxtests/psxkey07/psxkey07.scn b/testsuites/psxtests/psxkey07/psxkey07.scn
new file mode 100644
index 0000000..851876f
--- /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 0000000..c1f92ea
--- /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 at .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 0000000..367c0c1
--- /dev/null
+++ b/testsuites/psxtests/psxkey08/init.c
@@ -0,0 +1,166 @@
+/*
+ *  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 ) );
+
+  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 );
+
+  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_SUCCESSFUL) ||
+			 (sc == RTEMS_UNSATISFIED) );
+      /**
+       * 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 0000000..057df1c
--- /dev/null
+++ b/testsuites/psxtests/psxkey08/psxkey08.doc
@@ -0,0 +1,29 @@
+#  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 0000000..a4f1be4
--- /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 0000000..22d0f7c
--- /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 at .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 0000000..a44f0e3
--- /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 0000000..1789035
--- /dev/null
+++ b/testsuites/psxtests/psxkey09/psxkey09.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:  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 0000000..707c7d6
--- /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 0000000..8c7e91f
--- /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 at .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 0000000..eee0c18
--- /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 0000000..75c35c8
--- /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 0000000..98940e2
--- /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 ***
-- 
1.7.1




More information about the devel mailing list