Menu ▾ ▴

#491 Cover the event queue in the unit tests

NextRelease
closed-accepted
nobody
None
5
1 day ago
2 days ago
No

Problem

The event queue is core emulator machinery - registration, sorted insertion, dispatch, frame reduction and removal - but no unit test exercises it, and event.c documents a past crash from signed-subtraction overflow in its comparator that nothing pins.

Proposed change

unittests/unittests.c gains event_queue_test(): registration and naming via event_register()/event_name(); ordering by unsigned T-state with insertion on both sides of a distant event (Q at 0x100, P at 0xe0000000, R at 0x40000000 must dispatch as Q, R, P - the old signed-subtraction comparator would dispatch Q, P, R); equal-time events fire in registration order; event_frame() reduces every entry and recomputes the next event time; event_remove_type() and event_remove_type_user_data() null matching events, which dispatch silently; a callback may queue another event and the dispatch loop picks it up in the same call; event_force_events() jumps to the next event for the RZX playback path. The test clears the queue at entry and leaves it empty at exit, saving and restoring tstates and tstates_per_frame.

Notes

  • Test-only change; event.c itself is untouched.
  • The ordering case pins the documented overflow-safe comparator in event.c's event_add_cmp().
  • event_force_events() needs a machine, so the test runs inside ./fuse --unittests where machine_current exists.
  • Validated with the null-ui build profile (autogen, configure, make, make check); ./fuse --unittests reports Final return value 0 with the new test registered before the automation block.

Validation

  • null-ui profile passed all four stages (autogen, configure --with-null-ui --enable-automation, make, make check); ./fuse --unittests reports Final return value 0 with event_queue_test registered before the automation block. (passed)
  • Diff confined to unittests/unittests.c for this patch's changed-file group; no other file in the group. (passed)

Changed files

  • unittests/unittests.c

Repo-Assist-Effect: 7b1671ca5854813220ee65e54c3da4d2f5efa9a2e4b0fbec9861ffbbcb91d268

1 Attachments

Discussion

  • Fredrick Meunier

    • Description has changed:

    Diff:

    
    
    • status: open --> closed-accepted
    • Group: --> NextRelease
    • Priority: --> 5
     
  • Fredrick Meunier

    Applied in [b731db].

     

    Related

    Commit: [b731db]


Log in to post a comment.