OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [gcc-4.5.1/] [gcc/] [testsuite/] [ada/] [acats/] [support/] [tctouch.ada] - Blame information for rev 816

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 294 jeremybenn
-- TCTouch.A
2
--
3
--                             Grant of Unlimited Rights
4
--
5
--     Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
6
--     F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
7
--     unlimited rights in the software and documentation contained herein.
8
--     Unlimited rights are defined in DFAR 252.227-7013(a)(19).  By making
9
--     this public release, the Government intends to confer upon all
10
--     recipients unlimited rights  equal to those held by the Government.
11
--     These rights include rights to use, duplicate, release or disclose the
12
--     released technical data and computer software in whole or in part, in
13
--     any manner and for any purpose whatsoever, and to have or permit others
14
--     to do so.
15
--
16
--                                    DISCLAIMER
17
--
18
--     ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
19
--     DISCLOSED ARE AS IS.  THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
20
--     WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
21
--     SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
22
--     OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
23
--     PARTICULAR PURPOSE OF SAID MATERIAL.
24
--*
25
--
26
-- FOUNDATION DESCRIPTION:
27
--      The tools in this foundation are not peculiar to any particular
28
--      aspect of the language, but simplify the test writing and reading
29
--      process.  Assert and Assert_Not are used to reduce the textual
30
--      overhead of the test-that-this-condition-is-(not)-true paradigm.
31
--      Touch and Validate are used to simplify tracing an expected path
32
--      of execution.
33
--      A tag comment of the form:
34
--
35
--      TCTouch.Touch( 'A' ); ----------------------------------------- A
36
--
37
--      is recommended to improve readability of this feature.
38
--
39
--      Report.Test must be called before any of the procedures in this
40
--      package with the exception of Touch.
41
--      The usage paradigm is to call Touch in locations in the test where you
42
--      want a trace of execution.  Each call to Touch should have a unique
43
--      character associated with it.  At each place where a check can
44
--      reasonably be performed to determine correct execution of a
45
--      sub-test, a call to Validate should be made.  The first parameter
46
--      passed to Validate is the expected string of characters produced by
47
--      call(s) to Touch in the subtest just executed.  The second parameter
48
--      is the message to pass to Report.Failed if the expected sequence was
49
--      not executed.
50
--
51
--      Validate should always be called after calls to Touch before a test
52
--      completes.
53
--
54
--      In the event that calls may have been made to Touch that are not
55
--      intended to be recorded, or, the failure of a previous subtest may
56
--      leave Touch calls "Unvalidated", the procedure Flush will reset the
57
--      tracker to the "empty" state.  Flush does not make any calls to
58
--      Report.
59
--
60
--      Calls to Assert and Assert_Not are to replace the idiom:
61
--
62
--         if BadCondition then  -- or if not PositiveTest then
63
--           Report.Failed(Message);
64
--         end if;
65
--
66
--      with:
67
--
68
--         Assert_Not( BadCondition, Message ); -- or
69
--         Assert( PositiveTest, Message );
70
--
71
--      Implementation_Check is for use with tests that cross the boundary
72
--      between the core and the Special Needs Annexes.  There are several
73
--      instances where language in the core becomes enforceable only when
74
--      a Special Needs Annex is supported.  Implementation_Check should be
75
--      called in place of Report.Failed in these cases; it examines the
76
--      constants in Impdef that indicate if the particular Special Needs
77
--      Annex is being validated with this validation; and acts accordingly.
78
--
79
--      The constant Foundation_ID contains the internal change version
80
--      for this software.
81
--
82
-- ERROR CONDITIONS:
83
--
84
--      It is an error to perform more than Max_Touch_Count (80) calls to
85
--      Touch without a subsequent call to Validate.  To do so will cause
86
--      a false test failure.
87
--
88
-- CHANGE HISTORY:
89
--     02 JUN 94   SAIC    Initial version
90
--     27 OCT 94   SAIC    Revised version
91
--     07 AUG 95   SAIC    Added Implementation_Check
92
--     07 FEB 96   SAIC    Changed to match new Impdef for 2.1
93
--     16 MAR 00   RLB     Changed foundation id to reflect test suite version.
94
--     22 MAR 01   RLB     Changed foundation id to reflect test suite version.
95
--     29 MAR 02   RLB     Changed foundation id to reflect test suite version.
96
--
97
--!
98
 
99
package TCTouch is
100
  Foundation_ID   : constant String := "TCTouch ACATS 2.5";
101
  Max_Touch_Count : constant        := 80;
102
 
103
  procedure Assert    ( SB_True  : Boolean; Message : String );
104
  procedure Assert_Not( SB_False : Boolean; Message : String );
105
 
106
  procedure Touch   ( A_Tag   : Character );
107
  procedure Validate( Expected: String;
108
                      Message : String;
109
                      Order_Meaningful : Boolean := True );
110
 
111
  procedure Flush;
112
 
113
  type Special_Needs_Annexes is ( Annex_C, Annex_D, Annex_E,
114
                                  Annex_F, Annex_G, Annex_H );
115
 
116
  procedure Implementation_Check( Message : in String;
117
                                  Annex   : in Special_Needs_Annexes
118
                                          := Annex_C );
119
    -- If Impdef.Validating_Annex_<Annex> is true, will call Report.Failed
120
    -- otherwise will call Report.Not_Applicable.  This is to allow tests
121
    -- which are driven by wording in the core of the language, yet have
122
    -- their functionality dictated by the Special Needs Annexes to perform
123
    -- dual purpose.
124
    -- The default of Annex_C for the Annex parameter is to support early
125
    -- tests written with the assumption that Implementation_Check was
126
    -- expressly for use with the Systems Programming Annex.
127
 
128
end TCTouch;
129
 
130
with Report;
131
with Impdef;
132
package body TCTouch is
133
 
134
  procedure Assert( SB_True : Boolean; Message : String ) is
135
  begin
136
    if not SB_True then
137
      Report.Failed( "Assertion failed: " & Message );
138
    end if;
139
  end Assert;
140
 
141
  procedure Assert_Not( SB_False : Boolean; Message : String ) is
142
  begin
143
    if SB_False then
144
      Report.Failed( "Assertion failed: " & Message );
145
    end if;
146
  end Assert_Not;
147
 
148
  Collection : String(1..Max_Touch_Count);
149
  Finger     : Natural := 0;
150
 
151
  procedure Touch ( A_Tag : Character ) is
152
  begin
153
    Finger := Finger+1;
154
    Collection(Finger) := A_Tag;
155
  exception
156
    when Constraint_Error =>
157
      Report.Failed("Trace Overflow: " & Collection);
158
      Finger := 0;
159
  end Touch;
160
 
161
  procedure Sort_String( S: in out String ) is
162
  -- algorithm from Booch Components Page 472
163
    No_Swaps : Boolean;
164
    procedure Swap(C1, C2: in out Character) is
165
      T: Character := C1;
166
    begin  C1 := C2; C2 := T; end Swap;
167
  begin
168
    for OI in S'First+1..S'Last loop
169
      No_Swaps := True;
170
      for II in reverse OI..S'Last loop
171
        if S(II) < S(II-1) then
172
          Swap(S(II),S(II-1));
173
          No_Swaps := False;
174
        end if;
175
      end loop;
176
      exit when No_Swaps;
177
    end loop;
178
  end Sort_String;
179
 
180
  procedure Validate( Expected: String;
181
                      Message : String;
182
                      Order_Meaningful : Boolean := True) is
183
    Want : String(1..Expected'Length) := Expected;
184
  begin
185
    if not Order_Meaningful then
186
      Sort_String( Want );
187
      Sort_String( Collection(1..Finger) );
188
    end if;
189
    if Collection(1..Finger) /= Want then
190
      Report.Failed( Message & " Expecting: " & Want
191
                             & " Got: " & Collection(1..Finger) );
192
    end if;
193
    Finger := 0;
194
  end Validate;
195
 
196
  procedure Flush is
197
  begin
198
    Finger := 0;
199
  end Flush;
200
 
201
  procedure Implementation_Check( Message : in String;
202
                                  Annex   : in Special_Needs_Annexes
203
                                          := Annex_C ) is
204
                                          -- default to cover some legacy
205
  -- USAGE DISCIPLINE:
206
  --   Implementation_Check is designed to be used in tests that have
207
  --   interdependency on one of the Special Needs Annexes, yet are _really_
208
  --   tests based in the core language.  There will be instances where the
209
  --   execution of a test would be failing in the light of the requirements
210
  --   of the annex, yet from the point of view of the core language without
211
  --   the additional requirements of the annex, the test does not apply.
212
  --   In these cases, rather than issuing a call to Report.Failed, calling
213
  --   TCTouch.Implementation_Check will check that sensitivity, and if
214
  --   the implementation is attempting to validate against the specific
215
  --   annex, Report.Failed will be called, otherwise, Report.Not_Applicable
216
  --   will be called.
217
  begin
218
 
219
    case Annex is
220
      when Annex_C =>
221
        if ImpDef.Validating_Annex_C then
222
          Report.Failed( Message );
223
        else
224
          Report.Not_Applicable( Message & " Annex C not supported" );
225
       end if;
226
 
227
      when Annex_D =>
228
        if ImpDef.Validating_Annex_D then
229
          Report.Failed( Message );
230
        else
231
          Report.Not_Applicable( Message & " Annex D not supported" );
232
       end if;
233
 
234
      when Annex_E =>
235
        if ImpDef.Validating_Annex_E then
236
          Report.Failed( Message );
237
        else
238
          Report.Not_Applicable( Message & " Annex E not supported" );
239
       end if;
240
 
241
      when Annex_F =>
242
        if ImpDef.Validating_Annex_F then
243
          Report.Failed( Message );
244
        else
245
          Report.Not_Applicable( Message & " Annex F not supported" );
246
       end if;
247
 
248
      when Annex_G =>
249
        if ImpDef.Validating_Annex_G then
250
          Report.Failed( Message );
251
        else
252
          Report.Not_Applicable( Message & " Annex G not supported" );
253
       end if;
254
 
255
      when Annex_H =>
256
        if ImpDef.Validating_Annex_H then
257
          Report.Failed( Message );
258
        else
259
          Report.Not_Applicable( Message & " Annex H not supported" );
260
       end if;
261
    end case;
262
 end Implementation_Check;
263
 
264
end TCTouch;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.