[PATCH 2/2] privateenv: Use POSIX keys instead of task variables.

Gedare Bloom gedare at rtems.org
Wed Mar 26 15:23:45 UTC 2014


On Wed, Mar 26, 2014 at 8:29 AM, Christian Mauderer
<christian.mauderer at embedded-brains.de> wrote:
> From: Christian Mauderer <Christian.Mauderer at embedded-brains.de>
>
> ---
>  cpukit/include/rtems/userenv.h                 | 20 +++++++++++---
>  cpukit/libcsupport/include/rtems/libio_.h      |  2 ++
>  cpukit/libcsupport/src/__usrenv.c              |  2 +-
>  cpukit/libcsupport/src/libio_init.c            | 12 +++++++++
>  cpukit/libcsupport/src/privateenv.c            | 37 +++++++++++++-------------
>  cpukit/sapi/include/confdefs.h                 | 29 ++++++++++++--------
>  doc/shell/file.t                               |  4 ++-
>  testsuites/fstests/imfs_support/fs_support.c   |  1 +
>  testsuites/fstests/jffs2_support/fs_support.c  |  2 ++
>  testsuites/fstests/mdosfs_support/fs_support.c |  1 +
>  testsuites/fstests/mimfs_support/fs_support.c  |  1 +
>  testsuites/fstests/mrfs_support/fs_support.c   |  1 +
>  testsuites/libtests/ftp01/init.c               |  2 ++
>  testsuites/psxtests/psxchroot01/main.c         |  2 ++
>  testsuites/psxtests/psxmount/main.c            |  2 ++
>  testsuites/sptests/Makefile.am                 |  2 +-
>  testsuites/sptests/configure.ac                |  1 +
>  testsuites/sptests/spfatal27/Makefile.am       | 21 +++++++++++++++
>  testsuites/sptests/spfatal27/spfatal27.doc     | 19 +++++++++++++
>  testsuites/sptests/spfatal27/spfatal27.scn     |  4 +++
>  testsuites/sptests/spfatal27/testcase.h        | 27 +++++++++++++++++++
>  testsuites/sptests/spprivenv01/init.c          | 14 +++++++---
>  22 files changed, 168 insertions(+), 38 deletions(-)
>  create mode 100644 testsuites/sptests/spfatal27/Makefile.am
>  create mode 100644 testsuites/sptests/spfatal27/spfatal27.doc
>  create mode 100644 testsuites/sptests/spfatal27/spfatal27.scn
>  create mode 100644 testsuites/sptests/spfatal27/testcase.h
>
> diff --git a/cpukit/include/rtems/userenv.h b/cpukit/include/rtems/userenv.h
> index 8a9a4fc..576636e 100644
> --- a/cpukit/include/rtems/userenv.h
> +++ b/cpukit/include/rtems/userenv.h
> @@ -27,6 +27,8 @@
>   */
>  #include <limits.h>
>
> +#include <pthread.h>
> +
>  #include <rtems.h>
>  #include <rtems/fs.h>
>
> @@ -66,8 +68,18 @@ typedef struct {
>    pid_t                            pgrp; /* process group id */
>  } rtems_user_env_t;
>
> -extern rtems_user_env_t * rtems_current_user_env;
> -extern rtems_user_env_t   rtems_global_user_env;
> +extern rtems_user_env_t rtems_global_user_env;
> +extern pthread_key_t rtems_current_user_env_key;
> +
> +/**
> + * @brief Fetch the pointer to the current user environment.
> + *
> + * If the task has a private user environment the pointer to it will be
> + * returned. Otherwise the pointer to rtems_global_user_env will be returned.
> + */
> +rtems_user_env_t * rtems_current_user_env_get(void);
> +
> +#define rtems_current_user_env rtems_current_user_env_get()
>
>  #define rtems_filesystem_current     (rtems_current_user_env->current_directory)
>  #define rtems_filesystem_root        (rtems_current_user_env->root_directory)
> @@ -84,7 +96,9 @@ extern rtems_user_env_t   rtems_global_user_env;
>   *
>   * If the task has already a private environment nothing will be changed.  This
>   * function must be called from normal thread context and may block on a mutex.
> - * Thread dispatching is disabled to protect some critical sections.
> + * Thread dispatching is disabled to protect some critical sections. Please note
> + * that a POSIX key value pair has to be configured for each private
> + * environment.
>   *
>   * @retval RTEMS_SUCCESSFUL Successful operation.
>   * @retval RTEMS_NO_MEMORY Not enough memory.
> diff --git a/cpukit/libcsupport/include/rtems/libio_.h b/cpukit/libcsupport/include/rtems/libio_.h
> index 9960288..0347c5b 100644
> --- a/cpukit/libcsupport/include/rtems/libio_.h
> +++ b/cpukit/libcsupport/include/rtems/libio_.h
> @@ -238,6 +238,8 @@ void rtems_filesystem_location_free( rtems_filesystem_location_info_t *loc );
>   */
>  #include <rtems/userenv.h>
>
> +void rtems_libio_free_user_env( void *env );
> +
>  static inline void rtems_libio_lock( void )
>  {
>    rtems_semaphore_obtain( rtems_libio_semaphore, RTEMS_WAIT, RTEMS_NO_TIMEOUT );
> diff --git a/cpukit/libcsupport/src/__usrenv.c b/cpukit/libcsupport/src/__usrenv.c
> index 3ce6a2d..71efda9 100644
> --- a/cpukit/libcsupport/src/__usrenv.c
> +++ b/cpukit/libcsupport/src/__usrenv.c
> @@ -257,4 +257,4 @@ rtems_user_env_t rtems_global_user_env = {
>    .umask = S_IWGRP | S_IWOTH
>  };
>
> -rtems_user_env_t *rtems_current_user_env = &rtems_global_user_env;
> +pthread_key_t rtems_current_user_env_key;
> diff --git a/cpukit/libcsupport/src/libio_init.c b/cpukit/libcsupport/src/libio_init.c
> index 4d705fb..e64ddd6 100644
> --- a/cpukit/libcsupport/src/libio_init.c
> +++ b/cpukit/libcsupport/src/libio_init.c
> @@ -46,6 +46,7 @@ void rtems_libio_init( void )
>      rtems_status_code rc;
>      uint32_t i;
>      rtems_libio_t *iop;
> +    int eno;
>
>      if (rtems_libio_number_iops > 0)
>      {
> @@ -61,6 +62,17 @@ void rtems_libio_init( void )
>      }
>
>    /*
> +   *  Create the posix key for user environment.
> +   */
> +  eno = pthread_key_create(
> +    &rtems_current_user_env_key,
> +    rtems_libio_free_user_env
> +  );
> +  if (eno != 0) {
> +    rtems_fatal_error_occurred( RTEMS_UNSATISFIED );
> +  }
> +
> +  /*
>     *  Create the binary semaphore used to provide mutual exclusion
>     *  on the IOP Table.
>     */
> diff --git a/cpukit/libcsupport/src/privateenv.c b/cpukit/libcsupport/src/privateenv.c
> index bee94c1..60207b0 100644
> --- a/cpukit/libcsupport/src/privateenv.c
> +++ b/cpukit/libcsupport/src/privateenv.c
> @@ -29,7 +29,16 @@
>   *  Instantiate a private user environment for the calling thread.
>   */
>
> -static void free_user_env(void *arg)
> +rtems_user_env_t * rtems_current_user_env_get(void)
> +{
> +  void *ptr = pthread_getspecific(rtems_current_user_env_key);
> +  if (ptr == NULL) {
> +    ptr = &rtems_global_user_env;
> +  }
> +  return (rtems_user_env_t *) ptr;
> +}
> +
> +void rtems_libio_free_user_env(void *arg)
>  {
>    rtems_user_env_t *env = arg;
>    bool uses_global_env = env == &rtems_global_user_env;
> @@ -44,7 +53,7 @@ static void free_user_env(void *arg)
>  static void free_user_env_protected(rtems_user_env_t *env)
>  {
>    _Thread_Disable_dispatch();
> -  free_user_env(env);
> +  rtems_libio_free_user_env(env);
>    _Thread_Enable_dispatch();
>  }
>
> @@ -68,14 +77,13 @@ rtems_status_code rtems_libio_set_private_env(void)
>          !rtems_filesystem_global_location_is_null(new_env->root_directory)
>            && !rtems_filesystem_global_location_is_null(new_env->current_directory)
>        ) {
> -        sc = rtems_task_variable_add(
> -          RTEMS_SELF,
> -          (void **) &rtems_current_user_env,
> -          free_user_env
> +        int eno = pthread_setspecific(
> +          rtems_current_user_env_key,
> +          new_env
>          );
> -        if (sc == RTEMS_SUCCESSFUL) {
> +
> +        if (eno == 0) {
>            free_user_env_protected(old_env);
> -          rtems_current_user_env = new_env;
>          } else {
>            sc = RTEMS_TOO_MANY;
>          }
> @@ -84,7 +92,7 @@ rtems_status_code rtems_libio_set_private_env(void)
>        }
>
>        if (sc != RTEMS_SUCCESSFUL) {
> -        free_user_env(new_env);
> +        rtems_libio_free_user_env(new_env);
>        }
>      } else {
>        sc = RTEMS_NO_MEMORY;
> @@ -101,14 +109,7 @@ void rtems_libio_use_global_env(void)
>    bool uses_private_env = env != &rtems_global_user_env;
>
>    if (uses_private_env) {
> -    sc = rtems_task_variable_delete(
> -      RTEMS_SELF,
> -      (void **) &rtems_current_user_env
> -    );
> -    if (sc != RTEMS_SUCCESSFUL) {
> -      rtems_fatal_error_occurred(0xdeadbeef);
> -    }
> -
> -    rtems_current_user_env = &rtems_global_user_env;
> +    free_user_env_protected(env);
> +    pthread_setspecific(rtems_current_user_env_key, NULL);
>    }
>  }
> diff --git a/cpukit/sapi/include/confdefs.h b/cpukit/sapi/include/confdefs.h
> index aca99f0..5da3c2e 100644
> --- a/cpukit/sapi/include/confdefs.h
> +++ b/cpukit/sapi/include/confdefs.h
> @@ -148,6 +148,11 @@ const rtems_libio_helper rtems_fs_init_helper =
>   */
>  #define CONFIGURE_LIBIO_SEMAPHORES 1
>
> +/**
> + * POSIX key count used by the IO library.
> + */
> +#define CONFIGURE_LIBIO_POSIX_KEYS 1
> +
>  #ifdef CONFIGURE_INIT
>    /**
>     * When instantiating the configuration tables, this variable is
> @@ -1728,16 +1733,18 @@ const rtems_libio_helper rtems_fs_init_helper =
>  #include <rtems/posix/key.h>
>
>  #ifndef CONFIGURE_MAXIMUM_POSIX_KEYS
> -  #define CONFIGURE_MAXIMUM_POSIX_KEYS            0
> -  #define CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS 0
> -#else
> -  #ifndef CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS
> -    #define CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS \
> -      (CONFIGURE_MAXIMUM_POSIX_KEYS * \
> -       (CONFIGURE_MAXIMUM_POSIX_THREADS + CONFIGURE_MAXIMUM_TASKS))
> -  #endif
> +  #define CONFIGURE_MAXIMUM_POSIX_KEYS 0
> +#endif
> +
> +#ifndef CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS
> +  #define CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS \
> +    (CONFIGURE_MAXIMUM_POSIX_KEYS * \
> +     (CONFIGURE_MAXIMUM_POSIX_THREADS + CONFIGURE_MAXIMUM_TASKS))
>  #endif
>
> +#define CONFIGURE_POSIX_KEYS \
> +  (CONFIGURE_MAXIMUM_POSIX_KEYS + CONFIGURE_LIBIO_POSIX_KEYS)
> +
If you add another macro here like...
#define CONFIGURE_POSIX_KEY_VALUE_PAIRS
(CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS + (1 *
CONFIGURE_LIBIO_POSIX_KEYS))
and change the below to use the new macro, then the user does not need
to do any configuring of the posix keys for the private environment.

>  #define CONFIGURE_MEMORY_FOR_POSIX_KEYS(_keys, _key_value_pairs) \
>     (_Configure_Object_RAM(_keys, sizeof(POSIX_Keys_Control) ) \
>      + _Configure_From_workspace( \
> @@ -2216,7 +2223,7 @@ const rtems_libio_helper rtems_fs_init_helper =
>       CONFIGURE_TOTAL_TASKS_AND_THREADS, CONFIGURE_TOTAL_TASKS_AND_THREADS) + \
>     CONFIGURE_MEMORY_FOR_CLASSIC + \
>     CONFIGURE_MEMORY_FOR_POSIX_KEYS( \
> -      CONFIGURE_MAXIMUM_POSIX_KEYS, \
> +      CONFIGURE_POSIX_KEYS, \
>        CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS ) + \
>     CONFIGURE_MEMORY_FOR_POSIX + \
>     CONFIGURE_MEMORY_FOR_STATIC_EXTENSIONS + \
> @@ -2391,7 +2398,7 @@ const rtems_libio_helper rtems_fs_init_helper =
>      CONFIGURE_EXECUTIVE_RAM_SIZE,             /* required RTEMS workspace */
>      CONFIGURE_STACK_SPACE_SIZE,               /* required stack space */
>      CONFIGURE_MAXIMUM_USER_EXTENSIONS,        /* maximum dynamic extensions */
> -    CONFIGURE_MAXIMUM_POSIX_KEYS,             /* POSIX keys are always */
> +    CONFIGURE_POSIX_KEYS,                     /* POSIX keys are always */
>      CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS,  /*   enabled */
>      CONFIGURE_MICROSECONDS_PER_TICK,          /* microseconds per clock tick */
>      1000 * CONFIGURE_MICROSECONDS_PER_TICK,   /* nanoseconds per clock tick */
> @@ -2586,7 +2593,7 @@ const rtems_libio_helper rtems_fs_init_helper =
>      CONFIGURE_MEMORY_FOR_PERIODS(CONFIGURE_MAXIMUM_PERIODS),
>      CONFIGURE_MEMORY_FOR_BARRIERS(CONFIGURE_BARRIERS),
>      CONFIGURE_MEMORY_FOR_USER_EXTENSIONS(CONFIGURE_MAXIMUM_USER_EXTENSIONS),
> -    CONFIGURE_MEMORY_FOR_POSIX_KEYS( CONFIGURE_MAXIMUM_POSIX_KEYS, \
> +    CONFIGURE_MEMORY_FOR_POSIX_KEYS( CONFIGURE_POSIX_KEYS, \
>                                       CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS ),
>
>  #ifdef RTEMS_POSIX_API
> diff --git a/doc/shell/file.t b/doc/shell/file.t
> index 01a3b28..eb38fe3 100644
> --- a/doc/shell/file.t
> +++ b/doc/shell/file.t
> @@ -1148,7 +1148,9 @@ cat: /etc/passwd: No such file or directory
>  This command is included in the default shell command set.
>  When building a custom command set, define
>  @code{CONFIGURE_SHELL_COMMAND_CHROOT} to have this
> -command included.
> +command included. Additional to that you have to add one
> +POSIX key value pair for each thread where you want to use
> +the command.
>
>  This command can be excluded from the shell command set by
>  defining @code{CONFIGURE_SHELL_NO_COMMAND_CHROOT} when all
> diff --git a/testsuites/fstests/imfs_support/fs_support.c b/testsuites/fstests/imfs_support/fs_support.c
> index 8eb9cca..e853690 100644
> --- a/testsuites/fstests/imfs_support/fs_support.c
> +++ b/testsuites/fstests/imfs_support/fs_support.c
> @@ -41,6 +41,7 @@ test_shutdown_filesystem (void)
>  #define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM
>  #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 40
>  #define CONFIGURE_INIT_TASK_STACK_SIZE (16 * 1024)
> +#define CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS  1
>
>  #define CONFIGURE_INIT
>  #include <rtems/confdefs.h>
> diff --git a/testsuites/fstests/jffs2_support/fs_support.c b/testsuites/fstests/jffs2_support/fs_support.c
> index 2df6da3..1ff010d 100644
> --- a/testsuites/fstests/jffs2_support/fs_support.c
> +++ b/testsuites/fstests/jffs2_support/fs_support.c
> @@ -157,6 +157,8 @@ void test_shutdown_filesystem(void)
>
>  #define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
>
> +#define CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS 1
> +
>  #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
>
>  #define CONFIGURE_INIT
> diff --git a/testsuites/fstests/mdosfs_support/fs_support.c b/testsuites/fstests/mdosfs_support/fs_support.c
> index 8c5fef4..8d01e9c 100644
> --- a/testsuites/fstests/mdosfs_support/fs_support.c
> +++ b/testsuites/fstests/mdosfs_support/fs_support.c
> @@ -91,6 +91,7 @@ void test_shutdown_filesystem(void)
>  #define CONFIGURE_MAXIMUM_DRIVERS                   10
>  #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS    40
>  #define CONFIGURE_INIT_TASK_STACK_SIZE (16 * 1024)
> +#define CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS     1
>
>  #define CONFIGURE_APPLICATION_NEEDS_LIBBLOCK
>
> diff --git a/testsuites/fstests/mimfs_support/fs_support.c b/testsuites/fstests/mimfs_support/fs_support.c
> index 4b3c701..894d8f8 100644
> --- a/testsuites/fstests/mimfs_support/fs_support.c
> +++ b/testsuites/fstests/mimfs_support/fs_support.c
> @@ -56,6 +56,7 @@ test_shutdown_filesystem (void)
>  #define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM
>  #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 40
>  #define CONFIGURE_INIT_TASK_STACK_SIZE (16 * 1024)
> +#define CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS  1
>
>  #define CONFIGURE_INIT
>  #include <rtems/confdefs.h>
> diff --git a/testsuites/fstests/mrfs_support/fs_support.c b/testsuites/fstests/mrfs_support/fs_support.c
> index 8c9989e..a1b9a87 100644
> --- a/testsuites/fstests/mrfs_support/fs_support.c
> +++ b/testsuites/fstests/mrfs_support/fs_support.c
> @@ -70,6 +70,7 @@ test_shutdown_filesystem (void)
>  #define CONFIGURE_MAXIMUM_DRIVERS                   10
>  #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS    40
>  #define CONFIGURE_INIT_TASK_STACK_SIZE (32 * 1024)
> +#define CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS     1
>
>  #define CONFIGURE_APPLICATION_NEEDS_LIBBLOCK
>
> diff --git a/testsuites/libtests/ftp01/init.c b/testsuites/libtests/ftp01/init.c
> index dcae4b1..b0c20a2 100644
> --- a/testsuites/libtests/ftp01/init.c
> +++ b/testsuites/libtests/ftp01/init.c
> @@ -246,6 +246,8 @@ static rtems_task Init(rtems_task_argument argument)
>
>  #define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
>
> +#define CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS 2
> +
>  #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
>
>  #include <rtems/confdefs.h>
> diff --git a/testsuites/psxtests/psxchroot01/main.c b/testsuites/psxtests/psxchroot01/main.c
> index 0255724..5eeeebc 100644
> --- a/testsuites/psxtests/psxchroot01/main.c
> +++ b/testsuites/psxtests/psxchroot01/main.c
> @@ -34,6 +34,8 @@ rtems_task Init(
>
>  #define CONFIGURE_MAXIMUM_TASKS 1
>
> +#define CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS 1
> +
>  #define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
>
>  #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
> diff --git a/testsuites/psxtests/psxmount/main.c b/testsuites/psxtests/psxmount/main.c
> index 92ddb3e..c6479cb 100644
> --- a/testsuites/psxtests/psxmount/main.c
> +++ b/testsuites/psxtests/psxmount/main.c
> @@ -36,6 +36,8 @@ rtems_task Init(
>
>  #define CONFIGURE_MAXIMUM_TASKS 1
>
> +#define CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS 1
> +
>  #define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
>
>  #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
> diff --git a/testsuites/sptests/Makefile.am b/testsuites/sptests/Makefile.am
> index d57ae69..3150694 100644
> --- a/testsuites/sptests/Makefile.am
> +++ b/testsuites/sptests/Makefile.am
> @@ -18,7 +18,7 @@ SUBDIRS = \
>      spfatal01 spfatal02 spfatal03 spfatal04 spfatal05 spfatal06 spfatal07 \
>      spfatal08 spfatal09 spfatal10 spfatal11 spfatal12 spfatal13 spfatal14 \
>      spfatal15 spfatal16 spfatal17 spfatal18 spfatal19 spfatal20 \
> -    spfatal22 spfatal24 spfatal25 \
> +    spfatal22 spfatal24 spfatal25 spfatal27\
>      spfifo01 spfifo02 spfifo03 spfifo04 spfifo05 \
>      spfreechain01 \
>      spintrcritical01 spintrcritical02 spintrcritical03 spintrcritical04 \
> diff --git a/testsuites/sptests/configure.ac b/testsuites/sptests/configure.ac
> index 5f98ba7..71f0c8d 100644
> --- a/testsuites/sptests/configure.ac
> +++ b/testsuites/sptests/configure.ac
> @@ -166,6 +166,7 @@ spfatal20/Makefile
>  spfatal22/Makefile
>  spfatal24/Makefile
>  spfatal25/Makefile
> +spfatal27/Makefile
>  spfifo01/Makefile
>  spfifo02/Makefile
>  spfifo03/Makefile
> diff --git a/testsuites/sptests/spfatal27/Makefile.am b/testsuites/sptests/spfatal27/Makefile.am
> new file mode 100644
> index 0000000..744cef7
> --- /dev/null
> +++ b/testsuites/sptests/spfatal27/Makefile.am
> @@ -0,0 +1,21 @@
> +rtems_tests_PROGRAMS = spfatal27
> +spfatal27_SOURCES = ../spfatal_support/init.c \
> +    ../spfatal_support/system.h testcase.h
> +
> +dist_rtems_tests_DATA = spfatal27.scn
> +dist_rtems_tests_DATA += spfatal27.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)/../support/include
> +
> +LINK_OBJS = $(spfatal27_OBJECTS)
> +LINK_LIBS = $(spfatal27_LDLIBS)
> +
> +spfatal27$(EXEEXT): $(spfatal27_OBJECTS) $(spfatal27_DEPENDENCIES)
> +       @rm -f spfatal27$(EXEEXT)
> +       $(make-exe)
> +
> +include $(top_srcdir)/../automake/local.am
> diff --git a/testsuites/sptests/spfatal27/spfatal27.doc b/testsuites/sptests/spfatal27/spfatal27.doc
> new file mode 100644
> index 0000000..02abfef
> --- /dev/null
> +++ b/testsuites/sptests/spfatal27/spfatal27.doc
> @@ -0,0 +1,19 @@
> +#  COPYRIGHT (c) 1989-2010.
> +#  On-Line Applications Research Corporation (OAR).
> +#
> +#  The license and distribution terms for this file may be
> +#  found in the file LICENSE in this distribution or at
> +#  http://www.rtems.org/license/LICENSE.
> +#
> +
> +This file describes the directives and concepts tested by this test set.
> +
> +test set name:  spfatal22
> +
> +directives:
> +
> +  rtems_libio_init
> +
> +concepts:
> +
> ++ Exercise path when unable to allocate memory.
> diff --git a/testsuites/sptests/spfatal27/spfatal27.scn b/testsuites/sptests/spfatal27/spfatal27.scn
> new file mode 100644
> index 0000000..b4239e6
> --- /dev/null
> +++ b/testsuites/sptests/spfatal27/spfatal27.scn
> @@ -0,0 +1,4 @@
> +*** TEST FATAL FATAL 22 ***
> +Allocate_majority_of_heap:
> +Fatal error (libio init out of memory) hit
> +*** END OF TEST FATAL 22 ***
> diff --git a/testsuites/sptests/spfatal27/testcase.h b/testsuites/sptests/spfatal27/testcase.h
> new file mode 100644
> index 0000000..4dc4f9d
> --- /dev/null
> +++ b/testsuites/sptests/spfatal27/testcase.h
> @@ -0,0 +1,27 @@
> +/*
> + * Copyright (c) 2014 embedded brains GmbH.  All rights reserved.
> + *
> + *  embedded brains GmbH
> + *  Dornierstrasse 4
> + *  82178 Puchheim
> + *  Germany
> + *  <rtems at embedded-brains.de>
> + *
> + * The license and distribution terms for this file may be
> + * found in the file LICENSE in this distribution or at
> + * http://www.rtems.org/license/LICENSE.
> + */
> +
> +#define FATAL_ERROR_TEST_NAME            "FATAL 27"
> +#define FATAL_ERROR_DESCRIPTION          "libio init no posix key left"
> +#define FATAL_ERROR_EXPECTED_SOURCE      INTERNAL_ERROR_RTEMS_API
> +#define FATAL_ERROR_EXPECTED_IS_INTERNAL FALSE
> +#define FATAL_ERROR_EXPECTED_ERROR       RTEMS_UNSATISFIED
> +
> +#define CONFIGURE_MAXIMUM_POSIX_KEYS (-1)
> +#define CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS (0)
> +
> +void force_error()
> +{
> +  /* we should not reach this */
> +}
> diff --git a/testsuites/sptests/spprivenv01/init.c b/testsuites/sptests/spprivenv01/init.c
> index a670085..4f0660d 100644
> --- a/testsuites/sptests/spprivenv01/init.c
> +++ b/testsuites/sptests/spprivenv01/init.c
> @@ -63,14 +63,19 @@ rtems_task Init(
>
>    puts( "Init - allocating most of workspace memory" );
>    opaque = rtems_workspace_greedy_allocate( NULL, 0 );
> -
> -  puts( "Init - attempt to reset env - expect RTEMS_TOO_MANY" );
> +
> +  puts( "Init - attempt to reset env - expect RTEMS_SUCCESSFUL" );
>    sc = rtems_libio_set_private_env();
> -  rtems_test_assert( sc == RTEMS_TOO_MANY );
> +  rtems_test_assert( sc == RTEMS_SUCCESSFUL );
> +  rtems_test_assert( rtems_current_user_env != &rtems_global_user_env );
>
>    puts( "Init - freeing the workspace memory" );
>    rtems_workspace_greedy_free( opaque );
>
> +  puts( "Init - Reset to global environment" );
> +  rtems_libio_use_global_env();
> +  rtems_test_assert( rtems_current_user_env == &rtems_global_user_env );
> +
>    puts( "Init - Attempt to get a private environment" );
>    sc = rtems_libio_set_private_env();
>    rtems_test_assert( sc == RTEMS_SUCCESSFUL );
> @@ -118,6 +123,9 @@ rtems_task Init(
>
>  #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
>
> +#define CONFIGURE_MAXIMUM_POSIX_KEYS 1
> +#define CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS 2
> +
>  #define CONFIGURE_INIT
>
>  #include <rtems/confdefs.h>
> --
> 1.8.4.5
>
> _______________________________________________
> rtems-devel mailing list
> rtems-devel at rtems.org
> http://www.rtems.org/mailman/listinfo/rtems-devel



More information about the devel mailing list