Skip to content

Commit

Permalink
Add unit test for unimplemented validation in parameter_store compo…
Browse files Browse the repository at this point in the history
…nent
  • Loading branch information
Jbsco committed Aug 14, 2024
1 parent 437700e commit cd5d23f
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ package body Component.Parameter_Store.Implementation is
when Validate =>
-- This component does not perform component-specific validation, so table validation is unsupported:
-- Throw event:
Self.Event_T_Send_If_Connected (Self.Events.Table_Validation_Not_Supported (Self.Sys_Time_T_Get));
Self.Event_T_Send_If_Connected (Self.Events.Table_Validation_Not_Supported (Self.Sys_Time_T_Get, Arg.Region));
-- Set the return status:
To_Return := (Region => Arg.Region, Status => Parameter_Error);
end case;
Expand Down
1 change: 1 addition & 0 deletions src/components/parameter_store/parameter_store.events.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ events:
param_type: Parameters_Memory_Region.T
- name: Table_Validation_Not_Supported
description: Produced a packet with the contents of the parameter store.
param_type: Memory_Region.T
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,7 @@ package body Component.Parameter_Store.Implementation.Tester is
end Memory_Region_Dropped;

-- Produced a packet with the contents of the parameter store.
overriding procedure Table_Validation_Not_Supported (Self : in out Instance) is
Arg : constant Natural := 0;
overriding procedure Table_Validation_Not_Supported (Self : in out Instance; Arg : in Memory_Region.T) is
begin
-- Push the argument onto the test history for looking at later:
Self.Table_Validation_Not_Supported_History.Push (Arg);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ package Component.Parameter_Store.Implementation.Tester is
package Invalid_Command_Received_History_Package is new Printable_History (Invalid_Command_Info.T, Invalid_Command_Info.Representation.Image);
package Command_Dropped_History_Package is new Printable_History (Command_Header.T, Command_Header.Representation.Image);
package Memory_Region_Dropped_History_Package is new Printable_History (Parameters_Memory_Region.T, Parameters_Memory_Region.Representation.Image);
package Table_Validation_Not_Supported_History_Package is new Printable_History (Natural, Natural'Image);
package Table_Validation_Not_Supported_History_Package is new Printable_History (Memory_Region.T, Memory_Region.Representation.Image);

-- Packet history packages:
package Stored_Parameters_History_Package is new Printable_History (Packet.T, Packet.Representation.Image);
Expand Down Expand Up @@ -130,7 +130,7 @@ package Component.Parameter_Store.Implementation.Tester is
-- A memory region was dropped due to a full queue.
overriding procedure Memory_Region_Dropped (Self : in out Instance; Arg : in Parameters_Memory_Region.T);
-- Produced a packet with the contents of the parameter store.
overriding procedure Table_Validation_Not_Supported (Self : in out Instance);
overriding procedure Table_Validation_Not_Supported (Self : in out Instance; Arg : in Memory_Region.T);

-----------------------------------------------
-- Packet handler primitives:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ tests:
description: This unit test tests the behavior when updating the parameter table with a memory region of invalid length.
- name: Test_Table_Upload_Crc_Error
description: This unit test tests the behavior when updating the parameter table with a memory region that contains an invalid CRC.
- name: Test_Table_Validate_Unimplemented
description: This unit test tests the behavior when unimplemented validation of the parameter table by memory region upload is requested.
- name: Test_Table_Fetch_Length_Error
description: This unit test tests the behavior when fetching the parameter table with a memory region of invalid length.
- name: Test_No_Dump_On_Change
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,30 @@ package body Parameter_Store_Tests.Implementation is

end Test_Table_Upload_Crc_Error;

-- This unit test tests the behavior when validation of the parameter table by
-- memory region upload fails.
overriding procedure Test_Table_Validate_Unimplemented (Self : in out Instance) is
use Parameter_Enums.Parameter_Table_Update_Status;
use Parameter_Enums.Parameter_Table_Operation_Type;
T : Component.Parameter_Store.Implementation.Tester.Instance_Access renames Self.Tester;
-- Create a memory region that holds the parameter table data.
Table : aliased Basic_Types.Byte_Array := [0 .. 99 => 17];
Region : constant Memory_Region.T := (Address => Table'Address, Length => Table'Length);
begin
-- Send the memory region to the component:
T.Parameters_Memory_Region_T_Send ((Region => Region, Operation => Validate));
Natural_Assert.Eq (T.Dispatch_All, 1);

-- Check events:
Natural_Assert.Eq (T.Event_T_Recv_Sync_History.Get_Count, 1);
Natural_Assert.Eq (T.Table_Validation_Not_Supported_History.Get_Count, 1);
Memory_Region_Assert.Eq (T.Table_Validation_Not_Supported_History.Get (1), Region);

-- Make sure the memory location was released with the proper status:
Natural_Assert.Eq (T.Parameters_Memory_Region_Release_T_Recv_Sync_History.Get_Count, 1);
Parameters_Memory_Region_Release_Assert.Eq (T.Parameters_Memory_Region_Release_T_Recv_Sync_History.Get (1), (Region, Parameter_Error));
end Test_Table_Validate_Unimplemented;

overriding procedure Test_Table_Fetch_Length_Error (Self : in out Instance) is
use Parameter_Enums.Parameter_Table_Update_Status;
use Parameter_Enums.Parameter_Table_Operation_Type;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ private
overriding procedure Test_Table_Upload_Length_Error (Self : in out Instance);
-- This unit test tests the behavior when updating the parameter table with a memory region that contains an invalid CRC.
overriding procedure Test_Table_Upload_Crc_Error (Self : in out Instance);
-- This unit test tests the behavior when validation of the parameter table by memory region upload fails.
overriding procedure Test_Table_Validate_Unimplemented (Self : in out Instance);
-- This unit test tests the behavior when fetching the parameter table with a memory region of invalid length.
overriding procedure Test_Table_Fetch_Length_Error (Self : in out Instance);
-- This unit test tests the no-dump-on-change configuration for the Init function and makes sure the component behaves as expected.
Expand Down

0 comments on commit cd5d23f

Please sign in to comment.