-- CXA8002.A
|
-- CXA8002.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 resetting a file using mode Append_File allows for the
|
-- Check that resetting a file using mode Append_File allows for the
|
-- writing of elements to the file starting after the last element in
|
-- writing of elements to the file starting after the last element in
|
-- the file.
|
-- the file.
|
-- Check that the result of function Name can be used on a subsequent
|
-- Check that the result of function Name can be used on a subsequent
|
-- reopen of the file.
|
-- reopen of the file.
|
-- Check that a mode change occurs on reset of a file to/from mode
|
-- Check that a mode change occurs on reset of a file to/from mode
|
-- Append_File.
|
-- Append_File.
|
--
|
--
|
-- TEST DESCRIPTION:
|
-- TEST DESCRIPTION:
|
-- This test simulates the read/write of data from/to an individual
|
-- This test simulates the read/write of data from/to an individual
|
-- sequential file. New data can be appended to the end of the existing
|
-- sequential file. New data can be appended to the end of the existing
|
-- file, and the same file can be reset to allow reading of data from
|
-- file, and the same file can be reset to allow reading of data from
|
-- the file. This process can occur multiple times.
|
-- the file. This process can occur multiple times.
|
-- When the mode of the file is changed with a Reset, the current mode
|
-- When the mode of the file is changed with a Reset, the current mode
|
-- value assigned to the file is checked using the result of function
|
-- value assigned to the file is checked using the result of function
|
-- Mode. This, in conjunction with the read/write operations, verifies
|
-- Mode. This, in conjunction with the read/write operations, verifies
|
-- that a mode change has taken place on Reset.
|
-- that a mode change has taken place on Reset.
|
--
|
--
|
-- An expected common usage of the scenarios found in this test would
|
-- An expected common usage of the scenarios found in this test would
|
-- be a case where a single data file is kept open continuously, being
|
-- be a case where a single data file is kept open continuously, being
|
-- reset for read/append of data. For systems that do not support a
|
-- reset for read/append of data. For systems that do not support a
|
-- direct form of I/O, this would allow for efficient use of a sequential
|
-- direct form of I/O, this would allow for efficient use of a sequential
|
-- I/O file.
|
-- I/O file.
|
--
|
--
|
-- APPLICABILITY CRITERIA:
|
-- APPLICABILITY CRITERIA:
|
-- Applicable to all systems capable of supporting IO operations on
|
-- Applicable to all systems capable of supporting IO operations on
|
-- external Sequential_IO files.
|
-- external Sequential_IO files.
|
--
|
--
|
--
|
--
|
-- CHANGE HISTORY:
|
-- CHANGE HISTORY:
|
-- 06 Dec 94 SAIC ACVC 2.0
|
-- 06 Dec 94 SAIC ACVC 2.0
|
-- 19 Feb 97 PWB.CTA Fixed handling for file non-support and Reset
|
-- 19 Feb 97 PWB.CTA Fixed handling for file non-support and Reset
|
-- non-support.
|
-- non-support.
|
--!
|
--!
|
|
|
with Sequential_IO;
|
with Sequential_IO;
|
with Report;
|
with Report;
|
|
|
procedure CXA8002 is
|
procedure CXA8002 is
|
subtype Employee_Data is String (1 .. 11);
|
subtype Employee_Data is String (1 .. 11);
|
package Data_IO is new Sequential_IO (Employee_Data);
|
package Data_IO is new Sequential_IO (Employee_Data);
|
|
|
Employee_Data_File : Data_IO.File_Type;
|
Employee_Data_File : Data_IO.File_Type;
|
Employee_Filename : constant String :=
|
Employee_Filename : constant String :=
|
Report.Legal_File_Name (Nam => "CXA8002");
|
Report.Legal_File_Name (Nam => "CXA8002");
|
|
|
Incomplete : exception;
|
Incomplete : exception;
|
|
|
begin
|
begin
|
|
|
Report.Test ("CXA8002", "Check that resetting a file using mode " &
|
Report.Test ("CXA8002", "Check that resetting a file using mode " &
|
"Append_File allows for the writing of " &
|
"Append_File allows for the writing of " &
|
"elements to the file starting after the " &
|
"elements to the file starting after the " &
|
"last element in the file");
|
"last element in the file");
|
|
|
Test_for_Sequential_IO_Support:
|
Test_for_Sequential_IO_Support:
|
begin
|
begin
|
|
|
-- An implementation that does not support Sequential_IO in a particular
|
-- An implementation that does not support Sequential_IO in a particular
|
-- environment will raise Use_Error or Name_Error on calls to various
|
-- environment will raise Use_Error or Name_Error on calls to various
|
-- Sequential_IO operations. This block statement encloses a call to
|
-- Sequential_IO operations. This block statement encloses a call to
|
-- Create, which should produce an exception in a non-supportive
|
-- Create, which should produce an exception in a non-supportive
|
-- environment. These exceptions will be handled to produce a
|
-- environment. These exceptions will be handled to produce a
|
-- Not_Applicable result.
|
-- Not_Applicable result.
|
|
|
Data_IO.Create (File => Employee_Data_File, -- Create file in
|
Data_IO.Create (File => Employee_Data_File, -- Create file in
|
Mode => Data_IO.Append_File, -- mode Append_File.
|
Mode => Data_IO.Append_File, -- mode Append_File.
|
Name => Employee_Filename);
|
Name => Employee_Filename);
|
|
|
--
|
--
|
-- The following portion of code demonstrates the fact that a sequential
|
-- The following portion of code demonstrates the fact that a sequential
|
-- file can be created in Append_File mode, and that data can be written
|
-- file can be created in Append_File mode, and that data can be written
|
-- to the file.
|
-- to the file.
|
--
|
--
|
|
|
exception
|
exception
|
when Data_IO.Use_Error | Data_IO.Name_Error =>
|
when Data_IO.Use_Error | Data_IO.Name_Error =>
|
Report.Not_Applicable
|
Report.Not_Applicable
|
( "Sequential files not supported - Create as Append_File");
|
( "Sequential files not supported - Create as Append_File");
|
raise Incomplete;
|
raise Incomplete;
|
end Test_for_Sequential_IO_Support;
|
end Test_for_Sequential_IO_Support;
|
Operational_Test_Block:
|
Operational_Test_Block:
|
declare
|
declare
|
Blank_Data : constant Employee_Data := " ";
|
Blank_Data : constant Employee_Data := " ";
|
Employee_1 : constant Employee_Data := "123-45-6789";
|
Employee_1 : constant Employee_Data := "123-45-6789";
|
Employee_2 : Employee_Data := "987-65-4321";
|
Employee_2 : Employee_Data := "987-65-4321";
|
|
|
-- Note: Artificial numerical data chosen above to prevent any
|
-- Note: Artificial numerical data chosen above to prevent any
|
-- unintended similarity with persons alive or dead.
|
-- unintended similarity with persons alive or dead.
|
|
|
TC_Employee_Data : Employee_Data := Blank_Data;
|
TC_Employee_Data : Employee_Data := Blank_Data;
|
|
|
|
|
function TC_Mode_Selection (Selector : Integer)
|
function TC_Mode_Selection (Selector : Integer)
|
return Data_IO.File_Mode is
|
return Data_IO.File_Mode is
|
begin
|
begin
|
case Report.Ident_Int(Selector) is
|
case Report.Ident_Int(Selector) is
|
when 1 => return Data_IO.In_File;
|
when 1 => return Data_IO.In_File;
|
when 2 => return Data_IO.Out_File;
|
when 2 => return Data_IO.Out_File;
|
when others => return Data_IO.Append_File;
|
when others => return Data_IO.Append_File;
|
end case;
|
end case;
|
end TC_Mode_Selection;
|
end TC_Mode_Selection;
|
|
|
Employee_Filename : constant String := -- Use function Name to
|
Employee_Filename : constant String := -- Use function Name to
|
Data_IO.Name (File => Employee_Data_File); -- store filename in
|
Data_IO.Name (File => Employee_Data_File); -- store filename in
|
-- string variable.
|
-- string variable.
|
begin
|
begin
|
|
|
Data_IO.Write (File => Employee_Data_File, -- Write initial data
|
Data_IO.Write (File => Employee_Data_File, -- Write initial data
|
Item => Employee_1); -- entry to file.
|
Item => Employee_1); -- entry to file.
|
|
|
--
|
--
|
-- The following portion of code demonstrates that a sequential file
|
-- The following portion of code demonstrates that a sequential file
|
-- can be reset to various file modes, including Append_File mode,
|
-- can be reset to various file modes, including Append_File mode,
|
-- allowing data to be added to the end of the file.
|
-- allowing data to be added to the end of the file.
|
--
|
--
|
begin
|
begin
|
Data_IO.Reset (File => Employee_Data_File, -- Reset file with
|
Data_IO.Reset (File => Employee_Data_File, -- Reset file with
|
Mode => Data_IO.In_File); -- mode In_File.
|
Mode => Data_IO.In_File); -- mode In_File.
|
exception
|
exception
|
when Data_IO.Use_Error =>
|
when Data_IO.Use_Error =>
|
Report.Not_Applicable
|
Report.Not_Applicable
|
("Reset to In_File not supported for Sequential_IO");
|
("Reset to In_File not supported for Sequential_IO");
|
raise Incomplete;
|
raise Incomplete;
|
when others =>
|
when others =>
|
Report.Failed
|
Report.Failed
|
("Unexpected exception on Reset to In_File (Sequential_IO)");
|
("Unexpected exception on Reset to In_File (Sequential_IO)");
|
raise Incomplete;
|
raise Incomplete;
|
end;
|
end;
|
if Data_IO."="(Data_IO.Mode (Employee_Data_File),
|
if Data_IO."="(Data_IO.Mode (Employee_Data_File),
|
TC_Mode_Selection (1)) then -- Compare In_File mode
|
TC_Mode_Selection (1)) then -- Compare In_File mode
|
-- Reset successful,
|
-- Reset successful,
|
Data_IO.Read (File => Employee_Data_File, -- now verify file data.
|
Data_IO.Read (File => Employee_Data_File, -- now verify file data.
|
Item => TC_Employee_Data);
|
Item => TC_Employee_Data);
|
|
|
if ((TC_Employee_Data (1 .. 7) /= "123-45-") or
|
if ((TC_Employee_Data (1 .. 7) /= "123-45-") or
|
(TC_Employee_Data (5 .. 11) /= "45-6789")) then
|
(TC_Employee_Data (5 .. 11) /= "45-6789")) then
|
Report.Failed ("Data read error");
|
Report.Failed ("Data read error");
|
end if;
|
end if;
|
|
|
else
|
else
|
Report.Failed ("File mode not changed by Reset");
|
Report.Failed ("File mode not changed by Reset");
|
end if;
|
end if;
|
|
|
--
|
--
|
-- Simulate appending data to a file that has previously been written
|
-- Simulate appending data to a file that has previously been written
|
-- to and read from.
|
-- to and read from.
|
--
|
--
|
begin
|
begin
|
Data_IO.Reset (File => Employee_Data_File, -- Reset file with
|
Data_IO.Reset (File => Employee_Data_File, -- Reset file with
|
Mode => Data_IO.Append_File); -- mode Append_File.
|
Mode => Data_IO.Append_File); -- mode Append_File.
|
exception
|
exception
|
when Data_IO.Use_Error =>
|
when Data_IO.Use_Error =>
|
Report.Not_Applicable
|
Report.Not_Applicable
|
("Reset to Append_File not supported for Sequential_IO");
|
("Reset to Append_File not supported for Sequential_IO");
|
raise Incomplete;
|
raise Incomplete;
|
when others =>
|
when others =>
|
Report.Failed
|
Report.Failed
|
("Unexpected exception on Reset to Append_File (Sequential_IO)");
|
("Unexpected exception on Reset to Append_File (Sequential_IO)");
|
raise Incomplete;
|
raise Incomplete;
|
end;
|
end;
|
|
|
if Data_IO.Is_Open (Employee_Data_File) then -- File remains open
|
if Data_IO.Is_Open (Employee_Data_File) then -- File remains open
|
-- following Reset to
|
-- following Reset to
|
-- Append_File mode?
|
-- Append_File mode?
|
|
|
if Data_IO."=" (Data_IO.Mode (Employee_Data_File),
|
if Data_IO."=" (Data_IO.Mode (Employee_Data_File),
|
TC_Mode_Selection (3)) then -- Compare to
|
TC_Mode_Selection (3)) then -- Compare to
|
-- Append_File mode.
|
-- Append_File mode.
|
Data_IO.Write (File => Employee_Data_File, -- Write additional
|
Data_IO.Write (File => Employee_Data_File, -- Write additional
|
Item => Employee_2); -- data to file.
|
Item => Employee_2); -- data to file.
|
else
|
else
|
Report.Failed ("File mode not changed by Reset");
|
Report.Failed ("File mode not changed by Reset");
|
end if;
|
end if;
|
|
|
else
|
else
|
Report.Failed
|
Report.Failed
|
("File status not Open following Reset to Append mode");
|
("File status not Open following Reset to Append mode");
|
end if;
|
end if;
|
|
|
Data_IO.Close (Employee_Data_File);
|
Data_IO.Close (Employee_Data_File);
|
|
|
|
|
Test_Verification_Block:
|
Test_Verification_Block:
|
begin
|
begin
|
|
|
Data_IO.Open (File => Employee_Data_File, -- Reopen file, using
|
Data_IO.Open (File => Employee_Data_File, -- Reopen file, using
|
Mode => Data_IO.In_File, -- previous result of
|
Mode => Data_IO.In_File, -- previous result of
|
Name => Employee_Filename); -- function Name.
|
Name => Employee_Filename); -- function Name.
|
|
|
TC_Employee_Data := Blank_Data; -- Clear record field.
|
TC_Employee_Data := Blank_Data; -- Clear record field.
|
Data_IO.Read (Employee_Data_File, -- Read first record,
|
Data_IO.Read (Employee_Data_File, -- Read first record,
|
TC_Employee_Data); -- check ordering of
|
TC_Employee_Data); -- check ordering of
|
-- records.
|
-- records.
|
|
|
if not ((TC_Employee_Data (1 .. 3) = "123") and then
|
if not ((TC_Employee_Data (1 .. 3) = "123") and then
|
(TC_Employee_Data (4 .. 11) = "-45-6789")) then
|
(TC_Employee_Data (4 .. 11) = "-45-6789")) then
|
Report.Failed ("Data read error - first record");
|
Report.Failed ("Data read error - first record");
|
end if;
|
end if;
|
|
|
TC_Employee_Data := Blank_Data; -- Clear record field.
|
TC_Employee_Data := Blank_Data; -- Clear record field.
|
Data_IO.Read (Employee_Data_File, -- Read second record,
|
Data_IO.Read (Employee_Data_File, -- Read second record,
|
TC_Employee_Data); -- check for ordering of
|
TC_Employee_Data); -- check for ordering of
|
-- records.
|
-- records.
|
|
|
if ((TC_Employee_Data (1 .. 6) /= "987-65") or else
|
if ((TC_Employee_Data (1 .. 6) /= "987-65") or else
|
not (TC_Employee_Data (3 .. 11) = "7-65-4321")) then
|
not (TC_Employee_Data (3 .. 11) = "7-65-4321")) then
|
Report.Failed ("Data read error - second record");
|
Report.Failed ("Data read error - second record");
|
end if;
|
end if;
|
|
|
-- Check that only two items were written to the file.
|
-- Check that only two items were written to the file.
|
if not Data_IO.End_Of_File(Employee_Data_File) then
|
if not Data_IO.End_Of_File(Employee_Data_File) then
|
Report.Failed("Incorrect number of records in file");
|
Report.Failed("Incorrect number of records in file");
|
end if;
|
end if;
|
|
|
exception
|
exception
|
|
|
when Data_IO.End_Error => -- If two items not in
|
when Data_IO.End_Error => -- If two items not in
|
-- file (data overwritten),
|
-- file (data overwritten),
|
-- then fail.
|
-- then fail.
|
Report.Failed ("Incorrect number of record elements in file");
|
Report.Failed ("Incorrect number of record elements in file");
|
|
|
when others =>
|
when others =>
|
Report.Failed ("Error raised during data verification");
|
Report.Failed ("Error raised during data verification");
|
|
|
end Test_Verification_Block;
|
end Test_Verification_Block;
|
|
|
exception
|
exception
|
|
|
when others =>
|
when others =>
|
Report.Failed("Exception raised during Sequential_IO processing");
|
Report.Failed("Exception raised during Sequential_IO processing");
|
|
|
end Operational_Test_Block;
|
end Operational_Test_Block;
|
|
|
Final_Block:
|
Final_Block:
|
begin
|
begin
|
-- Check that file is open prior to deleting it.
|
-- Check that file is open prior to deleting it.
|
if Data_IO.Is_Open(Employee_Data_File) then
|
if Data_IO.Is_Open(Employee_Data_File) then
|
Data_IO.Delete (Employee_Data_File);
|
Data_IO.Delete (Employee_Data_File);
|
else
|
else
|
Data_IO.Open(Employee_Data_File,
|
Data_IO.Open(Employee_Data_File,
|
Data_IO.In_File,
|
Data_IO.In_File,
|
Employee_Filename);
|
Employee_Filename);
|
Data_IO.Delete (Employee_Data_File);
|
Data_IO.Delete (Employee_Data_File);
|
end if;
|
end if;
|
exception
|
exception
|
when others =>
|
when others =>
|
Report.Failed ("Sequential_IO Delete not properly supported");
|
Report.Failed ("Sequential_IO Delete not properly supported");
|
end Final_Block;
|
end Final_Block;
|
|
|
Report.Result;
|
Report.Result;
|
|
|
exception
|
exception
|
when Incomplete =>
|
when Incomplete =>
|
Report.Result;
|
Report.Result;
|
when others =>
|
when others =>
|
Report.Failed ("Unexpected exception");
|
Report.Failed ("Unexpected exception");
|
Report.Result;
|
Report.Result;
|
end CXA8002;
|
end CXA8002;
|
|
|