1 | /* SPDX-License-Identifier: BSD-2-Clause */ |
---|
2 | |
---|
3 | /** |
---|
4 | * @@file |
---|
5 | * |
---|
6 | * Odd Id Cases where API configured but No Threads |
---|
7 | * + Possibly Valid Id passed to directive |
---|
8 | */ |
---|
9 | |
---|
10 | /* |
---|
11 | * COPYRIGHT (c) 1989-2012. |
---|
12 | * On-Line Applications Research Corporation (OAR). |
---|
13 | * |
---|
14 | * Redistribution and use in source and binary forms, with or without |
---|
15 | * modification, are permitted provided that the following conditions |
---|
16 | * are met: |
---|
17 | * 1. Redistributions of source code must retain the above copyright |
---|
18 | * notice, this list of conditions and the following disclaimer. |
---|
19 | * 2. Redistributions in binary form must reproduce the above copyright |
---|
20 | * notice, this list of conditions and the following disclaimer in the |
---|
21 | * documentation and/or other materials provided with the distribution. |
---|
22 | * |
---|
23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
24 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
---|
27 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
28 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
29 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
30 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
31 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
---|
33 | * POSSIBILITY OF SUCH DAMAGE. |
---|
34 | */ |
---|
35 | |
---|
36 | #ifdef HAVE_CONFIG_H |
---|
37 | #include "config.h" |
---|
38 | #endif |
---|
39 | |
---|
40 | #include <rtems/sysinit.h> |
---|
41 | #include <rtems/score/memory.h> |
---|
42 | #include <rtems/score/thread.h> |
---|
43 | |
---|
44 | #include <tmacros.h> |
---|
45 | |
---|
46 | const char rtems_test_name[] = "SP 54"; |
---|
47 | |
---|
48 | static void *Init( uintptr_t ignored ) |
---|
49 | { |
---|
50 | rtems_status_code status; |
---|
51 | rtems_task_priority pri; |
---|
52 | rtems_id id; |
---|
53 | const rtems_api_configuration_table *config; |
---|
54 | |
---|
55 | puts( "Init - use valid id of API class with no objects" ); |
---|
56 | status = rtems_task_set_priority( |
---|
57 | rtems_build_id(0x2,0x1,0x01,0x0001) /* 0xa010001 */, |
---|
58 | RTEMS_CURRENT_PRIORITY, |
---|
59 | &pri |
---|
60 | ); |
---|
61 | fatal_directive_status( status, RTEMS_INVALID_ID, "rtems_task_set_priority" ); |
---|
62 | |
---|
63 | puts( "Init - lookup name within API class with no objects" ); |
---|
64 | status = rtems_task_ident( |
---|
65 | rtems_build_id( 0, 0, 0x12, 0x3456) /* 0x123456 */, |
---|
66 | RTEMS_SEARCH_ALL_NODES, |
---|
67 | &id |
---|
68 | ); |
---|
69 | fatal_directive_status( status, RTEMS_INVALID_NAME, "rtems_task_ident" ); |
---|
70 | |
---|
71 | rtems_test_assert( rtems_configuration_get_do_zero_of_workspace() ); |
---|
72 | |
---|
73 | config = rtems_configuration_get_rtems_api_configuration(); |
---|
74 | rtems_test_assert( config->number_of_initialization_tasks == 0 ); |
---|
75 | rtems_test_assert( config->User_initialization_tasks_table == NULL ); |
---|
76 | |
---|
77 | TEST_END(); |
---|
78 | rtems_test_exit(0); |
---|
79 | } |
---|
80 | |
---|
81 | static void check_dirty_memory( void ) |
---|
82 | { |
---|
83 | unsigned char *p; |
---|
84 | |
---|
85 | TEST_BEGIN(); |
---|
86 | |
---|
87 | p = _Memory_Allocate( _Memory_Get(), sizeof( *p ), RTEMS_ALIGNOF( *p ) ); |
---|
88 | rtems_test_assert( p != NULL ); |
---|
89 | rtems_test_assert( *p == 0xcf ); |
---|
90 | |
---|
91 | p = (unsigned char *) _Thread_Information.Objects.local_table; |
---|
92 | rtems_test_assert( *p == 0xcf ); |
---|
93 | } |
---|
94 | |
---|
95 | RTEMS_SYSINIT_ITEM( |
---|
96 | check_dirty_memory, |
---|
97 | RTEMS_SYSINIT_DIRTY_MEMORY, |
---|
98 | RTEMS_SYSINIT_ORDER_LAST |
---|
99 | ); |
---|
100 | |
---|
101 | static void check_zero_workspace_automatically( void ) |
---|
102 | { |
---|
103 | unsigned char *p; |
---|
104 | |
---|
105 | p = _Memory_Allocate( _Memory_Get(), sizeof( *p ), RTEMS_ALIGNOF( *p ) ); |
---|
106 | rtems_test_assert( p != NULL ); |
---|
107 | rtems_test_assert( *p == 0 ); |
---|
108 | |
---|
109 | p = (unsigned char *) _Thread_Information.Objects.local_table; |
---|
110 | rtems_test_assert( *p == 0 ); |
---|
111 | } |
---|
112 | |
---|
113 | RTEMS_SYSINIT_ITEM( |
---|
114 | check_zero_workspace_automatically, |
---|
115 | RTEMS_SYSINIT_ZERO_MEMORY, |
---|
116 | RTEMS_SYSINIT_ORDER_LAST |
---|
117 | ); |
---|
118 | |
---|
119 | /* configuration information */ |
---|
120 | |
---|
121 | #define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER |
---|
122 | #define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER |
---|
123 | |
---|
124 | /* |
---|
125 | * In this application, the initialization task performs the system |
---|
126 | * initialization and then transforms itself into the idle task. |
---|
127 | */ |
---|
128 | #define CONFIGURE_IDLE_TASK_BODY Init |
---|
129 | #define CONFIGURE_IDLE_TASK_INITIALIZES_APPLICATION |
---|
130 | |
---|
131 | #define CONFIGURE_DIRTY_MEMORY |
---|
132 | |
---|
133 | /* |
---|
134 | * Ensure we test the case where memory is zero. |
---|
135 | */ |
---|
136 | #define CONFIGURE_ZERO_WORKSPACE_AUTOMATICALLY |
---|
137 | |
---|
138 | #define CONFIGURE_INIT |
---|
139 | #include <rtems/confdefs.h> |
---|
140 | |
---|
141 | /* global variables */ |
---|