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 <gio/gunixsocketaddress.h>
29 /* ---------------------------------------------------------------------------------------------------- */
32 test_empty_address (void)
36 g_dbus_address_get_stream_sync ("",
40 g_assert_error (error, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT);
46 test_unix_address (void)
48 g_assert (!g_dbus_is_supported_address ("some-imaginary-transport:foo=bar", NULL));
49 g_assert (g_dbus_is_supported_address ("unix:path=/tmp/dbus-test", NULL));
50 g_assert (g_dbus_is_supported_address ("unix:abstract=/tmp/dbus-another-test", NULL));
51 g_assert (g_dbus_is_address ("unix:foo=bar"));
52 g_assert (!g_dbus_is_supported_address ("unix:foo=bar", NULL));
53 g_assert (!g_dbus_is_address ("unix:path=/foo;abstract=/bar"));
54 g_assert (!g_dbus_is_supported_address ("unix:path=/foo;abstract=/bar", NULL));
55 g_assert (g_dbus_is_supported_address ("unix:path=/tmp/concrete;unix:abstract=/tmp/abstract", NULL));
56 g_assert (g_dbus_is_address ("some-imaginary-transport:foo=bar"));
58 g_assert (g_dbus_is_address ("some-imaginary-transport:foo=bar;unix:path=/this/is/valid"));
59 g_assert (!g_dbus_is_supported_address ("some-imaginary-transport:foo=bar;unix:path=/this/is/valid", NULL));
64 test_nonce_tcp_address (void)
66 g_assert (g_dbus_is_supported_address ("nonce-tcp:host=localhost,port=42,noncefile=/foo/bar", NULL));
67 g_assert (g_dbus_is_supported_address ("nonce-tcp:host=localhost,port=42,noncefile=/foo/bar,family=ipv6", NULL));
68 g_assert (g_dbus_is_supported_address ("nonce-tcp:host=localhost,port=42,noncefile=/foo/bar,family=ipv4", NULL));
70 g_assert (!g_dbus_is_supported_address ("nonce-tcp:host=localhost,port=42,noncefile=/foo/bar,family=blah", NULL));
71 g_assert (!g_dbus_is_supported_address ("nonce-tcp:host=localhost,port=420000,noncefile=/foo/bar,family=ipv4", NULL));
72 g_assert (!g_dbus_is_supported_address ("nonce-tcp:host=,port=x42,noncefile=/foo/bar,family=ipv4", NULL));
73 g_assert (!g_dbus_is_supported_address ("nonce-tcp:host=,port=42x,noncefile=/foo/bar,family=ipv4", NULL));
74 g_assert (!g_dbus_is_supported_address ("nonce-tcp:host=,port=420000,noncefile=/foo/bar,family=ipv4", NULL));
82 g_test_init (&argc, &argv, NULL);
84 g_test_add_func ("/gdbus/empty-address", test_empty_address);
86 g_test_add_func ("/gdbus/unix-address", test_unix_address);
88 g_test_add_func ("/gdbus/nonce-tcp-address", test_nonce_tcp_address);