1 | /* |
---|
2 | * COPYRIGHT (c) 1989-2009. |
---|
3 | * On-Line Applications Research Corporation (OAR). |
---|
4 | * |
---|
5 | * The license and distribution terms for this file may be |
---|
6 | * found in the file LICENSE in this distribution or at |
---|
7 | * http://www.rtems.com/license/LICENSE. |
---|
8 | * |
---|
9 | * $Id$ |
---|
10 | */ |
---|
11 | |
---|
12 | #include <tmacros.h> |
---|
13 | |
---|
14 | static void test_create_initially_locked_prio_inherit_sema(void) |
---|
15 | { |
---|
16 | rtems_status_code sc; |
---|
17 | rtems_id id; |
---|
18 | rtems_task_priority prio_a; |
---|
19 | rtems_task_priority prio_b; |
---|
20 | rtems_task_priority prio_ceiling = 0; |
---|
21 | |
---|
22 | sc = rtems_task_set_priority(RTEMS_SELF, RTEMS_CURRENT_PRIORITY, &prio_a); |
---|
23 | rtems_test_assert(sc == RTEMS_SUCCESSFUL); |
---|
24 | |
---|
25 | rtems_test_assert(prio_a != prio_ceiling); |
---|
26 | |
---|
27 | sc = rtems_semaphore_create( |
---|
28 | rtems_build_name( 'S', 'E', 'M', 'A' ), |
---|
29 | 0, |
---|
30 | RTEMS_BINARY_SEMAPHORE | RTEMS_PRIORITY | RTEMS_INHERIT_PRIORITY, |
---|
31 | prio_ceiling, |
---|
32 | &id |
---|
33 | ); |
---|
34 | rtems_test_assert(sc == RTEMS_SUCCESSFUL); |
---|
35 | |
---|
36 | sc = rtems_task_set_priority(RTEMS_SELF, RTEMS_CURRENT_PRIORITY, &prio_b); |
---|
37 | rtems_test_assert(sc == RTEMS_SUCCESSFUL); |
---|
38 | |
---|
39 | rtems_test_assert(prio_a == prio_b); |
---|
40 | |
---|
41 | sc = rtems_semaphore_release(id); |
---|
42 | rtems_test_assert(sc == RTEMS_SUCCESSFUL); |
---|
43 | |
---|
44 | sc = rtems_semaphore_delete(id); |
---|
45 | rtems_test_assert(sc == RTEMS_SUCCESSFUL); |
---|
46 | } |
---|
47 | |
---|
48 | rtems_task Init( |
---|
49 | rtems_task_argument argument |
---|
50 | ) |
---|
51 | { |
---|
52 | rtems_status_code sc; |
---|
53 | rtems_id mutex; |
---|
54 | |
---|
55 | puts( "\n\n*** TEST 51 ***" ); |
---|
56 | |
---|
57 | puts( "Create semaphore - priority ceiling locked - violate ceiling" ); |
---|
58 | sc = rtems_semaphore_create( |
---|
59 | rtems_build_name( 'S', 'E', 'M', '1' ), |
---|
60 | 0, |
---|
61 | RTEMS_BINARY_SEMAPHORE | RTEMS_PRIORITY_CEILING | RTEMS_PRIORITY, |
---|
62 | (RTEMS_MAXIMUM_PRIORITY - 4u), |
---|
63 | &mutex |
---|
64 | ); |
---|
65 | fatal_directive_status(sc, RTEMS_INVALID_PRIORITY, "rtems_semaphore_create"); |
---|
66 | |
---|
67 | puts( "Create semaphore - priority ceiling unlocked" ); |
---|
68 | sc = rtems_semaphore_create( |
---|
69 | rtems_build_name( 'S', 'E', 'M', '1' ), |
---|
70 | 1, |
---|
71 | RTEMS_BINARY_SEMAPHORE | RTEMS_PRIORITY_CEILING | RTEMS_PRIORITY, |
---|
72 | (RTEMS_MAXIMUM_PRIORITY - 4u), |
---|
73 | &mutex |
---|
74 | ); |
---|
75 | directive_failed( sc, "rtems_semaphore_create" ); |
---|
76 | |
---|
77 | puts( "Obtain semaphore -- violate ceiling" ); |
---|
78 | sc = rtems_semaphore_obtain( mutex, RTEMS_DEFAULT_OPTIONS, 0 ); |
---|
79 | fatal_directive_status( |
---|
80 | sc, RTEMS_INVALID_PRIORITY, "rtems_semaphore_obtain" ); |
---|
81 | |
---|
82 | /* This returns successful because RTEMS eats the unneeded unlock */ |
---|
83 | puts( "Release semaphore we did not obtain" ); |
---|
84 | sc = rtems_semaphore_release( mutex ); |
---|
85 | directive_failed( sc, "rtems_semaphore_release" ); |
---|
86 | |
---|
87 | test_create_initially_locked_prio_inherit_sema(); |
---|
88 | |
---|
89 | puts( "*** END OF TEST 51 ***" ); |
---|
90 | rtems_test_exit( 0 ); |
---|
91 | } |
---|
92 | |
---|
93 | |
---|
94 | /**************** START OF CONFIGURATION INFORMATION ****************/ |
---|
95 | |
---|
96 | #define CONFIGURE_INIT |
---|
97 | #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER |
---|
98 | #define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER |
---|
99 | |
---|
100 | #define CONFIGURE_MAXIMUM_TASKS 1 |
---|
101 | #define CONFIGURE_MAXIMUM_SEMAPHORES 1 |
---|
102 | |
---|
103 | #define CONFIGURE_RTEMS_INIT_TASKS_TABLE |
---|
104 | |
---|
105 | #include <rtems/confdefs.h> |
---|
106 | |
---|
107 | /**************** END OF CONFIGURATION INFORMATION ****************/ |
---|