mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-27 16:06:16 +01:00
tests: Fix assertion failures when running fileutils test as root
This commit is contained in:
parent
d5d5fb9b5f
commit
e2973c9a41
@ -812,6 +812,9 @@ static void
|
|||||||
test_mkdir_with_parents (void)
|
test_mkdir_with_parents (void)
|
||||||
{
|
{
|
||||||
gchar *cwd, *new_path;
|
gchar *cwd, *new_path;
|
||||||
|
#ifndef G_OS_WIN32
|
||||||
|
gboolean can_override_dac = check_cap_dac_override (NULL);
|
||||||
|
#endif
|
||||||
if (g_test_verbose())
|
if (g_test_verbose())
|
||||||
g_printerr ("checking g_mkdir_with_parents() in subdir ./hum/");
|
g_printerr ("checking g_mkdir_with_parents() in subdir ./hum/");
|
||||||
test_mkdir_with_parents_1 ("hum");
|
test_mkdir_with_parents_1 ("hum");
|
||||||
@ -838,10 +841,20 @@ test_mkdir_with_parents (void)
|
|||||||
g_remove ("./test");
|
g_remove ("./test");
|
||||||
|
|
||||||
#ifndef G_OS_WIN32
|
#ifndef G_OS_WIN32
|
||||||
g_assert_cmpint (g_mkdir_with_parents ("/usr/b/c", 0), ==, -1);
|
if (can_override_dac)
|
||||||
/* EPERM or EROFS may be returned if the filesystem as a whole is read-only */
|
{
|
||||||
if (errno != EPERM && errno != EROFS)
|
g_assert_cmpint (g_mkdir_with_parents ("/usr/b/c", 0), ==, 0);
|
||||||
g_assert_cmpint (errno, ==, EACCES);
|
g_remove ("/usr/b/c");
|
||||||
|
g_remove ("/usr/b");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g_assert_cmpint (g_mkdir_with_parents ("/usr/b/c", 0), ==, -1);
|
||||||
|
/* EPERM or EROFS may be returned if the filesystem as a whole is read-only */
|
||||||
|
if (errno != EPERM && errno != EROFS)
|
||||||
|
g_assert_cmpint (errno, ==, EACCES);
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
g_assert_cmpint (g_mkdir_with_parents (NULL, 0), ==, -1);
|
g_assert_cmpint (g_mkdir_with_parents (NULL, 0), ==, -1);
|
||||||
|
Loading…
Reference in New Issue
Block a user