From b93c2a19f468930c6badf054f79597d99d86e76c Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 16 Apr 2009 12:59:10 +0100 Subject: [PATCH 5/5] fd.o #21219: regression test --- test/core/Makefile.am | 22 ++++++++++++++- test/core/run-test.sh | 1 + test/core/unregister.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 93 insertions(+), 1 deletions(-) create mode 100644 test/core/unregister.c diff --git a/test/core/Makefile.am b/test/core/Makefile.am index 48184a3..3b74837 100644 --- a/test/core/Makefile.am +++ b/test/core/Makefile.am @@ -39,7 +39,16 @@ endif ## we use noinst_PROGRAMS not check_PROGRAMS for TESTS so that we ## build even when not doing "make check" -noinst_PROGRAMS= test-dbus-glib test-service-glib $(THREAD_APPS) peer-server peer-client test-types test-5688 test-variant-recursion +noinst_PROGRAMS = \ + test-dbus-glib \ + test-service-glib \ + $(THREAD_APPS) \ + peer-server \ + peer-client \ + test-types \ + test-5688 \ + test-unregister \ + test-variant-recursion test_5688_SOURCES = \ my-object.c \ @@ -52,6 +61,17 @@ test_5688_LDADD = \ $(top_builddir)/dbus/libdbus-glib-1.la \ $(DBUS_GLIB_THREADS_LIBS) +test_unregister_SOURCES = \ + my-object.c \ + my-object.h \ + my-object-subclass.c \ + my-object-subclass.h \ + my-object-marshal.c \ + unregister.c +test_unregister_LDADD = \ + $(top_builddir)/dbus/libdbus-glib-1.la \ + $(DBUS_GLIB_THREADS_LIBS) + test_dbus_glib_SOURCES= \ my-object-marshal.c \ test-dbus-glib.c diff --git a/test/core/run-test.sh b/test/core/run-test.sh index 8058570..fc8d465 100755 --- a/test/core/run-test.sh +++ b/test/core/run-test.sh @@ -45,6 +45,7 @@ else fi ${DBUS_TOP_BUILDDIR}/libtool --mode=execute $DEBUG $DBUS_TOP_BUILDDIR/test/core/test-types || die "test-types failed" ${DBUS_TOP_BUILDDIR}/libtool --mode=execute $DEBUG $DBUS_TOP_BUILDDIR/test/core/test-5688 || die "test-5688 failed" + ${DBUS_TOP_BUILDDIR}/libtool --mode=execute $DEBUG $DBUS_TOP_BUILDDIR/test/core/test-unregister || die "test-unregister failed" ${DBUS_TOP_BUILDDIR}/libtool --mode=execute $DEBUG $DBUS_TOP_BUILDDIR/test/core/test-dbus-glib || die "test-dbus-glib failed" ${DBUS_TOP_BUILDDIR}/libtool --mode=execute $DEBUG $DBUS_TOP_BUILDDIR/test/core/test-variant-recursion || die "test-variant-recursion failed" fi diff --git a/test/core/unregister.c b/test/core/unregister.c new file mode 100644 index 0000000..0091444 --- /dev/null +++ b/test/core/unregister.c @@ -0,0 +1,71 @@ +/* Feature test for freedesktop.org #21219. + * + * Copyright © 2009 Collabora Ltd. + * Copyright © 2009 Nokia Corporation + * + * In preparation for dbus-glib relicensing (if it ever happens), this file is + * licensed under (at your option) either the AFL v2.1, the GPL v2 or later, + * or an MIT/X11-style license: + * + * Licensed under the Academic Free License version 2.1 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, copy, + * modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include + +#include "my-object.h" + +GMainLoop *loop; + +int +main (int argc, char **argv) +{ + DBusGConnection *connection; + GError *error = NULL; + GObject *obj; + + loop = g_main_loop_new (NULL, FALSE); + + g_type_init (); + g_log_set_always_fatal (G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL); + + connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error); + + if (connection == NULL) + g_error ("failed to get bus: %s %d: %s", g_quark_to_string (error->domain), + error->code, error->message); + + obj = g_object_new (MY_TYPE_OBJECT, NULL); + dbus_g_connection_register_g_object (connection, "/foo", obj); + g_assert (dbus_g_connection_lookup_g_object (connection, "/foo") == obj); + dbus_g_connection_unregister_g_object (connection, obj); + g_assert (dbus_g_connection_lookup_g_object (connection, "/foo") == NULL); + + g_object_unref (obj); + + return 0; +} -- 1.6.2.2