Natools

Check-in [908d0e14c9]
Login
Overview
Comment:cron-tests: add a test showing a bug in event list fusion
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 908d0e14c92d5457bda9fff65813a0ec3c3a839d
User & Date: nat on 2017-06-22 21:10:52
Other Links: manifest | tags
Context
2017-06-23
20:00
cron: fix fusion of even list check-in: 215f7beb0c user: nat tags: trunk
2017-06-22
21:10
cron-tests: add a test showing a bug in event list fusion check-in: 908d0e14c9 user: nat tags: trunk
2017-06-21
19:51
constant_indefinite_ordered_map_tests: test the new Rank primitive check-in: d01e18ba8f user: nat tags: trunk
Changes

Modified tests/natools-cron-tests.adb from [2e657633ab] to [c715546381].

77
78
79
80
81
82
83

84
85
86
87
88
89
90
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91







+







   procedure All_Tests (Report : in out NT.Reporter'Class) is
   begin
      Basic_Usage (Report);
      Delete_While_Busy (Report);
      Insert_While_Busy (Report);
      Time_Collision (Report);
      Delete_While_Collision (Report);
      Event_List_Fusion (Report);
   end All_Tests;



   -----------------------
   -- Inidividual Tests --
   -----------------------
222
223
224
225
226
227
228
























































229
230
231
232
233
234
235
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







      Check (Test, Get (Log), "(");
      delay 4 * Tick;
      Check (Test, Get (Log), "()<>");
   exception
      when Error : others => Test.Report_Exception (Error);
   end Delete_While_Collision;


   procedure Event_List_Fusion (Report : in out NT.Reporter'Class) is
      Test : NT.Test := Report.Item ("Fusion of synchronized callbacks");
      Total : constant Duration := 0.25;
      Log : aliased Bounded_String (256);
   begin
      declare
         use type Ada.Calendar.Time;
         First_Tick : constant Periodic_Time
           := (Origin => Ada.Calendar.Clock + Total / 8,
               Period => Total / 4);
         Second_Tick : constant Periodic_Time
           := (Origin => First_Tick.Origin + First_Tick.Period,
               Period => First_Tick.Period);

         A_Head, A_Tail, B_Head, B_Tail : Cron_Entry;
      begin
         A_Head.Set (First_Tick, Long_Callback'
           (Backend => Log'Access,
            Open => '(',
            Close => ')',
            Wait => Total / 8));
         A_Tail.Set (First_Tick, Test_Callback'
           (Backend => Log'Access,
            Symbol => 'A'));

         delay Total / 8 + Total / 16;
         Check (Test, Get (Log), "(");

         B_Head.Set (Second_Tick, Test_Callback'
           (Backend => Log'Access,
            Symbol => 'B'));
         B_Tail.Set (Second_Tick, Test_Callback'
           (Backend => Log'Access,
            Symbol => 'b'));

         delay Total / 4 + Total / 8;
         Check (Test, Get (Log), "()ABb()A");

         A_Tail.Reset;
         B_Tail.Reset;

         delay Total / 4;
         Check (Test, Get (Log), "()ABb()AB()");
      end;

      --  Timeline:  0   .   1/4   .   1/2   .   3/4   .   1
      --  Log:           (    )A  Bb(   )A   B(   )
      --  Code:      *     *               *         *   *

      delay Total / 8;
      Check (Test, Get (Log), "()ABb()AB()");
   exception
      when Error : others => Test.Report_Exception (Error);
   end Event_List_Fusion;


   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);
   begin
      declare

Modified tests/natools-cron-tests.ads from [460bcc2dff] to [1bfff1ac61].

25
26
27
28
29
30
31

32
33
34
35
36
37
38
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39







+







   package NT renames Natools.Tests;

   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 Event_List_Fusion (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

   type Bounded_String (Max_Size : Natural) is record
      Data : String (1 .. Max_Size);