diff options
Diffstat (limited to 'testsuites/psxtests/psxkey07/init.c')
-rw-r--r-- | testsuites/psxtests/psxkey07/init.c | 59 |
1 files changed, 42 insertions, 17 deletions
diff --git a/testsuites/psxtests/psxkey07/init.c b/testsuites/psxtests/psxkey07/init.c index 378349bbe6..ff7b3a0bd0 100644 --- a/testsuites/psxtests/psxkey07/init.c +++ b/testsuites/psxtests/psxkey07/init.c @@ -1,11 +1,30 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /* * Copyright (c) 2012 Zhongwei Yao. * COPYRIGHT (c) 1989-2014. * 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. + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. */ #ifdef HAVE_CONFIG_H @@ -20,22 +39,25 @@ const char rtems_test_name[] = "PSXKEY 7"; -/* forward declarations to avoid warnings */ -rtems_task Init(rtems_task_argument argument); -rtems_task Test_Thread(rtems_task_argument argument); +#define INITIAL_TASK_COUNT 10 -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; +#define ADDITIONAL_TASK_COUNT 13 -rtems_task Test_Thread(rtems_task_argument argument) +static pthread_key_t Key; +static int created_thread_count, setted_thread_count, got_thread_count; +static int all_thread_created; +static pthread_mutex_t mutex1, mutex2; +static pthread_cond_t create_condition_var, set_condition_var; + +static rtems_task Test_Thread(rtems_task_argument argument) { int sc; int *value_p, *value_p2; value_p = malloc( sizeof( int ) ); + rtems_test_assert(value_p != NULL); + + *value_p = 123; sc = pthread_setspecific( Key, value_p ); rtems_test_assert( !sc ); @@ -59,12 +81,13 @@ rtems_task Test_Thread(rtems_task_argument argument) rtems_task_exit(); } -rtems_task Init(rtems_task_argument argument) +static rtems_task Init(rtems_task_argument argument) { rtems_status_code rc; int sc; struct timespec delay_request; - uintptr_t max_free_size = 13 * RTEMS_MINIMUM_STACK_SIZE; + uintptr_t max_free_size = + ADDITIONAL_TASK_COUNT * RTEMS_MINIMUM_STACK_SIZE; void *greedy; all_thread_created = 0; @@ -100,7 +123,7 @@ rtems_task Init(rtems_task_argument argument) pthread_mutex_lock( &mutex1 ); rc = rtems_task_create( - rtems_build_name( 'T', 'E', 'S', 'T' ), + rtems_build_name( 'T', 'E', 'S', 'T' ), 1, RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, @@ -195,8 +218,10 @@ rtems_task Init(rtems_task_argument argument) #define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION -#define CONFIGURE_MAXIMUM_TASKS rtems_resource_unlimited(10) -#define CONFIGURE_MAXIMUM_POSIX_KEYS 1 +#define CONFIGURE_MAXIMUM_TASKS rtems_resource_unlimited(INITIAL_TASK_COUNT) +#define CONFIGURE_MAXIMUM_POSIX_KEYS 1 +#define CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS \ + (INITIAL_TASK_COUNT + ADDITIONAL_TASK_COUNT) #define CONFIGURE_UNIFIED_WORK_AREAS #define CONFIGURE_RTEMS_INIT_TASKS_TABLE |