3 -- Grant of Unlimited Rights
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
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.
27 -- Check that Append_File mode has not been added to package Direct_IO.
30 -- This test uses a procedure to change the mode of an existing Direct_IO
31 -- file. The file descriptor is passed as a parameter, along with a
32 -- numeric indicator for the new mode. Based on the numeric parameter,
33 -- a Direct_IO.Reset is performed using a File_Mode'Value transformation
34 -- of a string constant into a File_Mode value. An attempt to reset a
35 -- Direct_IO file to mode Append_File should cause an Constraint_Error
36 -- to be raised, as Append_File mode has not been added to Direct_IO in
39 -- APPLICABILITY CRITERIA:
40 -- This test is applicable to all implementations supporting Direct_IO
45 -- 06 Dec 94 SAIC ACVC 2.0
46 -- 19 Feb 97 PWB.CTA Allowed for non-support of Reset for certain
54 Incomplete
: exception;
57 Report
.Test
("CXA8003", "Check that Append_File mode has not " &
58 "been added to package Direct_IO");
60 Test_for_Direct_IO_Support
:
63 subtype String_Data_Type
is String (1 .. 20);
64 type Numeric_Data_Type
is range 1 .. 512;
65 type Composite_Data_Type
is array (1 .. 3) of String_Data_Type
;
67 type File_Data_Type
is record
68 Data_Field_1
: String_Data_Type
;
69 Data_Field_2
: Numeric_Data_Type
;
70 Data_Field_3
: Composite_Data_Type
;
73 package Dir_IO
is new Direct_IO
(File_Data_Type
);
75 Data_File
: Dir_IO
.File_Type
;
76 Dir_Filename
: constant String := Report
.Legal_File_Name
;
80 -- An application creates a text file with mode Out_File.
81 -- Use_Error will be raised if Direct_IO operations or external
82 -- files are not supported.
84 Dir_IO
.Create
(Data_File
,
91 TC_Append_Test_Executed
: Boolean := False;
93 type Mode_Selection_Type
is ( A
, I
, IO
, O
);
96 procedure Change_Mode
(File
: in out Dir_IO
.File_Type
;
97 To
: in Mode_Selection_Type
) is
101 TC_Append_Test_Executed
:= True;
103 (File
, Dir_IO
.File_Mode
'Value("Append_File"));
107 (File
, Dir_IO
.File_Mode
'Value("In_File"));
109 when Dir_IO
.Use_Error
=>
110 Report
.Not_Applicable
111 ("Reset to In_File not supported: Direct_IO");
117 (File
, Dir_IO
.File_Mode
'Value("Inout_File"));
119 when Dir_IO
.Use_Error
=>
120 Report
.Not_Applicable
121 ("Reset to InOut_File not supported: Direct_IO");
127 (File
, Dir_IO
.File_Mode
'Value("Out_File"));
129 when Dir_IO
.Use_Error
=>
130 Report
.Not_Applicable
131 ("Reset to Out_File not supported: Direct_IO");
140 -- At some point in the processing, the application may call a
141 -- procedure to change the mode of the file (perhaps for
142 -- additional data entry, data verification, etc.). It is at
143 -- this point that a use of Append_File mode for a Direct_IO
144 -- file would cause an exception.
146 for I
in reverse Mode_Selection_Type
loop
147 Change_Mode
(Data_File
, I
);
149 ("Mode changed to " &
150 Dir_IO
.File_Mode
'Image (Dir_IO
.Mode
(Data_File
)));
153 Report
.Failed
("No error raised on change to Append_File mode");
157 -- A handler has been provided in the application, which
158 -- handles the constraint error, allowing processing to
161 when Constraint_Error
=>
163 if TC_Append_Test_Executed
then
164 Report
.Comment
("Constraint_Error correctly raised on " &
165 "attempted Append_File mode selection " &
166 "for a Direct_IO file");
168 Report
.Failed
("Append test was not executed");
171 when Incomplete
=> raise;
173 when others => Report
.Failed
("Unexpected exception raised");
175 end Change_File_Mode
;
179 if Dir_IO
.Is_Open
(Data_File
) then
180 Dir_IO
.Delete
(Data_File
);
182 Dir_IO
.Open
(Data_File
, Dir_IO
.In_File
, Dir_Filename
);
183 Dir_IO
.Delete
(Data_File
);
187 Report
.Failed
("Delete not properly supported: Direct_IO");
192 -- Since Use_Error or Name_Error can be raised if, for the
193 -- specified mode, the environment does not support Direct_IO
194 -- operations, the following handlers are included:
196 when Dir_IO
.Name_Error
=>
197 Report
.Not_Applicable
("Name_Error raised on Direct IO Create");
199 when Dir_IO
.Use_Error
=>
200 Report
.Not_Applicable
("Use_Error raised on Direct IO Create");
204 ("Unexpected exception raised on Direct IO Create");
206 end Test_for_Direct_IO_Support
;