-- CXA8003.A
|
-- CXA8003.A
|
--
|
--
|
-- Grant of Unlimited Rights
|
-- Grant of Unlimited Rights
|
--
|
--
|
-- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
|
-- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
|
-- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
|
-- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
|
-- unlimited rights in the software and documentation contained herein.
|
-- unlimited rights in the software and documentation contained herein.
|
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
|
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
|
-- this public release, the Government intends to confer upon all
|
-- this public release, the Government intends to confer upon all
|
-- recipients unlimited rights equal to those held by the Government.
|
-- recipients unlimited rights equal to those held by the Government.
|
-- These rights include rights to use, duplicate, release or disclose the
|
-- These rights include rights to use, duplicate, release or disclose the
|
-- released technical data and computer software in whole or in part, in
|
-- released technical data and computer software in whole or in part, in
|
-- any manner and for any purpose whatsoever, and to have or permit others
|
-- any manner and for any purpose whatsoever, and to have or permit others
|
-- to do so.
|
-- to do so.
|
--
|
--
|
-- DISCLAIMER
|
-- DISCLAIMER
|
--
|
--
|
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
|
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
|
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
|
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
|
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
|
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
|
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
|
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
|
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
|
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
|
-- PARTICULAR PURPOSE OF SAID MATERIAL.
|
-- PARTICULAR PURPOSE OF SAID MATERIAL.
|
--*
|
--*
|
--
|
--
|
-- OBJECTIVE:
|
-- OBJECTIVE:
|
-- Check that Append_File mode has not been added to package Direct_IO.
|
-- Check that Append_File mode has not been added to package Direct_IO.
|
--
|
--
|
-- TEST DESCRIPTION:
|
-- TEST DESCRIPTION:
|
-- This test uses a procedure to change the mode of an existing Direct_IO
|
-- This test uses a procedure to change the mode of an existing Direct_IO
|
-- file. The file descriptor is passed as a parameter, along with a
|
-- file. The file descriptor is passed as a parameter, along with a
|
-- numeric indicator for the new mode. Based on the numeric parameter,
|
-- numeric indicator for the new mode. Based on the numeric parameter,
|
-- a Direct_IO.Reset is performed using a File_Mode'Value transformation
|
-- a Direct_IO.Reset is performed using a File_Mode'Value transformation
|
-- of a string constant into a File_Mode value. An attempt to reset a
|
-- of a string constant into a File_Mode value. An attempt to reset a
|
-- Direct_IO file to mode Append_File should cause an Constraint_Error
|
-- Direct_IO file to mode Append_File should cause an Constraint_Error
|
-- to be raised, as Append_File mode has not been added to Direct_IO in
|
-- to be raised, as Append_File mode has not been added to Direct_IO in
|
-- Ada 9X.
|
-- Ada 9X.
|
--
|
--
|
-- APPLICABILITY CRITERIA:
|
-- APPLICABILITY CRITERIA:
|
-- This test is applicable to all implementations supporting Direct_IO
|
-- This test is applicable to all implementations supporting Direct_IO
|
-- files.
|
-- files.
|
--
|
--
|
--
|
--
|
-- CHANGE HISTORY:
|
-- CHANGE HISTORY:
|
-- 06 Dec 94 SAIC ACVC 2.0
|
-- 06 Dec 94 SAIC ACVC 2.0
|
-- 19 Feb 97 PWB.CTA Allowed for non-support of Reset for certain
|
-- 19 Feb 97 PWB.CTA Allowed for non-support of Reset for certain
|
-- modes.
|
-- modes.
|
--!
|
--!
|
|
|
with Direct_IO;
|
with Direct_IO;
|
with Report;
|
with Report;
|
|
|
procedure CXA8003 is
|
procedure CXA8003 is
|
Incomplete : exception;
|
Incomplete : exception;
|
begin
|
begin
|
|
|
Report.Test ("CXA8003", "Check that Append_File mode has not " &
|
Report.Test ("CXA8003", "Check that Append_File mode has not " &
|
"been added to package Direct_IO");
|
"been added to package Direct_IO");
|
|
|
Test_for_Direct_IO_Support:
|
Test_for_Direct_IO_Support:
|
declare
|
declare
|
|
|
subtype String_Data_Type is String (1 .. 20);
|
subtype String_Data_Type is String (1 .. 20);
|
type Numeric_Data_Type is range 1 .. 512;
|
type Numeric_Data_Type is range 1 .. 512;
|
type Composite_Data_Type is array (1 .. 3) of String_Data_Type;
|
type Composite_Data_Type is array (1 .. 3) of String_Data_Type;
|
|
|
type File_Data_Type is record
|
type File_Data_Type is record
|
Data_Field_1 : String_Data_Type;
|
Data_Field_1 : String_Data_Type;
|
Data_Field_2 : Numeric_Data_Type;
|
Data_Field_2 : Numeric_Data_Type;
|
Data_Field_3 : Composite_Data_Type;
|
Data_Field_3 : Composite_Data_Type;
|
end record;
|
end record;
|
|
|
package Dir_IO is new Direct_IO (File_Data_Type);
|
package Dir_IO is new Direct_IO (File_Data_Type);
|
|
|
Data_File : Dir_IO.File_Type;
|
Data_File : Dir_IO.File_Type;
|
Dir_Filename : constant String := Report.Legal_File_Name;
|
Dir_Filename : constant String := Report.Legal_File_Name;
|
|
|
begin
|
begin
|
|
|
-- An application creates a text file with mode Out_File.
|
-- An application creates a text file with mode Out_File.
|
-- Use_Error will be raised if Direct_IO operations or external
|
-- Use_Error will be raised if Direct_IO operations or external
|
-- files are not supported.
|
-- files are not supported.
|
|
|
Dir_IO.Create (Data_File,
|
Dir_IO.Create (Data_File,
|
Dir_IO.Out_File,
|
Dir_IO.Out_File,
|
Dir_Filename);
|
Dir_Filename);
|
|
|
Change_File_Mode:
|
Change_File_Mode:
|
declare
|
declare
|
|
|
TC_Append_Test_Executed : Boolean := False;
|
TC_Append_Test_Executed : Boolean := False;
|
|
|
type Mode_Selection_Type is ( A, I, IO, O );
|
type Mode_Selection_Type is ( A, I, IO, O );
|
|
|
|
|
procedure Change_Mode (File : in out Dir_IO.File_Type;
|
procedure Change_Mode (File : in out Dir_IO.File_Type;
|
To : in Mode_Selection_Type) is
|
To : in Mode_Selection_Type) is
|
begin
|
begin
|
case To is
|
case To is
|
when A =>
|
when A =>
|
TC_Append_Test_Executed := True;
|
TC_Append_Test_Executed := True;
|
Dir_IO.Reset
|
Dir_IO.Reset
|
(File, Dir_IO.File_Mode'Value("Append_File"));
|
(File, Dir_IO.File_Mode'Value("Append_File"));
|
when I =>
|
when I =>
|
begin
|
begin
|
Dir_IO.Reset
|
Dir_IO.Reset
|
(File, Dir_IO.File_Mode'Value("In_File"));
|
(File, Dir_IO.File_Mode'Value("In_File"));
|
exception
|
exception
|
when Dir_IO.Use_Error =>
|
when Dir_IO.Use_Error =>
|
Report.Not_Applicable
|
Report.Not_Applicable
|
("Reset to In_File not supported: Direct_IO");
|
("Reset to In_File not supported: Direct_IO");
|
raise Incomplete;
|
raise Incomplete;
|
end;
|
end;
|
when IO =>
|
when IO =>
|
begin
|
begin
|
Dir_IO.Reset
|
Dir_IO.Reset
|
(File, Dir_IO.File_Mode'Value("Inout_File"));
|
(File, Dir_IO.File_Mode'Value("Inout_File"));
|
exception
|
exception
|
when Dir_IO.Use_Error =>
|
when Dir_IO.Use_Error =>
|
Report.Not_Applicable
|
Report.Not_Applicable
|
("Reset to InOut_File not supported: Direct_IO");
|
("Reset to InOut_File not supported: Direct_IO");
|
raise Incomplete;
|
raise Incomplete;
|
end;
|
end;
|
when O =>
|
when O =>
|
begin
|
begin
|
Dir_IO.Reset
|
Dir_IO.Reset
|
(File, Dir_IO.File_Mode'Value("Out_File"));
|
(File, Dir_IO.File_Mode'Value("Out_File"));
|
exception
|
exception
|
when Dir_IO.Use_Error =>
|
when Dir_IO.Use_Error =>
|
Report.Not_Applicable
|
Report.Not_Applicable
|
("Reset to Out_File not supported: Direct_IO");
|
("Reset to Out_File not supported: Direct_IO");
|
raise Incomplete;
|
raise Incomplete;
|
end;
|
end;
|
end case;
|
end case;
|
end Change_Mode;
|
end Change_Mode;
|
|
|
|
|
begin
|
begin
|
|
|
-- At some point in the processing, the application may call a
|
-- At some point in the processing, the application may call a
|
-- procedure to change the mode of the file (perhaps for
|
-- procedure to change the mode of the file (perhaps for
|
-- additional data entry, data verification, etc.). It is at
|
-- additional data entry, data verification, etc.). It is at
|
-- this point that a use of Append_File mode for a Direct_IO
|
-- this point that a use of Append_File mode for a Direct_IO
|
-- file would cause an exception.
|
-- file would cause an exception.
|
|
|
for I in reverse Mode_Selection_Type loop
|
for I in reverse Mode_Selection_Type loop
|
Change_Mode (Data_File, I);
|
Change_Mode (Data_File, I);
|
Report.Comment
|
Report.Comment
|
("Mode changed to " &
|
("Mode changed to " &
|
Dir_IO.File_Mode'Image (Dir_IO.Mode (Data_File)));
|
Dir_IO.File_Mode'Image (Dir_IO.Mode (Data_File)));
|
end loop;
|
end loop;
|
|
|
Report.Failed("No error raised on change to Append_File mode");
|
Report.Failed("No error raised on change to Append_File mode");
|
|
|
exception
|
exception
|
|
|
-- A handler has been provided in the application, which
|
-- A handler has been provided in the application, which
|
-- handles the constraint error, allowing processing to
|
-- handles the constraint error, allowing processing to
|
-- continue.
|
-- continue.
|
|
|
when Constraint_Error =>
|
when Constraint_Error =>
|
|
|
if TC_Append_Test_Executed then
|
if TC_Append_Test_Executed then
|
Report.Comment ("Constraint_Error correctly raised on " &
|
Report.Comment ("Constraint_Error correctly raised on " &
|
"attempted Append_File mode selection " &
|
"attempted Append_File mode selection " &
|
"for a Direct_IO file");
|
"for a Direct_IO file");
|
else
|
else
|
Report.Failed ("Append test was not executed");
|
Report.Failed ("Append test was not executed");
|
end if;
|
end if;
|
|
|
when Incomplete => raise;
|
when Incomplete => raise;
|
|
|
when others => Report.Failed ("Unexpected exception raised");
|
when others => Report.Failed ("Unexpected exception raised");
|
|
|
end Change_File_Mode;
|
end Change_File_Mode;
|
|
|
Final_Block:
|
Final_Block:
|
begin
|
begin
|
if Dir_IO.Is_Open (Data_File) then
|
if Dir_IO.Is_Open (Data_File) then
|
Dir_IO.Delete (Data_File);
|
Dir_IO.Delete (Data_File);
|
else
|
else
|
Dir_IO.Open (Data_File, Dir_IO.In_File, Dir_Filename);
|
Dir_IO.Open (Data_File, Dir_IO.In_File, Dir_Filename);
|
Dir_IO.Delete (Data_File);
|
Dir_IO.Delete (Data_File);
|
end if;
|
end if;
|
exception
|
exception
|
when others =>
|
when others =>
|
Report.Failed ("Delete not properly supported: Direct_IO");
|
Report.Failed ("Delete not properly supported: Direct_IO");
|
end Final_Block;
|
end Final_Block;
|
|
|
exception
|
exception
|
|
|
-- Since Use_Error or Name_Error can be raised if, for the
|
-- Since Use_Error or Name_Error can be raised if, for the
|
-- specified mode, the environment does not support Direct_IO
|
-- specified mode, the environment does not support Direct_IO
|
-- operations, the following handlers are included:
|
-- operations, the following handlers are included:
|
|
|
when Dir_IO.Name_Error =>
|
when Dir_IO.Name_Error =>
|
Report.Not_Applicable("Name_Error raised on Direct IO Create");
|
Report.Not_Applicable("Name_Error raised on Direct IO Create");
|
|
|
when Dir_IO.Use_Error =>
|
when Dir_IO.Use_Error =>
|
Report.Not_Applicable("Use_Error raised on Direct IO Create");
|
Report.Not_Applicable("Use_Error raised on Direct IO Create");
|
|
|
when others =>
|
when others =>
|
Report.Failed
|
Report.Failed
|
("Unexpected exception raised on Direct IO Create");
|
("Unexpected exception raised on Direct IO Create");
|
|
|
end Test_for_Direct_IO_Support;
|
end Test_for_Direct_IO_Support;
|
|
|
Report.Result;
|
Report.Result;
|
|
|
exception
|
exception
|
when Incomplete =>
|
when Incomplete =>
|
Report.Result;
|
Report.Result;
|
|
|
end CXA8003;
|
end CXA8003;
|
|
|