isl: Avoid EXPECT_DEATH in unit tests
authorMatt Turner <mattst88@gmail.com>
Thu, 12 Mar 2020 21:44:46 +0000 (14:44 -0700)
committerMatt Turner <mattst88@gmail.com>
Sat, 14 Mar 2020 00:48:03 +0000 (17:48 -0700)
commitb93a1952258ebef6319fd4f4186d704e04b3064c
treec9c1ab20dc4d1b8dd49980c1e367989c13ea3bba
parent5e523c9265d3a6f092bad17364cf7d7f5ead6e98
isl: Avoid EXPECT_DEATH in unit tests

EXPECT_DEATH works by forking the process and letting the forked process
fail with an assertion. This process is evidently incredibly expensive,
taking ~30 seconds to run the whole isl_aux_info_test on a 2.8GHz
Skylake. Annoyingly all of the (expected) assertion failures also leaves
lots of messages in dmesg and potentially generates lots of coredumps.

Instead, avoid the expense of fork/exec by redefining assert() and
unreachable() in the code we're testing to return a unit-test-only
value. With this patch, the test takes ~1ms.

Also, while modifying the EXPECT_EQ() calls, reverse the arguments so
that the expected value comes first, as is intended. Otherwise gtest
failure messages don't make much sense.

Fixes: https://gitlab.freedesktop.org/mesa/mesa/issues/2567
Reviewed-by: Nanley Chery <nanley.g.chery@intel.com>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4174>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4174>
src/intel/isl/isl.h
src/intel/isl/isl_aux_info.c
src/intel/isl/meson.build
src/intel/isl/tests/isl_aux_info_test.cpp