display-test: Fix a race condition in test suite
authorFergus Dall <sidereal@google.com>
Tue, 14 Dec 2021 23:31:41 +0000 (10:31 +1100)
committerSimon Ser <contact@emersion.fr>
Sat, 5 Feb 2022 14:29:39 +0000 (14:29 +0000)
commite949b3bfbb92363724ef1bd5b2f5736de8a9f98a
tree103dceb211bbd3356747c389732b1f060947ec01
parent5eb5620cbd317aac4a61e357c3c92bd889d6079b
display-test: Fix a race condition in test suite

Several tests in this suite use setting and checking client.display_stopped (in
test-compositor.h) to synchronise between threads. This is a data race because
display_stopped is a non-atomic int. Fix this by making it an atomic_bool
instead. We don't need to change the access code because reads and writes are
sequentially consistent by default.

This can be reproduced (with both clang and gcc) by running
```
meson -Db_sanitize=thread build
cd build
ninja
meson test
```

Signed-off-by: Fergus Dall <sidereal@google.com>
tests/test-compositor.h