Skip to content

Commit

Permalink
Update test
Browse files Browse the repository at this point in the history
  • Loading branch information
persan committed Mar 3, 2024
1 parent ff278a2 commit c8337f2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ada.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ jobs:
sudo apt-get install -y mosquitto &&
echo "127.0.0.1 mqtt" | sudo tee -a /etc/hosts &&
sudo systemctl start mosquitto &&
make test
MQTT_HOST=localhost make test
7 changes: 1 addition & 6 deletions mosquitto.gpr
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,7 @@ library project Mosquitto is
package Compiler is
for Driver ("toml") use "";
for Driver ("Makefile") use "";
for Default_Switches ("ada") use
("-gnatwa"
, "-gnatf"
, "-fstack-check"
, "-gnatyaAbBcdfhiknOptux"
) & Mosquitto_Config.Ada_Compiler_Switches;
for Default_Switches ("ada") use Mosquitto_Config.Ada_Compiler_Switches;
end Compiler;

package Binder is
Expand Down
10 changes: 7 additions & 3 deletions tests/src/mosquitto-tests-main.adb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
with Ada.Environment_Variables;
with GNAT.Time_Stamp;
with GNAT.Sockets;
with Ada.Directories;
Expand All @@ -8,7 +9,8 @@ procedure Mosquitto.Tests.Main is
task type Pump (Connection : access Handle) is
entry Start;
end Pump;

MQTT_HOST : constant String := Ada.Environment_Variables.Value
("MQTT_HOST", "mqtt");
task body Pump is
begin
accept Start;
Expand All @@ -24,9 +26,11 @@ begin
C.Initialize (GNAT.Sockets.Host_Name & "/" & Ada.Directories.Simple_Name (Ada.Command_Line.Command_Name) & Getpid'Img);
P.Start;
C.Set_Handler (A'Unchecked_Access);
C.Connect (Host => "mqtt", Keepalive => 30.0);
C.Connect (Host => MQTT_HOST, Keepalive => 30.0);
C.Subscribe (Topic => "#");
C.Publish (Mid => null, Topic => "test", Payload => "[" & GNAT.Time_Stamp.Current_Time & "] Hej", Qos => QOS_0, Retain => False);
C.Publish (Mid => null,
Topic => "test", Payload => "[" & GNAT.Time_Stamp.Current_Time & "] Hej",
Qos => QOS_0, Retain => False);
delay 1.0;
C.Disconnect;

Expand Down

0 comments on commit c8337f2

Please sign in to comment.