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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [ada/] [acats/] [tests/] [cxa/] [cxa8001.a] - Blame information for rev 720

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 720 jeremybenn
-- CXA8001.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
-- OBJECTIVE:
27
--      Check that all elements to be transferred to a sequential file of
28
--      mode Append_File will be placed following the last element currently
29
--      in the file.
30
--      Check that it is possible to append data to a file that has been
31
--      previously appended to.
32
--      Check that the predefined procedure Write will place an element after
33
--      the last element in the file in mode Append_File.
34
--
35
-- TEST DESCRIPTION:
36
--      This test implements a sequential file system that has the capability
37
--      to store data records at the end of a file.  Initially, the file is
38
--      opened with mode Out_File, and data is written to the file.  The file
39
--      is closed, then reopened with mode Append_File.  An additional record
40
--      is written, and again the file is closed.  The file is then reopened,
41
--      again with mode Append_File, and another record is written to the
42
--      file.
43
--      The file is closed again, the reopened with mode In_File, and the data
44
--      in the file is read and checked for proper ordering within the file.
45
--
46
--      An expected common usage of Append_File mode would be in the opening
47
--      of a file that currently contains data.  Likewise, the reopening of
48
--      files in Append_Mode that have been previously appended to for the
49
--      addition of more data would be frequently encountered.  This test
50
--      attempts to simulate both situations.  (Of course, in an actual user
51
--      environment, the open/write/close processing would be performed using
52
--      looping structures, rather than the straight-line processing displayed
53
--      here.)
54
--
55
-- APPLICABILITY CRITERIA:
56
--      Applicable to all systems capable of supporting IO operations on
57
--      external Sequential_IO files.
58
--
59
--
60
-- CHANGE HISTORY:
61
--      06 Dec 94   SAIC    ACVC 2.0
62
--      27 Feb 97   PWB.CTA Allowed for non-support of some IO operations
63
--!
64
 
65
with Sequential_IO;
66
with Report;
67
 
68
procedure CXA8001 is
69
 
70
   -- Declare data types and objects to be stored in the file.
71
   subtype Name_Type is String (1 .. 10);
72
   type    Tickets   is range 0 .. 1000;
73
 
74
   type Order_Type is record
75
      Name          : Name_Type;
76
      No_of_Tickets : Tickets;
77
   end record;
78
 
79
   package Order_IO is new Sequential_IO (Order_Type); -- Declare Seq_IO
80
                                                       -- package,
81
   Order_File     : Order_IO.File_Type;                -- and file object.
82
   Order_Filename : constant String :=
83
                           Report.Legal_File_Name ( Nam => "CXA8001" );
84
   Incomplete : exception;
85
 
86
begin
87
 
88
   Report.Test ("CXA8001", "Check that all elements to be transferred to a " &
89
                           "sequential file of mode Append_File will be "    &
90
                           "placed following the last element currently "    &
91
                           "in the file");
92
 
93
   Test_for_Sequential_IO_Support:
94
   begin
95
 
96
      -- An implementation that does not support Sequential_IO in a particular
97
      -- environment will raise Use_Error or Name_Error on calls to various
98
      -- Sequential_IO operations.  This block statement encloses a call to
99
      -- Create, which should produce an exception in a non-supportive
100
      -- environment.  These exceptions will be handled to produce a
101
      -- Not_Applicable result.
102
 
103
      Order_IO.Create (File => Order_File,        -- Create Sequential_IO file
104
                       Mode => Order_IO.Out_File, -- with mode Out_File.
105
                       Name => Order_Filename);
106
 
107
   exception
108
 
109
       when Order_IO.Use_Error | Order_IO.Name_Error =>
110
          Report.Not_Applicable
111
             ( "Files not supported - Create as Out_File for Sequential_IO" );
112
          raise Incomplete;
113
 
114
   end Test_for_Sequential_IO_Support;
115
 
116
   Operational_Test_Block:
117
   declare
118
      -- Assign values into the component fields of the data objects.
119
      Buyer_1 : constant Order_Type := ("John Smith", 3);
120
      Buyer_2 : constant Order_Type :=
121
                  (Name => "Jane Jones", No_of_Tickets => 2);
122
      Buyer_3 : Order_Type := ("Mike Brown", 5);
123
 
124
   begin
125
      Order_IO.Write (File => Order_File,      -- Write initial data item
126
                      Item => Buyer_1);        -- to file.
127
 
128
      Order_IO.Close (File => Order_File);     -- Close file.
129
 
130
      --
131
      -- Enter additional data records into the file.  (Append to a file of
132
      -- previous mode Out_File).
133
      --
134
      Order_IO.Open (Order_File,               -- Open Sequential_IO file
135
                     Order_IO.Append_File,     -- with mode Append_File.
136
                     Order_Filename);
137
 
138
      Order_IO.Write (Order_File, Buyer_2);    -- Write second data item
139
                                               -- to file.
140
      Order_IO.Close (File => Order_File);     -- Close file.
141
 
142
      -- Check to determine whether file is actually closed.
143
      begin
144
         Order_IO.Write (Order_File, Buyer_2);
145
         Report.Failed("Exception not raised on Write to Closed file");
146
      exception
147
         when Order_IO.Status_Error => null;   -- Expected exception.
148
         when others                =>
149
           Report.Failed("Incorrect exception on Write to Closed file");
150
      end;
151
 
152
      --
153
      -- The following code segment demonstrates appending data to a file
154
      -- that has been previously appended to.
155
      --
156
 
157
      Order_IO.Open (Order_File,               -- Open Sequential_IO file
158
                     Order_IO.Append_File,     -- with mode Append_File.
159
                     Order_Filename );
160
 
161
      Order_IO.Write (Order_File, Buyer_3);    -- Write third data item
162
                                               -- to file.
163
      Order_IO.Close (File => Order_File);     -- Close file.
164
 
165
 
166
      Test_Verification_Block:
167
      declare
168
         TC_Order1, TC_Order2, TC_Order3 : Order_Type;
169
      begin
170
 
171
         Order_IO.Open (Order_File,            -- Open Sequential_IO file
172
                        Order_IO.In_File,      -- with mode In_File.
173
                        Order_Filename );
174
 
175
         Order_IO.Read (File => Order_File,    -- Read records from file.
176
                        Item => TC_Order1);
177
         Order_IO.Read (Order_File, TC_Order2);
178
         Order_IO.Read (Order_File, TC_Order3);
179
 
180
         -- Compare the contents of each with the individual data items.
181
         -- If items read from file do not match the items placed into
182
         -- the file, in the appropriate order, then fail.
183
 
184
         if ((TC_Order1 /= Buyer_1)               or
185
             (TC_Order2.Name /= Buyer_2.Name)     or
186
             (TC_Order2.No_of_Tickets /= Buyer_2.No_of_Tickets) or
187
             not ((TC_Order3.Name = "Mike Brown") and
188
                  (TC_Order3.No_of_Tickets = 5))) then
189
            Report.Failed ("Incorrect appending of record data in file");
190
         end if;
191
 
192
         -- Check to determine that no more than three data records were
193
         -- actually written to the file.
194
         if not Order_IO.End_Of_File (Order_File) then
195
            Report.Failed("File not empty after three reads");
196
         end if;
197
 
198
      exception
199
 
200
         when Order_IO.End_Error =>            -- If three items not in
201
                                               -- file (data overwritten),
202
                                               -- then fail.
203
            Report.Failed ("Incorrect number of record elements in file");
204
 
205
         when others =>
206
            Report.Failed ("Error raised during data verification");
207
 
208
      end Test_Verification_Block;
209
 
210
   exception
211
 
212
      when others =>
213
         Report.Failed("Exception raised during Sequential_IO processing");
214
 
215
   end Operational_Test_Block;
216
 
217
   Deletion:
218
   begin
219
      -- Check that file is open prior to deleting it.
220
      if Order_IO.Is_Open(Order_File) then
221
         Order_IO.Delete (Order_File);
222
      else
223
         Order_IO.Open(Order_File, Order_IO.In_File, Order_Filename);
224
         Order_IO.Delete (Order_File);
225
      end if;
226
 
227
   exception
228
      when others =>
229
         Report.Failed
230
            ( "Delete not properly implemented for Sequential_IO" );
231
 
232
   end Deletion;
233
 
234
   Report.Result;
235
 
236
exception
237
   when Incomplete =>
238
      Report.Result;
239
   when others     =>
240
      Report.Failed ( "Unexpected exception" );
241
      Report.Result;
242
 
243
end CXA8001;

powered by: WebSVN 2.1.0

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