Enable Undefined Behaviour Sanitizer when running tests

This sanitizer is already enabled on Android. When Android upgrades to
the latest version of the library, we often discover sanitizer crashes
and have to fix them all at once before we can upgrade. Enabling more
sanitizers in the ChromeOS build should detect these crashes before
they're submitted into the ChromeOS tree.

We'd like to enable the sanitizers in all builds, but because of the
crashes that could be caused that'll take a more considered rollout
strategy. For now, enabling them when running unit tests is a good
start.

BUG=b:318520168
TEST=Add an integer overflow problem (int32_t k = 0x7fffffff; k++;) in
     the DistSq util function, run the unit tests [0], and check the
     UtilTest DistSqTest crashes with a suitable UBSan error.

[0]: cros_sdk env FEATURES="test" emerge-${BOARD} chromeos-base/gestures

Change-Id: I9677376f5500f5434198e17f540d173e0a9317a9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/gestures/+/5296935
Tested-by: Harry Cutts <hcutts@chromium.org>
Commit-Queue: Harry Cutts <hcutts@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Henry Barnor <hbarnor@chromium.org>
Code-Coverage: Henry Barnor <hbarnor@chromium.org>
1 file changed