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)
commitd15d1d730a972e053d306db7594973f9db7bb521
treebc2e38e38d893a0101d38d023e30e1710f7b6940
parent342e427bf08266df80c5f316dd81268e77ce93c8
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.

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
tests/regression/tools/tracker/test_event_tracker
This page took 0.025149 seconds and 4 git commands to generate.