summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2011-11-03 12:22:43 +0000
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2012-11-19 15:34:58 +0000
commit18a6eb96849b1931f478bfba0823f0c5a7d24fbe (patch)
treeb838e0063312f30e759b83232b03c0395d2e5075
parent82c724ab629d7aaea7f7461c375407ac41c0c09a (diff)
downloaddbus-glib-18a6eb96849b1931f478bfba0823f0c5a7d24fbe.tar.gz
Turn _dbus_glib_test into a standalone test case, since it only tests public API
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=40711 Reviewed-by: Dan Williams <dcbw@redhat.com>
-rw-r--r--.gitignore1
-rw-r--r--dbus/dbus-glib.c29
-rw-r--r--dbus/dbus-gtest.c4
-rw-r--r--dbus/dbus-gtest.h1
-rw-r--r--test/Makefile.am37
-rw-r--r--test/errors.c79
6 files changed, 111 insertions, 40 deletions
diff --git a/.gitignore b/.gitignore
index e33ce89..d8264b3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -191,6 +191,7 @@ missing
stamp-h1
test/Makefile
test/Makefile.in
+/test/test-errors
test/core/Makefile
test/core/Makefile.in
test/core/my-object-marshal.c
diff --git a/dbus/dbus-glib.c b/dbus/dbus-glib.c
index 4ca8db6..df36ecf 100644
--- a/dbus/dbus-glib.c
+++ b/dbus/dbus-glib.c
@@ -367,32 +367,3 @@ dbus_g_message_get_message (DBusGMessage *gmessage)
{
return DBUS_MESSAGE_FROM_G_MESSAGE (gmessage);
}
-
-#ifdef DBUS_BUILD_TESTS
-
-/*
- * Unit test for general glib stuff
- * Returns: %TRUE on success.
- */
-gboolean
-_dbus_glib_test (const char *test_data_dir)
-{
- DBusError err;
- GError *gerror = NULL;
-
- dbus_error_init (&err);
- dbus_set_error_const (&err, DBUS_ERROR_NO_MEMORY, "Out of memory!");
-
- dbus_set_g_error (&gerror, &err);
- g_assert (gerror != NULL);
- g_assert (gerror->domain == DBUS_GERROR);
- g_assert (gerror->code == DBUS_GERROR_NO_MEMORY);
- g_assert (!strcmp (gerror->message, "Out of memory!"));
-
- dbus_error_init (&err);
- g_clear_error (&gerror);
-
- return TRUE;
-}
-
-#endif /* DBUS_BUILD_TESTS */
diff --git a/dbus/dbus-gtest.c b/dbus/dbus-gtest.c
index 9783efd..59dbe5b 100644
--- a/dbus/dbus-gtest.c
+++ b/dbus/dbus-gtest.c
@@ -67,10 +67,6 @@ dbus_glib_internal_do_not_use_run_tests (const char *test_data_dir)
if (!_dbus_gvalue_test (test_data_dir))
die ("gvalue utils");
- printf ("%s: running glib tests\n", "dbus-glib-test");
- if (!_dbus_glib_test (test_data_dir))
- die ("glib");
-
printf ("%s: running mainloop integration tests\n", "dbus-glib-test");
if (!_dbus_gmain_test (test_data_dir))
die ("gmain");
diff --git a/dbus/dbus-gtest.h b/dbus/dbus-gtest.h
index 7a57b51..b94f506 100644
--- a/dbus/dbus-gtest.h
+++ b/dbus/dbus-gtest.h
@@ -29,7 +29,6 @@
gboolean _dbus_gmain_test (const char *test_data_dir);
gboolean _dbus_gobject_test (const char *test_data_dir);
gboolean _dbus_gutils_test (const char *test_data_dir);
-gboolean _dbus_glib_test (const char *test_data_dir);
gboolean _dbus_gvalue_test (const char *test_data_dir);
gboolean _dbus_gvalue_utils_test (const char *test_data_dir);
diff --git a/test/Makefile.am b/test/Makefile.am
index 1ffd63e..0905736 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -5,15 +5,27 @@ INCLUDES = \
-I$(top_srcdir) \
-I$(top_builddir) \
-I$(top_builddir)/dbus \
- $(DBUS_CFLAGS)
+ $(DBUS_CFLAGS) \
+ $(DBUS_GLIB_CFLAGS) \
+ $(NULL)
+
+LDADD = \
+ $(top_builddir)/dbus/libdbus-glib-1.la \
+ $(DBUS_GLIB_LIBS) \
+ $(NULL)
if DBUS_BUILD_TESTS
-TEST_BINARIES=test-service
-else
-TEST_BINARIES=
+test_programs = \
+ test-errors \
+ $(NULL)
+
+# not actually tests, but used by tests
+test_related_programs = \
+ test-service \
+ $(NULL)
endif
-noinst_PROGRAMS= $(TEST_BINARIES)
+test_errors_SOURCES = errors.c
test_service_SOURCES= \
test-service.c
@@ -23,4 +35,17 @@ test_service_LDADD=$(DBUS_LIBS)
EXTRA_DIST = data/nested-introspect.xml test-compile-nested.sh
TESTS_ENVIRONMENT=top_builddir=$(top_builddir) srcdir=$(srcdir)
-TESTS = test-compile-nested.sh
+
+test_scripts = \
+ test-compile-nested.sh \
+ $(NULL)
+
+TESTS = \
+ $(test_programs) \
+ $(test_scripts) \
+ $(NULL)
+
+noinst_PROGRAMS = \
+ $(test_programs) \
+ $(test_related_programs) \
+ $(NULL)
diff --git a/test/errors.c b/test/errors.c
new file mode 100644
index 0000000..ba08595
--- /dev/null
+++ b/test/errors.c
@@ -0,0 +1,79 @@
+/* Regression test for dbus-glib GError mapping
+ *
+ * Copyright © 2004 Red Hat, Inc.
+ * Copyright © 2011 Nokia Corporation
+ *
+ * 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.
+ *
+ * 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 Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#include <config.h>
+
+#include <string.h>
+
+#include <glib.h>
+
+#include <dbus/dbus-glib.h>
+#include <dbus/dbus-glib-lowlevel.h>
+
+typedef struct {
+ int dummy;
+} Fixture;
+
+static void
+setup (Fixture *f G_GNUC_UNUSED,
+ gconstpointer context G_GNUC_UNUSED)
+{
+}
+
+static void
+test_errors (Fixture *f G_GNUC_UNUSED,
+ gconstpointer context G_GNUC_UNUSED)
+{
+ DBusError err;
+ GError *gerror = NULL;
+
+ dbus_error_init (&err);
+ dbus_set_error_const (&err, DBUS_ERROR_NO_MEMORY, "Out of memory!");
+
+ dbus_set_g_error (&gerror, &err);
+ g_assert (gerror != NULL);
+ g_assert (gerror->domain == DBUS_GERROR);
+ g_assert (gerror->code == DBUS_GERROR_NO_MEMORY);
+ g_assert (!strcmp (gerror->message, "Out of memory!"));
+
+ dbus_error_init (&err);
+ g_clear_error (&gerror);
+}
+
+static void
+teardown (Fixture *f G_GNUC_UNUSED,
+ gconstpointer addr G_GNUC_UNUSED)
+{
+}
+
+int
+main (int argc,
+ char **argv)
+{
+ g_test_init (&argc, &argv, NULL);
+ g_type_init ();
+
+ g_test_add ("/errors", Fixture, NULL, setup, test_errors, teardown);
+
+ return g_test_run ();
+}