Fix: Tests: race condition in test_event_tracker
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 8 Sep 2021 19:54:32 +0000 (15:54 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 8 Sep 2021 20:00:54 +0000 (16:00 -0400)
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.

Backport
========
The changes applying to `test_event_tracker` introduced by 33e5571 were
squashed into this commit as the clean-up affected a lot of areas
impacted by this change.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I3c7dcb8e3c3427944fb9c07d2d0b9b6213b6ab32


No differences found
This page took 0.025161 seconds and 4 git commands to generate.