Commit 70041061 authored by Bernardo Dal Seno's avatar Bernardo Dal Seno
Browse files

unit tests: added fakeroot support



Tests ending in "-runasroot" or "-runasroot.py" are run through fakeroot,
so activity that needs root privileges can be tested.
Signed-off-by: default avatarBernardo Dal Seno <bdalseno@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent 5449685e
......@@ -24,6 +24,7 @@
/autotools/missing
/autotools/py-compile
/autotools/replace_vars.sed
/autotools/testrunner
/config.log
/config.status
/configure
......
......@@ -137,6 +137,7 @@ CLEANFILES = \
$(PYTHON_BOOTSTRAP) \
epydoc.conf \
autotools/replace_vars.sed \
autotools/testrunner \
daemons/daemon-util \
daemons/ganeti-cleaner \
devel/upload \
......@@ -430,6 +431,7 @@ 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) \
......@@ -566,7 +568,7 @@ EXTRA_DIST = \
autotools/convert-constants \
autotools/docpp \
autotools/gen-coverage \
autotools/testrunner \
autotools/testrunner.in \
$(RUN_IN_TEMPDIR) \
daemons/daemon-util.in \
daemons/ganeti-cleaner.in \
......@@ -838,6 +840,10 @@ 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 $@
......@@ -1048,6 +1054,7 @@ $(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
......
#!/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
......@@ -20,9 +20,21 @@
set -e
FAKEROOT='@FAKEROOT@'
filename=$1
execasroot() {
if [[ -z "$FAKEROOT" ]]; then
echo "'fakeroot' not found at configure time" >&2
exit 1
fi
exec "$FAKEROOT" "$@"
}
case "$filename" in
*-runasroot.py) execasroot $PYTHON "$@" ;;
*.py) exec $PYTHON "$@" ;;
*-runasroot) execasroot "$@" ;;
*) exec "$@" ;;
esac
......@@ -487,6 +487,15 @@ AM_CONDITIONAL([WANT_HTOOLS], [test x$HTOOLS = xyes])
AM_CONDITIONAL([WANT_HTOOLSTESTS], [test "x$GHC_PKG_QUICKCHECK" != x])
AM_CONDITIONAL([WANT_HTOOLSAPIDOC], [test x$HTOOLS_APIDOC = xyes])
# Check for fakeroot
AC_ARG_VAR(FAKEROOT_PATH, [fakeroot path])
AC_PATH_PROG(FAKEROOT_PATH, [fakeroot], [])
if test -z "$FAKEROOT_PATH"; then
AC_MSG_WARN(m4_normalize([fakeroot not found, tests that must run as root
will not be executed]))
fi
AM_CONDITIONAL([HAS_FAKEROOT], [test "x$FAKEROOT_PATH" != x])
SOCAT_USE_ESCAPE=
AC_ARG_ENABLE([socat-escape],
[AS_HELP_STRING([--enable-socat-escape],
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment