From 7b4ac5de11d90e9f7048f057d70d3da5104388b6 Mon Sep 17 00:00:00 2001 From: Havoc Pennington Date: Mon, 1 Sep 2003 18:02:06 +0000 Subject: 2003-09-01 Havoc Pennington * glib/Makefile.am: rearrange a bunch of files and get "make check" framework set up --- ChangeLog | 5 ++ doc/TODO | 3 ++ glib/Makefile.am | 30 ++++++++++-- glib/dbus-compiler-main.c | 48 ------------------ glib/dbus-glib-tool.c | 77 +++++++++++++++++++++++++++++ glib/dbus-gmain.c | 19 +++++++- glib/dbus-gparser.c | 121 ++++++++++++++++++++++++++++++++++++++++++++++ glib/dbus-gparser.h | 59 ++++++++++++++++++++++ 8 files changed, 308 insertions(+), 54 deletions(-) delete mode 100644 glib/dbus-compiler-main.c create mode 100644 glib/dbus-glib-tool.c create mode 100644 glib/dbus-gparser.c create mode 100644 glib/dbus-gparser.h diff --git a/ChangeLog b/ChangeLog index 5965b50a..f57c964a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2003-09-01 Havoc Pennington + + * glib/Makefile.am: rearrange a bunch of files and get "make + check" framework set up + 2003-08-31 Havoc Pennington * fix build with --disable-tests diff --git a/doc/TODO b/doc/TODO index 26e85a3e..6b308d39 100644 --- a/doc/TODO +++ b/doc/TODO @@ -79,3 +79,6 @@ - the invalid messages in the test suite are all useless because they are invalid for the wrong reasons due to protocol changes + + - Nuke the org.freedesktop.Broadcast service; instead, + just broadcast messages of type signal diff --git a/glib/Makefile.am b/glib/Makefile.am index 8cc09eb7..3d67db2f 100644 --- a/glib/Makefile.am +++ b/glib/Makefile.am @@ -11,18 +11,24 @@ dbusinclude_HEADERS= \ libdbus_glib_1_la_SOURCES = \ dbus-gmain.c \ dbus-gproxy.c \ + dbus-gtest.c \ + dbus-gtest.h \ dbus-gthread.c libdbus_glib_1_la_LIBADD= $(DBUS_GLIB_LIBS) $(top_builddir)/dbus/libdbus-1.la -bin_PROGRAMS=dbus-glib-compiler +bin_PROGRAMS=dbus-glib-tool -dbus_glib_compiler_SOURCES = \ +dbus_glib_tool_SOURCES = \ dbus-gidl.c \ dbus-gidl.h \ - dbus-compiler-main.c + dbus-glib-tool.c \ + dbus-gparser.c \ + dbus-gparser.h \ + dbus-gtool-test.h -dbus_glib_compiler_LDADD= libdbus-glib-1.la $(DBUS_GLIB_LIBS) $(top_builddir)/dbus/libdbus-1.la + +dbus_glib_tool_LDADD= libdbus-glib-1.la $(DBUS_GLIB_LIBS) $(top_builddir)/dbus/libdbus-1.la if DBUS_BUILD_TESTS @@ -42,15 +48,29 @@ test_thread_client_SOURCES= \ test_thread_client_LDADD= $(DBUS_GLIB_THREADS_LIBS) $(top_builddir)/glib/libdbus-glib-1.la endif -noinst_PROGRAMS= test-dbus-glib $(THREAD_APPS) +## we use noinst_PROGRAMS not check_PROGRAMS for TESTS so that we +## build even when not doing "make check" +noinst_PROGRAMS= $(TESTS) test-dbus-glib $(THREAD_APPS) test_dbus_glib_SOURCES= \ test-dbus-glib.c test_dbus_glib_LDADD= $(top_builddir)/glib/libdbus-glib-1.la +## note that TESTS has special meaning (stuff to use in make check) +## so if adding tests not to be run in make check, don't add them to +## TESTS +TESTS_ENVIRONMENT=DBUS_TEST_DATA=$(top_builddir)/test/data DBUS_TEST_HOMEDIR=$(top_builddir)/dbus +TESTS=dbus-glib-test + +dbus_glib_test_SOURCES= \ + dbus-gtest-main.c + +dbus_glib_test_LDADD= $(top_builddir)/glib/libdbus-glib-1.la + else ### not building tests +TESTS= if HAVE_GLIB_THREADS noinst_PROGRAMS=test-profile diff --git a/glib/dbus-compiler-main.c b/glib/dbus-compiler-main.c deleted file mode 100644 index d8bf7bde..00000000 --- a/glib/dbus-compiler-main.c +++ /dev/null @@ -1,48 +0,0 @@ -/* -*- mode: C; c-file-style: "gnu" -*- */ -/* dbus-compiler-main.c main() for GLib stubs/skels generator - * - * Copyright (C) 2003 Red Hat, Inc. - * - * Licensed under the Academic Free License version 1.2 - * - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#include "dbus-gidl.h" - -int -main (int argc, char **argv) -{ - - - return 0; -} - -#ifdef DBUS_BUILD_TESTS - -/** - * @ingroup DBusGCompiler - * Unit test for GLib stubs/skels compiler - * @returns #TRUE on success. - */ -dbus_bool_t -_dbus_gcompiler_test (void) -{ - - return TRUE; -} - -#endif /* DBUS_BUILD_TESTS */ diff --git a/glib/dbus-glib-tool.c b/glib/dbus-glib-tool.c new file mode 100644 index 00000000..aaf133d4 --- /dev/null +++ b/glib/dbus-glib-tool.c @@ -0,0 +1,77 @@ +/* -*- mode: C; c-file-style: "gnu" -*- */ +/* dbus-compiler-main.c main() for GLib stubs/skels generator + * + * Copyright (C) 2003 Red Hat, Inc. + * + * Licensed under the Academic Free License version 1.2 + * + * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "dbus-gidl.h" +#include + +#ifdef DBUS_BUILD_TESTS +static void run_all_tests (const char *test_data_dir); +#endif + +int +main (int argc, char **argv) +{ + setlocale(LC_ALL, ""); + + return 0; +} + +#ifdef DBUS_BUILD_TESTS +static void +test_die (const char *failure) +{ + fprintf (stderr, "Unit test failed: %s\n", failure); + exit (1); +} + +static void +run_all_tests (const char *test_data_dir) +{ + if (test_data_dir == NULL) + test_data_dir = _dbus_getenv ("DBUS_TEST_DATA"); + + if (test_data_dir != NULL) + printf ("Test data in %s\n", test_data_dir); + else + printf ("No test data!\n"); + + printf ("%s: running gtool tests\n", "dbus-glib-tool"); + if (!_dbus_gtool_test (test_data_dir)) + test_die ("gtool"); + + printf ("%s: completed successfully\n", "dbus-glib-test"); +} + +/** + * @ingroup DBusGTool + * Unit test for GLib utility tool + * @returns #TRUE on success. + */ +dbus_bool_t +_dbus_gtool_test (const char *test_data_dir) +{ + + return TRUE; +} + +#endif /* DBUS_BUILD_TESTS */ diff --git a/glib/dbus-gmain.c b/glib/dbus-gmain.c index 9b14049d..36c6c6b4 100644 --- a/glib/dbus-gmain.c +++ b/glib/dbus-gmain.c @@ -21,8 +21,9 @@ * */ +#include #include "dbus-glib.h" -#include +#include "dbus-gtest.h" /** * @defgroup DBusGLib GLib bindings @@ -491,3 +492,19 @@ dbus_server_setup_with_g_main (DBusServer *server, } /** @} */ /* end of public API */ + +#ifdef DBUS_BUILD_TESTS + +/** + * @ingroup DBusGLibInternals + * Unit test for GLib main loop integration + * @returns #TRUE on success. + */ +dbus_bool_t +_dbus_gmain_test (const char *test_data_dir) +{ + + return TRUE; +} + +#endif /* DBUS_BUILD_TESTS */ diff --git a/glib/dbus-gparser.c b/glib/dbus-gparser.c new file mode 100644 index 00000000..6fea4abc --- /dev/null +++ b/glib/dbus-gparser.c @@ -0,0 +1,121 @@ +/* -*- mode: C; c-file-style: "gnu" -*- */ +/* dbus-gparser.c parse DBus description files + * + * Copyright (C) 2003 Red Hat, Inc. + * + * Licensed under the Academic Free License version 1.2 + * + * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ +#include "dbus-gparser.h" +#include "dbus-gidl.h" + +struct Parser +{ + int refcount; + +}; + +Parser* +parser_new (void) +{ + Parser *parser; + + parser = g_new0 (Parser, 1); + + parser->refcount = 1; + + return parser; +} + +void +parser_ref (Parser *parser) +{ + parser->refcount += 1; +} + +void +parser_unref (Parser *parser) +{ + parser->refcount -= 1; + if (parser->refcount == 0) + { + + + g_free (parser); + } +} + +gboolean +parser_check_doctype (Parser *parser, + const char *doctype, + GError **error) +{ + g_return_val_if_fail (error == NULL || *error == NULL); + + if (strcmp (doctype, "dbus_description") != 0) + { + g_set_error (error, + G_MARKUP_ERROR_PARSE, + "D-BUS description file has the wrong document type %s, use dbus_description", + doctype); + return FALSE; + } + else + return TRUE; +} + +gboolean +parser_start_element (Parser *parser, + const char *element_name, + const char **attribute_names, + const char **attribute_values, + GError **error) +{ + g_return_val_if_fail (error == NULL || *error == NULL); + + return TRUE; +} + +gboolean +parser_end_element (Parser *parser, + const char *element_name, + GError **error) +{ + g_return_val_if_fail (error == NULL || *error == NULL); + + return TRUE; +} + +gboolean +parser_content (Parser *parser, + const char *content, + int len, + GError **error) +{ + g_return_val_if_fail (error == NULL || *error == NULL); + + return TRUE; +} + +gboolean +parser_finished (Parser *parser, + GError **error) +{ + g_return_val_if_fail (error == NULL || *error == NULL); + + return TRUE; +} diff --git a/glib/dbus-gparser.h b/glib/dbus-gparser.h new file mode 100644 index 00000000..01339fbf --- /dev/null +++ b/glib/dbus-gparser.h @@ -0,0 +1,59 @@ +/* -*- mode: C; c-file-style: "gnu" -*- */ +/* dbus-gparser.h parse DBus description files + * + * Copyright (C) 2003 Red Hat, Inc. + * + * Licensed under the Academic Free License version 1.2 + * + * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ +#ifndef DBUS_GLIB_PARSER_H +#define DBUS_GLIB_PARSER_H + +#include +#include + +G_BEGIN_DECLS + + +typedef struct Parser Parser; + +Parser* parser_new (void); +void parser_ref (Parser *parser); +void parser_unref (Parser *parser); +gboolean parser_check_doctype (Parser *parser, + const char *doctype, + GError **error); +gboolean parser_start_element (Parser *parser, + const char *element_name, + const char **attribute_names, + const char **attribute_values, + GError **error); +gboolean parser_end_element (Parser *parser, + const char *element_name, + GError **error); +gboolean parser_content (Parser *parser, + const char *content, + int len, + GError **error); +gboolean parser_finished (Parser *parser, + GError **error); + + + +G_END_DECLS + +#endif /* DBUS_GLIB_GPARSER_H */ -- cgit v1.2.1