test: replace the USING_VALGRIND env with the valgrind.h header

This header is intended to be included in the project, so let's do that and
have proper runtime detection of the valgrind environment.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Peter Hutterer 2019-04-30 13:10:42 +10:00
parent 40f3e2603f
commit 01efe9de4f
5 changed files with 6658 additions and 5 deletions

6647
include/valgrind/valgrind.h Normal file

File diff suppressed because it is too large Load diff

View file

@ -776,7 +776,8 @@ if get_option('tests')
'test/litest-device-xen-virtual-pointer.c', 'test/litest-device-xen-virtual-pointer.c',
'test/litest-device-vmware-virtual-usb-mouse.c', 'test/litest-device-vmware-virtual-usb-mouse.c',
'test/litest-device-yubikey.c', 'test/litest-device-yubikey.c',
'test/litest.c' 'test/litest.c',
'include/valgrind/valgrind.h'
] ]
dep_dl = cc.find_library('dl') dep_dl = cc.find_library('dl')
@ -890,7 +891,6 @@ if get_option('tests')
if valgrind.found() if valgrind.found()
valgrind_env = environment() valgrind_env = environment()
valgrind_env.set('CK_FORK', 'no') valgrind_env.set('CK_FORK', 'no')
valgrind_env.set('USING_VALGRIND', '1')
valgrind_suppressions_file = join_paths(dir_src_test, 'valgrind.suppressions') valgrind_suppressions_file = join_paths(dir_src_test, 'valgrind.suppressions')
add_test_setup('valgrind', add_test_setup('valgrind',
exe_wrapper : [ valgrind, exe_wrapper : [ valgrind,

View file

@ -3,6 +3,8 @@
#include <check.h> #include <check.h>
#include <signal.h> #include <signal.h>
#include <valgrind/valgrind.h>
#include "litest.h" #include "litest.h"
START_TEST(litest_assert_trigger) START_TEST(litest_assert_trigger)
@ -446,7 +448,7 @@ main (int argc, char **argv)
/* when running under valgrind we're using nofork mode, so a signal /* when running under valgrind we're using nofork mode, so a signal
* raised by a test will fail in valgrind. There's nothing to * raised by a test will fail in valgrind. There's nothing to
* memcheck here anyway, so just skip the valgrind test */ * memcheck here anyway, so just skip the valgrind test */
if (getenv("USING_VALGRIND")) if (RUNNING_ON_VALGRIND)
return EXIT_SUCCESS; return EXIT_SUCCESS;
s = litest_assert_macros_suite(); s = litest_assert_macros_suite();

View file

@ -54,6 +54,8 @@
#include <termios.h> #include <termios.h>
#endif #endif
#include <valgrind/valgrind.h>
#include "litest.h" #include "litest.h"
#include "litest-int.h" #include "litest-int.h"
#include "libinput-util.h" #include "libinput-util.h"
@ -623,7 +625,7 @@ litest_log_handler(struct libinput *libinput,
/* valgrind is too slow and some of our offsets are too /* valgrind is too slow and some of our offsets are too
* short, don't abort if during a valgrind run we get a * short, don't abort if during a valgrind run we get a
* negative offset */ * negative offset */
if (!getenv("USING_VALGRIND") || if (!RUNNING_ON_VALGRIND ||
!strstr(format, "offset negative")) !strstr(format, "offset negative"))
litest_abort_msg("libinput bug triggered, aborting.\n"); litest_abort_msg("libinput bug triggered, aborting.\n");
} }

View file

@ -26,6 +26,8 @@
#include <check.h> #include <check.h>
#include <libinput-util.h> #include <libinput-util.h>
#include <valgrind/valgrind.h>
#include "libinput-util.h" #include "libinput-util.h"
#define TEST_VERSIONSORT #define TEST_VERSIONSORT
#include "libinput-versionsort.h" #include "libinput-versionsort.h"
@ -1069,7 +1071,7 @@ int main(int argc, char **argv)
/* when running under valgrind we're using nofork mode, so a signal /* when running under valgrind we're using nofork mode, so a signal
* raised by a test will fail in valgrind. There's nothing to * raised by a test will fail in valgrind. There's nothing to
* memcheck here anyway, so just skip the valgrind test */ * memcheck here anyway, so just skip the valgrind test */
if (getenv("USING_VALGRIND")) if (RUNNING_ON_VALGRIND)
return EXIT_SUCCESS; return EXIT_SUCCESS;
s = litest_utils_suite(); s = litest_utils_suite();