From c8cbfd551c61bc05717e87d1496fd3108dbc9125 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Thu, 12 Apr 2018 12:42:48 +0100 Subject: [PATCH] tests: Skip some of the fileutils tests when running as root MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The tests which check permissions and errors like EACCES aren’t going to work as root, since root always has permission to do things. Skip them if running as root. Signed-off-by: Philip Withnall https://bugzilla.gnome.org/show_bug.cgi?id=766390 --- glib/tests/fileutils.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/glib/tests/fileutils.c b/glib/tests/fileutils.c index 78fca7dd2..555c58edf 100644 --- a/glib/tests/fileutils.c +++ b/glib/tests/fileutils.c @@ -880,6 +880,13 @@ test_stdio_wrappers (void) struct utimbuf ut; GError *error = NULL; + /* The permissions tests here don’t work when running as root. */ + if (getuid () == 0 || geteuid () == 0) + { + g_test_skip ("File permissions tests cannot be run as root"); + return; + } + g_remove ("mkdir-test/test-create"); ret = g_rmdir ("mkdir-test"); g_assert (ret == 0 || errno == ENOENT);