From 7f9d4d7aead98e79fc748737fbcc070e2c2d8d62 Mon Sep 17 00:00:00 2001 From: Keian Kaserman Date: Sat, 27 Jan 2024 18:22:46 -0500 Subject: [PATCH 1/6] Add test fixtures for TC_014 --- eRINA_Tests/src/test_rina_unregister.ads | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 eRINA_Tests/src/test_rina_unregister.ads diff --git a/eRINA_Tests/src/test_rina_unregister.ads b/eRINA_Tests/src/test_rina_unregister.ads new file mode 100644 index 0000000..ce4d5b7 --- /dev/null +++ b/eRINA_Tests/src/test_rina_unregister.ads @@ -0,0 +1,15 @@ +-- Temp disabling +pragma Style_Checks (Off); + +with AUnit.Test_Suites; +with AUnit.Test_Fixtures; + +package Test_RINA_Unregister is + function Suite return AUnit.Test_Suites.Access_Test_Suite; + +private + type Test is new AUnit.Test_Fixtures.Test_Fixture with null record; + + procedure Test_Unregister_DIF_Empty (Object : in out Test); + +end Test_RINA_Unregister; From 678551873c28ed6bd83bd5196f9bcafc4e9d5fa1 Mon Sep 17 00:00:00 2001 From: Keian Kaserman Date: Sat, 27 Jan 2024 18:23:47 -0500 Subject: [PATCH 2/6] Add test fixture TC015 --- eRINA_Tests/src/test_rina_unregister.ads | 1 + 1 file changed, 1 insertion(+) diff --git a/eRINA_Tests/src/test_rina_unregister.ads b/eRINA_Tests/src/test_rina_unregister.ads index ce4d5b7..9492188 100644 --- a/eRINA_Tests/src/test_rina_unregister.ads +++ b/eRINA_Tests/src/test_rina_unregister.ads @@ -11,5 +11,6 @@ private type Test is new AUnit.Test_Fixtures.Test_Fixture with null record; procedure Test_Unregister_DIF_Empty (Object : in out Test); + procedure Test_Unregister_DIF_Name_Not_Registered (Object : in out Test); end Test_RINA_Unregister; From 670d9ad9f25f7e6f4f18afb0049e138d372fc75e Mon Sep 17 00:00:00 2001 From: Keian Kaserman Date: Sat, 27 Jan 2024 18:25:09 -0500 Subject: [PATCH 3/6] Add Test Suite 3 to test case runner --- eRINA_Tests/src/erina_tests.adb | 1 + 1 file changed, 1 insertion(+) diff --git a/eRINA_Tests/src/erina_tests.adb b/eRINA_Tests/src/erina_tests.adb index cd5f174..a24a1f8 100644 --- a/eRINA_Tests/src/erina_tests.adb +++ b/eRINA_Tests/src/erina_tests.adb @@ -21,6 +21,7 @@ procedure eRINA_Tests is begin Result.Add_Test (Test_RINA_Open.Suite); Result.Add_Test (Test_RINA_Register.Suite); + Result.Add_Test (Test_RINA_Unregister.Suite); Result.Add_Test (Test_RINA_Flow_Alloc_Wait.Suite); Result.Add_Test (Test_RINA_Flow_Alloc.Suite); From 918b41a6af9e12626e745dcd3d00366417ff0ea2 Mon Sep 17 00:00:00 2001 From: Keian Kaserman Date: Sat, 27 Jan 2024 18:52:40 -0500 Subject: [PATCH 4/6] TC014 and TC0015 --- eRINA_Tests/src/test_rina_unregister.adb | 65 ++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 eRINA_Tests/src/test_rina_unregister.adb diff --git a/eRINA_Tests/src/test_rina_unregister.adb b/eRINA_Tests/src/test_rina_unregister.adb new file mode 100644 index 0000000..5c13af1 --- /dev/null +++ b/eRINA_Tests/src/test_rina_unregister.adb @@ -0,0 +1,65 @@ +-- Temp disabling +pragma Style_Checks (Off); + +with AUnit.Assertions; +with AUnit.Test_Caller; +with GNAT.OS_Lib; +with Bindings.Rlite.API; +with Exceptions; + +package body Test_RINA_Unregister is + use AUnit.Assertions; + use GNAT.OS_Lib; + use Bindings.Rlite.API; + + Application_Name : constant String := "TestApplicationName"; + DIF_Name : constant String := "test.DIF"; + RINA_Dev_FD : constant File_Descriptor := RINA_Open; + + package Caller is new AUnit.Test_Caller (Test); + + Test_Suite : aliased AUnit.Test_Suites.Test_Suite; + + function Suite return AUnit.Test_Suites.Access_Test_Suite is + Name_014 : constant String := "TC-014"; + Name_015 : constant String := "TC-015"; + begin + Test_Suite.Add_Test (Caller.Create + (Name_014 & " Verify rina_unregister throws exception when DIF name empty", Test_Unregister_DIF_Name_Empty'Access)); + Test_Suite.Add_Test (Caller.Create + (Name_015 & " Verify rina_unregister throws exception when DIF name isn't already registered", Test_Unregister_DIF_Name_Not_Registered'Access)); + + return Test_Suite'Access; + end Suite; + + --Test Case 014 + procedure Test_Unregister_DIF_Name_Empty (Object : in out Test) is + DIF_Name : constant String := ""; + App_Name : constant String := "Test App"; + Unregister_Success : File_Descriptor := Invalid_FD; + Caused_Error : Boolean := False; + begin + + Unregister_Success := RINA_Unregister (RINA_Dev_FD, DIF_Name, App_Name, 0); + exception + when Exceptions.Bounded_Length_Expcetion => + Caused_Error := True; + + Assert (Caused_Error and Unregister_Success = Invalid_FD, "DIF_Name is empty"); + end Test_Unregister_DIF_Name_Empty; + + procedure Test_Unregister_DIF_Name_Not_Registered (Object : in out Test) is + DIF_Name : constant String := "Unique_DIF_Name"; + App_Name : constant String := "Test App"; + Unregister_Success : File_Descriptor := Invalid_FD; + Caused_Error : Boolean := False; + begin + Unregister_Success := RINA_Unregister (RINA_Dev_FD, DIF_Name, App_Name, 0); + exception + when Exceptions.DIF_Registration_Failure => + Caused_Error := True; + + Assert (Caused_Error and Unregister_Success = Invalid_FD, "DIF_Name is not already registered"); + end Test_Unregister_DIF_Name_Not_Registered; + +end Test_RINA_Unregister; \ No newline at end of file From 09324bae239a1655a4b2b5a4211964420aea8a56 Mon Sep 17 00:00:00 2001 From: Keian Kaserman Date: Sat, 27 Jan 2024 18:53:02 -0500 Subject: [PATCH 5/6] Make TC014 name more descriptive --- eRINA_Tests/src/test_rina_unregister.ads | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eRINA_Tests/src/test_rina_unregister.ads b/eRINA_Tests/src/test_rina_unregister.ads index 9492188..dde01d1 100644 --- a/eRINA_Tests/src/test_rina_unregister.ads +++ b/eRINA_Tests/src/test_rina_unregister.ads @@ -10,7 +10,7 @@ package Test_RINA_Unregister is private type Test is new AUnit.Test_Fixtures.Test_Fixture with null record; - procedure Test_Unregister_DIF_Empty (Object : in out Test); + procedure Test_Unregister_DIF_Name_Empty (Object : in out Test); procedure Test_Unregister_DIF_Name_Not_Registered (Object : in out Test); end Test_RINA_Unregister; From bb5fa60146a266eaaec3360b78d182fc49305de2 Mon Sep 17 00:00:00 2001 From: Keian Kaserman Date: Sat, 27 Jan 2024 18:53:21 -0500 Subject: [PATCH 6/6] Make Unregister tests visible to runner --- eRINA_Tests/src/erina_tests.adb | 1 + 1 file changed, 1 insertion(+) diff --git a/eRINA_Tests/src/erina_tests.adb b/eRINA_Tests/src/erina_tests.adb index a24a1f8..cdd44bf 100644 --- a/eRINA_Tests/src/erina_tests.adb +++ b/eRINA_Tests/src/erina_tests.adb @@ -9,6 +9,7 @@ with AUnit.Test_Suites; -- Test suites with Test_RINA_Open; with Test_RINA_Register; +with Test_RINA_Unregister; with Test_RINA_Flow_Alloc_Wait; with Test_RINA_Flow_Alloc;