Back to home page

LXR

 
 

    


Warning, /testsuites/ada/support/test_support.adb is written in an unsupported language. File is not indexed.

0001 -- SPDX-License-Identifier: BSD-2-Clause
0002 
0003 --
0004 --  Test_Support / Specification
0005 --
0006 --  DESCRIPTION:
0007 --
0008 --  This package provides routines which aid the Test Suites
0009 --  and simplify their design and operation.
0010 --
0011 --  DEPENDENCIES: 
0012 --
0013 --  
0014 --
0015 --  COPYRIGHT (c) 1989-2011.
0016 --  On-Line Applications Research Corporation (OAR).
0017 --
0018 --  Redistribution and use in source and binary forms, with or without
0019 --  modification, are permitted provided that the following conditions
0020 --  are met:
0021 --  1. Redistributions of source code must retain the above copyright
0022 --     notice, this list of conditions and the following disclaimer.
0023 --  2. Redistributions in binary form must reproduce the above copyright
0024 --     notice, this list of conditions and the following disclaimer in the
0025 --     documentation and/or other materials provided with the distribution.
0026 --
0027 --  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0028 --  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0029 --  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0030 --  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0031 --  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0032 --  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0033 --  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0034 --  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0035 --  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0036 --  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0037 --  POSSIBILITY OF SUCH DAMAGE.
0038 --
0039 
0040 with Interfaces; use Interfaces;
0041 with Unsigned32_IO;
0042 with Status_IO;
0043 with Text_IO;
0044 with RTEMS.Fatal;
0045 
0046 package body Test_Support is
0047 
0048 --
0049 --  Fatal_Directive_Status
0050 --
0051 
0052    procedure Fatal_Directive_Status (
0053       Status  : in     RTEMS.Status_Codes;
0054       Desired : in     RTEMS.Status_Codes;
0055       Message : in     String
0056    ) is
0057    begin
0058 
0059       if not RTEMS.Are_Statuses_Equal( Status, Desired ) then
0060 
0061          Text_IO.Put( Message );
0062          Text_IO.Put( " FAILED -- expected " );
0063          Status_IO.Put( Desired );
0064          Text_IO.Put( " got " );
0065          Status_IO.Put( Status );
0066          Text_IO.New_Line;
0067 
0068          RTEMS.Fatal.Error_Occurred( RTEMS.Status_Codes'Pos( Status ) );
0069 
0070       end if;
0071 
0072    end Fatal_Directive_Status;
0073 
0074 --
0075 --  Directive_Failed
0076 --
0077 
0078    procedure Directive_Failed (
0079       Status  : in     RTEMS.Status_Codes;
0080       Message : in     String
0081    ) is
0082    begin
0083 
0084       Test_Support.Fatal_Directive_Status(
0085          Status, 
0086          RTEMS.Successful, 
0087          Message 
0088       );
0089 
0090    end Directive_Failed;
0091 
0092 --
0093 --  Print_Time
0094 --
0095 
0096    procedure Print_Time (
0097       Prefix      : in     String;
0098       Time_Buffer : in     RTEMS.Time_Of_Day;
0099       Suffix      : in     String
0100    ) is
0101    begin
0102 
0103       Text_IO.Put( Prefix );
0104       Unsigned32_IO.Put( Time_Buffer.Hour, Width=>2 );
0105       Text_IO.Put( ":" );
0106       Unsigned32_IO.Put( Time_Buffer.Minute, Width=>2 );
0107       Text_IO.Put( ":" );
0108       Unsigned32_IO.Put( Time_Buffer.Second, Width=>2 );
0109       Text_IO.Put( "   " );
0110       Unsigned32_IO.Put( Time_Buffer.Month, Width=>2 );
0111       Text_IO.Put( "/" );
0112       Unsigned32_IO.Put( Time_Buffer.Day, Width=>2 );
0113       Text_IO.Put( "/" );
0114       Unsigned32_IO.Put( Time_Buffer.Year, Width=>2 );
0115       Text_IO.Put( Suffix );
0116 
0117    end Print_Time;
0118 
0119 --
0120 --  Put_Dot
0121 --
0122  
0123    procedure Put_Dot (
0124       Buffer : in     String
0125    ) is
0126    begin
0127       Text_IO.Put( Buffer );
0128       Text_IO.FLUSH;
0129    end Put_Dot;
0130 
0131 --
0132 --  Pause
0133 --
0134 
0135    procedure Pause is
0136       --  Ignored_String : String( 1 .. 80 );
0137       --  Ignored_Last   : Natural;
0138       
0139    begin
0140 
0141       -- 
0142       --  Really should be a "put" followed by a "flush."
0143       -- 
0144       Text_IO.Put_Line( "<pause> " );
0145       -- Text_IO.Get_Line( Ignored_String, Ignored_Last );
0146 
0147    end Pause;
0148 
0149 --
0150 --  Pause_And_Screen_Number
0151 --
0152  
0153    procedure Pause_And_Screen_Number (
0154       SCREEN : in    RTEMS.Unsigned32
0155    ) is
0156       --  Ignored_String : String( 1 .. 80 );
0157       --  Ignored_Last   : Natural;
0158    begin
0159  
0160       --
0161       --  Really should be a "put" followed by a "flush."
0162       --
0163       Text_IO.Put( "<pause - screen  " );
0164       Unsigned32_IO.Put( SCREEN, Width=>2 );
0165       Text_IO.Put_Line( "> " );
0166    --    Text_IO.Get_Line( Ignored_String, Ignored_Last );
0167  
0168    end Pause_And_Screen_Number;
0169 
0170 --
0171 --  Put_Name
0172 --
0173 
0174    procedure Put_Name (
0175       Name     : in     RTEMS.Name;
0176       New_Line : in     Boolean
0177    ) is
0178       C1 : Character;
0179       C2 : Character;
0180       C3 : Character;
0181       C4 : Character;
0182    begin
0183 
0184       RTEMS.Name_To_Characters( Name, C1, C2, C3, C4 );
0185 
0186       Text_IO.Put( C1 );
0187       Text_IO.Put( C2 );
0188       Text_IO.Put( C3 );
0189       Text_IO.Put( C4 );
0190 
0191       if New_Line then
0192          Text_IO.New_Line;
0193       end if;
0194 
0195    end Put_Name;
0196  
0197 --
0198 --  Task_Number
0199 --
0200 
0201    function Task_Number (
0202       TID : in     RTEMS.ID
0203    ) return RTEMS.Unsigned32 is
0204    begin
0205 
0206       -- probably OK
0207       return RTEMS.Get_Index( TID ) - 1;
0208 
0209    end Task_Number;
0210 
0211 --
0212 --  Do_Nothing
0213 --
0214 
0215    procedure Do_Nothing is
0216    begin
0217       NULL;
0218    end Do_Nothing;
0219    
0220 
0221 --
0222 --  Milliseconds_Per_Tick
0223 --
0224 
0225    function Milliseconds_Per_Tick 
0226    return RTEMS.Unsigned32 is
0227       function Milliseconds_Per_Tick_Base return RTEMS.Unsigned32;
0228       pragma Import (C, Milliseconds_Per_Tick_Base, "milliseconds_per_tick");
0229    begin
0230       return Milliseconds_Per_Tick_Base;
0231    end Milliseconds_Per_Tick;
0232 
0233 --
0234 --  Milliseconds_Per_Tick
0235 --
0236    function Ticks_Per_Second 
0237    return RTEMS.Interval is
0238       function Ticks_Per_Second_Base return RTEMS.Unsigned32;
0239       pragma Import (C, Ticks_Per_Second_Base, "ticks_per_second");
0240    begin
0241       return Ticks_Per_Second_Base;
0242    end Ticks_Per_Second; 
0243 
0244 --
0245 --  Return the size of the RTEMS Workspace
0246 --
0247 
0248    function Work_Space_Size
0249    return RTEMS.Size is
0250       function Work_Space_Size_Base return RTEMS.Size;
0251       pragma Import (C, Work_Space_Size_Base, "work_space_size");
0252    begin
0253       return Work_Space_Size_Base;
0254    end Work_Space_Size;
0255 
0256 --
0257 --  Return an indication of whether multiprocessing is configured
0258 --
0259 
0260    function Is_Configured_Multiprocessing
0261    return Boolean is
0262       function Is_Configured_Multiprocessing_Base return RTEMS.Unsigned32;
0263       pragma Import (
0264          C, Is_Configured_Multiprocessing_Base, "is_configured_multiprocessing"
0265       );
0266    begin
0267       if Is_Configured_Multiprocessing_Base = 1 then
0268          return True;
0269       else
0270          return False;
0271       end if;
0272    end Is_Configured_Multiprocessing;
0273 
0274 --
0275 --  Node is the node number in a multiprocessor configuration
0276 --
0277 
0278    function Node 
0279    return RTEMS.Unsigned32 is
0280       function Get_Node_Base return RTEMS.Unsigned32;
0281       pragma Import (C, Get_Node_Base, "get_node");
0282    begin
0283       return Get_Node_Base;
0284    end Node;
0285 end Test_Support;