From ae863a69545fcfd995cdda661d216149efddd284 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Wed, 23 Apr 2014 16:54:54 +0200 Subject: [PATCH] platform/test: allow running root tests as sudo Call to nmtst_reexec_sudo(), which allows you to specify a program via environment variable to exec the test. This is useful to exec the test program with sudo. NMTST_DEBUG="no-debug,sudo-cmd=$PWD/tools/test-sudo-wrapper.sh" make -C src/platform/tests/ check Signed-off-by: Thomas Haller --- src/platform/tests/test-common.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/platform/tests/test-common.c b/src/platform/tests/test-common.c index 1c8550593b..8ca77f21db 100644 --- a/src/platform/tests/test-common.c +++ b/src/platform/tests/test-common.c @@ -150,6 +150,9 @@ main (int argc, char **argv) nmtst_init (&argc, &argv, NULL, "ALL"); if (SETUP == nm_linux_platform_setup && getuid() != 0) { + /* Try to exec as sudo, this function does not return, if a sudo-cmd is set. */ + nmtst_reexec_sudo (); + #ifdef REQUIRE_ROOT_TESTS g_message ("Fail test: requires root privileges (%s)", program); return EXIT_FAILURE;