[f3f06f79] | 1 | -- |
---|
| 2 | -- Test_Support / Specification |
---|
| 3 | -- |
---|
| 4 | -- DESCRIPTION: |
---|
| 5 | -- |
---|
| 6 | -- This package provides routines which aid the Test Suites |
---|
| 7 | -- and simplify their design and operation. |
---|
| 8 | -- |
---|
| 9 | -- DEPENDENCIES: |
---|
| 10 | -- |
---|
| 11 | -- |
---|
| 12 | -- |
---|
[ba3e1a4f] | 13 | -- COPYRIGHT (c) 1989-2007. |
---|
[f3f06f79] | 14 | -- On-Line Applications Research Corporation (OAR). |
---|
| 15 | -- |
---|
[196a6b9] | 16 | -- The license and distribution terms for this file may in |
---|
| 17 | -- the file LICENSE in this distribution or at |
---|
[35e4691] | 18 | -- http://www.rtems.com/license/LICENSE. |
---|
[f3f06f79] | 19 | -- |
---|
[196a6b9] | 20 | -- $Id$ |
---|
[f3f06f79] | 21 | -- |
---|
| 22 | |
---|
| 23 | with Interfaces; use Interfaces; |
---|
| 24 | with RTEMS; |
---|
| 25 | with Unsigned32_IO; |
---|
| 26 | with Status_IO; |
---|
| 27 | with Text_IO; |
---|
| 28 | |
---|
| 29 | package body Test_Support is |
---|
| 30 | |
---|
| 31 | --PAGE |
---|
| 32 | -- |
---|
| 33 | -- Fatal_Directive_Status |
---|
| 34 | -- |
---|
| 35 | |
---|
| 36 | procedure Fatal_Directive_Status ( |
---|
| 37 | Status : in RTEMS.Status_Codes; |
---|
| 38 | Desired : in RTEMS.Status_Codes; |
---|
| 39 | Message : in String |
---|
| 40 | ) is |
---|
| 41 | begin |
---|
| 42 | |
---|
| 43 | if not RTEMS.Are_Statuses_Equal( Status, Desired ) then |
---|
| 44 | |
---|
| 45 | Text_IO.Put( Message ); |
---|
| 46 | Text_IO.Put( " FAILED -- expected " ); |
---|
| 47 | Status_IO.Put( Desired ); |
---|
| 48 | Text_IO.Put( " got " ); |
---|
| 49 | Status_IO.Put( Status ); |
---|
| 50 | Text_IO.New_Line; |
---|
| 51 | |
---|
| 52 | RTEMS.Fatal_Error_Occurred( RTEMS.Status_Codes'Pos( Status ) ); |
---|
| 53 | |
---|
| 54 | end if; |
---|
| 55 | |
---|
| 56 | end Fatal_Directive_Status; |
---|
| 57 | |
---|
| 58 | --PAGE |
---|
| 59 | -- |
---|
| 60 | -- Directive_Failed |
---|
| 61 | -- |
---|
| 62 | |
---|
| 63 | procedure Directive_Failed ( |
---|
| 64 | Status : in RTEMS.Status_Codes; |
---|
| 65 | Message : in String |
---|
| 66 | ) is |
---|
| 67 | begin |
---|
| 68 | |
---|
| 69 | Test_Support.Fatal_Directive_Status( |
---|
| 70 | Status, |
---|
| 71 | RTEMS.Successful, |
---|
| 72 | Message |
---|
| 73 | ); |
---|
| 74 | |
---|
| 75 | end Directive_Failed; |
---|
| 76 | |
---|
| 77 | --PAGE |
---|
| 78 | -- |
---|
| 79 | -- Print_Time |
---|
| 80 | -- |
---|
| 81 | |
---|
| 82 | procedure Print_Time ( |
---|
| 83 | Prefix : in String; |
---|
| 84 | Time_Buffer : in RTEMS.Time_Of_Day; |
---|
| 85 | Suffix : in String |
---|
| 86 | ) is |
---|
| 87 | begin |
---|
| 88 | |
---|
| 89 | Text_IO.Put( Prefix ); |
---|
| 90 | Unsigned32_IO.Put( Time_Buffer.Hour, Width=>2 ); |
---|
| 91 | Text_IO.Put( ":" ); |
---|
| 92 | Unsigned32_IO.Put( Time_Buffer.Minute, Width=>2 ); |
---|
| 93 | Text_IO.Put( ":" ); |
---|
| 94 | Unsigned32_IO.Put( Time_Buffer.Second, Width=>2 ); |
---|
| 95 | Text_IO.Put( " " ); |
---|
| 96 | Unsigned32_IO.Put( Time_Buffer.Month, Width=>2 ); |
---|
| 97 | Text_IO.Put( "/" ); |
---|
| 98 | Unsigned32_IO.Put( Time_Buffer.Day, Width=>2 ); |
---|
| 99 | Text_IO.Put( "/" ); |
---|
| 100 | Unsigned32_IO.Put( Time_Buffer.Year, Width=>2 ); |
---|
| 101 | Text_IO.Put( Suffix ); |
---|
| 102 | |
---|
| 103 | end Print_Time; |
---|
| 104 | |
---|
| 105 | --PAGE |
---|
| 106 | -- |
---|
| 107 | -- Put_Dot |
---|
| 108 | -- |
---|
| 109 | |
---|
| 110 | procedure Put_Dot ( |
---|
| 111 | Buffer : in String |
---|
| 112 | ) is |
---|
| 113 | begin |
---|
| 114 | Text_IO.Put( Buffer ); |
---|
| 115 | Text_IO.FLUSH; |
---|
| 116 | end Put_Dot; |
---|
| 117 | |
---|
| 118 | --PAGE |
---|
| 119 | -- |
---|
| 120 | -- Pause |
---|
| 121 | -- |
---|
| 122 | |
---|
| 123 | procedure Pause is |
---|
[eefdc85] | 124 | -- Ignored_String : String( 1 .. 80 ); |
---|
| 125 | -- Ignored_Last : Natural; |
---|
[f3f06f79] | 126 | |
---|
| 127 | begin |
---|
| 128 | |
---|
| 129 | -- |
---|
| 130 | -- Really should be a "put" followed by a "flush." |
---|
| 131 | -- |
---|
| 132 | Text_IO.Put_Line( "<pause> " ); |
---|
[d0f426a1] | 133 | -- Text_IO.Get_Line( Ignored_String, Ignored_Last ); |
---|
[f3f06f79] | 134 | |
---|
[98150020] | 135 | -- exception |
---|
[f3f06f79] | 136 | |
---|
[98150020] | 137 | -- when Text_IO.End_Error => |
---|
| 138 | -- -- ignore this error. It happens when redirecting input from /dev/null |
---|
| 139 | -- return; |
---|
[f3f06f79] | 140 | |
---|
| 141 | end Pause; |
---|
| 142 | |
---|
| 143 | --PAGE |
---|
| 144 | -- |
---|
| 145 | -- Pause_And_Screen_Number |
---|
| 146 | -- |
---|
| 147 | |
---|
| 148 | procedure Pause_And_Screen_Number ( |
---|
| 149 | SCREEN : in RTEMS.Unsigned32 |
---|
| 150 | ) is |
---|
[eefdc85] | 151 | -- Ignored_String : String( 1 .. 80 ); |
---|
| 152 | -- Ignored_Last : Natural; |
---|
[f3f06f79] | 153 | begin |
---|
| 154 | |
---|
| 155 | -- |
---|
| 156 | -- Really should be a "put" followed by a "flush." |
---|
| 157 | -- |
---|
| 158 | Text_IO.Put( "<pause - screen " ); |
---|
| 159 | Unsigned32_IO.Put( SCREEN, Width=>2 ); |
---|
| 160 | Text_IO.Put_Line( "> " ); |
---|
[98150020] | 161 | -- Text_IO.Get_Line( Ignored_String, Ignored_Last ); |
---|
[f3f06f79] | 162 | |
---|
[98150020] | 163 | -- exception |
---|
[f3f06f79] | 164 | |
---|
[98150020] | 165 | -- when Text_IO.End_Error => |
---|
| 166 | -- -- ignore this error. It happens when redirecting input from /dev/null |
---|
| 167 | -- return; |
---|
[f3f06f79] | 168 | |
---|
| 169 | end Pause_And_Screen_Number; |
---|
| 170 | |
---|
| 171 | --PAGE |
---|
| 172 | -- |
---|
| 173 | -- Put_Name |
---|
| 174 | -- |
---|
| 175 | |
---|
| 176 | procedure Put_Name ( |
---|
| 177 | Name : in RTEMS.Name; |
---|
| 178 | New_Line : in Boolean |
---|
| 179 | ) is |
---|
| 180 | C1 : Character; |
---|
| 181 | C2 : Character; |
---|
| 182 | C3 : Character; |
---|
| 183 | C4 : Character; |
---|
| 184 | begin |
---|
| 185 | |
---|
| 186 | RTEMS.Name_To_Characters( Name, C1, C2, C3, C4 ); |
---|
| 187 | |
---|
| 188 | Text_IO.Put( C1 ); |
---|
| 189 | Text_IO.Put( C2 ); |
---|
| 190 | Text_IO.Put( C3 ); |
---|
| 191 | Text_IO.Put( C4 ); |
---|
| 192 | |
---|
| 193 | if New_Line = True then |
---|
| 194 | Text_IO.New_Line; |
---|
| 195 | end if; |
---|
| 196 | |
---|
| 197 | end Put_Name; |
---|
| 198 | |
---|
| 199 | --PAGE |
---|
| 200 | -- |
---|
| 201 | -- Task_Number |
---|
| 202 | -- |
---|
| 203 | |
---|
| 204 | function Task_Number ( |
---|
| 205 | TID : in RTEMS.ID |
---|
| 206 | ) return RTEMS.Unsigned32 is |
---|
| 207 | begin |
---|
| 208 | |
---|
[23848bbd] | 209 | -- probably OK |
---|
| 210 | return RTEMS.Get_Index( TID ) - 1; |
---|
| 211 | -- Ignoring this component. |
---|
| 212 | -- - RTEMS.Configuration.RTEMS_API_Configuration.Number_Of_Initialization_Tasks; |
---|
[f3f06f79] | 213 | |
---|
| 214 | end Task_Number; |
---|
| 215 | |
---|
| 216 | --PAGE |
---|
| 217 | -- |
---|
| 218 | -- Do_Nothing |
---|
| 219 | -- |
---|
| 220 | |
---|
| 221 | procedure Do_Nothing is |
---|
| 222 | begin |
---|
| 223 | NULL; |
---|
| 224 | end Do_Nothing; |
---|
| 225 | |
---|
| 226 | |
---|
| 227 | --PAGE |
---|
| 228 | -- |
---|
| 229 | -- Milliseconds_Per_Tick |
---|
| 230 | -- |
---|
| 231 | |
---|
| 232 | function Milliseconds_Per_Tick |
---|
| 233 | return RTEMS.Unsigned32 is |
---|
[23848bbd] | 234 | function Milliseconds_Per_Tick_Base return RTEMS.Unsigned32; |
---|
| 235 | pragma Import (C, Milliseconds_Per_Tick_Base, "milliseconds_per_tick"); |
---|
[f3f06f79] | 236 | begin |
---|
[23848bbd] | 237 | return Milliseconds_Per_Tick_Base; |
---|
[f3f06f79] | 238 | end Milliseconds_Per_Tick; |
---|
[23848bbd] | 239 | |
---|
| 240 | --PAGE |
---|
| 241 | -- |
---|
| 242 | -- Milliseconds_Per_Tick |
---|
| 243 | -- |
---|
| 244 | function Ticks_Per_Second |
---|
| 245 | return RTEMS.Interval is |
---|
| 246 | function Ticks_Per_Second_Base return RTEMS.Unsigned32; |
---|
| 247 | pragma Import (C, Ticks_Per_Second_Base, "ticks_per_second"); |
---|
| 248 | begin |
---|
| 249 | return Ticks_Per_Second_Base; |
---|
| 250 | end Ticks_Per_Second; |
---|
| 251 | |
---|
[ba3e1a4f] | 252 | -- |
---|
| 253 | -- Return the size of the RTEMS Workspace |
---|
| 254 | -- |
---|
| 255 | |
---|
| 256 | function Work_Space_Size |
---|
| 257 | return RTEMS.Unsigned32 is |
---|
| 258 | function Work_Space_Size_Base return RTEMS.Unsigned32; |
---|
| 259 | pragma Import (C, Work_Space_Size_Base, "work_space_size"); |
---|
| 260 | begin |
---|
| 261 | return Work_Space_Size_Base; |
---|
| 262 | end Work_Space_Size; |
---|
| 263 | |
---|
| 264 | -- |
---|
| 265 | -- Return an indication of whether multiprocessing is configured |
---|
| 266 | -- |
---|
| 267 | |
---|
| 268 | function Is_Configured_Multiprocessing |
---|
| 269 | return Boolean is |
---|
| 270 | function Is_Configured_Multiprocessing_Base return RTEMS.Unsigned32; |
---|
| 271 | pragma Import ( |
---|
| 272 | C, Is_Configured_Multiprocessing_Base, "is_configured_multiprocessing" |
---|
| 273 | ); |
---|
| 274 | begin |
---|
| 275 | if Is_Configured_Multiprocessing_Base = 1 then |
---|
| 276 | return True; |
---|
| 277 | else |
---|
| 278 | return False; |
---|
| 279 | end if; |
---|
| 280 | end Is_Configured_Multiprocessing; |
---|
| 281 | |
---|
[23848bbd] | 282 | -- |
---|
| 283 | -- Node is the node number in a multiprocessor configuration |
---|
| 284 | -- |
---|
| 285 | |
---|
| 286 | function Node |
---|
| 287 | return RTEMS.Unsigned32 is |
---|
| 288 | function Get_Node_Base return RTEMS.Unsigned32; |
---|
| 289 | pragma Import (C, Get_Node_Base, "get_node"); |
---|
| 290 | begin |
---|
| 291 | return Get_Node_Base; |
---|
| 292 | end Node; |
---|
[f3f06f79] | 293 | end Test_Support; |
---|