Index: tests/natools-cron-tests.adb ================================================================== --- tests/natools-cron-tests.adb +++ tests/natools-cron-tests.adb @@ -1,7 +1,7 @@ ------------------------------------------------------------------------------ --- Copyright (c) 2014-2016, Natacha Porté -- +-- Copyright (c) 2014-2017, Natacha Porté -- -- -- -- Permission to use, copy, modify, and distribute this software for any -- -- purpose with or without fee is hereby granted, provided that the above -- -- copyright notice and this permission notice appear in all copies. -- -- -- @@ -78,10 +78,11 @@ begin Basic_Usage (Report); Delete_While_Busy (Report); Insert_While_Busy (Report); Time_Collision (Report); + Delete_While_Collision (Report); end All_Tests; ----------------------- @@ -182,10 +183,51 @@ Check (Test, Get (Log), "()", "After wait"); exception when Error : others => Test.Report_Exception (Error); end Delete_While_Busy; + + procedure Delete_While_Collision (Report : in out NT.Reporter'Class) is + Test : NT.Test + := Report.Item ("Delete entry while callback list is running"); + Total : constant Duration := 0.0625; + Tick : constant Duration := Total / 8; + Log : aliased Bounded_String (256); + begin + declare + use type Ada.Calendar.Time; + Common : constant Periodic_Time + := (Origin => Ada.Calendar.Clock + 2 * Tick, + Period => 8 * Tick); + First, Second : Cron_Entry; + begin + First.Set (Common, Long_Callback' + (Backend => Log'Access, + Open => '(', + Close => ')', + Wait => 2 * Tick)); + Second.Set (Common, Long_Callback' + (Backend => Log'Access, + Open => '<', + Close => '>', + Wait => 2 * Tick)); + delay 3 * Tick; + end; + + -- Timeline: 0 . 1/4 . 1/2 . 3/4 . 1 . 5/4 + -- Triggers: * * + -- Log: ( )< > ( + -- End of Block: ^ + -- End of Test: ^ + + Check (Test, Get (Log), "("); + delay 4 * Tick; + Check (Test, Get (Log), "()<>"); + exception + when Error : others => Test.Report_Exception (Error); + end Delete_While_Collision; + procedure Insert_While_Busy (Report : in out NT.Reporter'Class) is Test : NT.Test := Report.Item ("Insert entry while callback is running"); Total : constant Duration := 1.0; Log : aliased Bounded_String (256); Index: tests/natools-cron-tests.ads ================================================================== --- tests/natools-cron-tests.ads +++ tests/natools-cron-tests.ads @@ -1,7 +1,7 @@ ------------------------------------------------------------------------------ --- Copyright (c) 2014, Natacha Porté -- +-- Copyright (c) 2014-2017, Natacha Porté -- -- -- -- Permission to use, copy, modify, and distribute this software for any -- -- purpose with or without fee is hereby granted, provided that the above -- -- copyright notice and this permission notice appear in all copies. -- -- -- @@ -26,10 +26,11 @@ procedure All_Tests (Report : in out NT.Reporter'Class); procedure Basic_Usage (Report : in out NT.Reporter'Class); procedure Delete_While_Busy (Report : in out NT.Reporter'Class); + procedure Delete_While_Collision (Report : in out NT.Reporter'Class); procedure Insert_While_Busy (Report : in out NT.Reporter'Class); procedure Time_Collision (Report : in out NT.Reporter'Class); private