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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [testsuite/] [ada/] [acats/] [tests/] [cxa/] [cxaa001.a] - Blame information for rev 309

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 294 jeremybenn
-- CXAA001.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 the Line_Length and Page_Length maximums for a Text_IO
28
--      file of mode Append_File are initially zero (unbounded) after a
29
--      Create, Open, or Reset, and that these values can be modified using
30
--      the procedures Set_Line_Length and Set_Page_Length.
31
--      Check that setting the Line_Length and Page_Length attributes to zero
32
--      results in an unbounded Text_IO file.
33
--      Check that setting the line length when in Append_Mode doesn't
34
--      change the length of lines previously written to the Text_IO file.
35
--
36
-- TEST DESCRIPTION:
37
--      This test attempts to simulate a possible text processing environment.
38
--      String values, from a number of different string types, are written to
39
--      a Text_IO file.  Prior to the writing of each, the line length is set
40
--      to the particular length of the data being written.  In addition, the
41
--      default line and page lengths are checked, to determine whether they
42
--      are unbounded (length = 0) following a create, reset, or open of a
43
--      Text_IO file with mode Append_File.
44
--
45
-- APPLICABILITY CRITERIA:
46
--      This test is applicable only to implementations that support text
47
--      files.
48
--
49
--
50
-- CHANGE HISTORY:
51
--      06 Dec 94   SAIC    ACVC 2.0
52
--      27 Feb 97   PWB.CTA Allowed for non-support of some IO operations
53
--!
54
 
55
with Ada.Text_IO;
56
with Report;
57
 
58
procedure CXAA001 is
59
   use Ada;
60
   Data_File      : Text_IO.File_Type;
61
   Data_Filename  : constant String :=
62
                              Report.Legal_File_Name ( Nam => "CXAA001" );
63
   Incomplete : exception;
64
begin
65
 
66
   Report.Test ("CXAA001","Check that the Line_Length and Page_Length "      &
67
                          "maximums for a Text_IO file of mode Append_File " &
68
                          "are initially zero (unbounded) after a Create, "  &
69
                          "Open, or Reset, and that these values can be "    &
70
                          "modified using the procedures Set_Line_Length "   &
71
                          "and Set_Page_Length");
72
 
73
   Test_for_Text_IO_Support:
74
   begin
75
 
76
      -- An implementation that does not support Text_IO in a particular
77
      -- environment will raise Use_Error on calls to various
78
      -- Text_IO operations.  This block statement encloses a call to
79
      -- Create, which should raise an exception in a non-supportive
80
      -- environment.  This exception will be handled to produce a
81
      -- Not_Applicable result.
82
 
83
      Text_IO.Create (File => Data_File,
84
                      Mode => Text_IO.Append_File,
85
                      Name => Data_Filename);
86
 
87
   exception
88
 
89
       when Text_IO.Use_Error | Text_IO.Name_Error =>
90
          Report.Not_Applicable
91
             ( "Files not supported - Create as Append_File for Text_IO" );
92
          raise Incomplete;
93
 
94
   end Test_for_Text_IO_Support;
95
 
96
   Operational_Test_Block:
97
   declare
98
 
99
      subtype Confidential_Data_Type is string (1 .. 10);
100
      subtype Secret_Data_Type       is string (1 .. 20);
101
      subtype Top_Secret_Data_Type   is string (1 .. 30);
102
 
103
      Zero                   : constant Text_IO.Count :=  0;
104
      Confidential_Data_Size : constant Text_IO.Count := 10;
105
      Secret_Data_Size       : constant Text_IO.Count := 20;
106
      Top_Secret_Data_Size   : constant Text_IO.Count := 30;
107
 
108
      -- The following generic procedure is designed to simulate a text
109
      -- processing environment where line and page sizes are set and
110
      -- verified prior to the writing of data to a file.
111
 
112
      generic
113
         Data_Size : Text_IO.Count;
114
      procedure Write_Data_To_File (Data_Item : in String);
115
 
116
      procedure Write_Data_To_File (Data_Item : in String) is
117
         use Text_IO;  -- Used to provide visibility to the "/=" operator.
118
      begin
119
         if (Text_IO.Line_Length (Data_File) /= Zero) then -- Check default
120
            Report.Failed("Line not of unbounded length"); -- line length,
121
         elsif (Text_IO.Page_Length (Data_File) /= Zero) then -- default
122
            Report.Failed ("Page not of unbounded length"); -- page length.
123
         end if;
124
 
125
         Text_IO.Set_Line_Length (File => Data_File,    -- Set the line
126
                                  To   => Data_Size);   -- length.
127
         Text_IO.Set_Page_Length (File => Data_File,    -- Set the page
128
                                  To   => Data_Size);   -- length.
129
         -- Verify the lengths set.
130
         if (Integer(Text_IO.Line_Length (Data_File)) /=
131
             Report.Ident_Int(Integer(Data_Size))) then
132
            Report.Failed ("Line length not set to appropriate length");
133
         elsif (Integer(Text_IO.Page_Length (Data_File)) /=
134
                Report.Ident_Int(Integer(Data_Size))) then
135
            Report.Failed ("Page length not set to appropriate length");
136
         end if;
137
 
138
         Text_IO.Put_Line (File => Data_File,           -- Write data to
139
                           Item => Data_Item);          -- file.
140
 
141
      end Write_Data_To_File;
142
 
143
      -- Instantiation for the three data types/sizes.
144
 
145
      procedure Write_Confidential_Data is
146
        new Write_Data_To_File (Data_Size => Confidential_Data_Size);
147
 
148
      procedure Write_Secret_Data is
149
        new Write_Data_To_File (Data_Size => Secret_Data_Size);
150
 
151
      procedure Write_Top_Secret_Data is
152
        new Write_Data_To_File (Data_Size => Top_Secret_Data_Size);
153
 
154
      Confidential_Item : Confidential_Data_Type := "Confidenti";
155
      Secret_Item       : Secret_Data_Type       := "Secret Data Values  ";
156
      Top_Secret_Item   : Top_Secret_Data_Type   :=
157
        "Extremely Top Secret Data     ";
158
 
159
   begin
160
 
161
      -- The following call simulates processing occurring after the create
162
      -- of a Text_IO file with mode Append_File.
163
 
164
      Write_Confidential_Data (Confidential_Item);
165
 
166
      -- The following call simulates processing occurring after the reset
167
      -- of a Text_IO file with mode Append_File.
168
 
169
      Reset1:
170
      begin
171
         Text_IO.Reset (Data_File, Text_IO.Append_File); -- Reset to
172
                                                         -- Append_File mode.
173
      exception
174
         when Text_IO.Use_Error =>
175
            Report.Not_Applicable
176
               ( "Reset to Append_File not supported for Text_IO" );
177
            raise Incomplete;
178
      end Reset1;
179
 
180
      Write_Secret_Data (Data_Item    => Secret_Item);
181
 
182
      Text_IO.Close (Data_File);                      -- Close file.
183
 
184
      -- The following processing simulates processing occurring after the
185
      -- opening of an existing file with mode Append_File.
186
 
187
      Text_IO.Open (Data_File,                        -- Open file in
188
                    Text_IO.Append_File,              -- Append_File mode.
189
                    Data_Filename);
190
 
191
      Write_Top_Secret_Data (Top_Secret_Item);
192
 
193
      Test_Verification_Block:
194
      declare
195
         TC_String1,
196
         TC_String2,
197
         TC_String3  : String (1..80) := (others => ' ');
198
         TC_Length1,
199
         TC_Length2,
200
         TC_Length3  : Natural := 0;
201
      begin
202
 
203
         Reset2:
204
         begin
205
            Text_IO.Reset (Data_File, Text_IO.In_File); -- Reset for reading.
206
         exception
207
            when Text_IO.Use_Error =>
208
               Report.Not_Applicable
209
                  ( "Reset to In_File not supported for Text_IO" );
210
               raise Incomplete;
211
         end Reset2;
212
 
213
         Text_IO.Get_Line (Data_File, TC_String1, TC_Length1);
214
         Text_IO.Get_Line (Data_File, TC_String2, TC_Length2);
215
         Text_IO.Get_Line (Data_File, TC_String3, TC_Length3);
216
 
217
         -- Verify that the line lengths of each line were accurate.
218
         -- Note: Each data line was written to the file after the
219
         -- particular line length had been set (to the data length).
220
 
221
         if not ((TC_Length1 = Natural(Confidential_Data_Size)) and
222
                 (TC_Length2 = Natural(Secret_Data_Size))       and
223
                 (TC_Length3 = Natural(Top_Secret_Data_Size)))  then
224
            Report.Failed ("Inaccurate line lengths read from file");
225
         end if;
226
 
227
         -- Verify that the data read from the file are accurate.
228
 
229
         if (TC_String1(1..TC_Length1) /= Confidential_Item) or else
230
            (TC_String2(1..TC_Length2) /= Secret_Item)       or else
231
            (TC_String3(1..TC_Length3) /= Top_Secret_Item)   then
232
            Report.Failed ("Corrupted data items read from file");
233
         end if;
234
 
235
      exception
236
 
237
         when Incomplete =>
238
            raise;
239
 
240
         when others =>
241
               Report.Failed ("Error raised during data verification");
242
 
243
      end Test_Verification_Block;
244
 
245
   exception
246
 
247
         when Incomplete =>
248
            raise;
249
 
250
         when others =>
251
            Report.Failed ("Exception raised during Text_IO processing");
252
 
253
      end Operational_Test_Block;
254
 
255
      Deletion:
256
      begin
257
         -- Check that the file is open prior to deleting it.
258
         if Text_IO.Is_Open(Data_File) then
259
            Text_IO.Delete(Data_File);
260
         else
261
            Text_IO.Open(Data_File, Text_IO.In_File, Data_Filename);
262
            Text_IO.Delete(Data_File);
263
         end if;
264
   exception
265
      when others =>
266
         Report.Failed
267
            ( "Delete not properly implemented for Text_IO" );
268
   end Deletion;
269
 
270
   Report.Result;
271
 
272
exception
273
   when Incomplete =>
274
      Report.Result;
275
   when others     =>
276
      Report.Failed ( "Unexpected exception" );
277
      Report.Result;
278
 
279
end CXAA001;

powered by: WebSVN 2.1.0

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