From b67cd6f052bb21a3c3c72840a9e55598951ba632 Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Mon, 31 Aug 2015 22:32:11 -0400 Subject: [PATCH] make check: add warning when LTTng processes are running MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This patch adds a warning when running LTTng/test processes are detected at the beginning of make check. It offers a convenient way to kill them and warns the user that some tests could fail if the processes are kept alive. The check can be disabled by setting $LTTNG_TOOLS_TESTS_DISABLE_WARN_LTTNG_PROCESSES to 1 Signed-off-by: Philippe Proulx Signed-off-by: Jérémie Galarneau --- configure.ac | 4 ++++ tests/Makefile.am | 6 ++++++ tests/utils/Makefile.am | 4 ++-- tests/utils/warn_lttng_processes.sh | 23 +++++++++++++++++++++++ 4 files changed, 35 insertions(+), 2 deletions(-) create mode 100755 tests/utils/warn_lttng_processes.sh diff --git a/configure.ac b/configure.ac index 6020596a1..4a0673e76 100644 --- a/configure.ac +++ b/configure.ac @@ -703,6 +703,10 @@ AM_CONDITIONAL([BUILD_LIB_SESSIOND_COMM], [test x$build_lib_sessiond_comm = xyes AM_CONDITIONAL([BUILD_LIB_TESTPOINT], [test x$build_lib_testpoint = xyes]) AM_CONDITIONAL([BUILD_LIB_UST_CONSUMER], [test x$build_lib_ust_consumer = xyes]) +# check for pgrep +AC_PATH_PROG([PGREP], [pgrep], [no]) +AM_CONDITIONAL([HAS_PGREP], [test "x$PGREP" != "xno"]) + if test ! -f "$srcdir/src/lib/lttng-ctl/filter/filter-parser.h"; then if test x"$(basename "$YACC")" != "xbison -y"; then AC_MSG_ERROR([[bison not found and is required when building from git. diff --git a/tests/Makefile.am b/tests/Makefile.am index 99c20422e..31a958ec3 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -7,6 +7,9 @@ endif installcheck-am: if BUILD_TESTS +if HAS_PGREP + ./utils/warn_lttng_processes.sh $(PGREP) +endif ./run.sh unit_tests ./run.sh fast_regression if PYTHON_BINDING @@ -20,6 +23,9 @@ endif check-am: if BUILD_TESTS +if HAS_PGREP + ./utils/warn_lttng_processes.sh $(PGREP) +endif ./run.sh unit_tests ./run.sh fast_regression if PYTHON_BINDING diff --git a/tests/utils/Makefile.am b/tests/utils/Makefile.am index b3d592973..f43233d86 100644 --- a/tests/utils/Makefile.am +++ b/tests/utils/Makefile.am @@ -1,7 +1,7 @@ SUBDIRS = tap testapp -EXTRA_DIST = utils.sh test_utils.py babelstats.pl -dist_noinst_SCRIPTS = utils.sh test_utils.py babelstats.pl +EXTRA_DIST = utils.sh test_utils.py babelstats.pl warn_lttng_processes.sh +dist_noinst_SCRIPTS = utils.sh test_utils.py babelstats.pl warn_lttng_processes.sh all-local: @if [ x"$(srcdir)" != x"$(builddir)" ]; then \ diff --git a/tests/utils/warn_lttng_processes.sh b/tests/utils/warn_lttng_processes.sh new file mode 100755 index 000000000..939163b39 --- /dev/null +++ b/tests/utils/warn_lttng_processes.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +if [ x$LTTNG_TOOLS_TESTS_DISABLE_WARN_LTTNG_PROCESSES == x1 ]; then + exit +fi + +color_warn='\E[1;33m' +color_reset='\E[0m' +color_bold='\E[1m' + +lttng_processes="$("$1" 'lttng|gen-ust-.+' -a | grep -v "$(basename "$0")")" + +if [ $? -eq 0 ]; then + pids="$(cut -d ' ' -f 1 <<< "$lttng_processes" | tr '\n' ' ')" + + echo -e "${color_warn}Warning: the following LTTng processes were detected running on the system:$color_reset" + echo + echo "$lttng_processes" + echo + echo -e "Here's how to kill them: ${color_bold}kill -9 $pids$color_reset" + echo -e "${color_warn}If you leave them alive, some tests could fail.$color_reset" + echo +fi -- 2.34.1