Fix: Tests: race condition in test_event_tracker
authorFrancis Deslauriers <francis.deslauriers@efficios.com>
Tue, 7 Sep 2021 21:10:31 +0000 (17:10 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 8 Sep 2021 19:37:23 +0000 (15:37 -0400)
commitc489057c2edf1e371cce5649fe17d681bbd5b5eb
tree6896059273521345304fa39a253273fb87f22f28
parent4f002736e957daab4ae95c01613950aa415ab005
Fix: Tests: race condition in test_event_tracker

Background
==========
The `test_event_tracker` file contains test cases when the event
generating app in executed in two distinct steps. Those two steps are
preparation and execution.
  1. the preparation is the launching the app in the background, and
  2. the execution is actually generating the event that should or
     should not be traced depending on the test case.

This is useful to test the tracker feature since we want to ensure that
already running apps are notified properly when changing their tracking
status.

Issue
=====
The `test_event_vpid_track_untrack` test case suffers from a race
condition that is easy to reproduce on Yocto.

The issue is that sometimes events are end up the trace when none is
expected.

This is due to the absence of synchronization point at the launch of the
app which leads to the app being scheduled in-between the track-untrack
calls leading to events being recorded to the trace.

It's easy to reproduce this issue on my machine by adding a `sleep 5`
between the track and untrack calls and setting the `NR_USEC_WAIT`
variable to 1.

Fix
===
Using the testapp `--sync-before-last-event-touch` flag to make the app
create a file when all but the last event are executed. We then have the
app wait until we create a file (`--sync-before-last-event`) to generate
that last event. This way, we are sure no event will be generated when
running the track and untrack commands.

Notes
=====
- This issue affects other test cases in this file.
- This commit fixes a typo in the test header.
- This commit adds `diag` calls to help tracking to what test the output
  relates to when reading the log.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ia2b68128dc9a805526f9748f31ec2c2d95566f31
tests/regression/tools/tracker/test_event_tracker
This page took 0.024732 seconds and 4 git commands to generate.