annotate gcc/testsuite/ada/acats/tests/cxa/cxa8002.a @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 -- CXA8002.A
kono
parents:
diff changeset
2 --
kono
parents:
diff changeset
3 -- Grant of Unlimited Rights
kono
parents:
diff changeset
4 --
kono
parents:
diff changeset
5 -- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
kono
parents:
diff changeset
6 -- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
kono
parents:
diff changeset
7 -- unlimited rights in the software and documentation contained herein.
kono
parents:
diff changeset
8 -- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
kono
parents:
diff changeset
9 -- this public release, the Government intends to confer upon all
kono
parents:
diff changeset
10 -- recipients unlimited rights equal to those held by the Government.
kono
parents:
diff changeset
11 -- These rights include rights to use, duplicate, release or disclose the
kono
parents:
diff changeset
12 -- released technical data and computer software in whole or in part, in
kono
parents:
diff changeset
13 -- any manner and for any purpose whatsoever, and to have or permit others
kono
parents:
diff changeset
14 -- to do so.
kono
parents:
diff changeset
15 --
kono
parents:
diff changeset
16 -- DISCLAIMER
kono
parents:
diff changeset
17 --
kono
parents:
diff changeset
18 -- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
kono
parents:
diff changeset
19 -- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
kono
parents:
diff changeset
20 -- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
kono
parents:
diff changeset
21 -- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
kono
parents:
diff changeset
22 -- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
kono
parents:
diff changeset
23 -- PARTICULAR PURPOSE OF SAID MATERIAL.
kono
parents:
diff changeset
24 --*
kono
parents:
diff changeset
25 --
kono
parents:
diff changeset
26 -- OBJECTIVE:
kono
parents:
diff changeset
27 -- Check that resetting a file using mode Append_File allows for the
kono
parents:
diff changeset
28 -- writing of elements to the file starting after the last element in
kono
parents:
diff changeset
29 -- the file.
kono
parents:
diff changeset
30 -- Check that the result of function Name can be used on a subsequent
kono
parents:
diff changeset
31 -- reopen of the file.
kono
parents:
diff changeset
32 -- Check that a mode change occurs on reset of a file to/from mode
kono
parents:
diff changeset
33 -- Append_File.
kono
parents:
diff changeset
34 --
kono
parents:
diff changeset
35 -- TEST DESCRIPTION:
kono
parents:
diff changeset
36 -- This test simulates the read/write of data from/to an individual
kono
parents:
diff changeset
37 -- sequential file. New data can be appended to the end of the existing
kono
parents:
diff changeset
38 -- file, and the same file can be reset to allow reading of data from
kono
parents:
diff changeset
39 -- the file. This process can occur multiple times.
kono
parents:
diff changeset
40 -- When the mode of the file is changed with a Reset, the current mode
kono
parents:
diff changeset
41 -- value assigned to the file is checked using the result of function
kono
parents:
diff changeset
42 -- Mode. This, in conjunction with the read/write operations, verifies
kono
parents:
diff changeset
43 -- that a mode change has taken place on Reset.
kono
parents:
diff changeset
44 --
kono
parents:
diff changeset
45 -- An expected common usage of the scenarios found in this test would
kono
parents:
diff changeset
46 -- be a case where a single data file is kept open continuously, being
kono
parents:
diff changeset
47 -- reset for read/append of data. For systems that do not support a
kono
parents:
diff changeset
48 -- direct form of I/O, this would allow for efficient use of a sequential
kono
parents:
diff changeset
49 -- I/O file.
kono
parents:
diff changeset
50 --
kono
parents:
diff changeset
51 -- APPLICABILITY CRITERIA:
kono
parents:
diff changeset
52 -- Applicable to all systems capable of supporting IO operations on
kono
parents:
diff changeset
53 -- external Sequential_IO files.
kono
parents:
diff changeset
54 --
kono
parents:
diff changeset
55 --
kono
parents:
diff changeset
56 -- CHANGE HISTORY:
kono
parents:
diff changeset
57 -- 06 Dec 94 SAIC ACVC 2.0
kono
parents:
diff changeset
58 -- 19 Feb 97 PWB.CTA Fixed handling for file non-support and Reset
kono
parents:
diff changeset
59 -- non-support.
kono
parents:
diff changeset
60 --!
kono
parents:
diff changeset
61
kono
parents:
diff changeset
62 with Sequential_IO;
kono
parents:
diff changeset
63 with Report;
kono
parents:
diff changeset
64
kono
parents:
diff changeset
65 procedure CXA8002 is
kono
parents:
diff changeset
66 subtype Employee_Data is String (1 .. 11);
kono
parents:
diff changeset
67 package Data_IO is new Sequential_IO (Employee_Data);
kono
parents:
diff changeset
68
kono
parents:
diff changeset
69 Employee_Data_File : Data_IO.File_Type;
kono
parents:
diff changeset
70 Employee_Filename : constant String :=
kono
parents:
diff changeset
71 Report.Legal_File_Name (Nam => "CXA8002");
kono
parents:
diff changeset
72
kono
parents:
diff changeset
73 Incomplete : exception;
kono
parents:
diff changeset
74
kono
parents:
diff changeset
75 begin
kono
parents:
diff changeset
76
kono
parents:
diff changeset
77 Report.Test ("CXA8002", "Check that resetting a file using mode " &
kono
parents:
diff changeset
78 "Append_File allows for the writing of " &
kono
parents:
diff changeset
79 "elements to the file starting after the " &
kono
parents:
diff changeset
80 "last element in the file");
kono
parents:
diff changeset
81
kono
parents:
diff changeset
82 Test_for_Sequential_IO_Support:
kono
parents:
diff changeset
83 begin
kono
parents:
diff changeset
84
kono
parents:
diff changeset
85 -- An implementation that does not support Sequential_IO in a particular
kono
parents:
diff changeset
86 -- environment will raise Use_Error or Name_Error on calls to various
kono
parents:
diff changeset
87 -- Sequential_IO operations. This block statement encloses a call to
kono
parents:
diff changeset
88 -- Create, which should produce an exception in a non-supportive
kono
parents:
diff changeset
89 -- environment. These exceptions will be handled to produce a
kono
parents:
diff changeset
90 -- Not_Applicable result.
kono
parents:
diff changeset
91
kono
parents:
diff changeset
92 Data_IO.Create (File => Employee_Data_File, -- Create file in
kono
parents:
diff changeset
93 Mode => Data_IO.Append_File, -- mode Append_File.
kono
parents:
diff changeset
94 Name => Employee_Filename);
kono
parents:
diff changeset
95
kono
parents:
diff changeset
96 --
kono
parents:
diff changeset
97 -- The following portion of code demonstrates the fact that a sequential
kono
parents:
diff changeset
98 -- file can be created in Append_File mode, and that data can be written
kono
parents:
diff changeset
99 -- to the file.
kono
parents:
diff changeset
100 --
kono
parents:
diff changeset
101
kono
parents:
diff changeset
102 exception
kono
parents:
diff changeset
103 when Data_IO.Use_Error | Data_IO.Name_Error =>
kono
parents:
diff changeset
104 Report.Not_Applicable
kono
parents:
diff changeset
105 ( "Sequential files not supported - Create as Append_File");
kono
parents:
diff changeset
106 raise Incomplete;
kono
parents:
diff changeset
107 end Test_for_Sequential_IO_Support;
kono
parents:
diff changeset
108 Operational_Test_Block:
kono
parents:
diff changeset
109 declare
kono
parents:
diff changeset
110 Blank_Data : constant Employee_Data := " ";
kono
parents:
diff changeset
111 Employee_1 : constant Employee_Data := "123-45-6789";
kono
parents:
diff changeset
112 Employee_2 : Employee_Data := "987-65-4321";
kono
parents:
diff changeset
113
kono
parents:
diff changeset
114 -- Note: Artificial numerical data chosen above to prevent any
kono
parents:
diff changeset
115 -- unintended similarity with persons alive or dead.
kono
parents:
diff changeset
116
kono
parents:
diff changeset
117 TC_Employee_Data : Employee_Data := Blank_Data;
kono
parents:
diff changeset
118
kono
parents:
diff changeset
119
kono
parents:
diff changeset
120 function TC_Mode_Selection (Selector : Integer)
kono
parents:
diff changeset
121 return Data_IO.File_Mode is
kono
parents:
diff changeset
122 begin
kono
parents:
diff changeset
123 case Report.Ident_Int(Selector) is
kono
parents:
diff changeset
124 when 1 => return Data_IO.In_File;
kono
parents:
diff changeset
125 when 2 => return Data_IO.Out_File;
kono
parents:
diff changeset
126 when others => return Data_IO.Append_File;
kono
parents:
diff changeset
127 end case;
kono
parents:
diff changeset
128 end TC_Mode_Selection;
kono
parents:
diff changeset
129
kono
parents:
diff changeset
130 Employee_Filename : constant String := -- Use function Name to
kono
parents:
diff changeset
131 Data_IO.Name (File => Employee_Data_File); -- store filename in
kono
parents:
diff changeset
132 -- string variable.
kono
parents:
diff changeset
133 begin
kono
parents:
diff changeset
134
kono
parents:
diff changeset
135 Data_IO.Write (File => Employee_Data_File, -- Write initial data
kono
parents:
diff changeset
136 Item => Employee_1); -- entry to file.
kono
parents:
diff changeset
137
kono
parents:
diff changeset
138 --
kono
parents:
diff changeset
139 -- The following portion of code demonstrates that a sequential file
kono
parents:
diff changeset
140 -- can be reset to various file modes, including Append_File mode,
kono
parents:
diff changeset
141 -- allowing data to be added to the end of the file.
kono
parents:
diff changeset
142 --
kono
parents:
diff changeset
143 begin
kono
parents:
diff changeset
144 Data_IO.Reset (File => Employee_Data_File, -- Reset file with
kono
parents:
diff changeset
145 Mode => Data_IO.In_File); -- mode In_File.
kono
parents:
diff changeset
146 exception
kono
parents:
diff changeset
147 when Data_IO.Use_Error =>
kono
parents:
diff changeset
148 Report.Not_Applicable
kono
parents:
diff changeset
149 ("Reset to In_File not supported for Sequential_IO");
kono
parents:
diff changeset
150 raise Incomplete;
kono
parents:
diff changeset
151 when others =>
kono
parents:
diff changeset
152 Report.Failed
kono
parents:
diff changeset
153 ("Unexpected exception on Reset to In_File (Sequential_IO)");
kono
parents:
diff changeset
154 raise Incomplete;
kono
parents:
diff changeset
155 end;
kono
parents:
diff changeset
156 if Data_IO."="(Data_IO.Mode (Employee_Data_File),
kono
parents:
diff changeset
157 TC_Mode_Selection (1)) then -- Compare In_File mode
kono
parents:
diff changeset
158 -- Reset successful,
kono
parents:
diff changeset
159 Data_IO.Read (File => Employee_Data_File, -- now verify file data.
kono
parents:
diff changeset
160 Item => TC_Employee_Data);
kono
parents:
diff changeset
161
kono
parents:
diff changeset
162 if ((TC_Employee_Data (1 .. 7) /= "123-45-") or
kono
parents:
diff changeset
163 (TC_Employee_Data (5 .. 11) /= "45-6789")) then
kono
parents:
diff changeset
164 Report.Failed ("Data read error");
kono
parents:
diff changeset
165 end if;
kono
parents:
diff changeset
166
kono
parents:
diff changeset
167 else
kono
parents:
diff changeset
168 Report.Failed ("File mode not changed by Reset");
kono
parents:
diff changeset
169 end if;
kono
parents:
diff changeset
170
kono
parents:
diff changeset
171 --
kono
parents:
diff changeset
172 -- Simulate appending data to a file that has previously been written
kono
parents:
diff changeset
173 -- to and read from.
kono
parents:
diff changeset
174 --
kono
parents:
diff changeset
175 begin
kono
parents:
diff changeset
176 Data_IO.Reset (File => Employee_Data_File, -- Reset file with
kono
parents:
diff changeset
177 Mode => Data_IO.Append_File); -- mode Append_File.
kono
parents:
diff changeset
178 exception
kono
parents:
diff changeset
179 when Data_IO.Use_Error =>
kono
parents:
diff changeset
180 Report.Not_Applicable
kono
parents:
diff changeset
181 ("Reset to Append_File not supported for Sequential_IO");
kono
parents:
diff changeset
182 raise Incomplete;
kono
parents:
diff changeset
183 when others =>
kono
parents:
diff changeset
184 Report.Failed
kono
parents:
diff changeset
185 ("Unexpected exception on Reset to Append_File (Sequential_IO)");
kono
parents:
diff changeset
186 raise Incomplete;
kono
parents:
diff changeset
187 end;
kono
parents:
diff changeset
188
kono
parents:
diff changeset
189 if Data_IO.Is_Open (Employee_Data_File) then -- File remains open
kono
parents:
diff changeset
190 -- following Reset to
kono
parents:
diff changeset
191 -- Append_File mode?
kono
parents:
diff changeset
192
kono
parents:
diff changeset
193 if Data_IO."=" (Data_IO.Mode (Employee_Data_File),
kono
parents:
diff changeset
194 TC_Mode_Selection (3)) then -- Compare to
kono
parents:
diff changeset
195 -- Append_File mode.
kono
parents:
diff changeset
196 Data_IO.Write (File => Employee_Data_File, -- Write additional
kono
parents:
diff changeset
197 Item => Employee_2); -- data to file.
kono
parents:
diff changeset
198 else
kono
parents:
diff changeset
199 Report.Failed ("File mode not changed by Reset");
kono
parents:
diff changeset
200 end if;
kono
parents:
diff changeset
201
kono
parents:
diff changeset
202 else
kono
parents:
diff changeset
203 Report.Failed
kono
parents:
diff changeset
204 ("File status not Open following Reset to Append mode");
kono
parents:
diff changeset
205 end if;
kono
parents:
diff changeset
206
kono
parents:
diff changeset
207 Data_IO.Close (Employee_Data_File);
kono
parents:
diff changeset
208
kono
parents:
diff changeset
209
kono
parents:
diff changeset
210 Test_Verification_Block:
kono
parents:
diff changeset
211 begin
kono
parents:
diff changeset
212
kono
parents:
diff changeset
213 Data_IO.Open (File => Employee_Data_File, -- Reopen file, using
kono
parents:
diff changeset
214 Mode => Data_IO.In_File, -- previous result of
kono
parents:
diff changeset
215 Name => Employee_Filename); -- function Name.
kono
parents:
diff changeset
216
kono
parents:
diff changeset
217 TC_Employee_Data := Blank_Data; -- Clear record field.
kono
parents:
diff changeset
218 Data_IO.Read (Employee_Data_File, -- Read first record,
kono
parents:
diff changeset
219 TC_Employee_Data); -- check ordering of
kono
parents:
diff changeset
220 -- records.
kono
parents:
diff changeset
221
kono
parents:
diff changeset
222 if not ((TC_Employee_Data (1 .. 3) = "123") and then
kono
parents:
diff changeset
223 (TC_Employee_Data (4 .. 11) = "-45-6789")) then
kono
parents:
diff changeset
224 Report.Failed ("Data read error - first record");
kono
parents:
diff changeset
225 end if;
kono
parents:
diff changeset
226
kono
parents:
diff changeset
227 TC_Employee_Data := Blank_Data; -- Clear record field.
kono
parents:
diff changeset
228 Data_IO.Read (Employee_Data_File, -- Read second record,
kono
parents:
diff changeset
229 TC_Employee_Data); -- check for ordering of
kono
parents:
diff changeset
230 -- records.
kono
parents:
diff changeset
231
kono
parents:
diff changeset
232 if ((TC_Employee_Data (1 .. 6) /= "987-65") or else
kono
parents:
diff changeset
233 not (TC_Employee_Data (3 .. 11) = "7-65-4321")) then
kono
parents:
diff changeset
234 Report.Failed ("Data read error - second record");
kono
parents:
diff changeset
235 end if;
kono
parents:
diff changeset
236
kono
parents:
diff changeset
237 -- Check that only two items were written to the file.
kono
parents:
diff changeset
238 if not Data_IO.End_Of_File(Employee_Data_File) then
kono
parents:
diff changeset
239 Report.Failed("Incorrect number of records in file");
kono
parents:
diff changeset
240 end if;
kono
parents:
diff changeset
241
kono
parents:
diff changeset
242 exception
kono
parents:
diff changeset
243
kono
parents:
diff changeset
244 when Data_IO.End_Error => -- If two items not in
kono
parents:
diff changeset
245 -- file (data overwritten),
kono
parents:
diff changeset
246 -- then fail.
kono
parents:
diff changeset
247 Report.Failed ("Incorrect number of record elements in file");
kono
parents:
diff changeset
248
kono
parents:
diff changeset
249 when others =>
kono
parents:
diff changeset
250 Report.Failed ("Error raised during data verification");
kono
parents:
diff changeset
251
kono
parents:
diff changeset
252 end Test_Verification_Block;
kono
parents:
diff changeset
253
kono
parents:
diff changeset
254 exception
kono
parents:
diff changeset
255
kono
parents:
diff changeset
256 when others =>
kono
parents:
diff changeset
257 Report.Failed("Exception raised during Sequential_IO processing");
kono
parents:
diff changeset
258
kono
parents:
diff changeset
259 end Operational_Test_Block;
kono
parents:
diff changeset
260
kono
parents:
diff changeset
261 Final_Block:
kono
parents:
diff changeset
262 begin
kono
parents:
diff changeset
263 -- Check that file is open prior to deleting it.
kono
parents:
diff changeset
264 if Data_IO.Is_Open(Employee_Data_File) then
kono
parents:
diff changeset
265 Data_IO.Delete (Employee_Data_File);
kono
parents:
diff changeset
266 else
kono
parents:
diff changeset
267 Data_IO.Open(Employee_Data_File,
kono
parents:
diff changeset
268 Data_IO.In_File,
kono
parents:
diff changeset
269 Employee_Filename);
kono
parents:
diff changeset
270 Data_IO.Delete (Employee_Data_File);
kono
parents:
diff changeset
271 end if;
kono
parents:
diff changeset
272 exception
kono
parents:
diff changeset
273 when others =>
kono
parents:
diff changeset
274 Report.Failed ("Sequential_IO Delete not properly supported");
kono
parents:
diff changeset
275 end Final_Block;
kono
parents:
diff changeset
276
kono
parents:
diff changeset
277 Report.Result;
kono
parents:
diff changeset
278
kono
parents:
diff changeset
279 exception
kono
parents:
diff changeset
280 when Incomplete =>
kono
parents:
diff changeset
281 Report.Result;
kono
parents:
diff changeset
282 when others =>
kono
parents:
diff changeset
283 Report.Failed ("Unexpected exception");
kono
parents:
diff changeset
284 Report.Result;
kono
parents:
diff changeset
285 end CXA8002;