diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2010-01-02 19:19:06 -0800 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2010-01-02 19:19:06 -0800 |
commit | b4e8b10030d97b1c4a2416b2b998f4f9ba8436e7 (patch) | |
tree | 4bdce44f677d4431cbfc4eabea5fc1da757006c6 | |
parent | 8c28004e03f20b4ca78f9a7d2e28ac1d9e4e5619 (diff) | |
download | connman-b4e8b10030d97b1c4a2416b2b998f4f9ba8436e7.tar.gz connman-b4e8b10030d97b1c4a2416b2b998f4f9ba8436e7.tar.bz2 connman-b4e8b10030d97b1c4a2416b2b998f4f9ba8436e7.zip |
Add test program for D-Bus library memory leak checks
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | Makefile.am | 5 | ||||
-rw-r--r-- | tools/dbus-test.c | 85 |
3 files changed, 90 insertions, 1 deletions
@@ -45,6 +45,7 @@ tools/addr-test tools/tap-test tools/polkit-test tools/supplicant-test +tools/dbus-test doc/*.bak doc/*.stamp doc/connman.* diff --git a/Makefile.am b/Makefile.am index 92e354b5..f294c254 100644 --- a/Makefile.am +++ b/Makefile.am @@ -113,7 +113,7 @@ client_cm_LDADD = @DBUS_LIBS@ endif if TOOLS -noinst_PROGRAMS += tools/wifi-scan tools/supplicant-test \ +noinst_PROGRAMS += tools/wifi-scan tools/supplicant-test tools/dbus-test \ tools/addr-test tools/tap-test tools/polkit-test tools_wifi_scan_LDADD = @GLIB_LIBS@ @NETLINK_LIBS@ @@ -123,6 +123,9 @@ tools_supplicant_test_SOURCES = $(gdbus_sources) tools/supplicant-test.c \ tools/supplicant.h tools/supplicant.c tools_supplicant_test_LDADD = @GLIB_LIBS@ @DBUS_LIBS@ +tools_dbus_test_SOURCES = $(gdbus_sources) tools/dbus-test.c +tools_dbus_test_LDADD = @GLIB_LIBS@ @DBUS_LIBS@ + tools_polkit_test_LDADD = @DBUS_LIBS@ endif diff --git a/tools/dbus-test.c b/tools/dbus-test.c new file mode 100644 index 00000000..f9f03fe7 --- /dev/null +++ b/tools/dbus-test.c @@ -0,0 +1,85 @@ +/* + * + * Connection Manager + * + * Copyright (C) 2007-2010 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <signal.h> + +#include <gdbus.h> + +#define DBG(fmt, arg...) do { \ + printf("%s() " fmt "\n", __FUNCTION__ , ## arg); \ +} while (0) + +static GMainLoop *main_loop = NULL; + +static void sig_term(int sig) +{ + g_main_loop_quit(main_loop); +} + +static void disconnect_callback(DBusConnection *conn, void *user_data) +{ + printf("D-Bus disconnect\n"); + + g_main_loop_quit(main_loop); +} + +int main(int argc, char *argv[]) +{ + DBusConnection *conn; + DBusError err; + struct sigaction sa; + + main_loop = g_main_loop_new(NULL, FALSE); + + dbus_error_init(&err); + + conn = g_dbus_setup_bus(DBUS_BUS_SYSTEM, NULL, &err); + if (conn == NULL) { + if (dbus_error_is_set(&err) == TRUE) { + fprintf(stderr, "%s\n", err.message); + dbus_error_free(&err); + } else + fprintf(stderr, "Can't register with system bus\n"); + exit(1); + } + + g_dbus_set_disconnect_function(conn, disconnect_callback, NULL, NULL); + + memset(&sa, 0, sizeof(sa)); + sa.sa_handler = sig_term; + sigaction(SIGINT, &sa, NULL); + sigaction(SIGTERM, &sa, NULL); + + g_main_loop_run(main_loop); + + dbus_connection_unref(conn); + + g_main_loop_unref(main_loop); + + return 0; +} |