OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [tags/] [gnu-src/] [gcc-4.5.1/] [gcc-4.5.1-or32-1.0rc2/] [gcc/] [testsuite/] [ada/] [acats/] [tests/] [cb/] [cb20004.a] - Diff between revs 294 and 384

Only display areas with differences | Details | Blame | View Log

Rev 294 Rev 384
-- CB20004.A
-- CB20004.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 exceptions propagate correctly from objects of
--      Check that exceptions propagate correctly from objects of
--      protected types. Check propagation from protected entry bodies.
--      protected types. Check propagation from protected entry bodies.
--
--
-- TEST DESCRIPTION:
-- TEST DESCRIPTION:
--      Declare a package with a protected type, including entries and private
--      Declare a package with a protected type, including entries and private
--      data, simulating a bounded buffer abstraction.  In the main procedure,
--      data, simulating a bounded buffer abstraction.  In the main procedure,
--      perform entry calls on an object of the protected type that raises
--      perform entry calls on an object of the protected type that raises
--      exceptions.
--      exceptions.
--      Ensure that the exceptions are:
--      Ensure that the exceptions are:
--         1) raised and handled locally in the entry body
--         1) raised and handled locally in the entry body
--         2) raised in the entry body and handled/reraised to be handled
--         2) raised in the entry body and handled/reraised to be handled
--            by the caller.
--            by the caller.
--         3) raised in the entry body and propagated directly to the calling
--         3) raised in the entry body and propagated directly to the calling
--            procedure.
--            procedure.
--
--
--
--
-- CHANGE HISTORY:
-- CHANGE HISTORY:
--      06 Dec 94   SAIC    ACVC 2.0
--      06 Dec 94   SAIC    ACVC 2.0
--
--
--!
--!
package CB20004_0 is               -- Package Buffer.
package CB20004_0 is               -- Package Buffer.
   Max_Buffer_Size       : constant := 2;
   Max_Buffer_Size       : constant := 2;
   Handled_In_Body,
   Handled_In_Body,
   Propagated_To_Caller,
   Propagated_To_Caller,
   Handled_In_Caller     : Boolean := False;
   Handled_In_Caller     : Boolean := False;
   Data_Over_5,
   Data_Over_5,
   Data_Degradation      : exception;
   Data_Degradation      : exception;
   type Data_Item is range 0 .. 100;
   type Data_Item is range 0 .. 100;
   type Item_Array_Type is array (1 .. Max_Buffer_Size) of Data_Item;
   type Item_Array_Type is array (1 .. Max_Buffer_Size) of Data_Item;
   protected type Bounded_Buffer is
   protected type Bounded_Buffer is
      entry Put (Item : in     Data_Item);
      entry Put (Item : in     Data_Item);
      entry Get (Item :    out Data_Item);
      entry Get (Item :    out Data_Item);
   private
   private
      Item_Array : Item_Array_Type;
      Item_Array : Item_Array_Type;
      I, J       : Integer range 1 .. Max_Buffer_Size := 1;
      I, J       : Integer range 1 .. Max_Buffer_Size := 1;
      Count      : Integer range 0 .. Max_Buffer_Size := 0;
      Count      : Integer range 0 .. Max_Buffer_Size := 0;
   end Bounded_Buffer;
   end Bounded_Buffer;
end CB20004_0;
end CB20004_0;
     --=================================================================--
     --=================================================================--
with Report;
with Report;
package body CB20004_0 is               -- Package Buffer.
package body CB20004_0 is               -- Package Buffer.
   protected body Bounded_Buffer is
   protected body Bounded_Buffer is
      entry Put (Item : in Data_Item) when Count < Max_Buffer_Size is
      entry Put (Item : in Data_Item) when Count < Max_Buffer_Size is
      begin
      begin
         if Item > 10 then
         if Item > 10 then
            Item_Array (I) := Item * 8;  -- Constraint_Error will be raised
            Item_Array (I) := Item * 8;  -- Constraint_Error will be raised
         elsif Item > 5 then             -- and handled in entry body.
         elsif Item > 5 then             -- and handled in entry body.
            raise Data_Over_5;           -- Exception  handled/reraised in
            raise Data_Over_5;           -- Exception  handled/reraised in
         else                            -- entry body, propagated to caller.
         else                            -- entry body, propagated to caller.
            Item_Array (I) := Item;      -- Store data item in buffer.
            Item_Array (I) := Item;      -- Store data item in buffer.
            I := (I mod Max_Buffer_Size) + 1;
            I := (I mod Max_Buffer_Size) + 1;
            Count := Count + 1;
            Count := Count + 1;
         end if;
         end if;
      exception
      exception
         when Constraint_Error =>
         when Constraint_Error =>
            Handled_In_Body := True;
            Handled_In_Body := True;
         when Data_Over_5 =>
         when Data_Over_5 =>
            Propagated_To_Caller := True;
            Propagated_To_Caller := True;
            raise;    -- Propagate the exception to the caller.
            raise;    -- Propagate the exception to the caller.
      end Put;
      end Put;
      entry Get (Item : out Data_Item) when Count > 0 is
      entry Get (Item : out Data_Item) when Count > 0 is
      begin
      begin
         Item := Item_Array(J);
         Item := Item_Array(J);
         J := (J mod Max_Buffer_Size) + 1;
         J := (J mod Max_Buffer_Size) + 1;
         Count := Count - 1;
         Count := Count - 1;
         if Count = 0 then
         if Count = 0 then
            raise Data_Degradation;   -- Exception to propagate to caller.
            raise Data_Degradation;   -- Exception to propagate to caller.
         end if;
         end if;
      end Get;
      end Get;
   end Bounded_Buffer;
   end Bounded_Buffer;
end CB20004_0;
end CB20004_0;
     --=================================================================--
     --=================================================================--
with CB20004_0;                   -- Package Buffer.
with CB20004_0;                   -- Package Buffer.
with Report;
with Report;
procedure CB20004 is
procedure CB20004 is
   package Buffer renames CB20004_0;
   package Buffer renames CB20004_0;
   Data        : Buffer.Data_Item := Buffer.Data_Item'First;
   Data        : Buffer.Data_Item := Buffer.Data_Item'First;
   Data_Buffer : Buffer.Bounded_Buffer;   -- an object of protected type.
   Data_Buffer : Buffer.Bounded_Buffer;   -- an object of protected type.
   Handled_In_Caller : Boolean := False;  -- same name as boolean declared
   Handled_In_Caller : Boolean := False;  -- same name as boolean declared
                                          -- in package Buffer.
                                          -- in package Buffer.
begin
begin
   Report.Test ("CB20004", "Check that exceptions propagate correctly " &
   Report.Test ("CB20004", "Check that exceptions propagate correctly " &
                           "from objects of protected types" );
                           "from objects of protected types" );
   Initial_Data_Block:
   Initial_Data_Block:
   begin                                    -- Data causes Constraint_Error.
   begin                                    -- Data causes Constraint_Error.
      Data_Buffer.Put (CB20004_0.Data_Item(Report.Ident_Int(51)));
      Data_Buffer.Put (CB20004_0.Data_Item(Report.Ident_Int(51)));
   exception
   exception
      when Constraint_Error =>
      when Constraint_Error =>
         Buffer.Handled_In_Body := False;     -- Improper exception handling
         Buffer.Handled_In_Body := False;     -- Improper exception handling
                                              -- in entry body.
                                              -- in entry body.
         Report.Failed ("Exception propagated to caller " &
         Report.Failed ("Exception propagated to caller " &
                        " from Initial_Data_Block");
                        " from Initial_Data_Block");
      when others =>
      when others =>
         Report.Failed ("Exception raised in processing and " &
         Report.Failed ("Exception raised in processing and " &
                        "propagated to caller from Initial_Data_Block");
                        "propagated to caller from Initial_Data_Block");
   end Initial_Data_Block;
   end Initial_Data_Block;
   Data_Entry_Block:
   Data_Entry_Block:
   begin
   begin
                                              -- Valid data. No exception.
                                              -- Valid data. No exception.
      Data_Buffer.Put (CB20004_0.Data_Item(Report.Ident_Int(3)));
      Data_Buffer.Put (CB20004_0.Data_Item(Report.Ident_Int(3)));
                                              -- Data will cause exception.
                                              -- Data will cause exception.
      Data_Buffer.Put (7);                    -- Call protected object entry,
      Data_Buffer.Put (7);                    -- Call protected object entry,
                                              -- exception to be handled/
                                              -- exception to be handled/
                                              -- reraised in entry body.
                                              -- reraised in entry body.
      Report.Failed ("Data_Over_5 Exception not raised in processing");
      Report.Failed ("Data_Over_5 Exception not raised in processing");
   exception
   exception
      when Buffer.Data_Over_5 =>
      when Buffer.Data_Over_5 =>
         if Buffer.Propagated_To_Caller then   -- Reraised in entry body?
         if Buffer.Propagated_To_Caller then   -- Reraised in entry body?
            Buffer.Handled_In_Caller := True;
            Buffer.Handled_In_Caller := True;
         else
         else
            Report.Failed ("Exception not reraised in entry body");
            Report.Failed ("Exception not reraised in entry body");
         end if;
         end if;
      when others =>
      when others =>
         Report.Failed ("Exception raised in processing and propagated " &
         Report.Failed ("Exception raised in processing and propagated " &
                        "to caller from Data_Entry_Block");
                        "to caller from Data_Entry_Block");
   end Data_Entry_Block;
   end Data_Entry_Block;
   Data_Retrieval_Block:
   Data_Retrieval_Block:
   begin
   begin
      Data_Buffer.Get (Data);  -- Retrieval of buffer data, buffer now empty.
      Data_Buffer.Get (Data);  -- Retrieval of buffer data, buffer now empty.
                               -- Exception will be raised in entry body, with
                               -- Exception will be raised in entry body, with
                               -- propagation to caller.
                               -- propagation to caller.
      Report.Failed ("Data_Degradation Exception not raised in processing");
      Report.Failed ("Data_Degradation Exception not raised in processing");
   exception
   exception
      when Buffer.Data_Degradation =>
      when Buffer.Data_Degradation =>
         Handled_In_Caller := True;   -- Local Boolean used here.
         Handled_In_Caller := True;   -- Local Boolean used here.
      when others =>
      when others =>
         Report.Failed ("Exception raised in processing and propagated " &
         Report.Failed ("Exception raised in processing and propagated " &
                        "to caller from Data_Retrieval_Block");
                        "to caller from Data_Retrieval_Block");
   end Data_Retrieval_Block;
   end Data_Retrieval_Block;
   if not (Buffer.Handled_In_Body      and    -- Validate proper exception
   if not (Buffer.Handled_In_Body      and    -- Validate proper exception
           Buffer.Propagated_To_Caller and    -- handling in entry bodies.
           Buffer.Propagated_To_Caller and    -- handling in entry bodies.
           Buffer.Handled_In_Caller    and
           Buffer.Handled_In_Caller    and
           Handled_In_Caller)
           Handled_In_Caller)
   then
   then
      Report.Failed ("Improper exception handling by entry bodies");
      Report.Failed ("Improper exception handling by entry bodies");
   end if;
   end if;
   Report.Result;
   Report.Result;
end CB20004;
end CB20004;
 
 

powered by: WebSVN 2.1.0

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