Skip to content

Commit

Permalink
Merge branch 'master' into CDAP_Protobuf
Browse files Browse the repository at this point in the history
  • Loading branch information
masonticehurst authored Feb 10, 2024
2 parents 534020f + b05ac13 commit 36c7808
Show file tree
Hide file tree
Showing 13 changed files with 178 additions and 31 deletions.
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,17 @@ eRINA aims to take the fundamental principles of RINA and implement them as a so
2. Ensure `modprobe rlite` and `modprobe rlite-normal` are run to load those kernel modules
3. Run `sudo rlite-uipcps` before running tests
4. Enter `eRINA_Tests` directory with `cd eRINA_Tests`
5. Run tests: `alr build` and `alr run`
5. Run tests: `alr build` and `alr run`

## Tests Implemented Progress

| Test Suite | Done |
| ---------- | ---- |
| TS-001 | :white_check_mark: |
| TS-002 | :x: |
| TS-003 | :construction: |
| TS-004 | :construction: |
| TS-005 | :x: |
| TS-006 | :white_check_mark: |
| TS-007 | :white_check_mark: |
| TS-008 | :x: |
2 changes: 1 addition & 1 deletion eRINA_STM32F7/alire.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ name = "erina_stm32f7"
version = "0.1.0-dev"

[[depends-on]]
ada_enet = "0.1.1-dev"
ada_enet = "0.1.0-dev"
stm32_gui = "0.1.0"
stm32f746disco = "0.1.0"
[[pins]]
Expand Down
22 changes: 8 additions & 14 deletions eRINA_STM32F7/src/rina/demo.adb
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,15 @@ procedure Demo is

procedure Header is
begin
Demos.Put (0, 0, "eRINA_Debug");
Demos.Put (0, 0, "eRINA Debug");
end Header;

-- Debug only, remove later
Demo_IPCP_Name : constant IPCP_Name.Bounded_String :=
IPCP_Name.To_Bounded_String ("Demo.IPCP");
procedure Initialize is new Demos.Initialize_Blank (Header);
begin
Initialize;

procedure DoStuff is
begin
-- I am an "application process"
-- I run concurrently with the rest of the system and communicate over IPC
-- Keep board from immediately terminating
loop
null;
end DoStuff;

Demo_IPCP : IPCP := (Name => Demo_IPCP_Name, Executable => DoStuff'Unrestricted_Access, IO_Buffer => <>);
begin
Header;
end Demo;
end loop;
end Demo;
84 changes: 84 additions & 0 deletions eRINA_STM32F7/src/rina/gui.adb
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
with Bitmapped_Drawing;
with HAL.Bitmap;
with STM32.Board;
with STM32.RNG.Interrupts;


package body GUI is
pragma Warnings (Off);

CONSOLE_STARTING_POINT : HAL.Bitmap.Point := (0, 100);
CURRENT_CONSOLE_POSITION : HAL.Bitmap.Point := (0, 100);
FONT_HEIGHT : Natural := BMP_Fonts.Char_Height(Font => Large_Font);


function Scale (Point : in HAL.Bitmap.Point) return HAL.Bitmap.Point;

function Scale (Point : in HAL.Bitmap.Point) return HAL.Bitmap.Point is
begin
if STM32.Board.LCD_Natural_Width > 480 then
return (Point.X * 800 / 480, Point.Y * 480 / 272);
else
return Point;
end if;
end Scale;

procedure Print (X : in Natural; Y : in Natural; Msg : in String) is
begin
Bitmapped_Drawing.Draw_String (Buffer => STM32.Board.Display.Hidden_Buffer (1).all,
Start => Scale ((X,Y)),
Msg => Msg,
Font => Large_Font,
Foreground => Foreground,
Background => Background);
end Print;

procedure Initialize (Title : in String) is
begin
STM32.RNG.Interrupts.Initialize_RNG;
STM32.Board.Display.Initialize;
STM32.Board.Display.Initialize_Layer (1, HAL.Bitmap.ARGB_1555);
Print(0, 0, Title);
end Initialize;

-- Probably a cleaner way to do this
procedure PrintToConsole(Msg : in String) is
currentLine : Natural := (CURRENT_CONSOLE_POSITION.Y - 100) / FONT_HEIGHT; -- zero indexed
begin
if currentLine = 14 then --make dynamic
declare
iterator : Integer := 1;
begin
while iterator < 13 loop --make dynamic
CopyLine(iterator, iterator - 1, false);
iterator := iterator + 1;
end loop;
CopyLine(13, 12, True); --make dynamic
end;
CURRENT_CONSOLE_POSITION.Y := CURRENT_CONSOLE_POSITION.Y - FONT_HEIGHT;
Print(CURRENT_CONSOLE_POSITION.X, CURRENT_CONSOLE_POSITION.Y, Msg);
CURRENT_CONSOLE_POSITION.Y := CURRENT_CONSOLE_POSITION.Y + FONT_HEIGHT;

else
Print(CURRENT_CONSOLE_POSITION.X, CURRENT_CONSOLE_POSITION.Y, Msg);
CURRENT_CONSOLE_POSITION.Y := CURRENT_CONSOLE_POSITION.Y + FONT_HEIGHT;
end if;

STM32.Board.Display.Update_Layer(1, True);
end PrintToConsole;


procedure CopyLine(SrcLineNumber : in Natural; DstLineNumer : in Natural; DeleteSrc : in Boolean) is
srcToPoint : HAL.Bitmap.Point := (0, (CONSOLE_STARTING_POINT.Y + (FONT_HEIGHT * SrcLineNumber)));
dstToPoint : HAL.Bitmap.Point := (0, (CONSOLE_STARTING_POINT.Y + (FONT_HEIGHT * DstLineNumer)));
srcRect : HAL.Bitmap.Rect := (Position => srcToPoint, Width => 480, Height => FONT_HEIGHT); -- dont hardcode 480
begin
HAL.Bitmap.Copy_Rect(Src_Buffer => STM32.Board.Display.Hidden_Buffer (1).all, Src_Pt => srcToPoint, Dst_Buffer => STM32.Board.Display.Hidden_Buffer (1).all, Dst_Pt => dstToPoint, Width => 480, Height => FONT_HEIGHT, Synchronous => True);
if DeleteSrc then
HAL.Bitmap.Fill_Rect(Buffer => STM32.Board.Display.Hidden_Buffer (1).all, Area => srcRect);
end if;
STM32.Board.Display.Update_Layer(1, True);
end CopyLine;


end GUI;
17 changes: 17 additions & 0 deletions eRINA_STM32F7/src/rina/gui.ads
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
with BMP_Fonts;
with HAL.Bitmap;
package GUI is
pragma Warnings(Off);

Large_Font : BMP_Fonts.BMP_Font := BMP_Fonts.Font12x12;
Foreground : HAL.Bitmap.Bitmap_Color := HAL.Bitmap.White;
Background : HAL.Bitmap.Bitmap_Color := HAL.Bitmap.Black;

procedure Print (X : in Natural; Y : in Natural; Msg : in String);

procedure Initialize (Title : in String);

procedure PrintToConsole(Msg : in String);

procedure CopyLine(SrcLineNumber : in Natural; DstLineNumer : in Natural; DeleteSrc : in Boolean);
end GUI;
13 changes: 13 additions & 0 deletions eRINA_STM32F7/src/utils/demos.adb
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,19 @@ package body Demos is
end if;
end Refresh_Ifnet_Stats;

procedure Initialize_Blank is
begin
STM32.RNG.Interrupts.Initialize_RNG;
STM32.Board.Display.Initialize;
STM32.Board.Display.Initialize_Layer (1, HAL.Bitmap.ARGB_1555);

Current_Font := BMP_Fonts.Font16x24;
Header;
Current_Font := Default_Font;

STM32.Board.Display.Update_Layer (1);
end Initialize_Blank;

-- ------------------------------
-- Initialize the board and the interface.
-- ------------------------------
Expand Down
4 changes: 4 additions & 0 deletions eRINA_STM32F7/src/utils/demos.ads
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ package Demos is
with procedure Header;
procedure Initialize (Title : in String);

generic
with procedure Header;
procedure Initialize_Blank;

pragma Warnings (Off);

-- Get the default font size according to the display size.
Expand Down
20 changes: 10 additions & 10 deletions eRINA_Tests/src/erina_tests.adb
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ with AUnit.Run;
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;
with Test_RINA_Open; -- TS-001
with Test_RINA_Register; -- TS-002
with Test_RINA_Unregister; -- TS-003
with Test_RINA_Flow_Alloc; -- TS-007
with Test_RINA_Flow_Alloc_Wait; -- TS-008

procedure eRINA_Tests is

Expand All @@ -20,12 +20,12 @@ procedure eRINA_Tests is
function Suite return AUnit.Test_Suites.Access_Test_Suite is
Result : constant AUnit.Test_Suites.Access_Test_Suite := AUnit.Test_Suites.New_Suite;
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_Open.Suite); -- TS-001
Result.Add_Test (Test_RINA_Register.Suite); -- TS-002
Result.Add_Test (Test_RINA_Unregister.Suite); -- TS-003

Result.Add_Test (Test_RINA_Flow_Alloc_Wait.Suite);
Result.Add_Test (Test_RINA_Flow_Alloc.Suite);
Result.Add_Test (Test_RINA_Flow_Alloc.Suite); -- TS-007
Result.Add_Test (Test_RINA_Flow_Alloc_Wait.Suite); -- TS-008
return Result;
end Suite;

Expand Down
12 changes: 8 additions & 4 deletions eRINA_Tests/src/test_rina_flow_alloc.adb
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,21 @@ package body Test_RINA_Flow_Alloc is
begin
Test_Suite.Add_Test
(Caller.Create
("TC-025 Valid Flow Allocation",
("TC-024 Valid Flow Allocation",
Test_Valid_Flow_Allocation'Access));
Test_Suite.Add_Test
(Caller.Create ("TC-026 Invalid Flags", Test_Invalid_Flags'Access));
(Caller.Create ("TC-025 Invalid Flags", Test_Invalid_Flags'Access));
Test_Suite.Add_Test
(Caller.Create
("TC-027 Incorrect Flowspec Version",
("TC-026 Incorrect Flowspec Version",
Test_Incorrect_Flowspec_Version'Access));
Test_Suite.Add_Test
(Caller.Create
("TC-028 RINA Open Failure", Test_RINA_Open_Failure'Access));
("TC-027 RINA Open Failure", Test_RINA_Open_Failure'Access));
return Test_Suite'Access;
end Suite;

-- TC 024
procedure Test_Valid_Flow_Allocation (Object : in out Test) is
dif_name : Bounded_String := To_Bounded_String ("TestDIF");
local_appl : Bounded_String := To_Bounded_String ("TestLocalAppl");
Expand All @@ -56,6 +57,7 @@ package body Test_RINA_Flow_Alloc is
Assert (result /= Invalid_FD, "Invalid file descriptor returned");
end Test_Valid_Flow_Allocation;

-- TC 025
procedure Test_Invalid_Flags (Object : in out Test) is
dif_name : Bounded_String := To_Bounded_String ("TestDIF");
local_appl : Bounded_String := To_Bounded_String ("TestLocalAppl");
Expand All @@ -71,6 +73,7 @@ package body Test_RINA_Flow_Alloc is
Assert (result = Invalid_FD, "Invalid file descriptor returned");
end Test_Invalid_Flags;

-- TC 026
procedure Test_Incorrect_Flowspec_Version (Object : in out Test) is
dif_name : Bounded_String := To_Bounded_String ("TestDIF");
local_appl : Bounded_String := To_Bounded_String ("TestLocalAppl");
Expand All @@ -87,6 +90,7 @@ package body Test_RINA_Flow_Alloc is
Assert (result = Invalid_FD, "Invalid file descriptor returned");
end Test_Incorrect_Flowspec_Version;

-- TC 027
procedure Test_RINA_Open_Failure (Object : in out Test) is
dif_name : Bounded_String := To_Bounded_String ("TEST123DIF");
local_appl : Bounded_String := To_Bounded_String ("TestLocalAppl");
Expand Down
3 changes: 2 additions & 1 deletion eRINA_Tests/src/test_rina_flow_alloc_wait.adb
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ package body Test_RINA_Flow_Alloc_Wait is
Name : constant String := "RINA_Flow_Alloc_Wait";
begin
Test_Suite.Add_Test (Caller.Create
("TC-029 Positive Flow Alloc Response", Test_Positive_Flow_Alloc_Response'Access));
("TC-028 Positive Flow Alloc Response", Test_Positive_Flow_Alloc_Response'Access));
return Test_Suite'Access;
end Suite;

-- TC 028
procedure Test_Positive_Flow_Alloc_Response (Object : in out Test) is
wfd : File_Descriptor := 1;
port_id : Unsigned_16 := 2020;
Expand Down
2 changes: 2 additions & 0 deletions eRINA_Tests/src/test_rina_open.adb
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,15 @@ package body Test_RINA_Open is
return Test_Suite'Access;
end Suite;

-- TC 001
procedure Test_Open (Object : in out Test) is
Rlite_Fd : File_Descriptor := Invalid_FD;
begin
Rlite_Fd := RINA_Open;
Assert(Rlite_Fd /= Invalid_FD, "Invalid file descriptor returned");
end Test_Open;

-- TC 002
procedure Test_Open_Failure (Object : in out Test) is
Fd : File_Descriptor := Invalid_FD;
begin
Expand Down
14 changes: 14 additions & 0 deletions eRINA_Tests/src/test_rina_unregister.adb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ package body Test_RINA_Unregister is
Name_015 : constant String := "TC-015";
Name_016 : constant String := "TC-016";
Name_017 : constant String := "TC-017";
Name_018 : constant String := "TC-018";
begin
Test_Suite.Add_Test (Caller.Create
(Name_012 & " Verify that rina_unregister successfully unregisters an application name from a DIF", Test_Unregister_AppName_to_DIF'Access));
Expand All @@ -40,6 +41,9 @@ package body Test_RINA_Unregister is
(Name_016 & " Verify rina_unregister throws exception when application name is too long", Test_Unregister_App_Name_Too_Long'Access));
Test_Suite.Add_Test (Caller.Create
(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));


return Test_Suite'Access;
end Suite;
Expand Down Expand Up @@ -124,4 +128,14 @@ package body Test_RINA_Unregister is
Assert (Caused_Error and Unregister_Success = Invalid_FD, "App name is empty");
end Test_Unregister_App_Name_Empty;

-- TC 018
procedure Test_Unregister_Invalid_File_Descriptor (Object : in out Test) is
Invalid_FileD : File_Descriptor := Invalid_FD;
Unregister_Success : File_Descriptor;
Caused_Error : Boolean := False;
begin
Unregister_Success := RINA_Register(Invalid_FileD, DIF_Name, "NewTestAppName", 0);
Assert (Caused_Error = False and Unregister_Success = Invalid_FD, "Invalid file descriptor passed for control device");
end Test_Unregister_Invalid_File_Descriptor;

end Test_RINA_Unregister;
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 @@ -16,5 +16,6 @@ private
procedure Test_Unregister_DIF_Name_Not_Registered (Object : in out Test);
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);

end Test_RINA_Unregister;

0 comments on commit 36c7808

Please sign in to comment.