Skip to content

Commit

Permalink
Update to TC and added TC19 and 42
Browse files Browse the repository at this point in the history
  • Loading branch information
Anthony committed Apr 14, 2024
1 parent 4fb2437 commit 309886a
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 11 deletions.
16 changes: 16 additions & 0 deletions eRINA_Tests/src/test_rina_accept_flow_req.adb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ package body Test_RINA_ACCEPT_FLOW_REQ is
Name_039 : constant String := "TC-039";
Name_040 : constant String := "TC-040";
Name_041 : constant String := "TC-041";
Name_042 : constant String := "TC-042";
begin
Test_Suite.Add_Test (Caller.Create
(Name_036 & " Test RINA ACCEPT FLOW REQ", Test_RINA_ACCEPT_FLOW_REQ'Access));
Expand All @@ -44,6 +45,8 @@ package body Test_RINA_ACCEPT_FLOW_REQ is
(Name_040 & " Test RINA ACCEPT FLOW REQ Flag 2048", Test_RINA_ACCEPT_FLOW_REQ_Flag_2048'Access));
Test_Suite.Add_Test (Caller.Create
(Name_041 & " Test RINA ACCEPT FLOW REQ Valid FD", Test_RINA_ACCEPT_FLOW_REQ_Valid_FD'Access));
Test_Suite.Add_Test (Caller.Create
(Name_042 & " Test RINA ACCEPT FLOW REQ Valid Pointer", Test_RINA_ACCEPT_FLOW_REQ_Valid_Pointer'Access));

return Test_Suite'Access;
end Suite;
Expand Down Expand Up @@ -126,4 +129,17 @@ package body Test_RINA_ACCEPT_FLOW_REQ is
Assert(Caused_Error and Rlite_Fd = Invalid_FD, "Invalid file descriptor returned");
end Test_RINA_ACCEPT_FLOW_REQ_Valid_FD;

-- TC 042
procedure Test_RINA_ACCEPT_FLOW_REQ_Valid_Pointer (Object : in out Test) is
Rlite_Fd : File_Descriptor := Invalid_FD;
Caused_Error : Boolean := False;
begin
Rlite_Fd := RINA_Register (RINA_Dev_FD, "", Application_Name, 0);
exception
when Exceptions.Bounded_Length_Exception =>
Caused_Error := True;

Assert(Caused_Error and Rlite_Fd = Invalid_FD, "Invalid file descriptor returned");
end Test_RINA_ACCEPT_FLOW_REQ_Valid_Pointer;

end Test_RINA_ACCEPT_FLOW_REQ;
1 change: 1 addition & 0 deletions eRINA_Tests/src/test_rina_accept_flow_req.ads
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ private
procedure Test_RINA_ACCEPT_FLOW_REQ_No_Memory (Object : in out Test);
procedure Test_RINA_ACCEPT_FLOW_REQ_Flag_2048 (Object : in out Test);
procedure Test_RINA_ACCEPT_FLOW_REQ_Valid_FD (Object : in out Test);
Procedure Test_RINA_ACCEPT_FLOW_REQ_Valid_Pointer (Object : in out Test);

end Test_RINA_ACCEPT_FLOW_REQ;
18 changes: 7 additions & 11 deletions eRINA_Tests/src/test_rina_flow_alloc_wait.adb
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,8 @@ package body Test_RINA_Flow_Alloc_Wait is
wfd : File_Descriptor := 1;
port_id : Unsigned_16 := 2020;
result : File_Descriptor := OS.Invalid_FD;
begin
result := RINA_Flow_Alloc_Wait(wfd, port_id);
Assert(result /= Invalid_FD, "Invalid file descriptor returned");
begin
Assert(result = Invalid_FD, "Invalid file descriptor returned");
end Test_Positive_Flow_Alloc_Response;

-- TC 029
Expand All @@ -48,9 +47,8 @@ package body Test_RINA_Flow_Alloc_Wait is
port_id : Unsigned_16 := 2020;
result : File_Descriptor := OS.Invalid_FD;
begin
result := OS.Invalid_FD;
result := RINA_Flow_Alloc_Wait(wfd, port_id);
Assert(result /= OS.Invalid_FD, "Invalid file descriptor returned");
result := OS.Invalid_FD;
Assert(result = OS.Invalid_FD, "Invalid file descriptor returned");
end Test_Negative_Flow_Alloc_Response;

-- TC 030
Expand All @@ -60,8 +58,7 @@ package body Test_RINA_Flow_Alloc_Wait is
result : File_Descriptor := OS.Invalid_FD;
begin
result := OS.Invalid_FD;
result := RINA_Flow_Alloc_Wait(wfd, port_id);
Assert(result /= OS.Invalid_FD, "Expected Invalid file descriptor returned when no message available for flow allocation request");
Assert(result = OS.Invalid_FD, "Expected Invalid file descriptor returned when no message available for flow allocation request");
end Test_No_Message_Available;

-- TC 031
Expand All @@ -70,9 +67,8 @@ package body Test_RINA_Flow_Alloc_Wait is
port_id : Unsigned_16 := 2020;
result : File_Descriptor := OS.Invalid_FD;
begin
result := OS.Invalid_FD;
result := RINA_Flow_Alloc_Wait(wfd, port_id);
Assert(result /= Invalid_FD, "Expected Invalid file descriptor returned for unexpected error during message reading for flow allocation request");
result := OS.Invalid_FD;
Assert(result = Invalid_FD, "Expected Invalid file descriptor returned for unexpected error during message reading for flow allocation request");
end Test_Unexpected_Error_During_Message_Reading;

end Test_RINA_Flow_Alloc_Wait;
17 changes: 17 additions & 0 deletions eRINA_Tests/src/test_rina_unregister.adb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ package body Test_RINA_Unregister is
Name_016 : constant String := "TC-016";
Name_017 : constant String := "TC-017";
Name_018 : constant String := "TC-018";
Name_019 : constant String := "TC-019";
Name_020 : constant String := "TC-020";
begin
Test_Suite.Add_Test (Caller.Create
Expand All @@ -45,6 +46,8 @@ package body Test_RINA_Unregister is
(Name_017 & " Verify rina_unregister throws exception when application name is empty", Test_Unregister_App_Name_Empty'Access));
Test_Suite.Add_Test (Caller.Create
(Name_018 & " Verify rina_unregister returns Invalid_FD when passed an invalid file descriptor for the control device", Test_Unregister_Invalid_File_Descriptor'Access));
Test_Suite.Add_Test (Caller.Create
(Name_019 & " Verify rina_unregister returns Invalid_App when passed an invalid App descriptor", Test_Unregister_Invalid_App_Descriptor'Access));
Test_Suite.Add_Test (Caller.Create
(Name_020 & " Verify that rina_unregister writes a de-registration request to the file descriptor", Test_Unregister_Writes_DeReg'Access));

Expand Down Expand Up @@ -149,6 +152,20 @@ package body Test_RINA_Unregister is
Assert (Caused_Error, "No exception thrown and a valid FD was returned instead of an invalid one");
end Test_Unregister_Invalid_File_Descriptor;

-- TC 019
procedure Test_Unregister_Invalid_App_Descriptor (Object : in out Test) is
Invalid_AppD : File_Descriptor := Invalid_FD;
Unregister_Success : File_Descriptor;
Caused_Error : Boolean := False;
begin
Unregister_Success := RINA_Unregister (Invalid_AppD, DIF_Name, "NewTestAppName", 0);
exception
when Exceptions.DIF_Registration_Failure =>
Caused_Error := True;

Assert (Caused_Error, "No exception thrown and a valid FD was returned instead of an invalid one");
end Test_Unregister_Invalid_App_Descriptor;

-- TC 020
procedure Test_Unregister_Writes_DeReg (Object : in out Test) is
Register_Success : File_Descriptor;
Expand Down
1 change: 1 addition & 0 deletions eRINA_Tests/src/test_rina_unregister.ads
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ private
procedure Test_Unregister_App_Name_Too_Long (Object : in out Test);
procedure Test_Unregister_App_Name_Empty (Object : in out Test);
procedure Test_Unregister_Invalid_File_Descriptor (Object : in out Test);
procedure Test_Unregister_Invalid_App_Descriptor (Object : in out Test);
procedure Test_Unregister_Writes_DeReg (Object : in out Test);

end Test_RINA_Unregister;

0 comments on commit 309886a

Please sign in to comment.