mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-03-12 10:45:13 +01:00
Don't fail a couple of tests when running as root
root can access and write to a directory when it doesn't have exec and write permissions respectively. So expect the tests that check that to succeed rather than to fail when running as root. https://bugzilla.gnome.org/show_bug.cgi?id=552912
This commit is contained in:
parent
4535683b3f
commit
202d7d37d6
@ -23,6 +23,8 @@
|
||||
#include <glib/glib.h>
|
||||
#include <gio/gio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
@ -100,6 +102,7 @@ static const struct StructureItem sample_struct[] = {
|
||||
{"lost_symlink", "nowhere", G_FILE_TYPE_SYMBOLIC_LINK, G_FILE_CREATE_NONE, 0, 0, TEST_COPY | TEST_DELETE_NORMAL | TEST_OPEN | TEST_INVALID_SYMLINK},
|
||||
};
|
||||
|
||||
static gboolean test_suite;
|
||||
static gboolean write_test;
|
||||
static gboolean verbose;
|
||||
static gboolean posix_compat;
|
||||
@ -714,10 +717,19 @@ do_copy_move (GFile * root, struct StructureItem item, const char *target_dir,
|
||||
/* source or target path permission denied */
|
||||
else if (((item.extra_flags & TEST_NO_ACCESS) == TEST_NO_ACCESS) ||
|
||||
(extra_flags == TEST_NO_ACCESS))
|
||||
{
|
||||
/* This works for root, see bug #552912 */
|
||||
if (test_suite && getuid () == 0)
|
||||
{
|
||||
g_assert_cmpint (res, ==, TRUE);
|
||||
g_assert_no_error (error);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_assert_cmpint (res, ==, FALSE);
|
||||
g_assert_error (error, G_IO_ERROR, G_IO_ERROR_PERMISSION_DENIED);
|
||||
}
|
||||
}
|
||||
/* no error should be found, all exceptions defined above */
|
||||
else
|
||||
{
|
||||
@ -1111,6 +1123,7 @@ main (int argc, char *argv[])
|
||||
{NULL}
|
||||
};
|
||||
|
||||
test_suite = FALSE;
|
||||
verbose = FALSE;
|
||||
write_test = FALSE;
|
||||
only_create_struct = FALSE;
|
||||
@ -1124,6 +1137,7 @@ main (int argc, char *argv[])
|
||||
/* no extra parameters specified, assume we're executed from glib test suite */
|
||||
if (argc < 2)
|
||||
{
|
||||
test_suite = TRUE;
|
||||
verbose = TRUE;
|
||||
write_test = TRUE;
|
||||
only_create_struct = FALSE;
|
||||
|
Loading…
x
Reference in New Issue
Block a user