diff options
author | hanhuihui <h30015730@china.huawei.com> | 2023-05-11 14:59:34 +0800 |
---|---|---|
committer | Philip Withnall <pwithnall@endlessos.org> | 2023-05-11 11:45:36 +0100 |
commit | d5d5fb9b5f04eacd31ea6bb013e9dec222e6a741 (patch) | |
tree | 7f2007f1153c1a676ed6b3f7e189a4dbe9081bd8 | |
parent | a14803d06d89f5e73bae8acf5d78b365ecfad151 (diff) | |
download | glib-d5d5fb9b5f04eacd31ea6bb013e9dec222e6a741.tar.gz |
tests: Move a function to allow looking at CAP_DAC_OVERRIDE
This introduces no functional changes but allows `CAP_DAC_OVERRIDE` to
be used in a subsequent commit.
-rw-r--r-- | glib/tests/fileutils.c | 80 |
1 files changed, 40 insertions, 40 deletions
diff --git a/glib/tests/fileutils.c b/glib/tests/fileutils.c index b9149720d..0d6012a5f 100644 --- a/glib/tests/fileutils.c +++ b/glib/tests/fileutils.c @@ -723,46 +723,6 @@ test_mkdir_with_parents_1 (const gchar *base) g_free (p0); } -static void -test_mkdir_with_parents (void) -{ - gchar *cwd, *new_path; - if (g_test_verbose()) - g_printerr ("checking g_mkdir_with_parents() in subdir ./hum/"); - test_mkdir_with_parents_1 ("hum"); - g_remove ("hum"); - if (g_test_verbose()) - g_printerr ("checking g_mkdir_with_parents() in subdir ./hii///haa/hee/"); - test_mkdir_with_parents_1 ("./hii///haa/hee///"); - g_remove ("hii/haa/hee"); - g_remove ("hii/haa"); - g_remove ("hii"); - cwd = g_get_current_dir (); - if (g_test_verbose()) - g_printerr ("checking g_mkdir_with_parents() in cwd: %s", cwd); - test_mkdir_with_parents_1 (cwd); - - new_path = g_build_filename (cwd, "new", NULL); - g_assert_cmpint (g_mkdir_with_parents (new_path, 0), ==, 0); - g_assert_cmpint (g_rmdir (new_path), ==, 0); - g_free (new_path); - g_free (cwd); - - g_assert_cmpint (g_mkdir_with_parents ("./test", 0), ==, 0); - g_assert_cmpint (g_mkdir_with_parents ("./test", 0), ==, 0); - g_remove ("./test"); - -#ifndef G_OS_WIN32 - 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 - - g_assert_cmpint (g_mkdir_with_parents (NULL, 0), ==, -1); - g_assert_cmpint (errno, ==, EINVAL); -} - /* * check_cap_dac_override: * @tmpdir: (nullable): A temporary directory in which we can create @@ -848,6 +808,46 @@ check_cap_dac_override (const char *tmpdir) #endif } +static void +test_mkdir_with_parents (void) +{ + gchar *cwd, *new_path; + if (g_test_verbose()) + g_printerr ("checking g_mkdir_with_parents() in subdir ./hum/"); + test_mkdir_with_parents_1 ("hum"); + g_remove ("hum"); + if (g_test_verbose()) + g_printerr ("checking g_mkdir_with_parents() in subdir ./hii///haa/hee/"); + test_mkdir_with_parents_1 ("./hii///haa/hee///"); + g_remove ("hii/haa/hee"); + g_remove ("hii/haa"); + g_remove ("hii"); + cwd = g_get_current_dir (); + if (g_test_verbose()) + g_printerr ("checking g_mkdir_with_parents() in cwd: %s", cwd); + test_mkdir_with_parents_1 (cwd); + + new_path = g_build_filename (cwd, "new", NULL); + g_assert_cmpint (g_mkdir_with_parents (new_path, 0), ==, 0); + g_assert_cmpint (g_rmdir (new_path), ==, 0); + g_free (new_path); + g_free (cwd); + + g_assert_cmpint (g_mkdir_with_parents ("./test", 0), ==, 0); + g_assert_cmpint (g_mkdir_with_parents ("./test", 0), ==, 0); + g_remove ("./test"); + +#ifndef G_OS_WIN32 + 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 + + g_assert_cmpint (g_mkdir_with_parents (NULL, 0), ==, -1); + g_assert_cmpint (errno, ==, EINVAL); +} + /* Reproducer for https://gitlab.gnome.org/GNOME/glib/issues/1852 */ static void test_mkdir_with_parents_permission (void) |