[glib: 2/3] Fudge glib fileutils test to pass on Windows
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib: 2/3] Fudge glib fileutils test to pass on Windows
- Date: Tue, 2 Oct 2018 08:56:04 +0000 (UTC)
commit b9f91437bb3e6c7d6c0b3bf5b34802cff7c3aaa6
Author: Руслан Ижбулатов <lrn1986 gmail com>
Date: Tue Aug 21 11:58:15 2018 +0000
Fudge glib fileutils test to pass on Windows
1) Creating a directory with 0666 does not prevent
traversal on Windows (ACL determines the possibility
of traversal, and Windows mkdir() does not translate
permission bits into ACL). Don't do the traversal check on Windows.
2) Creating a file with 0555 also isn't translated into
read-only ACL, Windows sets the read-only attribute instead,
which blocks all changes, including changes to file times.
Add the write permissions on Windows before changing file times.
glib/tests/fileutils.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
---
diff --git a/glib/tests/fileutils.c b/glib/tests/fileutils.c
index c2a553bd5..3ef6615d0 100644
--- a/glib/tests/fileutils.c
+++ b/glib/tests/fileutils.c
@@ -913,9 +913,12 @@ test_stdio_wrappers (void)
cwd = g_get_current_dir ();
path = g_build_filename (cwd, "mkdir-test", NULL);
g_free (cwd);
+#ifndef G_OS_WIN32
+ /* 0666 on directories means nothing to Windows, it only obeys ACLs */
ret = g_chdir (path);
g_assert_cmpint (errno, ==, EACCES);
g_assert_cmpint (ret, ==, -1);
+#endif
ret = g_chmod (path, 0777);
g_assert_cmpint (ret, ==, 0);
ret = g_chdir (path);
@@ -945,6 +948,15 @@ test_stdio_wrappers (void)
g_close (ret, &error);
g_assert_no_error (error);
+#ifdef G_OS_WIN32
+ /* On Windows the 5 permission bit results in a read-only file
+ * that cannot be modified in any way (attribute changes included).
+ * Remove the read-only attribute via chmod().
+ */
+ ret = g_chmod ("test-create", 0666);
+ g_assert_cmpint (ret, ==, 0);
+#endif
+
ut.actime = ut.modtime = (time_t)0;
ret = g_utime ("test-create", &ut);
g_assert_cmpint (ret, ==, 0);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]