1 | /* SPDX-License-Identifier: BSD-2-Clause */ |
---|
2 | |
---|
3 | /* |
---|
4 | * COPYRIGHT (c) 1989-2012. |
---|
5 | * On-Line Applications Research Corporation (OAR). |
---|
6 | * |
---|
7 | * Redistribution and use in source and binary forms, with or without |
---|
8 | * modification, are permitted provided that the following conditions |
---|
9 | * are met: |
---|
10 | * 1. Redistributions of source code must retain the above copyright |
---|
11 | * notice, this list of conditions and the following disclaimer. |
---|
12 | * 2. Redistributions in binary form must reproduce the above copyright |
---|
13 | * notice, this list of conditions and the following disclaimer in the |
---|
14 | * documentation and/or other materials provided with the distribution. |
---|
15 | * |
---|
16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
---|
20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
---|
26 | * POSSIBILITY OF SUCH DAMAGE. |
---|
27 | */ |
---|
28 | |
---|
29 | #ifdef HAVE_CONFIG_H |
---|
30 | #include "config.h" |
---|
31 | #endif |
---|
32 | |
---|
33 | #include "tmacros.h" |
---|
34 | #include <pthread.h> |
---|
35 | #include <errno.h> |
---|
36 | |
---|
37 | const char rtems_test_name[] = "PSXAUTOINIT 1"; |
---|
38 | |
---|
39 | /* forward declarations to avoid warnings */ |
---|
40 | void *POSIX_Init(void *argument); |
---|
41 | |
---|
42 | void *POSIX_Init( |
---|
43 | void *argument |
---|
44 | ) |
---|
45 | { |
---|
46 | int sc; |
---|
47 | pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER; |
---|
48 | pthread_mutex_t mutex2 = PTHREAD_MUTEX_INITIALIZER; |
---|
49 | int prioceiling; |
---|
50 | |
---|
51 | TEST_BEGIN(); |
---|
52 | |
---|
53 | /* path using mutex get with interrupts disabled */ |
---|
54 | puts( "Init - pthread_mutex_lock - auto initialize - OK" ); |
---|
55 | sc = pthread_mutex_lock( &mutex1 ); |
---|
56 | fatal_posix_service_status( sc, 0, "mutex lock OK" ); |
---|
57 | |
---|
58 | puts( "Init - pthread_mutex_unlock - OK" ); |
---|
59 | sc = pthread_mutex_unlock( &mutex1 ); |
---|
60 | fatal_posix_service_status( sc, 0, "mutex unlock OK" ); |
---|
61 | |
---|
62 | puts( "Init - pthread_mutex_destroy - OK" ); |
---|
63 | sc = pthread_mutex_destroy( &mutex1 ); |
---|
64 | fatal_posix_service_status( sc, 0, "mutex destroy OK" ); |
---|
65 | |
---|
66 | /* path using mutex get with dispatching disabled */ |
---|
67 | puts( "Init - pthread_mutex_getprioceiling - auto initialize - OK" ); |
---|
68 | prioceiling = 1; |
---|
69 | sc = pthread_mutex_getprioceiling( &mutex2, &prioceiling ); |
---|
70 | fatal_posix_service_status( sc, 0, "mutex getprioceiling OK" ); |
---|
71 | rtems_test_assert( prioceiling == 0 ); |
---|
72 | |
---|
73 | puts( "Init - pthread_mutex_destroy - OK" ); |
---|
74 | sc = pthread_mutex_destroy( &mutex2 ); |
---|
75 | fatal_posix_service_status( sc, 0, "mutex destroy OK" ); |
---|
76 | |
---|
77 | TEST_END(); |
---|
78 | rtems_test_exit( 0 ); |
---|
79 | |
---|
80 | return NULL; /* just so the compiler thinks we returned something */ |
---|
81 | } |
---|
82 | |
---|
83 | #define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER |
---|
84 | #define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER |
---|
85 | |
---|
86 | #define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION |
---|
87 | |
---|
88 | #define CONFIGURE_MAXIMUM_POSIX_THREADS 1 |
---|
89 | |
---|
90 | #define CONFIGURE_POSIX_INIT_THREAD_TABLE |
---|
91 | |
---|
92 | #define CONFIGURE_INIT |
---|
93 | #include <rtems/confdefs.h> |
---|