[CRIU] [PATCH 1/2] Makefile, travis: unify checking GCOV env var

Kir Kolyshkin kir at openvz.org
Thu Oct 20 20:04:47 PDT 2016


Setting GCOV environment variable is used for doing profiling (gcov).
Unfortunately, it is checked in two different ways:

1. In top Makefile and scripts/travis, it is checked against "1".
2. In other places, it's checked to be set to a non-empty value.

So, giving various values to GCOV will lead to different results.

Let's unify the approaches used. Apparently, among all the code the
easiest (and not too strict) way is to check for non-empty value
(this also leads to the smallest possible patch size).

Note that in Python, evaluating an empty string in a binary context
(such as after an "if" statement) equals to False.

Signed-off-by: Kir Kolyshkin <kir at openvz.org>
---
 Makefile                            | 2 +-
 scripts/travis/travis-after_success | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index 6947d9c..c75cbfb 100644
--- a/Makefile
+++ b/Makefile
@@ -110,7 +110,7 @@ WARNINGS		:= -Wall -Wformat-security
 CFLAGS-GCOV		:= --coverage -fno-exceptions -fno-inline
 export CFLAGS-GCOV
 
-ifeq ($(GCOV),1)
+ifneq ($(GCOV),)
         LDFLAGS         += -lgcov
         CFLAGS          += $(CFLAGS-GCOV)
 endif
diff --git a/scripts/travis/travis-after_success b/scripts/travis/travis-after_success
index 05322ef..bc0888a 100755
--- a/scripts/travis/travis-after_success
+++ b/scripts/travis/travis-after_success
@@ -2,7 +2,7 @@
 set -x -e
 
 # We only need to run the below for gcov-enabled builds
-[ "$GCOV" = "1" ] || exit 0
+test -z "$GCOV" && exit 0
 
 sudo apt-get install -qq -y lcov
 gem install coveralls-lcov
-- 
2.7.4



More information about the CRIU mailing list