[glib] tests: Skip some of the fileutils tests when running as root



commit c8cbfd551c61bc05717e87d1496fd3108dbc9125
Author: Philip Withnall <withnall endlessm com>
Date:   Thu Apr 12 12:42:48 2018 +0100

    tests: Skip some of the fileutils tests when running as root
    
    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 <withnall endlessm com>
    
    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);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]