[glib] Fix the Keyfile Test on Windows
- From: Chun-wei Fan <fanchunwei src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] Fix the Keyfile Test on Windows
- Date: Sat, 4 Jan 2014 02:44:59 +0000 (UTC)
commit 3fd6edab66244b100c32dc0a8b0720fe61431dcc
Author: Chun-wei Fan <fanchunwei src gnome org>
Date: Tue Dec 17 10:58:15 2013 +0800
Fix the Keyfile Test on Windows
Windows will not allow one to write to a temp file opened by g_mkstemp()
by opening another fd associated with it before one closes the fd that
is returned by g_mkstemp(), which will cause the test_save test to fail.
Fix this by using a variable to store the fd from g_mkstemp() and checking
it, and call close() on that variable before attempting to call
g_key_file_save_to_file() on the temp file as that will attempt to open
another fd (which would not work) associated with that temp file.
https://bugzilla.gnome.org/show_bug.cgi?id=719344
glib/tests/keyfile.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
---
diff --git a/glib/tests/keyfile.c b/glib/tests/keyfile.c
index e00460b..d3f70c5 100644
--- a/glib/tests/keyfile.c
+++ b/glib/tests/keyfile.c
@@ -1370,13 +1370,16 @@ test_save (void)
gchar *file;
guint64 c;
GError *error = NULL;
+ int fd;
kf = g_key_file_new ();
ok = g_key_file_load_from_data (kf, data, strlen (data), 0, NULL);
g_assert (ok);
file = g_strdup ("key_file_XXXXXX");
- g_mkstemp (file);
+ fd = g_mkstemp (file);
+ g_assert (fd != -1);
+ close (fd);
ok = g_key_file_save_to_file (kf, file, &error);
g_assert (ok);
g_assert_no_error (error);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]