1 /* GLib testing framework examples and tests
3 * Copyright (C) 2008-2010 Red Hat, Inc.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General
16 * Public License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
18 * Boston, MA 02111-1307, USA.
20 * Author: David Zeuthen <davidz@redhat.com>
26 #include <sys/types.h>
27 #include <sys/socket.h>
28 #include <gio/gunixconnection.h>
33 test_unix_from_fd (void)
39 fd = socket (AF_UNIX, SOCK_STREAM, 0);
40 g_assert_cmpint (fd, !=, -1);
43 s = g_socket_new_from_fd (fd, &error);
44 g_assert_no_error (error);
45 g_assert_cmpint (g_socket_get_family (s), ==, G_SOCKET_FAMILY_UNIX);
46 g_assert_cmpint (g_socket_get_socket_type (s), ==, G_SOCKET_TYPE_STREAM);
47 g_assert_cmpint (g_socket_get_protocol (s), ==, G_SOCKET_PROTOCOL_DEFAULT);
52 test_unix_connection (void)
59 fd = socket (AF_UNIX, SOCK_STREAM, 0);
60 g_assert_cmpint (fd, !=, -1);
63 s = g_socket_new_from_fd (fd, &error);
64 g_assert_no_error (error);
65 c = g_socket_connection_factory_create_connection (s);
66 g_assert (G_IS_UNIX_CONNECTION (c));
70 #endif /* G_OS_UNIX */
77 g_test_init (&argc, &argv, NULL);
80 g_test_add_func ("/socket/unix-from-fd", test_unix_from_fd);
81 g_test_add_func ("/socket/unix-connection", test_unix_connection);