From df69e0a02f347986a1f29e12142c56efa685aff9 Mon Sep 17 00:00:00 2001
From: Bernardo Dal Seno <bdalseno@google.com>
Date: Thu, 22 Dec 2011 14:49:24 +0100
Subject: [PATCH] Fix failure in distcheck and coverage tests

autotools/testrunner was missing in distcheck.  Now some changes from
7004106119c5c56c93085ccfb1250b3561b5b6ad have been reverted, and testrunner
is not built anymore.  coverage now uses fakeroot when needed.

Signed-off-by: Bernardo Dal Seno <bdalseno@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>
---
 .gitignore                              |  1 -
 Makefile.am                             | 12 +++---------
 autotools/gen-coverage                  | 13 +++++++++++--
 autotools/{testrunner.in => testrunner} |  4 +---
 4 files changed, 15 insertions(+), 15 deletions(-)
 rename autotools/{testrunner.in => testrunner} (93%)

diff --git a/.gitignore b/.gitignore
index 86e80c24e..1b82e7c2c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -24,7 +24,6 @@
 /autotools/missing
 /autotools/py-compile
 /autotools/replace_vars.sed
-/autotools/testrunner
 /config.log
 /config.status
 /configure
diff --git a/Makefile.am b/Makefile.am
index 11a4d22ce..7650418f0 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -137,7 +137,6 @@ CLEANFILES = \
 	$(PYTHON_BOOTSTRAP) \
 	epydoc.conf \
 	autotools/replace_vars.sed \
-	autotools/testrunner \
 	daemons/daemon-util \
 	daemons/ganeti-cleaner \
 	devel/upload \
@@ -441,7 +440,6 @@ docpng = $(patsubst %.dot,%.png,$(docdot))
 # Things to build but not to install (add it to EXTRA_DIST if it should be
 # distributed)
 noinst_DATA = \
-	autotools/testrunner \
 	devel/upload \
 	doc/html \
 	$(BUILT_EXAMPLES) \
@@ -578,7 +576,7 @@ EXTRA_DIST = \
 	autotools/convert-constants \
 	autotools/docpp \
 	autotools/gen-coverage \
-	autotools/testrunner.in \
+	autotools/testrunner \
 	$(RUN_IN_TEMPDIR) \
 	daemons/daemon-util.in \
 	daemons/ganeti-cleaner.in \
@@ -775,7 +773,8 @@ TESTS = $(dist_TESTS) $(nodist_TESTS)
 
 # Environment for all tests
 PLAIN_TESTS_ENVIRONMENT = \
-	PYTHONPATH=. TOP_SRCDIR=$(abs_top_srcdir) PYTHON=$(PYTHON) $(RUN_IN_TEMPDIR)
+	PYTHONPATH=. TOP_SRCDIR=$(abs_top_srcdir) PYTHON=$(PYTHON) \
+	FAKEROOT=$(FAKEROOT_PATH) $(RUN_IN_TEMPDIR)
 
 # Environment for tests run by automake
 TESTS_ENVIRONMENT = \
@@ -854,10 +853,6 @@ tools/kvm-ifup: tools/kvm-ifup.in $(REPLACE_VARS_SED)
 	sed -f $(REPLACE_VARS_SED) < $< > $@
 	chmod +x $@
 
-autotools/testrunner: autotools/testrunner.in $(REPLACE_VARS_SED)
-	sed -f $(REPLACE_VARS_SED) < $< > $@
-	chmod u+x $@
-
 devel/upload: devel/upload.in $(REPLACE_VARS_SED)
 	sed -f $(REPLACE_VARS_SED) < $< > $@
 	chmod u+x $@
@@ -1068,7 +1063,6 @@ $(REPLACE_VARS_SED): Makefile
 	  echo 's#@GNTMASTERDGROUP@#$(MASTERD_GROUP)#g'; \
 	  echo 's#@GNTDAEMONSGROUP@#$(DAEMONS_GROUP)#g'; \
 	  echo 's#@CUSTOM_ENABLE_CONFD@#$(ENABLE_CONFD)#g'; \
-	  echo 's#@FAKEROOT@#$(FAKEROOT_PATH)#g'; \
 	} > $@
 
 # Using deferred evaluation
diff --git a/autotools/gen-coverage b/autotools/gen-coverage
index 8d6c2d47e..1324724fb 100755
--- a/autotools/gen-coverage
+++ b/autotools/gen-coverage
@@ -1,7 +1,7 @@
 #!/bin/bash
 #
 
-# Copyright (C) 2010 Google Inc.
+# Copyright (C) 2010, 2011 Google Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -34,7 +34,16 @@ omit="--omit=$omit"
 $COVERAGE erase
 
 for script; do
-  $COVERAGE run --branch --append $script
+  if [[ "$script" == *-runasroot.py ]]; then
+    if [[ -z "$FAKEROOT" ]]; then
+      echo "FAKEROOT variable not set and needed for $script" >&2
+      exit 1
+    fi
+    cmdprefix="$FAKEROOT"
+  else
+    cmdprefix=
+  fi
+  $cmdprefix $COVERAGE run --branch --append $script
 done
 
 echo "Writing text report to $TEXT_COVERAGE ..." >&2
diff --git a/autotools/testrunner.in b/autotools/testrunner
similarity index 93%
rename from autotools/testrunner.in
rename to autotools/testrunner
index 879b4c7a7..cbd1de92e 100755
--- a/autotools/testrunner.in
+++ b/autotools/testrunner
@@ -20,13 +20,11 @@
 
 set -e
 
-FAKEROOT='@FAKEROOT@'
-
 filename=$1
 
 execasroot() {
   if [[ -z "$FAKEROOT" ]]; then
-    echo "'fakeroot' not found at configure time" >&2
+    echo "FAKEROOT variable not set" >&2
     exit 1
   fi
   exec "$FAKEROOT" "$@"
-- 
GitLab