[glib] Improve glib-unix test coverage
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] Improve glib-unix test coverage
- Date: Wed, 1 Jan 2014 23:03:12 +0000 (UTC)
commit d264d32d3b0a5080bc41186d3ef11dd4373af2b5
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Dec 29 13:47:43 2013 -0500
Improve glib-unix test coverage
glib/tests/unix.c | 33 +++++++++++++++++++++++++++++++++
1 files changed, 33 insertions(+), 0 deletions(-)
---
diff --git a/glib/tests/unix.c b/glib/tests/unix.c
index 273b4d4..3543458 100644
--- a/glib/tests/unix.c
+++ b/glib/tests/unix.c
@@ -64,6 +64,38 @@ test_error (void)
g_clear_error (&error);
}
+static void
+test_nonblocking (void)
+{
+ GError *error = NULL;
+ int pipefd[2];
+ gboolean res;
+ int flags;
+
+ res = g_unix_open_pipe (pipefd, FD_CLOEXEC, &error);
+ g_assert (res);
+ g_assert_no_error (error);
+
+ res = g_unix_set_fd_nonblocking (pipefd[0], TRUE, &error);
+ g_assert (res);
+ g_assert_no_error (error);
+
+ flags = fcntl (pipefd[0], F_GETFL);
+ g_assert_cmpint (flags, !=, -1);
+ g_assert (flags & O_NONBLOCK);
+
+ res = g_unix_set_fd_nonblocking (pipefd[0], FALSE, &error);
+ g_assert (res);
+ g_assert_no_error (error);
+
+ flags = fcntl (pipefd[0], F_GETFL);
+ g_assert_cmpint (flags, !=, -1);
+ g_assert (!(flags & O_NONBLOCK));
+
+ close (pipefd[0]);
+ close (pipefd[1]);
+}
+
static gboolean sig_received = FALSE;
static gboolean sig_timeout = FALSE;
static int sig_counter = 0;
@@ -221,6 +253,7 @@ main (int argc,
g_test_add_func ("/glib-unix/pipe", test_pipe);
g_test_add_func ("/glib-unix/error", test_error);
+ g_test_add_func ("/glib-unix/nonblocking", test_nonblocking);
g_test_add_func ("/glib-unix/sighup", test_sighup);
g_test_add_func ("/glib-unix/sigterm", test_sigterm);
g_test_add_func ("/glib-unix/sighup_again", test_sighup);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]