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 <thaller@redhat.com>
This commit is contained in:
Thomas Haller 2014-04-23 16:54:54 +02:00
parent e3784fa618
commit ae863a6954

View file

@ -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;