commit ba5258ee4f2c4ba16005d89334c0119c9007418c
Author: Pavel Šimerda <psimerda@redhat.com>
Date:   Thu Apr 17 09:53:36 2014 +0200

    always run root tests when uid is zero

diff --git a/configure.ac b/configure.ac
index 74db8c1..1871e1a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -733,7 +733,7 @@ dnl -------------------------
 VAPIGEN_CHECK(0.17.1.24)
 
 # Tests, utilities and documentation
-AC_ARG_ENABLE(tests, AS_HELP_STRING([--enable-tests=root|yes|no], [Build NetworkManager tests (default: yes)]))
+AC_ARG_ENABLE(tests, AS_HELP_STRING([--enable-tests=yes|no], [Build NetworkManager tests (default: yes)]))
 AC_ARG_WITH(valgrind, AS_HELP_STRING([--with-valgrind=yes|no|path], [Use valgrind to memory-check the tests (default: yes)]))
 # Fallback to --with-tests
 AC_ARG_WITH(tests, AS_HELP_STRING([--with-tests], [Build NetworkManager tests (deprecated)]))
@@ -748,7 +748,6 @@ AS_IF([test "$with_valgrind" == "yes"],
 	[AC_PATH_PROGS(with_valgrind, valgrind, no)])
 # Add conditionals and substitutions
 AM_CONDITIONAL(ENABLE_TESTS, test "$enable_tests" != "no")
-AM_CONDITIONAL(RUN_ROOT_TESTS, test "$enable_tests" == "root")
 AS_IF([test "$with_valgrind" != "no"],
 	AC_SUBST(VALGRIND_RULES, 'TESTS_ENVIRONMENT = "$(top_srcdir)/tools/run-test-valgrind.sh" "$(LIBTOOL)" "$(with_valgrind)" "$(top_srcdir)/valgrind.suppressions"'),
 	AC_SUBST(VALGRIND_RULES, []))
diff --git a/src/platform/tests/Makefile.am b/src/platform/tests/Makefile.am
index b94e12e..25ab18e 100644
--- a/src/platform/tests/Makefile.am
+++ b/src/platform/tests/Makefile.am
@@ -112,13 +112,5 @@ test_cleanup_linux_LDADD = $(PLATFORM_LDADD)
 # However, we can check whether the fake platform fakes platform behavior
 # correctly.
 
-@VALGRIND_RULES@
-USERTESTS = test-link-fake test-address-fake test-route-fake test-cleanup-fake
-ROOTTESTS = test-link-linux test-address-linux test-route-linux test-cleanup-linux
-
-# If explicitly enabled, we can run the root tests
-if RUN_ROOT_TESTS
-TESTS = $(USERTESTS) $(ROOTTESTS)
-else
-TESTS = $(USERTESTS)
-endif
+#@VALGRIND_RULES@
+TESTS = test-link-fake test-address-fake test-route-fake test-cleanup-fake test-link-linux test-address-linux test-route-linux test-cleanup-linux
diff --git a/src/platform/tests/test-common.c b/src/platform/tests/test-common.c
index 8d54e7a..6f3833b 100644
--- a/src/platform/tests/test-common.c
+++ b/src/platform/tests/test-common.c
@@ -113,6 +113,7 @@ int
 main (int argc, char **argv)
 {
 	int result;
+	const char *program = *argv;
 
 	openlog (G_LOG_DOMAIN, LOG_CONS | LOG_PERROR, LOG_DAEMON);
 	g_type_init ();
@@ -124,6 +125,11 @@ main (int argc, char **argv)
 		}
 	}
 
+	if (SETUP == nm_linux_platform_setup && getuid() != 0) {
+		g_message("Skipping test: requires root privileges (%s)", program);
+		return EXIT_SUCCESS;
+	}
+
 	SETUP ();
 
 	setup_tests ();
