tests: Correct use of taskset in snapshot tests
authorKienan Stewart <kstewart@efficios.com>
Fri, 10 May 2024 18:41:11 +0000 (14:41 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 24 May 2024 11:26:55 +0000 (07:26 -0400)
commit849019151cf07f376a4a68ce1669e357f4775657
treea3885cf820b915db200f9c28cea5311fc4189b94
parent8a8bca410a240a7177deb09201878bad7a41d46b
tests: Correct use of taskset in snapshot tests

Observed issue
==============

While investigating potential changes to how buffers are flushed
during snapshots, I discovered that the changes made the small
overwrite test flaky.

After investigation, the issue appears to be a problem with the test
that was exposed by the other changes.

Cause
=====

`taskset` handles its arguments more strictly than many other CLI
programs, and the argument order used is not valid. As the return
of the taskset invocation in the test isn't validated, there was
little indication of the issue save a warning that is easily lost
in the text.

The following example demonstrates the situation:

```
$ bash -x test.sh
+ taskset -p 910843
pid 910843's current affinity mask: f
+ echo 0
0
+ ./tests/utils/testapp/gen-ust-events/gen-ust-events
Process 910845 has 4 cpus in its affinity set
        CPU 0 is set? 1
        CPU 1 is set? 1
        CPU 2 is set? 1
        CPU 3 is set? 1
+ taskset -c 0 -p 910843
taskset: failed to execute -p: No such file or directory
+ echo 127
127
+ ./tests/utils/testapp/gen-ust-events/gen-ust-events
Process 910849 has 4 cpus in its affinity set
        CPU 0 is set? 1
        CPU 1 is set? 1
        CPU 2 is set? 1
        CPU 3 is set? 1
+ taskset -pc 0 910843
pid 910843's current affinity list: 0-3
pid 910843's new affinity list: 0
+ echo 0
0
+ ./tests/utils/testapp/gen-ust-events/gen-ust-events
Process 910853 has 1 cpus in its affinity set
        CPU 0 is set? 1
```

Solution
========

Correct the invocation of taskset and add a check on its return code
when used to set the cpu affinity of the current process.

Known drawbacks
===============

None.

Change-Id: Ia629121624532746431875b2031dd65df207666d
Signed-off-by: Kienan Stewart <kstewart@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
tests/regression/tools/snapshots/ust_test
This page took 0.029037 seconds and 4 git commands to generate.