1 | -- SPDX-License-Identifier: BSD-2-Clause |
---|
2 | |
---|
3 | -- |
---|
4 | -- Test_Support / Specification |
---|
5 | -- |
---|
6 | -- DESCRIPTION: |
---|
7 | -- |
---|
8 | -- This package provides routines which aid the Test Suites |
---|
9 | -- and simplify their design and operation. |
---|
10 | -- |
---|
11 | -- DEPENDENCIES: |
---|
12 | -- |
---|
13 | -- |
---|
14 | -- |
---|
15 | -- COPYRIGHT (c) 1989-2011. |
---|
16 | -- On-Line Applications Research Corporation (OAR). |
---|
17 | -- |
---|
18 | -- Redistribution and use in source and binary forms, with or without |
---|
19 | -- modification, are permitted provided that the following conditions |
---|
20 | -- are met: |
---|
21 | -- 1. Redistributions of source code must retain the above copyright |
---|
22 | -- notice, this list of conditions and the following disclaimer. |
---|
23 | -- 2. Redistributions in binary form must reproduce the above copyright |
---|
24 | -- notice, this list of conditions and the following disclaimer in the |
---|
25 | -- documentation and/or other materials provided with the distribution. |
---|
26 | -- |
---|
27 | -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
28 | -- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
29 | -- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
30 | -- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
---|
31 | -- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
32 | -- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
33 | -- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
34 | -- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
35 | -- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
36 | -- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
---|
37 | -- POSSIBILITY OF SUCH DAMAGE. |
---|
38 | -- |
---|
39 | |
---|
40 | with Interfaces; use Interfaces; |
---|
41 | with Unsigned32_IO; |
---|
42 | with Status_IO; |
---|
43 | with Text_IO; |
---|
44 | with RTEMS.Fatal; |
---|
45 | |
---|
46 | package body Test_Support is |
---|
47 | |
---|
48 | -- |
---|
49 | -- Fatal_Directive_Status |
---|
50 | -- |
---|
51 | |
---|
52 | procedure Fatal_Directive_Status ( |
---|
53 | Status : in RTEMS.Status_Codes; |
---|
54 | Desired : in RTEMS.Status_Codes; |
---|
55 | Message : in String |
---|
56 | ) is |
---|
57 | begin |
---|
58 | |
---|
59 | if not RTEMS.Are_Statuses_Equal( Status, Desired ) then |
---|
60 | |
---|
61 | Text_IO.Put( Message ); |
---|
62 | Text_IO.Put( " FAILED -- expected " ); |
---|
63 | Status_IO.Put( Desired ); |
---|
64 | Text_IO.Put( " got " ); |
---|
65 | Status_IO.Put( Status ); |
---|
66 | Text_IO.New_Line; |
---|
67 | |
---|
68 | RTEMS.Fatal.Error_Occurred( RTEMS.Status_Codes'Pos( Status ) ); |
---|
69 | |
---|
70 | end if; |
---|
71 | |
---|
72 | end Fatal_Directive_Status; |
---|
73 | |
---|
74 | -- |
---|
75 | -- Directive_Failed |
---|
76 | -- |
---|
77 | |
---|
78 | procedure Directive_Failed ( |
---|
79 | Status : in RTEMS.Status_Codes; |
---|
80 | Message : in String |
---|
81 | ) is |
---|
82 | begin |
---|
83 | |
---|
84 | Test_Support.Fatal_Directive_Status( |
---|
85 | Status, |
---|
86 | RTEMS.Successful, |
---|
87 | Message |
---|
88 | ); |
---|
89 | |
---|
90 | end Directive_Failed; |
---|
91 | |
---|
92 | -- |
---|
93 | -- Print_Time |
---|
94 | -- |
---|
95 | |
---|
96 | procedure Print_Time ( |
---|
97 | Prefix : in String; |
---|
98 | Time_Buffer : in RTEMS.Time_Of_Day; |
---|
99 | Suffix : in String |
---|
100 | ) is |
---|
101 | begin |
---|
102 | |
---|
103 | Text_IO.Put( Prefix ); |
---|
104 | Unsigned32_IO.Put( Time_Buffer.Hour, Width=>2 ); |
---|
105 | Text_IO.Put( ":" ); |
---|
106 | Unsigned32_IO.Put( Time_Buffer.Minute, Width=>2 ); |
---|
107 | Text_IO.Put( ":" ); |
---|
108 | Unsigned32_IO.Put( Time_Buffer.Second, Width=>2 ); |
---|
109 | Text_IO.Put( " " ); |
---|
110 | Unsigned32_IO.Put( Time_Buffer.Month, Width=>2 ); |
---|
111 | Text_IO.Put( "/" ); |
---|
112 | Unsigned32_IO.Put( Time_Buffer.Day, Width=>2 ); |
---|
113 | Text_IO.Put( "/" ); |
---|
114 | Unsigned32_IO.Put( Time_Buffer.Year, Width=>2 ); |
---|
115 | Text_IO.Put( Suffix ); |
---|
116 | |
---|
117 | end Print_Time; |
---|
118 | |
---|
119 | -- |
---|
120 | -- Put_Dot |
---|
121 | -- |
---|
122 | |
---|
123 | procedure Put_Dot ( |
---|
124 | Buffer : in String |
---|
125 | ) is |
---|
126 | begin |
---|
127 | Text_IO.Put( Buffer ); |
---|
128 | Text_IO.FLUSH; |
---|
129 | end Put_Dot; |
---|
130 | |
---|
131 | -- |
---|
132 | -- Pause |
---|
133 | -- |
---|
134 | |
---|
135 | procedure Pause is |
---|
136 | -- Ignored_String : String( 1 .. 80 ); |
---|
137 | -- Ignored_Last : Natural; |
---|
138 | |
---|
139 | begin |
---|
140 | |
---|
141 | -- |
---|
142 | -- Really should be a "put" followed by a "flush." |
---|
143 | -- |
---|
144 | Text_IO.Put_Line( "<pause> " ); |
---|
145 | -- Text_IO.Get_Line( Ignored_String, Ignored_Last ); |
---|
146 | |
---|
147 | end Pause; |
---|
148 | |
---|
149 | -- |
---|
150 | -- Pause_And_Screen_Number |
---|
151 | -- |
---|
152 | |
---|
153 | procedure Pause_And_Screen_Number ( |
---|
154 | SCREEN : in RTEMS.Unsigned32 |
---|
155 | ) is |
---|
156 | -- Ignored_String : String( 1 .. 80 ); |
---|
157 | -- Ignored_Last : Natural; |
---|
158 | begin |
---|
159 | |
---|
160 | -- |
---|
161 | -- Really should be a "put" followed by a "flush." |
---|
162 | -- |
---|
163 | Text_IO.Put( "<pause - screen " ); |
---|
164 | Unsigned32_IO.Put( SCREEN, Width=>2 ); |
---|
165 | Text_IO.Put_Line( "> " ); |
---|
166 | -- Text_IO.Get_Line( Ignored_String, Ignored_Last ); |
---|
167 | |
---|
168 | end Pause_And_Screen_Number; |
---|
169 | |
---|
170 | -- |
---|
171 | -- Put_Name |
---|
172 | -- |
---|
173 | |
---|
174 | procedure Put_Name ( |
---|
175 | Name : in RTEMS.Name; |
---|
176 | New_Line : in Boolean |
---|
177 | ) is |
---|
178 | C1 : Character; |
---|
179 | C2 : Character; |
---|
180 | C3 : Character; |
---|
181 | C4 : Character; |
---|
182 | begin |
---|
183 | |
---|
184 | RTEMS.Name_To_Characters( Name, C1, C2, C3, C4 ); |
---|
185 | |
---|
186 | Text_IO.Put( C1 ); |
---|
187 | Text_IO.Put( C2 ); |
---|
188 | Text_IO.Put( C3 ); |
---|
189 | Text_IO.Put( C4 ); |
---|
190 | |
---|
191 | if New_Line then |
---|
192 | Text_IO.New_Line; |
---|
193 | end if; |
---|
194 | |
---|
195 | end Put_Name; |
---|
196 | |
---|
197 | -- |
---|
198 | -- Task_Number |
---|
199 | -- |
---|
200 | |
---|
201 | function Task_Number ( |
---|
202 | TID : in RTEMS.ID |
---|
203 | ) return RTEMS.Unsigned32 is |
---|
204 | begin |
---|
205 | |
---|
206 | -- probably OK |
---|
207 | return RTEMS.Get_Index( TID ) - 1; |
---|
208 | |
---|
209 | end Task_Number; |
---|
210 | |
---|
211 | -- |
---|
212 | -- Do_Nothing |
---|
213 | -- |
---|
214 | |
---|
215 | procedure Do_Nothing is |
---|
216 | begin |
---|
217 | NULL; |
---|
218 | end Do_Nothing; |
---|
219 | |
---|
220 | |
---|
221 | -- |
---|
222 | -- Milliseconds_Per_Tick |
---|
223 | -- |
---|
224 | |
---|
225 | function Milliseconds_Per_Tick |
---|
226 | return RTEMS.Unsigned32 is |
---|
227 | function Milliseconds_Per_Tick_Base return RTEMS.Unsigned32; |
---|
228 | pragma Import (C, Milliseconds_Per_Tick_Base, "milliseconds_per_tick"); |
---|
229 | begin |
---|
230 | return Milliseconds_Per_Tick_Base; |
---|
231 | end Milliseconds_Per_Tick; |
---|
232 | |
---|
233 | -- |
---|
234 | -- Milliseconds_Per_Tick |
---|
235 | -- |
---|
236 | function Ticks_Per_Second |
---|
237 | return RTEMS.Interval is |
---|
238 | function Ticks_Per_Second_Base return RTEMS.Unsigned32; |
---|
239 | pragma Import (C, Ticks_Per_Second_Base, "ticks_per_second"); |
---|
240 | begin |
---|
241 | return Ticks_Per_Second_Base; |
---|
242 | end Ticks_Per_Second; |
---|
243 | |
---|
244 | -- |
---|
245 | -- Return the size of the RTEMS Workspace |
---|
246 | -- |
---|
247 | |
---|
248 | function Work_Space_Size |
---|
249 | return RTEMS.Size is |
---|
250 | function Work_Space_Size_Base return RTEMS.Size; |
---|
251 | pragma Import (C, Work_Space_Size_Base, "work_space_size"); |
---|
252 | begin |
---|
253 | return Work_Space_Size_Base; |
---|
254 | end Work_Space_Size; |
---|
255 | |
---|
256 | -- |
---|
257 | -- Return an indication of whether multiprocessing is configured |
---|
258 | -- |
---|
259 | |
---|
260 | function Is_Configured_Multiprocessing |
---|
261 | return Boolean is |
---|
262 | function Is_Configured_Multiprocessing_Base return RTEMS.Unsigned32; |
---|
263 | pragma Import ( |
---|
264 | C, Is_Configured_Multiprocessing_Base, "is_configured_multiprocessing" |
---|
265 | ); |
---|
266 | begin |
---|
267 | if Is_Configured_Multiprocessing_Base = 1 then |
---|
268 | return True; |
---|
269 | else |
---|
270 | return False; |
---|
271 | end if; |
---|
272 | end Is_Configured_Multiprocessing; |
---|
273 | |
---|
274 | -- |
---|
275 | -- Node is the node number in a multiprocessor configuration |
---|
276 | -- |
---|
277 | |
---|
278 | function Node |
---|
279 | return RTEMS.Unsigned32 is |
---|
280 | function Get_Node_Base return RTEMS.Unsigned32; |
---|
281 | pragma Import (C, Get_Node_Base, "get_node"); |
---|
282 | begin |
---|
283 | return Get_Node_Base; |
---|
284 | end Node; |
---|
285 | end Test_Support; |
---|