diff options
Diffstat (limited to 'test')
63 files changed, 14113 insertions, 0 deletions
diff --git a/test/Makefile.am b/test/Makefile.am new file mode 100644 index 0000000..1ffd63e --- /dev/null +++ b/test/Makefile.am @@ -0,0 +1,26 @@ +SUBDIRS = lib . core interfaces manual +DIST_SUBDIRS = lib core interfaces manual + +INCLUDES = \ + -I$(top_srcdir) \ + -I$(top_builddir) \ + -I$(top_builddir)/dbus \ + $(DBUS_CFLAGS) + +if DBUS_BUILD_TESTS +TEST_BINARIES=test-service +else +TEST_BINARIES= +endif + +noinst_PROGRAMS= $(TEST_BINARIES) + +test_service_SOURCES= \ + test-service.c + +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 diff --git a/test/Makefile.in b/test/Makefile.in new file mode 100644 index 0000000..7c1d21d --- /dev/null +++ b/test/Makefile.in @@ -0,0 +1,815 @@ +# Makefile.in generated by automake 1.11.5 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software +# Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +VPATH = @srcdir@ +am__make_dryrun = \ + { \ + am__dry=no; \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \ + | grep '^AM OK$$' >/dev/null || am__dry=yes;; \ + *) \ + for am__flg in $$MAKEFLAGS; do \ + case $$am__flg in \ + *=*|--*) ;; \ + *n*) am__dry=yes; break;; \ + esac; \ + done;; \ + esac; \ + test $$am__dry = yes; \ + } +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +noinst_PROGRAMS = $(am__EXEEXT_1) +subdir = test +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/gtk-doc.m4 \ + $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ + $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ + $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +@DBUS_BUILD_TESTS_TRUE@am__EXEEXT_1 = test-service$(EXEEXT) +PROGRAMS = $(noinst_PROGRAMS) +am_test_service_OBJECTS = test-service.$(OBJEXT) +test_service_OBJECTS = $(am_test_service_OBJECTS) +am__DEPENDENCIES_1 = +test_service_DEPENDENCIES = $(am__DEPENDENCIES_1) +AM_V_lt = $(am__v_lt_@AM_V@) +am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) +am__v_lt_0 = --silent +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CFLAGS) $(CFLAGS) +AM_V_CC = $(am__v_CC_@AM_V@) +am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) +am__v_CC_0 = @echo " CC " $@; +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ +CCLD = $(CC) +LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +AM_V_CCLD = $(am__v_CCLD_@AM_V@) +am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) +am__v_CCLD_0 = @echo " CCLD " $@; +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; +SOURCES = $(test_service_SOURCES) +DIST_SOURCES = $(test_service_SOURCES) +RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ + html-recursive info-recursive install-data-recursive \ + install-dvi-recursive install-exec-recursive \ + install-html-recursive install-info-recursive \ + install-pdf-recursive install-ps-recursive install-recursive \ + installcheck-recursive installdirs-recursive pdf-recursive \ + ps-recursive uninstall-recursive +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ + distclean-recursive maintainer-clean-recursive +AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \ + $(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \ + distdir +ETAGS = etags +CTAGS = ctags +am__tty_colors = \ +red=; grn=; lgn=; blu=; std= +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +am__relativize = \ + dir0=`pwd`; \ + sed_first='s,^\([^/]*\)/.*$$,\1,'; \ + sed_rest='s,^[^/]*/*,,'; \ + sed_last='s,^.*/\([^/]*\)$$,\1,'; \ + sed_butlast='s,/*[^/]*$$,,'; \ + while test -n "$$dir1"; do \ + first=`echo "$$dir1" | sed -e "$$sed_first"`; \ + if test "$$first" != "."; then \ + if test "$$first" = ".."; then \ + dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ + dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ + else \ + first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ + if test "$$first2" = "$$first"; then \ + dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ + else \ + dir2="../$$dir2"; \ + fi; \ + dir0="$$dir0"/"$$first"; \ + fi; \ + fi; \ + dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ + done; \ + reldir="$$dir2" +ABSOLUTE_TOP_BUILDDIR = @ABSOLUTE_TOP_BUILDDIR@ +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DBUS_BINDING_TOOL = @DBUS_BINDING_TOOL@ +DBUS_CFLAGS = @DBUS_CFLAGS@ +DBUS_GLIB_CFLAGS = @DBUS_GLIB_CFLAGS@ +DBUS_GLIB_LIBS = @DBUS_GLIB_LIBS@ +DBUS_GLIB_THREADS_CFLAGS = @DBUS_GLIB_THREADS_CFLAGS@ +DBUS_GLIB_THREADS_LIBS = @DBUS_GLIB_THREADS_LIBS@ +DBUS_GLIB_TOOL_CFLAGS = @DBUS_GLIB_TOOL_CFLAGS@ +DBUS_GLIB_TOOL_LIBS = @DBUS_GLIB_TOOL_LIBS@ +DBUS_LIBS = @DBUS_LIBS@ +DBUS_PATH_OR_ABSTRACT = @DBUS_PATH_OR_ABSTRACT@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +EXPANDED_BINDIR = @EXPANDED_BINDIR@ +EXPANDED_DATADIR = @EXPANDED_DATADIR@ +EXPANDED_LIBDIR = @EXPANDED_LIBDIR@ +EXPANDED_LOCALSTATEDIR = @EXPANDED_LOCALSTATEDIR@ +EXPANDED_SYSCONFDIR = @EXPANDED_SYSCONFDIR@ +FGREP = @FGREP@ +GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ +GREP = @GREP@ +GTKDOC_CHECK = @GTKDOC_CHECK@ +GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@ +GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@ +GTKDOC_MKPDF = @GTKDOC_MKPDF@ +GTKDOC_REBASE = @GTKDOC_REBASE@ +HTML_DIR = @HTML_DIR@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +LT_AGE = @LT_AGE@ +LT_CURRENT = @LT_CURRENT@ +LT_REVISION = @LT_REVISION@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ +MKDIR_P = @MKDIR_P@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PKG_CONFIG = @PKG_CONFIG@ +PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ +PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +TEST_CORE_SERVICE_BINARY = @TEST_CORE_SERVICE_BINARY@ +TEST_EXIT_BINARY = @TEST_EXIT_BINARY@ +TEST_INTERFACES_SERVICE_BINARY = @TEST_INTERFACES_SERVICE_BINARY@ +TEST_SEGFAULT_BINARY = @TEST_SEGFAULT_BINARY@ +TEST_SERVICE_BINARY = @TEST_SERVICE_BINARY@ +TEST_SERVICE_DIR = @TEST_SERVICE_DIR@ +TEST_SHELL_SERVICE_BINARY = @TEST_SHELL_SERVICE_BINARY@ +TEST_SLEEP_FOREVER_BINARY = @TEST_SLEEP_FOREVER_BINARY@ +TEST_SOCKET_DIR = @TEST_SOCKET_DIR@ +VERSION = @VERSION@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +SUBDIRS = lib . core interfaces manual +DIST_SUBDIRS = lib core interfaces manual +INCLUDES = \ + -I$(top_srcdir) \ + -I$(top_builddir) \ + -I$(top_builddir)/dbus \ + $(DBUS_CFLAGS) + +@DBUS_BUILD_TESTS_FALSE@TEST_BINARIES = +@DBUS_BUILD_TESTS_TRUE@TEST_BINARIES = test-service +test_service_SOURCES = \ + test-service.c + +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 +all: all-recursive + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu test/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu test/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): + +clean-noinstPROGRAMS: + @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \ + echo " rm -f" $$list; \ + rm -f $$list || exit $$?; \ + test -n "$(EXEEXT)" || exit 0; \ + list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f" $$list; \ + rm -f $$list +test-service$(EXEEXT): $(test_service_OBJECTS) $(test_service_DEPENDENCIES) $(EXTRA_test_service_DEPENDENCIES) + @rm -f test-service$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_service_OBJECTS) $(test_service_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-service.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +# This directory's subdirectories are mostly independent; you can cd +# into them and run `make' without going through this Makefile. +# To change the values of `make' variables: instead of editing Makefiles, +# (1) if the variable is set in `config.status', edit `config.status' +# (which will cause the Makefiles to be regenerated when you run `make'); +# (2) otherwise, pass the desired values on the `make' command line. +$(RECURSIVE_TARGETS): + @fail= failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + target=`echo $@ | sed s/-recursive//`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + dot_seen=yes; \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done; \ + if test "$$dot_seen" = "no"; then \ + $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ + fi; test -z "$$fail" + +$(RECURSIVE_CLEAN_TARGETS): + @fail= failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + case "$@" in \ + distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ + *) list='$(SUBDIRS)' ;; \ + esac; \ + rev=''; for subdir in $$list; do \ + if test "$$subdir" = "."; then :; else \ + rev="$$subdir $$rev"; \ + fi; \ + done; \ + rev="$$rev ."; \ + target=`echo $@ | sed s/-recursive//`; \ + for subdir in $$rev; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done && test -z "$$fail" +tags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ + done +ctags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ + done + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + set x; \ + here=`pwd`; \ + if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ + include_option=--etags-include; \ + empty_fix=.; \ + else \ + include_option=--include; \ + empty_fix=; \ + fi; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test ! -f $$subdir/TAGS || \ + set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ + fi; \ + done; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: CTAGS +CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +check-TESTS: $(TESTS) + @failed=0; all=0; xfail=0; xpass=0; skip=0; \ + srcdir=$(srcdir); export srcdir; \ + list=' $(TESTS) '; \ + $(am__tty_colors); \ + if test -n "$$list"; then \ + for tst in $$list; do \ + if test -f ./$$tst; then dir=./; \ + elif test -f $$tst; then dir=; \ + else dir="$(srcdir)/"; fi; \ + if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *[\ \ ]$$tst[\ \ ]*) \ + xpass=`expr $$xpass + 1`; \ + failed=`expr $$failed + 1`; \ + col=$$red; res=XPASS; \ + ;; \ + *) \ + col=$$grn; res=PASS; \ + ;; \ + esac; \ + elif test $$? -ne 77; then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *[\ \ ]$$tst[\ \ ]*) \ + xfail=`expr $$xfail + 1`; \ + col=$$lgn; res=XFAIL; \ + ;; \ + *) \ + failed=`expr $$failed + 1`; \ + col=$$red; res=FAIL; \ + ;; \ + esac; \ + else \ + skip=`expr $$skip + 1`; \ + col=$$blu; res=SKIP; \ + fi; \ + echo "$${col}$$res$${std}: $$tst"; \ + done; \ + if test "$$all" -eq 1; then \ + tests="test"; \ + All=""; \ + else \ + tests="tests"; \ + All="All "; \ + fi; \ + if test "$$failed" -eq 0; then \ + if test "$$xfail" -eq 0; then \ + banner="$$All$$all $$tests passed"; \ + else \ + if test "$$xfail" -eq 1; then failures=failure; else failures=failures; fi; \ + banner="$$All$$all $$tests behaved as expected ($$xfail expected $$failures)"; \ + fi; \ + else \ + if test "$$xpass" -eq 0; then \ + banner="$$failed of $$all $$tests failed"; \ + else \ + if test "$$xpass" -eq 1; then passes=pass; else passes=passes; fi; \ + banner="$$failed of $$all $$tests did not behave as expected ($$xpass unexpected $$passes)"; \ + fi; \ + fi; \ + dashes="$$banner"; \ + skipped=""; \ + if test "$$skip" -ne 0; then \ + if test "$$skip" -eq 1; then \ + skipped="($$skip test was not run)"; \ + else \ + skipped="($$skip tests were not run)"; \ + fi; \ + test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \ + dashes="$$skipped"; \ + fi; \ + report=""; \ + if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \ + report="Please report to $(PACKAGE_BUGREPORT)"; \ + test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \ + dashes="$$report"; \ + fi; \ + dashes=`echo "$$dashes" | sed s/./=/g`; \ + if test "$$failed" -eq 0; then \ + col="$$grn"; \ + else \ + col="$$red"; \ + fi; \ + echo "$${col}$$dashes$${std}"; \ + echo "$${col}$$banner$${std}"; \ + test -z "$$skipped" || echo "$${col}$$skipped$${std}"; \ + test -z "$$report" || echo "$${col}$$report$${std}"; \ + echo "$${col}$$dashes$${std}"; \ + test "$$failed" -eq 0; \ + else :; fi + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done + @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + $(am__make_dryrun) \ + || test -d "$(distdir)/$$subdir" \ + || $(MKDIR_P) "$(distdir)/$$subdir" \ + || exit 1; \ + dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ + $(am__relativize); \ + new_distdir=$$reldir; \ + dir1=$$subdir; dir2="$(top_distdir)"; \ + $(am__relativize); \ + new_top_distdir=$$reldir; \ + echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ + echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ + ($(am__cd) $$subdir && \ + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$$new_top_distdir" \ + distdir="$$new_distdir" \ + am__remove_distdir=: \ + am__skip_length_check=: \ + am__skip_mode_fix=: \ + distdir) \ + || exit 1; \ + fi; \ + done +check-am: all-am + $(MAKE) $(AM_MAKEFLAGS) check-TESTS +check: check-recursive +all-am: Makefile $(PROGRAMS) +installdirs: installdirs-recursive +installdirs-am: +install: install-recursive +install-exec: install-exec-recursive +install-data: install-data-recursive +uninstall: uninstall-recursive + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-recursive +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-recursive + +clean-am: clean-generic clean-libtool clean-noinstPROGRAMS \ + mostlyclean-am + +distclean: distclean-recursive + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-recursive + +dvi-am: + +html: html-recursive + +html-am: + +info: info-recursive + +info-am: + +install-data-am: + +install-dvi: install-dvi-recursive + +install-dvi-am: + +install-exec-am: + +install-html: install-html-recursive + +install-html-am: + +install-info: install-info-recursive + +install-info-am: + +install-man: + +install-pdf: install-pdf-recursive + +install-pdf-am: + +install-ps: install-ps-recursive + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-recursive + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-recursive + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-recursive + +pdf-am: + +ps: ps-recursive + +ps-am: + +uninstall-am: + +.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) check-am \ + ctags-recursive install-am install-strip tags-recursive + +.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ + all all-am check check-TESTS check-am clean clean-generic \ + clean-libtool clean-noinstPROGRAMS ctags ctags-recursive \ + distclean distclean-compile distclean-generic \ + distclean-libtool distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-dvi install-dvi-am install-exec \ + install-exec-am install-html install-html-am install-info \ + install-info-am install-man install-pdf install-pdf-am \ + install-ps install-ps-am install-strip installcheck \ + installcheck-am installdirs installdirs-am maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags tags-recursive uninstall uninstall-am + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/test/core/30574.c b/test/core/30574.c new file mode 100644 index 0000000..3cbe1b5 --- /dev/null +++ b/test/core/30574.c @@ -0,0 +1,98 @@ +#include <config.h> + +#include <stdio.h> +#include <stdlib.h> +#include <dbus/dbus.h> +#include <glib.h> +#include <dbus/dbus-glib-lowlevel.h> + +DBusConnection *bus; +GMainContext *main_context; + +typedef struct _SpiReentrantCallClosure +{ + GMainLoop *loop; + DBusMessage *reply; +} SpiReentrantCallClosure; + +static void +set_reply (DBusPendingCall * pending, void *user_data) +{ + SpiReentrantCallClosure* closure = (SpiReentrantCallClosure *) user_data; + + closure->reply = dbus_pending_call_steal_reply (pending); + dbus_connection_setup_with_g_main (bus, NULL); + + g_main_loop_quit (closure->loop); +} + +static DBusMessage * +send_and_allow_reentry (DBusConnection * bus, DBusMessage * message) +{ + DBusPendingCall *pending; + SpiReentrantCallClosure closure; + + closure.loop = g_main_loop_new (main_context, FALSE); + dbus_connection_setup_with_g_main (bus, main_context); + + if (!dbus_connection_send_with_reply (bus, message, &pending, 3000)) + { + dbus_connection_setup_with_g_main (bus, NULL); + return NULL; + } + dbus_pending_call_set_notify (pending, set_reply, (void *) &closure, NULL); + g_main_loop_run (closure.loop); + + g_main_loop_unref (closure.loop); + return closure.reply; +} + +int +main(int argc, const char *argv[]) +{ + DBusError error; + DBusMessage *message = NULL, *reply = NULL; + const char *str; + + main_context = g_main_context_new (); + dbus_error_init (&error); + bus = dbus_bus_get (DBUS_BUS_SESSION, &error); + if (!bus) + { + fprintf(stderr, "Couldn't connect to bus: %s\n", error.name); + return 1; + } + dbus_connection_setup_with_g_main (bus, NULL); + message = dbus_message_new_method_call ("org.freedesktop.DBus", "/org/freedesktop/DBus", DBUS_INTERFACE_DBUS, "GetId"); + reply = send_and_allow_reentry (bus, message); + if (dbus_message_get_type (reply) == DBUS_MESSAGE_TYPE_ERROR) + { + char *err; + dbus_message_get_args (reply, NULL, DBUS_TYPE_STRING, &err, DBUS_TYPE_INVALID); + fprintf (stderr, "Got error: %s\n", err); + return 1; + } + dbus_message_unref (reply); + dbus_message_unref (message); + message = dbus_message_new_method_call ("org.freedesktop.DBus", "/org/freedesktop/DBus", DBUS_INTERFACE_DBUS, "GetId"); + reply = send_and_allow_reentry (bus, message); + if (!reply) + { + fprintf(stderr, "Sorry; dbus wouldn't answer me: %s\n", error.message); + exit(1); + } + if (dbus_message_get_type (reply) == DBUS_MESSAGE_TYPE_ERROR) + { + char *err; + dbus_message_get_args (reply, NULL, DBUS_TYPE_STRING, &err, DBUS_TYPE_INVALID); + fprintf (stderr, "Got error: %s\n", err); + return 1; + } + if (!dbus_message_get_args (reply, &error, DBUS_TYPE_STRING, &str, DBUS_TYPE_INVALID)) + { + fprintf(stderr, "Sorry; can't communicate: %s\n", error.message); + exit(1); + } + + return 0; +} diff --git a/test/core/Makefile.am b/test/core/Makefile.am new file mode 100644 index 0000000..9a8c799 --- /dev/null +++ b/test/core/Makefile.am @@ -0,0 +1,164 @@ +INCLUDES = \ + -I$(top_srcdir) \ + -I$(top_srcdir)/dbus \ + -I$(top_builddir) \ + -I$(top_builddir)/dbus \ + $(DBUS_CFLAGS) \ + $(DBUS_GLIB_CFLAGS) \ + -DDBUS_COMPILATION + +LDADD = \ + $(DBUS_GLIB_THREADS_LIBS) \ + $(DBUS_GLIB_LIBS) \ + $(DBUS_LIBS) \ + $(top_builddir)/dbus/libdbus-glib-1.la \ + $(top_builddir)/test/lib/libtest.la \ + $(NULL) + +tool_ldadd = \ + $(LDADD) \ + $(DBUS_GLIB_TOOL_LIBS) \ + $(top_builddir)/dbus/libdbus-gtool.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 +if DBUS_BUILD_TESTS +TESTS_ENVIRONMENT=DBUS_TOP_BUILDDIR=$(ABSOLUTE_TOP_BUILDDIR) +TESTS=run-test.sh run-peer-test.sh +else +TESTS= +endif + +EXTRA_DIST=run-test.sh run-peer-test.sh test-service-glib.xml my-object-marshal.list test-service-glib-subclass.xml + +if DBUS_BUILD_TESTS + +if HAVE_GLIB_THREADS +THREAD_APPS=test-thread-server test-thread-client test-profile + +test_thread_server_SOURCES= \ + test-thread-server.c \ + test-thread.h + +test_thread_client_SOURCES= \ + test-thread-client.c \ + test-thread.h +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-error-mapping \ + test-service-glib \ + $(THREAD_APPS) \ + peer-server \ + peer-client \ + test-types \ + test-30574 \ + test-peer-on-bus \ + test-proxy-peer \ + test-registrations \ + test-variant-recursion \ + test-gvariant + +test_30574_SOURCES = \ + 30574.c + +test_proxy_peer_SOURCES = \ + my-object-marshal.c \ + my-object.c \ + my-object.h \ + proxy-peer.c + +test_registrations_SOURCES = \ + my-object.c \ + my-object.h \ + my-object-subclass.c \ + my-object-subclass.h \ + my-object-marshal.c \ + registrations.c + +test_dbus_glib_SOURCES= \ + my-object.c \ + my-object.h \ + my-object-marshal.c \ + test-dbus-glib.c + +test_dbus_glib_LDADD= $(tool_ldadd) + +test_error_mapping_SOURCES = \ + my-object.c \ + my-object.h \ + my-object-marshal.c \ + error-mapping.c + +test_variant_recursion_SOURCES=test-variant-recursion.c + +test_variant_recursion_LDADD= $(tool_ldadd) + +BUILT_SOURCES = test-service-glib-glue.h test-service-glib-subclass-glue.h test-service-glib-bindings.h my-object-marshal.c my-object-marshal.h + +test_service_glib_SOURCES= \ + my-object.c \ + my-object.h \ + my-object-subclass.c \ + my-object-subclass.h \ + my-object-marshal.c \ + test-service-glib.c + +test-service-glib-glue.h: test-service-glib.xml $(top_builddir)/dbus/dbus-binding-tool$(EXEEXT) + $(DEBUG) $(DBUS_BINDING_TOOL) --prefix=my_object --mode=glib-server --output=test-service-glib-glue.h $(srcdir)/test-service-glib.xml + +test-service-glib-subclass-glue.h: test-service-glib-subclass.xml $(top_builddir)/dbus/dbus-binding-tool$(EXEEXT) + $(DEBUG) $(DBUS_BINDING_TOOL) --prefix=my_object_subclass --mode=glib-server --output=test-service-glib-subclass-glue.h $(srcdir)/test-service-glib-subclass.xml + +test-service-glib-bindings.h: test-service-glib.xml $(top_builddir)/dbus/dbus-binding-tool$(EXEEXT) + $(DEBUG) $(DBUS_BINDING_TOOL) --prefix=my_object --mode=glib-client --output=test-service-glib-bindings.h $(srcdir)/test-service-glib.xml + +my-object-marshal.c: Makefile my-object-marshal.list + echo "#include <config.h>" > $@.tmp + @GLIB_GENMARSHAL@ --prefix=my_object_marshal $(srcdir)/my-object-marshal.list --header --body >> $@.tmp + mv $@.tmp $@ + +my-object-marshal.h: Makefile my-object-marshal.list + @GLIB_GENMARSHAL@ --prefix=my_object_marshal $(srcdir)/my-object-marshal.list --header > my-object-marshal.h + + +peer_server_SOURCES = \ + my-object.c \ + my-object.h \ + my-object-subclass.c \ + my-object-subclass.h \ + my-object-marshal.c \ + peer-server.c + +peer_client_SOURCES = \ + peer-client.c + +test_types_SOURCES = \ + test-types.c + +test_gvariant_SOURCES = \ + test-gvariant.c + +test_peer_on_bus_SOURCES = peer-on-bus.c + +CLEANFILES = \ + $(BUILT_SOURCES) \ + run-with-tmp-session-bus.conf + +else +### not building tests + +if HAVE_GLIB_THREADS +noinst_PROGRAMS=test-profile +endif + +endif + +if HAVE_GLIB_THREADS +test_profile_SOURCES= \ + test-profile.c +endif diff --git a/test/core/Makefile.in b/test/core/Makefile.in new file mode 100644 index 0000000..45e3728 --- /dev/null +++ b/test/core/Makefile.in @@ -0,0 +1,1011 @@ +# Makefile.in generated by automake 1.11.5 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software +# Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +VPATH = @srcdir@ +am__make_dryrun = \ + { \ + am__dry=no; \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \ + | grep '^AM OK$$' >/dev/null || am__dry=yes;; \ + *) \ + for am__flg in $$MAKEFLAGS; do \ + case $$am__flg in \ + *=*|--*) ;; \ + *n*) am__dry=yes; break;; \ + esac; \ + done;; \ + esac; \ + test $$am__dry = yes; \ + } +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +@DBUS_BUILD_TESTS_TRUE@TESTS = run-test.sh run-peer-test.sh +@DBUS_BUILD_TESTS_FALSE@@HAVE_GLIB_THREADS_TRUE@noinst_PROGRAMS = test-profile$(EXEEXT) +@DBUS_BUILD_TESTS_TRUE@noinst_PROGRAMS = test-dbus-glib$(EXEEXT) \ +@DBUS_BUILD_TESTS_TRUE@ test-error-mapping$(EXEEXT) \ +@DBUS_BUILD_TESTS_TRUE@ test-service-glib$(EXEEXT) \ +@DBUS_BUILD_TESTS_TRUE@ $(am__EXEEXT_1) peer-server$(EXEEXT) \ +@DBUS_BUILD_TESTS_TRUE@ peer-client$(EXEEXT) \ +@DBUS_BUILD_TESTS_TRUE@ test-types$(EXEEXT) test-30574$(EXEEXT) \ +@DBUS_BUILD_TESTS_TRUE@ test-peer-on-bus$(EXEEXT) \ +@DBUS_BUILD_TESTS_TRUE@ test-proxy-peer$(EXEEXT) \ +@DBUS_BUILD_TESTS_TRUE@ test-registrations$(EXEEXT) \ +@DBUS_BUILD_TESTS_TRUE@ test-variant-recursion$(EXEEXT) \ +@DBUS_BUILD_TESTS_TRUE@ test-gvariant$(EXEEXT) +subdir = test/core +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/gtk-doc.m4 \ + $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ + $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ + $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +@DBUS_BUILD_TESTS_TRUE@@HAVE_GLIB_THREADS_TRUE@am__EXEEXT_1 = test-thread-server$(EXEEXT) \ +@DBUS_BUILD_TESTS_TRUE@@HAVE_GLIB_THREADS_TRUE@ test-thread-client$(EXEEXT) \ +@DBUS_BUILD_TESTS_TRUE@@HAVE_GLIB_THREADS_TRUE@ test-profile$(EXEEXT) +PROGRAMS = $(noinst_PROGRAMS) +am__peer_client_SOURCES_DIST = peer-client.c +@DBUS_BUILD_TESTS_TRUE@am_peer_client_OBJECTS = peer-client.$(OBJEXT) +peer_client_OBJECTS = $(am_peer_client_OBJECTS) +peer_client_LDADD = $(LDADD) +am__DEPENDENCIES_1 = +peer_client_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) $(top_builddir)/dbus/libdbus-glib-1.la \ + $(top_builddir)/test/lib/libtest.la +AM_V_lt = $(am__v_lt_@AM_V@) +am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) +am__v_lt_0 = --silent +am__peer_server_SOURCES_DIST = my-object.c my-object.h \ + my-object-subclass.c my-object-subclass.h my-object-marshal.c \ + peer-server.c +@DBUS_BUILD_TESTS_TRUE@am_peer_server_OBJECTS = my-object.$(OBJEXT) \ +@DBUS_BUILD_TESTS_TRUE@ my-object-subclass.$(OBJEXT) \ +@DBUS_BUILD_TESTS_TRUE@ my-object-marshal.$(OBJEXT) \ +@DBUS_BUILD_TESTS_TRUE@ peer-server.$(OBJEXT) +peer_server_OBJECTS = $(am_peer_server_OBJECTS) +peer_server_LDADD = $(LDADD) +peer_server_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) $(top_builddir)/dbus/libdbus-glib-1.la \ + $(top_builddir)/test/lib/libtest.la +am__test_30574_SOURCES_DIST = 30574.c +@DBUS_BUILD_TESTS_TRUE@am_test_30574_OBJECTS = 30574.$(OBJEXT) +test_30574_OBJECTS = $(am_test_30574_OBJECTS) +test_30574_LDADD = $(LDADD) +test_30574_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) $(top_builddir)/dbus/libdbus-glib-1.la \ + $(top_builddir)/test/lib/libtest.la +am__test_dbus_glib_SOURCES_DIST = my-object.c my-object.h \ + my-object-marshal.c test-dbus-glib.c +@DBUS_BUILD_TESTS_TRUE@am_test_dbus_glib_OBJECTS = \ +@DBUS_BUILD_TESTS_TRUE@ my-object.$(OBJEXT) \ +@DBUS_BUILD_TESTS_TRUE@ my-object-marshal.$(OBJEXT) \ +@DBUS_BUILD_TESTS_TRUE@ test-dbus-glib.$(OBJEXT) +test_dbus_glib_OBJECTS = $(am_test_dbus_glib_OBJECTS) +am__DEPENDENCIES_2 = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) $(top_builddir)/dbus/libdbus-glib-1.la \ + $(top_builddir)/test/lib/libtest.la +am__DEPENDENCIES_3 = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) \ + $(top_builddir)/dbus/libdbus-gtool.la +@DBUS_BUILD_TESTS_TRUE@test_dbus_glib_DEPENDENCIES = \ +@DBUS_BUILD_TESTS_TRUE@ $(am__DEPENDENCIES_3) +am__test_error_mapping_SOURCES_DIST = my-object.c my-object.h \ + my-object-marshal.c error-mapping.c +@DBUS_BUILD_TESTS_TRUE@am_test_error_mapping_OBJECTS = \ +@DBUS_BUILD_TESTS_TRUE@ my-object.$(OBJEXT) \ +@DBUS_BUILD_TESTS_TRUE@ my-object-marshal.$(OBJEXT) \ +@DBUS_BUILD_TESTS_TRUE@ error-mapping.$(OBJEXT) +test_error_mapping_OBJECTS = $(am_test_error_mapping_OBJECTS) +test_error_mapping_LDADD = $(LDADD) +test_error_mapping_DEPENDENCIES = $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(top_builddir)/dbus/libdbus-glib-1.la \ + $(top_builddir)/test/lib/libtest.la +am__test_gvariant_SOURCES_DIST = test-gvariant.c +@DBUS_BUILD_TESTS_TRUE@am_test_gvariant_OBJECTS = \ +@DBUS_BUILD_TESTS_TRUE@ test-gvariant.$(OBJEXT) +test_gvariant_OBJECTS = $(am_test_gvariant_OBJECTS) +test_gvariant_LDADD = $(LDADD) +test_gvariant_DEPENDENCIES = $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(top_builddir)/dbus/libdbus-glib-1.la \ + $(top_builddir)/test/lib/libtest.la +am__test_peer_on_bus_SOURCES_DIST = peer-on-bus.c +@DBUS_BUILD_TESTS_TRUE@am_test_peer_on_bus_OBJECTS = \ +@DBUS_BUILD_TESTS_TRUE@ peer-on-bus.$(OBJEXT) +test_peer_on_bus_OBJECTS = $(am_test_peer_on_bus_OBJECTS) +test_peer_on_bus_LDADD = $(LDADD) +test_peer_on_bus_DEPENDENCIES = $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(top_builddir)/dbus/libdbus-glib-1.la \ + $(top_builddir)/test/lib/libtest.la +am__test_profile_SOURCES_DIST = test-profile.c +@HAVE_GLIB_THREADS_TRUE@am_test_profile_OBJECTS = \ +@HAVE_GLIB_THREADS_TRUE@ test-profile.$(OBJEXT) +test_profile_OBJECTS = $(am_test_profile_OBJECTS) +test_profile_LDADD = $(LDADD) +test_profile_DEPENDENCIES = $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(top_builddir)/dbus/libdbus-glib-1.la \ + $(top_builddir)/test/lib/libtest.la +am__test_proxy_peer_SOURCES_DIST = my-object-marshal.c my-object.c \ + my-object.h proxy-peer.c +@DBUS_BUILD_TESTS_TRUE@am_test_proxy_peer_OBJECTS = \ +@DBUS_BUILD_TESTS_TRUE@ my-object-marshal.$(OBJEXT) \ +@DBUS_BUILD_TESTS_TRUE@ my-object.$(OBJEXT) \ +@DBUS_BUILD_TESTS_TRUE@ proxy-peer.$(OBJEXT) +test_proxy_peer_OBJECTS = $(am_test_proxy_peer_OBJECTS) +test_proxy_peer_LDADD = $(LDADD) +test_proxy_peer_DEPENDENCIES = $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(top_builddir)/dbus/libdbus-glib-1.la \ + $(top_builddir)/test/lib/libtest.la +am__test_registrations_SOURCES_DIST = my-object.c my-object.h \ + my-object-subclass.c my-object-subclass.h my-object-marshal.c \ + registrations.c +@DBUS_BUILD_TESTS_TRUE@am_test_registrations_OBJECTS = \ +@DBUS_BUILD_TESTS_TRUE@ my-object.$(OBJEXT) \ +@DBUS_BUILD_TESTS_TRUE@ my-object-subclass.$(OBJEXT) \ +@DBUS_BUILD_TESTS_TRUE@ my-object-marshal.$(OBJEXT) \ +@DBUS_BUILD_TESTS_TRUE@ registrations.$(OBJEXT) +test_registrations_OBJECTS = $(am_test_registrations_OBJECTS) +test_registrations_LDADD = $(LDADD) +test_registrations_DEPENDENCIES = $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(top_builddir)/dbus/libdbus-glib-1.la \ + $(top_builddir)/test/lib/libtest.la +am__test_service_glib_SOURCES_DIST = my-object.c my-object.h \ + my-object-subclass.c my-object-subclass.h my-object-marshal.c \ + test-service-glib.c +@DBUS_BUILD_TESTS_TRUE@am_test_service_glib_OBJECTS = \ +@DBUS_BUILD_TESTS_TRUE@ my-object.$(OBJEXT) \ +@DBUS_BUILD_TESTS_TRUE@ my-object-subclass.$(OBJEXT) \ +@DBUS_BUILD_TESTS_TRUE@ my-object-marshal.$(OBJEXT) \ +@DBUS_BUILD_TESTS_TRUE@ test-service-glib.$(OBJEXT) +test_service_glib_OBJECTS = $(am_test_service_glib_OBJECTS) +test_service_glib_LDADD = $(LDADD) +test_service_glib_DEPENDENCIES = $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(top_builddir)/dbus/libdbus-glib-1.la \ + $(top_builddir)/test/lib/libtest.la +am__test_thread_client_SOURCES_DIST = test-thread-client.c \ + test-thread.h +@DBUS_BUILD_TESTS_TRUE@@HAVE_GLIB_THREADS_TRUE@am_test_thread_client_OBJECTS = test-thread-client.$(OBJEXT) +test_thread_client_OBJECTS = $(am_test_thread_client_OBJECTS) +test_thread_client_LDADD = $(LDADD) +test_thread_client_DEPENDENCIES = $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(top_builddir)/dbus/libdbus-glib-1.la \ + $(top_builddir)/test/lib/libtest.la +am__test_thread_server_SOURCES_DIST = test-thread-server.c \ + test-thread.h +@DBUS_BUILD_TESTS_TRUE@@HAVE_GLIB_THREADS_TRUE@am_test_thread_server_OBJECTS = test-thread-server.$(OBJEXT) +test_thread_server_OBJECTS = $(am_test_thread_server_OBJECTS) +test_thread_server_LDADD = $(LDADD) +test_thread_server_DEPENDENCIES = $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(top_builddir)/dbus/libdbus-glib-1.la \ + $(top_builddir)/test/lib/libtest.la +am__test_types_SOURCES_DIST = test-types.c +@DBUS_BUILD_TESTS_TRUE@am_test_types_OBJECTS = test-types.$(OBJEXT) +test_types_OBJECTS = $(am_test_types_OBJECTS) +test_types_LDADD = $(LDADD) +test_types_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) $(top_builddir)/dbus/libdbus-glib-1.la \ + $(top_builddir)/test/lib/libtest.la +am__test_variant_recursion_SOURCES_DIST = test-variant-recursion.c +@DBUS_BUILD_TESTS_TRUE@am_test_variant_recursion_OBJECTS = \ +@DBUS_BUILD_TESTS_TRUE@ test-variant-recursion.$(OBJEXT) +test_variant_recursion_OBJECTS = $(am_test_variant_recursion_OBJECTS) +@DBUS_BUILD_TESTS_TRUE@test_variant_recursion_DEPENDENCIES = \ +@DBUS_BUILD_TESTS_TRUE@ $(am__DEPENDENCIES_3) +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CFLAGS) $(CFLAGS) +AM_V_CC = $(am__v_CC_@AM_V@) +am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) +am__v_CC_0 = @echo " CC " $@; +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ +CCLD = $(CC) +LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +AM_V_CCLD = $(am__v_CCLD_@AM_V@) +am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) +am__v_CCLD_0 = @echo " CCLD " $@; +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; +SOURCES = $(peer_client_SOURCES) $(peer_server_SOURCES) \ + $(test_30574_SOURCES) $(test_dbus_glib_SOURCES) \ + $(test_error_mapping_SOURCES) $(test_gvariant_SOURCES) \ + $(test_peer_on_bus_SOURCES) $(test_profile_SOURCES) \ + $(test_proxy_peer_SOURCES) $(test_registrations_SOURCES) \ + $(test_service_glib_SOURCES) $(test_thread_client_SOURCES) \ + $(test_thread_server_SOURCES) $(test_types_SOURCES) \ + $(test_variant_recursion_SOURCES) +DIST_SOURCES = $(am__peer_client_SOURCES_DIST) \ + $(am__peer_server_SOURCES_DIST) $(am__test_30574_SOURCES_DIST) \ + $(am__test_dbus_glib_SOURCES_DIST) \ + $(am__test_error_mapping_SOURCES_DIST) \ + $(am__test_gvariant_SOURCES_DIST) \ + $(am__test_peer_on_bus_SOURCES_DIST) \ + $(am__test_profile_SOURCES_DIST) \ + $(am__test_proxy_peer_SOURCES_DIST) \ + $(am__test_registrations_SOURCES_DIST) \ + $(am__test_service_glib_SOURCES_DIST) \ + $(am__test_thread_client_SOURCES_DIST) \ + $(am__test_thread_server_SOURCES_DIST) \ + $(am__test_types_SOURCES_DIST) \ + $(am__test_variant_recursion_SOURCES_DIST) +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +ETAGS = etags +CTAGS = ctags +am__tty_colors = \ +red=; grn=; lgn=; blu=; std= +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ABSOLUTE_TOP_BUILDDIR = @ABSOLUTE_TOP_BUILDDIR@ +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DBUS_BINDING_TOOL = @DBUS_BINDING_TOOL@ +DBUS_CFLAGS = @DBUS_CFLAGS@ +DBUS_GLIB_CFLAGS = @DBUS_GLIB_CFLAGS@ +DBUS_GLIB_LIBS = @DBUS_GLIB_LIBS@ +DBUS_GLIB_THREADS_CFLAGS = @DBUS_GLIB_THREADS_CFLAGS@ +DBUS_GLIB_THREADS_LIBS = @DBUS_GLIB_THREADS_LIBS@ +DBUS_GLIB_TOOL_CFLAGS = @DBUS_GLIB_TOOL_CFLAGS@ +DBUS_GLIB_TOOL_LIBS = @DBUS_GLIB_TOOL_LIBS@ +DBUS_LIBS = @DBUS_LIBS@ +DBUS_PATH_OR_ABSTRACT = @DBUS_PATH_OR_ABSTRACT@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +EXPANDED_BINDIR = @EXPANDED_BINDIR@ +EXPANDED_DATADIR = @EXPANDED_DATADIR@ +EXPANDED_LIBDIR = @EXPANDED_LIBDIR@ +EXPANDED_LOCALSTATEDIR = @EXPANDED_LOCALSTATEDIR@ +EXPANDED_SYSCONFDIR = @EXPANDED_SYSCONFDIR@ +FGREP = @FGREP@ +GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ +GREP = @GREP@ +GTKDOC_CHECK = @GTKDOC_CHECK@ +GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@ +GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@ +GTKDOC_MKPDF = @GTKDOC_MKPDF@ +GTKDOC_REBASE = @GTKDOC_REBASE@ +HTML_DIR = @HTML_DIR@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +LT_AGE = @LT_AGE@ +LT_CURRENT = @LT_CURRENT@ +LT_REVISION = @LT_REVISION@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ +MKDIR_P = @MKDIR_P@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PKG_CONFIG = @PKG_CONFIG@ +PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ +PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +TEST_CORE_SERVICE_BINARY = @TEST_CORE_SERVICE_BINARY@ +TEST_EXIT_BINARY = @TEST_EXIT_BINARY@ +TEST_INTERFACES_SERVICE_BINARY = @TEST_INTERFACES_SERVICE_BINARY@ +TEST_SEGFAULT_BINARY = @TEST_SEGFAULT_BINARY@ +TEST_SERVICE_BINARY = @TEST_SERVICE_BINARY@ +TEST_SERVICE_DIR = @TEST_SERVICE_DIR@ +TEST_SHELL_SERVICE_BINARY = @TEST_SHELL_SERVICE_BINARY@ +TEST_SLEEP_FOREVER_BINARY = @TEST_SLEEP_FOREVER_BINARY@ +TEST_SOCKET_DIR = @TEST_SOCKET_DIR@ +VERSION = @VERSION@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +INCLUDES = \ + -I$(top_srcdir) \ + -I$(top_srcdir)/dbus \ + -I$(top_builddir) \ + -I$(top_builddir)/dbus \ + $(DBUS_CFLAGS) \ + $(DBUS_GLIB_CFLAGS) \ + -DDBUS_COMPILATION + +LDADD = \ + $(DBUS_GLIB_THREADS_LIBS) \ + $(DBUS_GLIB_LIBS) \ + $(DBUS_LIBS) \ + $(top_builddir)/dbus/libdbus-glib-1.la \ + $(top_builddir)/test/lib/libtest.la \ + $(NULL) + +tool_ldadd = \ + $(LDADD) \ + $(DBUS_GLIB_TOOL_LIBS) \ + $(top_builddir)/dbus/libdbus-gtool.la + +@DBUS_BUILD_TESTS_TRUE@TESTS_ENVIRONMENT = DBUS_TOP_BUILDDIR=$(ABSOLUTE_TOP_BUILDDIR) +EXTRA_DIST = run-test.sh run-peer-test.sh test-service-glib.xml my-object-marshal.list test-service-glib-subclass.xml +@DBUS_BUILD_TESTS_TRUE@@HAVE_GLIB_THREADS_TRUE@THREAD_APPS = test-thread-server test-thread-client test-profile +@DBUS_BUILD_TESTS_TRUE@@HAVE_GLIB_THREADS_TRUE@test_thread_server_SOURCES = \ +@DBUS_BUILD_TESTS_TRUE@@HAVE_GLIB_THREADS_TRUE@ test-thread-server.c \ +@DBUS_BUILD_TESTS_TRUE@@HAVE_GLIB_THREADS_TRUE@ test-thread.h + +@DBUS_BUILD_TESTS_TRUE@@HAVE_GLIB_THREADS_TRUE@test_thread_client_SOURCES = \ +@DBUS_BUILD_TESTS_TRUE@@HAVE_GLIB_THREADS_TRUE@ test-thread-client.c \ +@DBUS_BUILD_TESTS_TRUE@@HAVE_GLIB_THREADS_TRUE@ test-thread.h + +@DBUS_BUILD_TESTS_TRUE@test_30574_SOURCES = \ +@DBUS_BUILD_TESTS_TRUE@ 30574.c + +@DBUS_BUILD_TESTS_TRUE@test_proxy_peer_SOURCES = \ +@DBUS_BUILD_TESTS_TRUE@ my-object-marshal.c \ +@DBUS_BUILD_TESTS_TRUE@ my-object.c \ +@DBUS_BUILD_TESTS_TRUE@ my-object.h \ +@DBUS_BUILD_TESTS_TRUE@ proxy-peer.c + +@DBUS_BUILD_TESTS_TRUE@test_registrations_SOURCES = \ +@DBUS_BUILD_TESTS_TRUE@ my-object.c \ +@DBUS_BUILD_TESTS_TRUE@ my-object.h \ +@DBUS_BUILD_TESTS_TRUE@ my-object-subclass.c \ +@DBUS_BUILD_TESTS_TRUE@ my-object-subclass.h \ +@DBUS_BUILD_TESTS_TRUE@ my-object-marshal.c \ +@DBUS_BUILD_TESTS_TRUE@ registrations.c + +@DBUS_BUILD_TESTS_TRUE@test_dbus_glib_SOURCES = \ +@DBUS_BUILD_TESTS_TRUE@ my-object.c \ +@DBUS_BUILD_TESTS_TRUE@ my-object.h \ +@DBUS_BUILD_TESTS_TRUE@ my-object-marshal.c \ +@DBUS_BUILD_TESTS_TRUE@ test-dbus-glib.c + +@DBUS_BUILD_TESTS_TRUE@test_dbus_glib_LDADD = $(tool_ldadd) +@DBUS_BUILD_TESTS_TRUE@test_error_mapping_SOURCES = \ +@DBUS_BUILD_TESTS_TRUE@ my-object.c \ +@DBUS_BUILD_TESTS_TRUE@ my-object.h \ +@DBUS_BUILD_TESTS_TRUE@ my-object-marshal.c \ +@DBUS_BUILD_TESTS_TRUE@ error-mapping.c + +@DBUS_BUILD_TESTS_TRUE@test_variant_recursion_SOURCES = test-variant-recursion.c +@DBUS_BUILD_TESTS_TRUE@test_variant_recursion_LDADD = $(tool_ldadd) +@DBUS_BUILD_TESTS_TRUE@BUILT_SOURCES = test-service-glib-glue.h test-service-glib-subclass-glue.h test-service-glib-bindings.h my-object-marshal.c my-object-marshal.h +@DBUS_BUILD_TESTS_TRUE@test_service_glib_SOURCES = \ +@DBUS_BUILD_TESTS_TRUE@ my-object.c \ +@DBUS_BUILD_TESTS_TRUE@ my-object.h \ +@DBUS_BUILD_TESTS_TRUE@ my-object-subclass.c \ +@DBUS_BUILD_TESTS_TRUE@ my-object-subclass.h \ +@DBUS_BUILD_TESTS_TRUE@ my-object-marshal.c \ +@DBUS_BUILD_TESTS_TRUE@ test-service-glib.c + +@DBUS_BUILD_TESTS_TRUE@peer_server_SOURCES = \ +@DBUS_BUILD_TESTS_TRUE@ my-object.c \ +@DBUS_BUILD_TESTS_TRUE@ my-object.h \ +@DBUS_BUILD_TESTS_TRUE@ my-object-subclass.c \ +@DBUS_BUILD_TESTS_TRUE@ my-object-subclass.h \ +@DBUS_BUILD_TESTS_TRUE@ my-object-marshal.c \ +@DBUS_BUILD_TESTS_TRUE@ peer-server.c + +@DBUS_BUILD_TESTS_TRUE@peer_client_SOURCES = \ +@DBUS_BUILD_TESTS_TRUE@ peer-client.c + +@DBUS_BUILD_TESTS_TRUE@test_types_SOURCES = \ +@DBUS_BUILD_TESTS_TRUE@ test-types.c + +@DBUS_BUILD_TESTS_TRUE@test_gvariant_SOURCES = \ +@DBUS_BUILD_TESTS_TRUE@ test-gvariant.c + +@DBUS_BUILD_TESTS_TRUE@test_peer_on_bus_SOURCES = peer-on-bus.c +@DBUS_BUILD_TESTS_TRUE@CLEANFILES = \ +@DBUS_BUILD_TESTS_TRUE@ $(BUILT_SOURCES) \ +@DBUS_BUILD_TESTS_TRUE@ run-with-tmp-session-bus.conf + +@HAVE_GLIB_THREADS_TRUE@test_profile_SOURCES = \ +@HAVE_GLIB_THREADS_TRUE@ test-profile.c + +all: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu test/core/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu test/core/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): + +clean-noinstPROGRAMS: + @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \ + echo " rm -f" $$list; \ + rm -f $$list || exit $$?; \ + test -n "$(EXEEXT)" || exit 0; \ + list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f" $$list; \ + rm -f $$list +peer-client$(EXEEXT): $(peer_client_OBJECTS) $(peer_client_DEPENDENCIES) $(EXTRA_peer_client_DEPENDENCIES) + @rm -f peer-client$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(peer_client_OBJECTS) $(peer_client_LDADD) $(LIBS) +peer-server$(EXEEXT): $(peer_server_OBJECTS) $(peer_server_DEPENDENCIES) $(EXTRA_peer_server_DEPENDENCIES) + @rm -f peer-server$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(peer_server_OBJECTS) $(peer_server_LDADD) $(LIBS) +test-30574$(EXEEXT): $(test_30574_OBJECTS) $(test_30574_DEPENDENCIES) $(EXTRA_test_30574_DEPENDENCIES) + @rm -f test-30574$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_30574_OBJECTS) $(test_30574_LDADD) $(LIBS) +test-dbus-glib$(EXEEXT): $(test_dbus_glib_OBJECTS) $(test_dbus_glib_DEPENDENCIES) $(EXTRA_test_dbus_glib_DEPENDENCIES) + @rm -f test-dbus-glib$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_dbus_glib_OBJECTS) $(test_dbus_glib_LDADD) $(LIBS) +test-error-mapping$(EXEEXT): $(test_error_mapping_OBJECTS) $(test_error_mapping_DEPENDENCIES) $(EXTRA_test_error_mapping_DEPENDENCIES) + @rm -f test-error-mapping$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_error_mapping_OBJECTS) $(test_error_mapping_LDADD) $(LIBS) +test-gvariant$(EXEEXT): $(test_gvariant_OBJECTS) $(test_gvariant_DEPENDENCIES) $(EXTRA_test_gvariant_DEPENDENCIES) + @rm -f test-gvariant$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_gvariant_OBJECTS) $(test_gvariant_LDADD) $(LIBS) +test-peer-on-bus$(EXEEXT): $(test_peer_on_bus_OBJECTS) $(test_peer_on_bus_DEPENDENCIES) $(EXTRA_test_peer_on_bus_DEPENDENCIES) + @rm -f test-peer-on-bus$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_peer_on_bus_OBJECTS) $(test_peer_on_bus_LDADD) $(LIBS) +test-profile$(EXEEXT): $(test_profile_OBJECTS) $(test_profile_DEPENDENCIES) $(EXTRA_test_profile_DEPENDENCIES) + @rm -f test-profile$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_profile_OBJECTS) $(test_profile_LDADD) $(LIBS) +test-proxy-peer$(EXEEXT): $(test_proxy_peer_OBJECTS) $(test_proxy_peer_DEPENDENCIES) $(EXTRA_test_proxy_peer_DEPENDENCIES) + @rm -f test-proxy-peer$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_proxy_peer_OBJECTS) $(test_proxy_peer_LDADD) $(LIBS) +test-registrations$(EXEEXT): $(test_registrations_OBJECTS) $(test_registrations_DEPENDENCIES) $(EXTRA_test_registrations_DEPENDENCIES) + @rm -f test-registrations$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_registrations_OBJECTS) $(test_registrations_LDADD) $(LIBS) +test-service-glib$(EXEEXT): $(test_service_glib_OBJECTS) $(test_service_glib_DEPENDENCIES) $(EXTRA_test_service_glib_DEPENDENCIES) + @rm -f test-service-glib$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_service_glib_OBJECTS) $(test_service_glib_LDADD) $(LIBS) +test-thread-client$(EXEEXT): $(test_thread_client_OBJECTS) $(test_thread_client_DEPENDENCIES) $(EXTRA_test_thread_client_DEPENDENCIES) + @rm -f test-thread-client$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_thread_client_OBJECTS) $(test_thread_client_LDADD) $(LIBS) +test-thread-server$(EXEEXT): $(test_thread_server_OBJECTS) $(test_thread_server_DEPENDENCIES) $(EXTRA_test_thread_server_DEPENDENCIES) + @rm -f test-thread-server$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_thread_server_OBJECTS) $(test_thread_server_LDADD) $(LIBS) +test-types$(EXEEXT): $(test_types_OBJECTS) $(test_types_DEPENDENCIES) $(EXTRA_test_types_DEPENDENCIES) + @rm -f test-types$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_types_OBJECTS) $(test_types_LDADD) $(LIBS) +test-variant-recursion$(EXEEXT): $(test_variant_recursion_OBJECTS) $(test_variant_recursion_DEPENDENCIES) $(EXTRA_test_variant_recursion_DEPENDENCIES) + @rm -f test-variant-recursion$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_variant_recursion_OBJECTS) $(test_variant_recursion_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/30574.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/error-mapping.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/my-object-marshal.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/my-object-subclass.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/my-object.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/peer-client.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/peer-on-bus.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/peer-server.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/proxy-peer.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/registrations.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-dbus-glib.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-gvariant.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-profile.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-service-glib.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-thread-client.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-thread-server.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-types.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-variant-recursion.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + set x; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +check-TESTS: $(TESTS) + @failed=0; all=0; xfail=0; xpass=0; skip=0; \ + srcdir=$(srcdir); export srcdir; \ + list=' $(TESTS) '; \ + $(am__tty_colors); \ + if test -n "$$list"; then \ + for tst in $$list; do \ + if test -f ./$$tst; then dir=./; \ + elif test -f $$tst; then dir=; \ + else dir="$(srcdir)/"; fi; \ + if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *[\ \ ]$$tst[\ \ ]*) \ + xpass=`expr $$xpass + 1`; \ + failed=`expr $$failed + 1`; \ + col=$$red; res=XPASS; \ + ;; \ + *) \ + col=$$grn; res=PASS; \ + ;; \ + esac; \ + elif test $$? -ne 77; then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *[\ \ ]$$tst[\ \ ]*) \ + xfail=`expr $$xfail + 1`; \ + col=$$lgn; res=XFAIL; \ + ;; \ + *) \ + failed=`expr $$failed + 1`; \ + col=$$red; res=FAIL; \ + ;; \ + esac; \ + else \ + skip=`expr $$skip + 1`; \ + col=$$blu; res=SKIP; \ + fi; \ + echo "$${col}$$res$${std}: $$tst"; \ + done; \ + if test "$$all" -eq 1; then \ + tests="test"; \ + All=""; \ + else \ + tests="tests"; \ + All="All "; \ + fi; \ + if test "$$failed" -eq 0; then \ + if test "$$xfail" -eq 0; then \ + banner="$$All$$all $$tests passed"; \ + else \ + if test "$$xfail" -eq 1; then failures=failure; else failures=failures; fi; \ + banner="$$All$$all $$tests behaved as expected ($$xfail expected $$failures)"; \ + fi; \ + else \ + if test "$$xpass" -eq 0; then \ + banner="$$failed of $$all $$tests failed"; \ + else \ + if test "$$xpass" -eq 1; then passes=pass; else passes=passes; fi; \ + banner="$$failed of $$all $$tests did not behave as expected ($$xpass unexpected $$passes)"; \ + fi; \ + fi; \ + dashes="$$banner"; \ + skipped=""; \ + if test "$$skip" -ne 0; then \ + if test "$$skip" -eq 1; then \ + skipped="($$skip test was not run)"; \ + else \ + skipped="($$skip tests were not run)"; \ + fi; \ + test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \ + dashes="$$skipped"; \ + fi; \ + report=""; \ + if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \ + report="Please report to $(PACKAGE_BUGREPORT)"; \ + test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \ + dashes="$$report"; \ + fi; \ + dashes=`echo "$$dashes" | sed s/./=/g`; \ + if test "$$failed" -eq 0; then \ + col="$$grn"; \ + else \ + col="$$red"; \ + fi; \ + echo "$${col}$$dashes$${std}"; \ + echo "$${col}$$banner$${std}"; \ + test -z "$$skipped" || echo "$${col}$$skipped$${std}"; \ + test -z "$$report" || echo "$${col}$$report$${std}"; \ + echo "$${col}$$dashes$${std}"; \ + test "$$failed" -eq 0; \ + else :; fi + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am + $(MAKE) $(AM_MAKEFLAGS) check-TESTS +check: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) check-am +all-am: Makefile $(PROGRAMS) +installdirs: +install: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." + -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) +clean: clean-am + +clean-am: clean-generic clean-libtool clean-noinstPROGRAMS \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: all check check-am install install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-TESTS check-am clean \ + clean-generic clean-libtool clean-noinstPROGRAMS ctags \ + distclean distclean-compile distclean-generic \ + distclean-libtool distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-dvi install-dvi-am install-exec \ + install-exec-am install-html install-html-am install-info \ + install-info-am install-man install-pdf install-pdf-am \ + install-ps install-ps-am install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags uninstall uninstall-am + + +@DBUS_BUILD_TESTS_TRUE@test-service-glib-glue.h: test-service-glib.xml $(top_builddir)/dbus/dbus-binding-tool$(EXEEXT) +@DBUS_BUILD_TESTS_TRUE@ $(DEBUG) $(DBUS_BINDING_TOOL) --prefix=my_object --mode=glib-server --output=test-service-glib-glue.h $(srcdir)/test-service-glib.xml + +@DBUS_BUILD_TESTS_TRUE@test-service-glib-subclass-glue.h: test-service-glib-subclass.xml $(top_builddir)/dbus/dbus-binding-tool$(EXEEXT) +@DBUS_BUILD_TESTS_TRUE@ $(DEBUG) $(DBUS_BINDING_TOOL) --prefix=my_object_subclass --mode=glib-server --output=test-service-glib-subclass-glue.h $(srcdir)/test-service-glib-subclass.xml + +@DBUS_BUILD_TESTS_TRUE@test-service-glib-bindings.h: test-service-glib.xml $(top_builddir)/dbus/dbus-binding-tool$(EXEEXT) +@DBUS_BUILD_TESTS_TRUE@ $(DEBUG) $(DBUS_BINDING_TOOL) --prefix=my_object --mode=glib-client --output=test-service-glib-bindings.h $(srcdir)/test-service-glib.xml + +@DBUS_BUILD_TESTS_TRUE@my-object-marshal.c: Makefile my-object-marshal.list +@DBUS_BUILD_TESTS_TRUE@ echo "#include <config.h>" > $@.tmp +@DBUS_BUILD_TESTS_TRUE@ @GLIB_GENMARSHAL@ --prefix=my_object_marshal $(srcdir)/my-object-marshal.list --header --body >> $@.tmp +@DBUS_BUILD_TESTS_TRUE@ mv $@.tmp $@ + +@DBUS_BUILD_TESTS_TRUE@my-object-marshal.h: Makefile my-object-marshal.list +@DBUS_BUILD_TESTS_TRUE@ @GLIB_GENMARSHAL@ --prefix=my_object_marshal $(srcdir)/my-object-marshal.list --header > my-object-marshal.h + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/test/core/error-mapping.c b/test/core/error-mapping.c new file mode 100644 index 0000000..122b6de --- /dev/null +++ b/test/core/error-mapping.c @@ -0,0 +1,301 @@ +/* Feature test for exported object methods raising errors + * + * Copyright © 2006-2010 Red Hat, Inc. + * Copyright © 2006-2010 Collabora Ltd. + * Copyright © 2006-2011 Nokia Corporation + * Copyright © 2006 Steve Frécinaux + * + * 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 <glib.h> +#include <gio/gio.h> + +#include <dbus/dbus.h> +#include <dbus/dbus-glib.h> +#include <dbus/dbus-glib-lowlevel.h> + +#include <string.h> + +#include "my-object.h" +#include "test-service-glib-bindings.h" + +/* my-object wants this to exist */ +GMainLoop *loop = NULL; + +typedef struct { + GError *error; + gchar *error_name; + DBusGConnection *conn; + DBusGProxy *proxy; + GObject *object; +} Fixture; + +#define assert_contains(haystack, needle) \ + assert_contains_impl (__FILE__, __LINE__, G_STRINGIFY (haystack), haystack, \ + G_STRINGIFY (needle), needle) + +static void +assert_contains_impl (const gchar *file, + gint line, + const gchar *haystack_desc, + const gchar *haystack, + const gchar *needle_desc, + const gchar *needle) +{ + if (G_UNLIKELY (strstr (haystack, needle) == NULL)) + { + g_error ("%s:%d: assertion failed: (%s) contains (%s): " + "values are \"%s\", \"%s\"", + file, line, haystack_desc, needle_desc, haystack, needle); + } +} + +static void +setup (Fixture *f, + gconstpointer context) +{ + static gsize once = 0; + + dbus_g_type_specialized_init (); + + if (g_once_init_enter (&once)) + { + /* this may only be called once */ + dbus_g_error_domain_register (MY_OBJECT_ERROR, NULL, MY_TYPE_ERROR); + + g_once_init_leave (&once, 1); + } + + f->conn = dbus_g_bus_get_private (DBUS_BUS_SESSION, NULL, &f->error); + g_assert_no_error (f->error); + g_assert (f->conn != NULL); + + f->object = g_object_new (MY_TYPE_OBJECT, NULL); + g_assert (MY_IS_OBJECT (f->object)); + dbus_g_connection_register_g_object (f->conn, "/com/example/Test/Object", + f->object); + + f->proxy = dbus_g_proxy_new_for_name (f->conn, + dbus_bus_get_unique_name (dbus_g_connection_get_connection (f->conn)), + "/com/example/Test/Object", "org.freedesktop.DBus.GLib.Tests.MyObject"); + g_assert (f->proxy != NULL); +} + +static void +throw_error_cb (DBusGProxy *proxy, + GError *error, + gpointer user_data) +{ + Fixture *f = user_data; + + g_assert (error != NULL); + g_clear_error (&f->error); + g_free (f->error_name); + f->error = g_error_copy (error); + + if (g_error_matches (error, DBUS_GERROR, DBUS_GERROR_REMOTE_EXCEPTION)) + f->error_name = g_strdup (dbus_g_error_get_name (error)); + else + f->error_name = NULL; +} + +static void +test_async (Fixture *f, + gconstpointer context) +{ + /* This is equivalent to test_simple but uses a method that's implemented + * async at the service side - it's a different calling convention for the + * service, but is indistinguishable here. */ + + my_object_save_error ((MyObject *) f->object, MY_OBJECT_ERROR, + MY_OBJECT_ERROR_FOO, "<foo>"); + + if (!org_freedesktop_DBus_GLib_Tests_MyObject_async_throw_error_async ( + f->proxy, throw_error_cb, f)) + g_error ("Failed to start async AsyncThrowError call"); + + while (f->error == NULL) + g_main_context_iteration (NULL, TRUE); + + g_assert_error (f->error, DBUS_GERROR, DBUS_GERROR_REMOTE_EXCEPTION); + g_assert_cmpstr (f->error_name, ==, + "org.freedesktop.DBus.GLib.Tests.MyObject.Foo"); + assert_contains (f->error->message, "<foo>"); +} + +static void +test_simple (Fixture *f, + gconstpointer context) +{ + my_object_save_error ((MyObject *) f->object, MY_OBJECT_ERROR, + MY_OBJECT_ERROR_FOO, "<foo>"); + + if (!org_freedesktop_DBus_GLib_Tests_MyObject_throw_error_async ( + f->proxy, throw_error_cb, f)) + g_error ("Failed to start async ThrowError call"); + + while (f->error == NULL) + g_main_context_iteration (NULL, TRUE); + + g_assert_error (f->error, DBUS_GERROR, DBUS_GERROR_REMOTE_EXCEPTION); + g_assert_cmpstr (f->error_name, ==, + "org.freedesktop.DBus.GLib.Tests.MyObject.Foo"); + assert_contains (f->error->message, "<foo>"); +} + +static void +test_builtin (Fixture *f, + gconstpointer context) +{ + g_test_bug ("16776"); + + my_object_save_error ((MyObject *) f->object, DBUS_GERROR, + DBUS_GERROR_NOT_SUPPORTED, "<not supported>"); + + if (!org_freedesktop_DBus_GLib_Tests_MyObject_throw_error_async ( + f->proxy, throw_error_cb, f)) + g_error ("Failed to start async ThrowError call"); + + while (f->error == NULL) + g_main_context_iteration (NULL, TRUE); + + g_assert_error (f->error, DBUS_GERROR, DBUS_GERROR_NOT_SUPPORTED); + assert_contains (f->error->message, "<not supported>"); +} + +static void +test_multi_word (Fixture *f, + gconstpointer context) +{ + /* no bug#, but this is a regression test for commit 3d69cfeab177e */ + + my_object_save_error ((MyObject *) f->object, MY_OBJECT_ERROR, + MY_OBJECT_ERROR_MULTI_WORD, "this method's error has a hyphen"); + + if (!org_freedesktop_DBus_GLib_Tests_MyObject_throw_error_async ( + f->proxy, throw_error_cb, f)) + g_error ("Failed to start async ThrowError call"); + + while (f->error == NULL) + g_main_context_iteration (NULL, TRUE); + + g_assert_error (f->error, DBUS_GERROR, DBUS_GERROR_REMOTE_EXCEPTION); + g_assert_cmpstr (f->error_name, ==, + "org.freedesktop.DBus.GLib.Tests.MyObject.MultiWord"); + assert_contains (f->error->message, "this method's error has a hyphen"); +} + +static void +test_underscore (Fixture *f, + gconstpointer context) +{ + g_test_bug ("30274"); + + my_object_save_error ((MyObject *) f->object, MY_OBJECT_ERROR, + MY_OBJECT_ERROR_UNDER_SCORE, "this method's error has an underscore"); + + if (!org_freedesktop_DBus_GLib_Tests_MyObject_throw_error_async ( + f->proxy, throw_error_cb, f)) + g_error ("Failed to start async ThrowError call"); + + while (f->error == NULL) + g_main_context_iteration (NULL, TRUE); + + g_assert_error (f->error, DBUS_GERROR, DBUS_GERROR_REMOTE_EXCEPTION); + g_assert_cmpstr (f->error_name, ==, + "org.freedesktop.DBus.GLib.Tests.MyObject.Under_score"); + assert_contains (f->error->message, "this method's error has an underscore"); +} + +static void +test_unregistered (Fixture *f, + gconstpointer context) +{ + g_test_bug ("27799"); + + my_object_save_error ((MyObject *) f->object, G_IO_ERROR, + G_IO_ERROR_NOT_INITIALIZED, + "dbus-glib does not know about this error domain"); + + if (!org_freedesktop_DBus_GLib_Tests_MyObject_throw_error_async ( + f->proxy, throw_error_cb, f)) + g_error ("Failed to start async ThrowError call"); + + while (f->error == NULL) + g_main_context_iteration (NULL, TRUE); + + g_assert_error (f->error, DBUS_GERROR, DBUS_GERROR_REMOTE_EXCEPTION); + assert_contains (f->error->message, + "dbus-glib does not know about this error domain"); +} + +static void +teardown (Fixture *f, + gconstpointer context G_GNUC_UNUSED) +{ + g_free (f->error_name); + + g_clear_error (&f->error); + + if (f->proxy != NULL) + { + g_object_unref (f->proxy); + f->proxy = NULL; + } + + if (f->object != NULL) + { + g_object_unref (f->object); + f->object = NULL; + } + + if (f->conn != NULL) + { + dbus_connection_close (dbus_g_connection_get_connection (f->conn)); + dbus_g_connection_unref (f->conn); + f->conn = NULL; + } +} + +int +main (int argc, + char **argv) +{ + g_test_init (&argc, &argv, NULL); + g_test_bug_base ("https://bugs.freedesktop.org/show_bug.cgi?id="); + + g_type_init (); + + g_test_add ("/error-mapping/async", Fixture, NULL, setup, test_async, + teardown); + g_test_add ("/error-mapping/builtin", Fixture, NULL, setup, test_builtin, + teardown); + g_test_add ("/error-mapping/multi-word", Fixture, NULL, setup, + test_multi_word, teardown); + g_test_add ("/error-mapping/simple", Fixture, NULL, setup, test_simple, + teardown); + g_test_add ("/error-mapping/underscore", Fixture, NULL, setup, + test_underscore, teardown); + g_test_add ("/error-mapping/unregistered", Fixture, NULL, setup, + test_unregistered, teardown); + + return g_test_run (); +} diff --git a/test/core/my-object-marshal.c b/test/core/my-object-marshal.c new file mode 100644 index 0000000..ff91cab --- /dev/null +++ b/test/core/my-object-marshal.c @@ -0,0 +1,150 @@ +#include <config.h> + +#ifndef __my_object_marshal_MARSHAL_H__ +#define __my_object_marshal_MARSHAL_H__ + +#include <glib-object.h> + +G_BEGIN_DECLS + +#ifdef G_ENABLE_DEBUG +#define g_marshal_value_peek_boolean(v) g_value_get_boolean (v) +#define g_marshal_value_peek_char(v) g_value_get_schar (v) +#define g_marshal_value_peek_uchar(v) g_value_get_uchar (v) +#define g_marshal_value_peek_int(v) g_value_get_int (v) +#define g_marshal_value_peek_uint(v) g_value_get_uint (v) +#define g_marshal_value_peek_long(v) g_value_get_long (v) +#define g_marshal_value_peek_ulong(v) g_value_get_ulong (v) +#define g_marshal_value_peek_int64(v) g_value_get_int64 (v) +#define g_marshal_value_peek_uint64(v) g_value_get_uint64 (v) +#define g_marshal_value_peek_enum(v) g_value_get_enum (v) +#define g_marshal_value_peek_flags(v) g_value_get_flags (v) +#define g_marshal_value_peek_float(v) g_value_get_float (v) +#define g_marshal_value_peek_double(v) g_value_get_double (v) +#define g_marshal_value_peek_string(v) (char*) g_value_get_string (v) +#define g_marshal_value_peek_param(v) g_value_get_param (v) +#define g_marshal_value_peek_boxed(v) g_value_get_boxed (v) +#define g_marshal_value_peek_pointer(v) g_value_get_pointer (v) +#define g_marshal_value_peek_object(v) g_value_get_object (v) +#define g_marshal_value_peek_variant(v) g_value_get_variant (v) +#else /* !G_ENABLE_DEBUG */ +/* WARNING: This code accesses GValues directly, which is UNSUPPORTED API. + * Do not access GValues directly in your code. Instead, use the + * g_value_get_*() functions + */ +#define g_marshal_value_peek_boolean(v) (v)->data[0].v_int +#define g_marshal_value_peek_char(v) (v)->data[0].v_int +#define g_marshal_value_peek_uchar(v) (v)->data[0].v_uint +#define g_marshal_value_peek_int(v) (v)->data[0].v_int +#define g_marshal_value_peek_uint(v) (v)->data[0].v_uint +#define g_marshal_value_peek_long(v) (v)->data[0].v_long +#define g_marshal_value_peek_ulong(v) (v)->data[0].v_ulong +#define g_marshal_value_peek_int64(v) (v)->data[0].v_int64 +#define g_marshal_value_peek_uint64(v) (v)->data[0].v_uint64 +#define g_marshal_value_peek_enum(v) (v)->data[0].v_long +#define g_marshal_value_peek_flags(v) (v)->data[0].v_ulong +#define g_marshal_value_peek_float(v) (v)->data[0].v_float +#define g_marshal_value_peek_double(v) (v)->data[0].v_double +#define g_marshal_value_peek_string(v) (v)->data[0].v_pointer +#define g_marshal_value_peek_param(v) (v)->data[0].v_pointer +#define g_marshal_value_peek_boxed(v) (v)->data[0].v_pointer +#define g_marshal_value_peek_pointer(v) (v)->data[0].v_pointer +#define g_marshal_value_peek_object(v) (v)->data[0].v_pointer +#define g_marshal_value_peek_variant(v) (v)->data[0].v_pointer +#endif /* !G_ENABLE_DEBUG */ + + +/* NONE:STRING,INT,STRING (/home/smcv/src/fdo/dbus-glib/test/core/my-object-marshal.list:1) */ +extern void my_object_marshal_VOID__STRING_INT_STRING (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); +void +my_object_marshal_VOID__STRING_INT_STRING (GClosure *closure, + GValue *return_value G_GNUC_UNUSED, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint G_GNUC_UNUSED, + gpointer marshal_data) +{ + typedef void (*GMarshalFunc_VOID__STRING_INT_STRING) (gpointer data1, + gpointer arg_1, + gint arg_2, + gpointer arg_3, + gpointer data2); + register GMarshalFunc_VOID__STRING_INT_STRING callback; + register GCClosure *cc = (GCClosure*) closure; + register gpointer data1, data2; + + g_return_if_fail (n_param_values == 4); + + if (G_CCLOSURE_SWAP_DATA (closure)) + { + data1 = closure->data; + data2 = g_value_peek_pointer (param_values + 0); + } + else + { + data1 = g_value_peek_pointer (param_values + 0); + data2 = closure->data; + } + callback = (GMarshalFunc_VOID__STRING_INT_STRING) (marshal_data ? marshal_data : cc->callback); + + callback (data1, + g_marshal_value_peek_string (param_values + 1), + g_marshal_value_peek_int (param_values + 2), + g_marshal_value_peek_string (param_values + 3), + data2); +} +#define my_object_marshal_NONE__STRING_INT_STRING my_object_marshal_VOID__STRING_INT_STRING + +/* NONE:STRING,BOXED (/home/smcv/src/fdo/dbus-glib/test/core/my-object-marshal.list:2) */ +extern void my_object_marshal_VOID__STRING_BOXED (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); +void +my_object_marshal_VOID__STRING_BOXED (GClosure *closure, + GValue *return_value G_GNUC_UNUSED, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint G_GNUC_UNUSED, + gpointer marshal_data) +{ + typedef void (*GMarshalFunc_VOID__STRING_BOXED) (gpointer data1, + gpointer arg_1, + gpointer arg_2, + gpointer data2); + register GMarshalFunc_VOID__STRING_BOXED callback; + register GCClosure *cc = (GCClosure*) closure; + register gpointer data1, data2; + + g_return_if_fail (n_param_values == 3); + + if (G_CCLOSURE_SWAP_DATA (closure)) + { + data1 = closure->data; + data2 = g_value_peek_pointer (param_values + 0); + } + else + { + data1 = g_value_peek_pointer (param_values + 0); + data2 = closure->data; + } + callback = (GMarshalFunc_VOID__STRING_BOXED) (marshal_data ? marshal_data : cc->callback); + + callback (data1, + g_marshal_value_peek_string (param_values + 1), + g_marshal_value_peek_boxed (param_values + 2), + data2); +} +#define my_object_marshal_NONE__STRING_BOXED my_object_marshal_VOID__STRING_BOXED + +G_END_DECLS + +#endif /* __my_object_marshal_MARSHAL_H__ */ + diff --git a/test/core/my-object-marshal.h b/test/core/my-object-marshal.h new file mode 100644 index 0000000..445d63b --- /dev/null +++ b/test/core/my-object-marshal.h @@ -0,0 +1,30 @@ + +#ifndef __my_object_marshal_MARSHAL_H__ +#define __my_object_marshal_MARSHAL_H__ + +#include <glib-object.h> + +G_BEGIN_DECLS + +/* NONE:STRING,INT,STRING (/home/smcv/src/fdo/dbus-glib/test/core/my-object-marshal.list:1) */ +extern void my_object_marshal_VOID__STRING_INT_STRING (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); +#define my_object_marshal_NONE__STRING_INT_STRING my_object_marshal_VOID__STRING_INT_STRING + +/* NONE:STRING,BOXED (/home/smcv/src/fdo/dbus-glib/test/core/my-object-marshal.list:2) */ +extern void my_object_marshal_VOID__STRING_BOXED (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); +#define my_object_marshal_NONE__STRING_BOXED my_object_marshal_VOID__STRING_BOXED + +G_END_DECLS + +#endif /* __my_object_marshal_MARSHAL_H__ */ + diff --git a/test/core/my-object-marshal.list b/test/core/my-object-marshal.list new file mode 100644 index 0000000..48cbfad --- /dev/null +++ b/test/core/my-object-marshal.list @@ -0,0 +1,2 @@ +NONE:STRING,INT,STRING +NONE:STRING,BOXED diff --git a/test/core/my-object-subclass.c b/test/core/my-object-subclass.c new file mode 100644 index 0000000..7b4ae9e --- /dev/null +++ b/test/core/my-object-subclass.c @@ -0,0 +1,115 @@ +#include <config.h> +#include <string.h> +#include <glib/gi18n.h> +#include <glib-object.h> +#include "my-object-subclass.h" + +#include "test-service-glib-subclass-glue.h" + +/* Properties */ +enum +{ + PROP_0, + PROP_THIS_IS_A_SUBCLASS_STRING, + PROP_THIS_IS_A_SUBCLASS_UINT +}; + +G_DEFINE_TYPE(MyObjectSubclass, my_object_subclass, MY_TYPE_OBJECT) + +static void +my_object_subclass_finalize (GObject *object) +{ + MyObjectSubclass *mobject = MY_OBJECT_SUBCLASS (object); + + g_free (mobject->this_is_a_subclass_string); + + (G_OBJECT_CLASS (my_object_subclass_parent_class)->finalize) (object); +} + +static void +my_object_subclass_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + MyObjectSubclass *mobject; + + mobject = MY_OBJECT_SUBCLASS (object); + + switch (prop_id) + { + case PROP_THIS_IS_A_SUBCLASS_STRING: + g_free (mobject->this_is_a_subclass_string); + mobject->this_is_a_subclass_string = g_value_dup_string (value); + break; + + case PROP_THIS_IS_A_SUBCLASS_UINT: + mobject->this_is_a_subclass_uint = g_value_get_uint (value); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +my_object_subclass_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + MyObjectSubclass *mobject; + + mobject = MY_OBJECT_SUBCLASS (object); + + switch (prop_id) + { + case PROP_THIS_IS_A_SUBCLASS_STRING: + g_value_set_string (value, mobject->this_is_a_subclass_string); + break; + + case PROP_THIS_IS_A_SUBCLASS_UINT: + g_value_set_uint (value, mobject->this_is_a_subclass_uint); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +my_object_subclass_init (MyObjectSubclass *obj) +{ +} + +static void +my_object_subclass_class_init (MyObjectSubclassClass *mobject_class) +{ + GObjectClass *gobject_class = G_OBJECT_CLASS (mobject_class); + + dbus_g_object_type_install_info (MY_TYPE_OBJECT_SUBCLASS, + &dbus_glib_my_object_subclass_object_info); + + gobject_class->finalize = my_object_subclass_finalize; + gobject_class->set_property = my_object_subclass_set_property; + gobject_class->get_property = my_object_subclass_get_property; + + g_object_class_install_property (gobject_class, + PROP_THIS_IS_A_SUBCLASS_STRING, + g_param_spec_string ("this_is_a_subclass_string", + _("Sample string"), + _("Example of a string property"), + "default subclass value", + G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); + + g_object_class_install_property (gobject_class, + PROP_THIS_IS_A_SUBCLASS_UINT, + g_param_spec_uint ("this_is_a_subclass_uint", + _("Sample uint"), + _("Example of a uint property"), + 0, G_MAXUINT32, 1234567, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); +} + diff --git a/test/core/my-object-subclass.h b/test/core/my-object-subclass.h new file mode 100644 index 0000000..edb03cd --- /dev/null +++ b/test/core/my-object-subclass.h @@ -0,0 +1,33 @@ +#ifndef __MY_OBJECT_SUBCLASS_H__ +#define __MY_OBJECT_SUBCLASS_H__ + +#include <glib-object.h> +#include <dbus/dbus-glib.h> + +#include "my-object.h" + +typedef struct MyObjectSubclass MyObjectSubclass; +typedef struct MyObjectSubclassClass MyObjectSubclassClass; + +GType my_object_subclass_get_type (void); + +struct MyObjectSubclass +{ + MyObject parent; + char *this_is_a_subclass_string; + guint this_is_a_subclass_uint; +}; + +struct MyObjectSubclassClass +{ + MyObjectClass parent; +}; + +#define MY_TYPE_OBJECT_SUBCLASS (my_object_subclass_get_type ()) +#define MY_OBJECT_SUBCLASS(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), MY_TYPE_OBJECT_SUBCLASS, MyObjectSubclass)) +#define MY_OBJECT_SUBCLASS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MY_TYPE_OBJECT_SUBCLASS, MyObjectSubclassClass)) +#define MY_IS_OBJECT_SUBCLASS(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), MY_TYPE_OBJECT_SUBCLASS)) +#define MY_IS_OBJECT_SUBCLASS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MY_TYPE_OBJECT_SUBCLASS)) +#define MY_OBJECT_SUBCLASS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MY_TYPE_OBJECT_SUBCLASS, MyObjectSubclassClass)) + +#endif diff --git a/test/core/my-object.c b/test/core/my-object.c new file mode 100644 index 0000000..82b6322 --- /dev/null +++ b/test/core/my-object.c @@ -0,0 +1,882 @@ +#include <config.h> +#include <string.h> +#include <glib/gi18n.h> +#include <glib-object.h> +#include "my-object.h" +#include "my-object-marshal.h" + +#include "test-service-glib-glue.h" + +void +my_object_register_marshallers (void) +{ + dbus_g_object_register_marshaller (my_object_marshal_VOID__STRING_INT_STRING, + G_TYPE_NONE, G_TYPE_STRING, G_TYPE_INT, G_TYPE_STRING, G_TYPE_INVALID); + + dbus_g_object_register_marshaller (my_object_marshal_VOID__STRING_BOXED, + G_TYPE_NONE, G_TYPE_STRING, G_TYPE_VALUE, G_TYPE_INVALID); +} + +/* Properties */ +enum +{ + PROP_0, + PROP_THIS_IS_A_STRING, + PROP_NO_TOUCHING, + PROP_SUPER_STUDLY, + PROP_SHOULD_BE_HIDDEN +}; + +enum +{ + FROBNICATE, + OBJECTIFIED, + SIG0, + SIG1, + SIG2, + LAST_SIGNAL +}; + +static guint signals[LAST_SIGNAL] = { 0 }; + +G_DEFINE_TYPE(MyObject, my_object, G_TYPE_OBJECT) + +static void +my_object_finalize (GObject *object) +{ + MyObject *mobject = MY_OBJECT (object); + + g_free (mobject->this_is_a_string); + g_clear_error (&mobject->saved_error); + + (G_OBJECT_CLASS (my_object_parent_class)->finalize) (object); +} + +static void +my_object_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + MyObject *mobject; + + mobject = MY_OBJECT (object); + + switch (prop_id) + { + case PROP_THIS_IS_A_STRING: + g_free (mobject->this_is_a_string); + mobject->this_is_a_string = g_value_dup_string (value); + break; + + case PROP_NO_TOUCHING: + mobject->notouching = g_value_get_uint (value); + break; + + case PROP_SUPER_STUDLY: + mobject->super_studly = g_value_get_double (value); + break; + + case PROP_SHOULD_BE_HIDDEN: + mobject->should_be_hidden = g_value_get_boolean (value); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +my_object_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + MyObject *mobject; + + mobject = MY_OBJECT (object); + + switch (prop_id) + { + case PROP_THIS_IS_A_STRING: + g_value_set_string (value, mobject->this_is_a_string); + break; + + case PROP_NO_TOUCHING: + g_value_set_uint (value, mobject->notouching); + break; + + case PROP_SUPER_STUDLY: + g_value_set_double (value, mobject->super_studly); + break; + + case PROP_SHOULD_BE_HIDDEN: + g_value_set_boolean (value, mobject->should_be_hidden); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +my_object_init (MyObject *obj) +{ + obj->val = 0; + obj->notouching = 42; + obj->saved_error = g_error_new_literal (MY_OBJECT_ERROR, + MY_OBJECT_ERROR_FOO, "this method always loses"); +} + +static void +my_object_class_init (MyObjectClass *mobject_class) +{ + GObjectClass *gobject_class = G_OBJECT_CLASS (mobject_class); + + my_object_register_marshallers (); + + dbus_g_object_type_install_info (MY_TYPE_OBJECT, + &dbus_glib_my_object_object_info); + + gobject_class->finalize = my_object_finalize; + gobject_class->set_property = my_object_set_property; + gobject_class->get_property = my_object_get_property; + + g_object_class_install_property (gobject_class, + PROP_THIS_IS_A_STRING, + g_param_spec_string ("this_is_a_string", + _("Sample string"), + _("Example of a string property"), + "default value", + G_PARAM_READWRITE)); + g_object_class_install_property (gobject_class, + PROP_NO_TOUCHING, + g_param_spec_uint ("no_touching", + _("Don't touch"), + _("Example of a readonly property (for export)"), + 0, 100, 42, + G_PARAM_READWRITE)); + + g_object_class_install_property (gobject_class, + PROP_SUPER_STUDLY, + g_param_spec_double ("super-studly", + _("In Studly Caps"), + _("Example of a StudlyCaps property"), + 0, 256, 128, + G_PARAM_READWRITE)); + + g_object_class_install_property (gobject_class, + PROP_SHOULD_BE_HIDDEN, + g_param_spec_boolean ("should-be-hidden", + _("A non-exported property"), + _("Example of a property we don't want exported"), + FALSE, + G_PARAM_READWRITE)); + + signals[FROBNICATE] = + g_signal_new ("frobnicate", + G_OBJECT_CLASS_TYPE (mobject_class), + G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, + 0, + NULL, NULL, + g_cclosure_marshal_VOID__INT, + G_TYPE_NONE, 1, G_TYPE_INT); + + signals[OBJECTIFIED] = + g_signal_new ("objectified", + G_OBJECT_CLASS_TYPE (mobject_class), + G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, + 0, + NULL, NULL, + g_cclosure_marshal_VOID__OBJECT, + G_TYPE_NONE, 1, G_TYPE_OBJECT); + + signals[SIG0] = + g_signal_new ("sig0", + G_OBJECT_CLASS_TYPE (mobject_class), + G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, + 0, + NULL, NULL, + my_object_marshal_VOID__STRING_INT_STRING, + G_TYPE_NONE, 3, G_TYPE_STRING, G_TYPE_INT, G_TYPE_STRING); + + signals[SIG1] = + g_signal_new ("sig1", + G_OBJECT_CLASS_TYPE (mobject_class), + G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, + 0, + NULL, NULL, + my_object_marshal_VOID__STRING_BOXED, + G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_VALUE); + + signals[SIG2] = + g_signal_new ("sig2", + G_OBJECT_CLASS_TYPE (mobject_class), + G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, + 0, + NULL, NULL, + g_cclosure_marshal_VOID__BOXED, + G_TYPE_NONE, 1, DBUS_TYPE_G_STRING_STRING_HASHTABLE); +} + +GQuark +my_object_error_quark (void) +{ + static GQuark quark = 0; + if (!quark) + quark = g_quark_from_static_string ("my_object_error"); + + return quark; +} + +/* This should really be standard. */ +#define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC } + +GType +my_object_error_get_type (void) +{ + static GType etype = 0; + + if (etype == 0) + { + static const GEnumValue values[] = + { + + ENUM_ENTRY (MY_OBJECT_ERROR_FOO, "Foo"), + ENUM_ENTRY (MY_OBJECT_ERROR_BAR, "Bar"), + ENUM_ENTRY (MY_OBJECT_ERROR_MULTI_WORD, "Multi-word"), + ENUM_ENTRY (MY_OBJECT_ERROR_UNDER_SCORE, "Under_score"), + { 0, 0, 0 } + }; + + etype = g_enum_register_static ("MyObjectError", values); + } + + return etype; +} + +gboolean +my_object_do_nothing (MyObject *obj, GError **error) +{ + return TRUE; +} + +gboolean +my_object_increment (MyObject *obj, gint32 x, gint32 *ret, GError **error) +{ + *ret = x +1; + return TRUE; +} + +gint32 +my_object_increment_retval (MyObject *obj, gint32 x) +{ + return x + 1; +} + +gint32 +my_object_increment_retval_error (MyObject *obj, gint32 x, GError **error) +{ + if (x + 1 > 10) + { + g_set_error (error, + MY_OBJECT_ERROR, + MY_OBJECT_ERROR_FOO, + "%s", + "x is bigger than 9"); + return FALSE; + } + return x + 1; +} + +void +my_object_save_error (MyObject *obj, + GQuark domain, + gint code, + const gchar *message) +{ + g_clear_error (&obj->saved_error); + g_set_error_literal (&obj->saved_error, domain, code, message); +} + +gboolean +my_object_throw_error (MyObject *obj, GError **error) +{ + g_set_error_literal (error, obj->saved_error->domain, + obj->saved_error->code, obj->saved_error->message); + return FALSE; +} + +gboolean +my_object_throw_unregistered_error (MyObject *obj, GError **error) +{ + /* Unregistered errors shouldn't cause a dbus abort. See + * https://bugzilla.redhat.com/show_bug.cgi?id=581794 + * + * This is arguably invalid usage - a domain of 0 (which stringifies + * to NULL) is meaningless. (See GNOME#660731.) + * + * We can't just use my_object_save_error() and ThrowError() for + * this, because g_error_new() is stricter about the domain than + * g_error_new_valist(). Perhaps this method should be removed entirely, + * though. + */ + g_set_error (error, 0, 0, + "%s", + "this method always loses more"); + return FALSE; +} + + +gboolean +my_object_uppercase (MyObject *obj, const char *str, char **ret, GError **error) +{ + *ret = g_ascii_strup (str, -1); + return TRUE; +} + +gboolean +my_object_many_args (MyObject *obj, guint32 x, const char *str, double trouble, double *d_ret, char **str_ret, GError **error) +{ + *d_ret = trouble + (x * 2); + *str_ret = g_ascii_strup (str, -1); + return TRUE; +} + +gboolean +my_object_many_return (MyObject *obj, guint32 *arg0, char **arg1, gint32 *arg2, guint32 *arg3, guint32 *arg4, const char **arg5, GError **error) +{ + *arg0 = 42; + *arg1 = g_strdup ("42"); + *arg2 = -67; + *arg3 = 2; + *arg4 = 26; + *arg5 = "hello world"; /* Annotation specifies as const */ + return TRUE; +} + +gboolean +my_object_stringify (MyObject *obj, GValue *value, char **ret, GError **error) +{ + GValue valstr = {0, }; + + g_value_init (&valstr, G_TYPE_STRING); + if (!g_value_transform (value, &valstr)) + { + g_set_error (error, + MY_OBJECT_ERROR, + MY_OBJECT_ERROR_FOO, + "couldn't transform value"); + return FALSE; + } + *ret = g_value_dup_string (&valstr); + g_value_unset (&valstr); + return TRUE; +} + +gboolean +my_object_unstringify (MyObject *obj, const char *str, GValue *value, GError **error) +{ + if (str[0] == '\0' || !g_ascii_isdigit (str[0])) { + g_value_init (value, G_TYPE_STRING); + g_value_set_string (value, str); + } else { + g_value_init (value, G_TYPE_INT); + g_value_set_int (value, (int) g_ascii_strtoull (str, NULL, 10)); + } + return TRUE; +} + +gboolean +my_object_recursive1 (MyObject *obj, GArray *array, guint32 *len_ret, GError **error) +{ + *len_ret = array->len; + return TRUE; +} + +gboolean +my_object_recursive2 (MyObject *obj, guint32 reqlen, GArray **ret, GError **error) +{ + guint32 val; + GArray *array; + + array = g_array_new (FALSE, TRUE, sizeof (guint32)); + + while (reqlen > 0) { + val = 42; + g_array_append_val (array, val); + val = 26; + g_array_append_val (array, val); + reqlen--; + } + val = 2; + g_array_append_val (array, val); + *ret = array; + return TRUE; +} + +gboolean +my_object_many_uppercase (MyObject *obj, const char * const *in, char ***out, GError **error) +{ + int len; + int i; + + len = g_strv_length ((char**) in); + + *out = g_new0 (char *, len + 1); + for (i = 0; i < len; i++) + { + (*out)[i] = g_ascii_strup (in[i], -1); + } + (*out)[i] = NULL; + + return TRUE; +} + +static void +hash_foreach_stringify (gpointer key, gpointer val, gpointer user_data) +{ + const char *keystr = key; + const GValue *value = val; + GValue *sval; + GHashTable *ret = user_data; + + sval = g_new0 (GValue, 1); + g_value_init (sval, G_TYPE_STRING); + if (!g_value_transform (value, sval)) + g_assert_not_reached (); + + g_hash_table_insert (ret, g_strdup (keystr), sval); +} + +static void +unset_and_free_gvalue (gpointer val) +{ + g_value_unset (val); + g_free (val); +} + +gboolean +my_object_many_stringify (MyObject *obj, GHashTable /* char * -> GValue * */ *vals, GHashTable /* char * -> GValue * */ **ret, GError **error) +{ + *ret = g_hash_table_new_full (g_str_hash, g_str_equal, + g_free, unset_and_free_gvalue); + g_hash_table_foreach (vals, hash_foreach_stringify, *ret); + return TRUE; +} + +gboolean +my_object_rec_arrays (MyObject *obj, GPtrArray *in, GPtrArray **ret, GError **error) +{ + char **strs; + GArray *ints; + guint v_UINT; + + if (in->len != 2) + { + g_set_error (error, + MY_OBJECT_ERROR, + MY_OBJECT_ERROR_FOO, + "invalid array len"); + return FALSE; + } + + strs = g_ptr_array_index (in, 0); + if (!*strs || strcmp (*strs, "foo")) + { + g_set_error (error, + MY_OBJECT_ERROR, + MY_OBJECT_ERROR_FOO, + "invalid string 0"); + return FALSE; + } + strs++; + if (!*strs || strcmp (*strs, "bar")) + { + g_set_error (error, + MY_OBJECT_ERROR, + MY_OBJECT_ERROR_FOO, + "invalid string 1"); + return FALSE; + } + strs++; + if (*strs) + { + g_set_error (error, + MY_OBJECT_ERROR, + MY_OBJECT_ERROR_FOO, + "invalid string array len in pos 0"); + return FALSE; + } + strs = g_ptr_array_index (in, 1); + if (!*strs || strcmp (*strs, "baz")) + { + g_set_error (error, + MY_OBJECT_ERROR, + MY_OBJECT_ERROR_FOO, + "invalid string 0"); + return FALSE; + } + strs++; + if (!*strs || strcmp (*strs, "whee")) + { + g_set_error (error, + MY_OBJECT_ERROR, + MY_OBJECT_ERROR_FOO, + "invalid string 1"); + return FALSE; + } + strs++; + if (!*strs || strcmp (*strs, "moo")) + { + g_set_error (error, + MY_OBJECT_ERROR, + MY_OBJECT_ERROR_FOO, + "invalid string 2"); + return FALSE; + } + strs++; + if (*strs) + { + g_set_error (error, + MY_OBJECT_ERROR, + MY_OBJECT_ERROR_FOO, + "invalid string array len in pos 1"); + return FALSE; + } + + *ret = g_ptr_array_new (); + + ints = g_array_new (TRUE, TRUE, sizeof (guint)); + v_UINT = 10; + g_array_append_val (ints, v_UINT); + v_UINT = 42; + g_array_append_val (ints, v_UINT); + v_UINT = 27; + g_array_append_val (ints, v_UINT); + g_ptr_array_add (*ret, ints); + + ints = g_array_new (TRUE, TRUE, sizeof (guint)); + v_UINT = 30; + g_array_append_val (ints, v_UINT); + g_ptr_array_add (*ret, ints); + return TRUE; +} + +gboolean +my_object_objpath (MyObject *obj, const char *incoming, const char **outgoing, GError **error) +{ + if (strcmp (incoming, "/org/freedesktop/DBus/GLib/Tests/MyTestObject")) + { + g_set_error (error, + MY_OBJECT_ERROR, + MY_OBJECT_ERROR_FOO, + "invalid incoming object"); + return FALSE; + } + *outgoing = "/org/freedesktop/DBus/GLib/Tests/MyTestObject2"; + return TRUE; +} + +gboolean +my_object_get_objs (MyObject *obj, GPtrArray **objs, GError **error) +{ + *objs = g_ptr_array_new (); + + g_ptr_array_add (*objs, g_strdup ("/org/freedesktop/DBus/GLib/Tests/MyTestObject")); + g_ptr_array_add (*objs, g_strdup ("/org/freedesktop/DBus/GLib/Tests/MyTestObject2")); + + return TRUE; +} + +static void +hash_foreach (gpointer key, gpointer val, gpointer user_data) +{ + const char *keystr = key; + const char *valstr = val; + guint *count = user_data; + + *count += (strlen (keystr) + strlen (valstr)); + g_print ("%s -> %s\n", keystr, valstr); +} + +gboolean +my_object_str_hash_len (MyObject *obj, GHashTable *table, guint *len, GError **error) +{ + *len = 0; + g_hash_table_foreach (table, hash_foreach, len); + return TRUE; +} + +gboolean +my_object_send_car (MyObject *obj, GValueArray *invals, GValueArray **outvals, GError **error) +{ + if (invals->n_values != 3 + || G_VALUE_TYPE (g_value_array_get_nth (invals, 0)) != G_TYPE_STRING + || G_VALUE_TYPE (g_value_array_get_nth (invals, 1)) != G_TYPE_UINT + || G_VALUE_TYPE (g_value_array_get_nth (invals, 2)) != G_TYPE_VALUE) + { + g_set_error (error, + MY_OBJECT_ERROR, + MY_OBJECT_ERROR_FOO, + "invalid incoming values"); + return FALSE; + } + *outvals = g_value_array_new (2); + g_value_array_append (*outvals, NULL); + g_value_init (g_value_array_get_nth (*outvals, (*outvals)->n_values - 1), G_TYPE_UINT); + g_value_set_uint (g_value_array_get_nth (*outvals, (*outvals)->n_values - 1), + g_value_get_uint (g_value_array_get_nth (invals, 1)) + 1); + g_value_array_append (*outvals, NULL); + g_value_init (g_value_array_get_nth (*outvals, (*outvals)->n_values - 1), DBUS_TYPE_G_OBJECT_PATH); + g_value_set_boxed (g_value_array_get_nth (*outvals, (*outvals)->n_values - 1), + g_strdup ("/org/freedesktop/DBus/GLib/Tests/MyTestObject2")); + return TRUE; +} + +gboolean +my_object_get_hash (MyObject *obj, GHashTable **ret, GError **error) +{ + GHashTable *table; + + table = g_hash_table_new (g_str_hash, g_str_equal); + g_hash_table_insert (table, "foo", "bar"); + g_hash_table_insert (table, "baz", "whee"); + g_hash_table_insert (table, "cow", "crack"); + *ret = table; + return TRUE; +} + +gboolean +my_object_increment_val (MyObject *obj, GError **error) +{ + obj->val++; + return TRUE; +} + +gboolean +my_object_get_val (MyObject *obj, guint *ret, GError **error) +{ + *ret = obj->val; + return TRUE; +} + +gboolean +my_object_get_value (MyObject *obj, guint *ret, GError **error) +{ + *ret = obj->val; + return TRUE; +} + +gboolean +my_object_echo_variant (MyObject *obj, GValue *variant, GValue *ret, GError **error) +{ + GType t; + t = G_VALUE_TYPE(variant); + g_value_init (ret, t); + g_value_copy (variant, ret); + + return TRUE; +} + +gboolean +my_object_echo_signature (MyObject *obj, const gchar *in, gchar **out, GError **error) +{ + *out = g_strdup (in); + return TRUE; +} + +gboolean +my_object_process_variant_of_array_of_ints123 (MyObject *obj, GValue *variant, GError **error) +{ + GArray *array; + int i; + int j; + + j = 0; + + array = (GArray *)g_value_get_boxed (variant); + + for (i = 0; i <= 2; i++) + { + j = g_array_index (array, int, i); + if (j != i + 1) + goto error; + } + + return TRUE; + +error: + *error = g_error_new (MY_OBJECT_ERROR, + MY_OBJECT_ERROR_FOO, + "Error decoding a variant of type ai (i + 1 = %i, j = %i)", + i, j + 1); + return FALSE; +} + + +typedef struct _HashAndString HashAndString; + +struct _HashAndString +{ + GHashTable *hash; + gchar* string; +}; + +static void +hash_foreach_prepend_string (gpointer key, gpointer val, gpointer user_data) +{ + HashAndString *data = (HashAndString*) user_data; + gchar *in = (gchar*) val; + g_hash_table_insert (data->hash, g_strdup ((gchar*) key), + g_strjoin (" ", data->string, in, NULL)); +} + + +static void +hash_foreach_mangle_dict_of_strings (gpointer key, gpointer val, gpointer user_data) +{ + GHashTable *out = (GHashTable*) user_data; + GHashTable *in_dict = (GHashTable *) val; + HashAndString *data = g_new0 (HashAndString, 1); + + data->string = (gchar*) key; + data->hash = g_hash_table_new_full (g_str_hash, g_str_equal, + g_free, g_free); + g_hash_table_foreach (in_dict, hash_foreach_prepend_string, data); + + g_hash_table_insert(out, g_strdup ((gchar*) key), data->hash); +} + +gboolean +my_object_dict_of_dicts (MyObject *obj, GHashTable *in, + GHashTable **out, GError **error) +{ + *out = g_hash_table_new_full (g_str_hash, g_str_equal, + (GDestroyNotify) g_free, + (GDestroyNotify) g_hash_table_destroy); + g_hash_table_foreach (in, hash_foreach_mangle_dict_of_strings, *out); + return TRUE; +} + +void +my_object_dict_of_sigs (MyObject *obj, + GHashTable *dict, + DBusGMethodInvocation *context) +{ + dbus_g_method_return (context, dict); +} + +void +my_object_dict_of_objs (MyObject *obj, + GHashTable *dict, + DBusGMethodInvocation *context) +{ + dbus_g_method_return (context, dict); +} + +gboolean +my_object_emit_frobnicate (MyObject *obj, GError **error) +{ + g_signal_emit (obj, signals[FROBNICATE], 0, 42); + return TRUE; +} + +gboolean +my_object_emit_signals (MyObject *obj, GError **error) +{ + GValue val = {0, }; + + g_signal_emit (obj, signals[SIG0], 0, "foo", 22, "moo"); + + g_value_init (&val, G_TYPE_STRING); + g_value_set_string (&val, "bar"); + g_signal_emit (obj, signals[SIG1], 0, "baz", &val); + g_value_unset (&val); + + return TRUE; +} + +gboolean +my_object_emit_signal2 (MyObject *obj, GError **error) +{ + GHashTable *table; + + table = g_hash_table_new (g_str_hash, g_str_equal); + g_hash_table_insert (table, "baz", "cow"); + g_hash_table_insert (table, "bar", "foo"); + g_signal_emit (obj, signals[SIG2], 0, table); + g_hash_table_destroy (table); + return TRUE; +} + +typedef struct { + gint32 x; + DBusGMethodInvocation *context; +} IncrementData; + +static gboolean +do_async_increment (IncrementData *data) +{ + gint32 newx = data->x + 1; + dbus_g_method_return (data->context, newx); + g_free (data); + return FALSE; +} + +void +my_object_async_increment (MyObject *obj, gint32 x, DBusGMethodInvocation *context) +{ + IncrementData *data = g_new0 (IncrementData, 1); + data->x = x; + data->context = context; + g_idle_add ((GSourceFunc)do_async_increment, data); +} + +typedef struct { + GError *error; + DBusGMethodInvocation *context; +} ErrorData; + +static gboolean +do_async_error (ErrorData *data) +{ + dbus_g_method_return_error (data->context, data->error); + g_error_free (data->error); + g_free (data); + return FALSE; +} + +void +my_object_async_throw_error (MyObject *obj, DBusGMethodInvocation *context) +{ + ErrorData *data = g_new0 (ErrorData, 1); + + data->error = g_error_copy (obj->saved_error); + data->context = context; + g_idle_add ((GSourceFunc) do_async_error, data); +} + +void +my_object_unsafe_disable_legacy_property_access (MyObject *obj) +{ + dbus_glib_global_set_disable_legacy_property_access (); +} + +extern GMainLoop *loop; + +gboolean +my_object_terminate (MyObject *obj, GError **error) +{ + g_main_loop_quit (loop); + return TRUE; +} + +void +my_object_emit_objectified (MyObject *obj, + GObject *other) +{ + g_signal_emit (obj, signals[OBJECTIFIED], 0, other); +} diff --git a/test/core/my-object.h b/test/core/my-object.h new file mode 100644 index 0000000..d50d0b4 --- /dev/null +++ b/test/core/my-object.h @@ -0,0 +1,127 @@ +#ifndef __MY_OBJECT_H__ +#define __MY_OBJECT_H__ + +#include <glib-object.h> +#include <dbus/dbus-glib.h> + +typedef struct MyObject MyObject; +typedef struct MyObjectClass MyObjectClass; + +void my_object_register_marshallers (void); +GType my_object_get_type (void); + +struct MyObject +{ + GObject parent; + GError *saved_error; + char *this_is_a_string; + guint notouching; + guint val; + gdouble super_studly; + gboolean should_be_hidden; +}; + +struct MyObjectClass +{ + GObjectClass parent; +}; + +#define MY_TYPE_OBJECT (my_object_get_type ()) +#define MY_OBJECT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), MY_TYPE_OBJECT, MyObject)) +#define MY_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MY_TYPE_OBJECT, MyObjectClass)) +#define MY_IS_OBJECT(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), MY_TYPE_OBJECT)) +#define MY_IS_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MY_TYPE_OBJECT)) +#define MY_OBJECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MY_TYPE_OBJECT, MyObjectClass)) + +typedef enum +{ + MY_OBJECT_ERROR_FOO, + MY_OBJECT_ERROR_BAR, + MY_OBJECT_ERROR_MULTI_WORD, + MY_OBJECT_ERROR_UNDER_SCORE +} MyObjectError; + +#define MY_OBJECT_ERROR (my_object_error_quark ()) +#define MY_TYPE_ERROR (my_object_error_get_type ()) + +GQuark my_object_error_quark (void); +GType my_object_error_get_type (void); + +gboolean my_object_do_nothing (MyObject *obj, GError **error); + +gboolean my_object_increment (MyObject *obj, gint32 x, gint32 *ret, GError **error); + +gint32 my_object_increment_retval (MyObject *obj, gint32 x); + +gint32 my_object_increment_retval_error (MyObject *obj, gint32 x, GError **error); + +gboolean my_object_throw_error (MyObject *obj, GError **error); +gboolean my_object_throw_not_supported (MyObject *obj, GError **error); +gboolean my_object_throw_error_multi_word (MyObject *obj, GError **error); +gboolean my_object_throw_unregistered_error (MyObject *obj, GError **error); + +gboolean my_object_uppercase (MyObject *obj, const char *str, char **ret, GError **error); + +gboolean my_object_many_args (MyObject *obj, guint32 x, const char *str, double trouble, double *d_ret, char **str_ret, GError **error); + +gboolean my_object_many_return (MyObject *obj, guint32 *arg0, char **arg1, gint32 *arg2, guint32 *arg3, guint32 *arg4, const char **arg5, GError **error); + +gboolean my_object_recursive1 (MyObject *obj, GArray *array, guint32 *len_ret, GError **error); +gboolean my_object_recursive2 (MyObject *obj, guint32 reqlen, GArray **array, GError **error); + +gboolean my_object_many_stringify (MyObject *obj, GHashTable *vals, GHashTable **ret, GError **error); + +gboolean my_object_rec_arrays (MyObject *obj, GPtrArray *in, GPtrArray **ret, GError **error); + +gboolean my_object_objpath (MyObject *obj, const char *in, const char **arg1, GError **error); + +gboolean my_object_get_objs (MyObject *obj, GPtrArray **objs, GError **error); + +gboolean my_object_stringify (MyObject *obj, GValue *value, char **ret, GError **error); +gboolean my_object_unstringify (MyObject *obj, const char *str, GValue *value, GError **error); + +gboolean my_object_many_uppercase (MyObject *obj, const char * const *in, char ***out, GError **error); + +gboolean my_object_str_hash_len (MyObject *obj, GHashTable *table, guint *len, GError **error); + +gboolean my_object_send_car (MyObject *obj, GValueArray *invals, GValueArray **outvals, GError **error); + +gboolean my_object_get_hash (MyObject *obj, GHashTable **table, GError **error); + +gboolean my_object_increment_val (MyObject *obj, GError **error); + +gboolean my_object_get_val (MyObject *obj, guint *ret, GError **error); + +gboolean my_object_get_value (MyObject *obj, guint *ret, GError **error); + +gboolean my_object_emit_signals (MyObject *obj, GError **error); +gboolean my_object_emit_signal2 (MyObject *obj, GError **error); + +gboolean my_object_emit_frobnicate (MyObject *obj, GError **error); + +gboolean my_object_echo_variant (MyObject *obj, GValue *variant, GValue *ret, GError **error); +gboolean my_object_echo_signature (MyObject *obj, const gchar *in, gchar **out, GError **error); + +gboolean my_object_process_variant_of_array_of_ints123 (MyObject *obj, GValue *variant, GError **error); + +gboolean my_object_dict_of_dicts (MyObject *obj, GHashTable *dict, GHashTable **ret, GError **error); + +void my_object_dict_of_sigs (MyObject *obj, GHashTable *dict, DBusGMethodInvocation *ctx); + +void my_object_dict_of_objs (MyObject *obj, GHashTable *dict, DBusGMethodInvocation *ctx); + +gboolean my_object_terminate (MyObject *obj, GError **error); + +void my_object_async_increment (MyObject *obj, gint32 x, DBusGMethodInvocation *context); + +void my_object_async_throw_error (MyObject *obj, DBusGMethodInvocation *context); + +void my_object_unsafe_disable_legacy_property_access (MyObject *obj); + +void my_object_emit_objectified (MyObject *obj, GObject *other); + +/* Not a D-Bus method. */ +void my_object_save_error (MyObject *obj, GQuark domain, gint code, + const gchar *message); + +#endif diff --git a/test/core/peer-client.c b/test/core/peer-client.c new file mode 100644 index 0000000..95a7db4 --- /dev/null +++ b/test/core/peer-client.c @@ -0,0 +1,140 @@ +#include <config.h> + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <dbus/dbus.h> +#include <dbus/dbus-glib.h> + +static GMainLoop *loop; +static guint exit_timeout = 0; +static int n_times_frobnicate_received = 0; +static gboolean terminating = FALSE, terminated = FALSE; + +static void +lose (const char *str, ...) +{ + va_list args; + va_start (args, str); + + vfprintf (stderr, str, args); + fputc ('\n', stderr); + + va_end (args); + exit (1); +} + +static void +lose_gerror (const char *prefix, GError *error) +{ + if (error->domain == DBUS_GERROR && error->code == DBUS_GERROR_REMOTE_EXCEPTION) + lose ("%s (%s): %s", prefix, dbus_g_error_get_name (error), + error->message); + else + lose ("%s: %s", prefix, error->message); +} + +static gboolean +timed_exit (gpointer loop) +{ + g_print ("timed exit!\n"); + g_main_loop_quit (loop); + return TRUE; +} + +static void +frobnicate_signal_handler (DBusGProxy *proxy, int val, void *user_data) +{ + n_times_frobnicate_received += 1; + + g_assert (val == 42); + + g_main_loop_quit (loop); + g_source_remove (exit_timeout); +} + +static void +destroy_cb (DBusGProxy *proxy, gpointer user_data) +{ + if (!terminating) { + lose ("Proxy destroyed when it shouldn't have been"); + } else { + terminated = TRUE; + g_main_loop_quit (loop); + g_source_remove (exit_timeout); + } +} + +int +main (int argc, char **argv) +{ + GError *error = NULL; + DBusGConnection *conn; + DBusGProxy *proxy; + guint32 v_UINT32_2; + char *addrbuf; + gsize lineoffset; + GIOChannel *io; + + g_thread_init (NULL); dbus_g_thread_init (); + g_type_init (); + + io = g_io_channel_unix_new (0); + if (!g_io_channel_read_line (io, &addrbuf, NULL, &lineoffset, &error)) + lose_gerror ("failed to read address from stdin", error); + /* trim newline */ + addrbuf[lineoffset] = '\0'; + + loop = g_main_loop_new (NULL, TRUE); + + conn = dbus_g_connection_open (addrbuf, &error); + if (!conn) + g_error ("Cannot open connection: %s", error->message); + + proxy = dbus_g_proxy_new_for_peer (conn, "/", "org.freedesktop.DBus.GLib.Tests.MyObject"); + g_assert (proxy); + + + if (!dbus_g_proxy_call (proxy, "DoNothing", &error, G_TYPE_INVALID, G_TYPE_INVALID)) + lose_gerror ("Failed to complete DoNothing call", error); + + + if (!dbus_g_proxy_call (proxy, "Increment", &error, + G_TYPE_UINT, 42, + G_TYPE_INVALID, + G_TYPE_UINT, &v_UINT32_2, + G_TYPE_INVALID)) + lose_gerror ("Failed to complete Increment call", error); + if (v_UINT32_2 != 43) + lose ("Increment call returned %d, should be 43", v_UINT32_2); + + + n_times_frobnicate_received = 0; + dbus_g_proxy_add_signal (proxy, "Frobnicate", G_TYPE_INT, G_TYPE_INVALID); + dbus_g_proxy_connect_signal (proxy, "Frobnicate", + G_CALLBACK (frobnicate_signal_handler), + NULL, NULL); + g_signal_connect (G_OBJECT (proxy), "destroy", + G_CALLBACK (destroy_cb), + NULL); + + if (!dbus_g_proxy_call (proxy, "EmitFrobnicate", &error, G_TYPE_INVALID, G_TYPE_INVALID)) + lose_gerror ("Failed to complete EmitFrobnicate call", error); + exit_timeout = g_timeout_add (5000, timed_exit, loop); + g_main_loop_run (loop); + if (n_times_frobnicate_received != 1) + lose ("Frobnicate signal received %d times, should have been 1", n_times_frobnicate_received); + + terminating = TRUE; + if (!dbus_g_proxy_call (proxy, "Terminate", &error, G_TYPE_INVALID, G_TYPE_INVALID)) + lose_gerror ("Failed to complete Terminate call", error); + exit_timeout = g_timeout_add (5000, timed_exit, loop); + g_main_loop_run (loop); + if (!terminated) + lose ("Proxy didn't destroy when peer terminated"); + + g_main_loop_unref (loop); + + return 0; +} diff --git a/test/core/peer-on-bus.c b/test/core/peer-on-bus.c new file mode 100644 index 0000000..7c5147d --- /dev/null +++ b/test/core/peer-on-bus.c @@ -0,0 +1,148 @@ +/* Regression test for object registration and unregistration + * + * Copyright © 2009 Collabora Ltd. <http://www.collabora.co.uk/> + * Copyright © 2009-2011 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 <config.h> + +#include <dbus/dbus-glib.h> +#include <dbus/dbus-glib-lowlevel.h> + +#include "test/lib/util.h" + +GMainLoop *loop = NULL; + +typedef struct { + DBusGConnection *bus; + DBusGConnection *bus2; +} Fixture; + +static void +setup (Fixture *f, + gconstpointer path_to_use) +{ + f->bus = dbus_g_bus_get_private (DBUS_BUS_SESSION, NULL, NULL); + g_assert (f->bus != NULL); + + f->bus2 = dbus_g_bus_get_private (DBUS_BUS_SESSION, NULL, NULL); + g_assert (f->bus2 != NULL); +} + +static void +teardown (Fixture *f, + gconstpointer test_data G_GNUC_UNUSED) +{ + if (f->bus != NULL) + { + test_run_until_disconnected (f->bus, NULL); + dbus_g_connection_unref (f->bus); + } + + if (f->bus2 != NULL) + { + test_run_until_disconnected (f->bus2, NULL); + dbus_g_connection_unref (f->bus2); + } + + dbus_shutdown (); +} + +static void +destroy_cb (DBusGProxy *proxy G_GNUC_UNUSED, + gpointer user_data) +{ + gboolean *destroyed = user_data; + + *destroyed = TRUE; +} + +static void +test_name_owner_changed (Fixture *f, + gconstpointer test_data G_GNUC_UNUSED) +{ + DBusGProxy *peer; + DBusGProxy *named; + gboolean destroyed = FALSE; + + g_test_bug ("41126"); + + /* bus has a proxy for bus2... */ + named = dbus_g_proxy_new_for_name (f->bus, + dbus_bus_get_unique_name (dbus_g_connection_get_connection (f->bus2)), + "/", "org.freedesktop.DBus.Peer"); + /* ... and also a proxy for the peer (i.e. the dbus-daemon) */ + peer = dbus_g_proxy_new_for_peer (f->bus, "/", "org.freedesktop.DBus.Peer"); + + g_signal_connect (G_OBJECT (named), "destroy", G_CALLBACK (destroy_cb), + &destroyed); + + /* Disconnect bus2, to provoke a NameOwnerChanged signal on bus */ + test_run_until_disconnected (f->bus2, NULL); + dbus_g_connection_unref (f->bus2); + f->bus2 = NULL; + + /* Wait for that NameOwnerChanged to be processed */ + while (!destroyed) + g_main_context_iteration (NULL, TRUE); + + g_signal_handlers_disconnect_by_func (named, destroy_cb, &destroyed); + + /* The first part of the bug was that we'd never get here, because checking + * whether 'peer' was affected by the NameOwnerChanged caused a NULL + * dereference and segfault. If we get here, all is OK. + * + * The second part of the bug was that if the last proxy in existence was + * for a peer, when it was unregistered there would be no owner_match_rules, + * causing a crash. Unref named before peer, to exercise that. */ + + g_object_unref (named); + g_object_unref (peer); +} + +int +main (int argc, char **argv) +{ + g_setenv ("DBUS_FATAL_WARNINGS", "1", TRUE); + g_type_init (); + g_log_set_always_fatal (G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL); + dbus_g_type_specialized_init (); + g_test_bug_base ("https://bugs.freedesktop.org/show_bug.cgi?id="); + g_test_init (&argc, &argv, NULL); + + g_test_add ("/peer-on-bus/name-owner-changed", Fixture, NULL, + setup, test_name_owner_changed, teardown); + + return g_test_run (); +} diff --git a/test/core/peer-server.c b/test/core/peer-server.c new file mode 100644 index 0000000..7e59625 --- /dev/null +++ b/test/core/peer-server.c @@ -0,0 +1,59 @@ +#include <config.h> + +#include <stdio.h> +#include <stdlib.h> + +#include <dbus/dbus.h> +#include <dbus/dbus-glib.h> +#include <dbus/dbus-glib-lowlevel.h> + +#include "my-object.h" + +GMainLoop *loop; + +static void +new_connection_func (DBusServer *server, DBusConnection *conn, gpointer user_data) +{ + GObject *obj; + + obj = g_object_new (MY_TYPE_OBJECT, NULL); + + dbus_connection_ref (conn); + dbus_connection_setup_with_g_main (conn, NULL); + + dbus_g_connection_register_g_object + (dbus_connection_get_g_connection (conn), "/", obj); +} + +int +main (int argc, char **argv) +{ + DBusError error; + DBusServer *server; + char *addr; + + dbus_error_init (&error); + + g_thread_init (NULL); dbus_g_thread_init (); + g_type_init (); + + loop = g_main_loop_new (NULL, TRUE); + + server = dbus_server_listen ("unix:tmpdir=/tmp", &error); + if (!server) + { + g_warning ("Cannot create server: %s", error.message); + return 1; + } + addr = dbus_server_get_address (server); + fprintf (stdout, "%s\n", addr); + fflush (stdout); + free (addr); + dbus_server_setup_with_g_main (server, NULL); + dbus_server_set_new_connection_function (server, new_connection_func, NULL, NULL); + + g_main_loop_run (loop); + + g_main_loop_unref (loop); + return 0; +} diff --git a/test/core/proxy-peer.c b/test/core/proxy-peer.c new file mode 100644 index 0000000..8c1b867 --- /dev/null +++ b/test/core/proxy-peer.c @@ -0,0 +1,274 @@ +/* Regression tests for using a DBusGProxy on a peer-to-peer connection. + * + * Author: Simon McVittie <simon.mcvittie@collabora.co.uk> + * Copyright © 2011 Nokia Corporation + * + * 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 <config.h> + +#include <glib.h> + +#include <dbus/dbus.h> +#include <dbus/dbus-glib.h> +#include <dbus/dbus-glib-lowlevel.h> + +#include "my-object.h" + +GMainLoop *loop; + +typedef struct { + DBusError e; + + DBusServer *server; + DBusConnection *server_conn; + DBusGConnection *server_gconn; + + DBusConnection *client_conn; + DBusGConnection *client_gconn; + + DBusGProxy *proxy; + gboolean proxy_destroyed; + GObject *object; + GHashTable *in_flight; + GHashTable *completed; +} Fixture; + +static void +assert_no_error (const DBusError *e) +{ + if (G_UNLIKELY (dbus_error_is_set (e))) + g_error ("expected success but got error: %s: %s", e->name, e->message); +} + +static void +new_conn_cb (DBusServer *server, + DBusConnection *server_conn, + void *data) +{ + Fixture *f = data; + + g_assert (f->server_conn == NULL); + f->server_conn = dbus_connection_ref (server_conn); + dbus_connection_setup_with_g_main (server_conn, NULL); + f->server_gconn = dbus_connection_get_g_connection (server_conn); +} + +static void +destroy_cb (DBusGProxy *proxy, + gpointer user_data) +{ + Fixture *f = user_data; + + g_assert (proxy == f->proxy); + + f->proxy_destroyed = TRUE; +} + +static void +setup (Fixture *f, + gconstpointer addr) +{ + dbus_error_init (&f->e); + + f->server = dbus_server_listen (addr, &f->e); + assert_no_error (&f->e); + g_assert (f->server != NULL); + + dbus_server_set_new_connection_function (f->server, + new_conn_cb, f, NULL); + dbus_server_setup_with_g_main (f->server, NULL); + + g_assert (f->server_conn == NULL); + + f->client_conn = dbus_connection_open_private ( + dbus_server_get_address (f->server), &f->e); + assert_no_error (&f->e); + g_assert (f->client_conn != NULL); + dbus_connection_setup_with_g_main (f->client_conn, NULL); + f->client_gconn = dbus_connection_get_g_connection (f->client_conn); + + while (f->server_conn == NULL) + { + g_print ("."); + g_main_context_iteration (NULL, TRUE); + } + + f->object = g_object_new (MY_TYPE_OBJECT, + NULL); + dbus_g_connection_register_g_object (f->server_gconn, + "/org/freedesktop/DBus/GLib/Tests/MyTestObject", f->object); + + f->proxy = dbus_g_proxy_new_for_peer (f->client_gconn, + "/org/freedesktop/DBus/GLib/Tests/MyTestObject", + "org.freedesktop.DBus.GLib.Tests.MyObject"); + g_assert (f->proxy != NULL); + g_assert (DBUS_IS_G_PROXY (f->proxy)); + + g_signal_connect (f->proxy, "destroy", G_CALLBACK (destroy_cb), f); + + f->in_flight = g_hash_table_new (NULL, NULL); + f->completed = g_hash_table_new (NULL, NULL); +} + +static void +call_cb (DBusGProxy *proxy, + DBusGProxyCall *call, + gpointer data) +{ + Fixture *f = data; + gboolean found; + + found = g_hash_table_remove (f->in_flight, call); + g_assert (found); + g_hash_table_insert (f->completed, call, call); +} + +static void +test_method (Fixture *f, + gconstpointer addr) +{ + GError *error = NULL; + gboolean ok; + DBusGProxyCall *call; + + call = dbus_g_proxy_begin_call (f->proxy, "DoNothing", call_cb, f, NULL, + G_TYPE_INVALID); + g_assert (call != NULL); + g_hash_table_insert (f->in_flight, call, call); + + while (g_hash_table_size (f->in_flight) > 0) + { + g_print ("."); + g_main_context_iteration (NULL, TRUE); + } + + ok = g_hash_table_remove (f->completed, call); + g_assert (ok); + ok = dbus_g_proxy_end_call (f->proxy, call, &error, + G_TYPE_INVALID); + g_assert_no_error (error); + g_assert (ok); +} + +static void +test_disconnect (Fixture *f, + gconstpointer addr) +{ + GError *error = NULL; + gboolean ok; + DBusGProxyCall *fail; + + g_test_bug ("38406"); + + dbus_connection_close (f->client_conn); + dbus_connection_close (f->server_conn); + + fail = dbus_g_proxy_begin_call (f->proxy, "DoNothing", call_cb, f, NULL, + G_TYPE_INVALID); + g_assert (fail == NULL); + + ok = dbus_g_proxy_end_call (f->proxy, fail, &error, + G_TYPE_INVALID); + g_assert_error (error, DBUS_GERROR, DBUS_GERROR_DISCONNECTED); + g_assert (!ok); + g_clear_error (&error); + + while (!f->proxy_destroyed) + { + g_print ("."); + g_main_context_iteration (NULL, TRUE); + } +} + +static void +teardown (Fixture *f, + gconstpointer addr G_GNUC_UNUSED) +{ + f->client_gconn = NULL; + f->server_gconn = NULL; + + if (f->in_flight != NULL) + { + g_hash_table_unref (f->in_flight); + f->in_flight = NULL; + } + + if (f->completed != NULL) + { + g_hash_table_unref (f->completed); + f->completed = NULL; + } + + if (f->proxy != NULL) + { + g_signal_handlers_disconnect_by_func (f->proxy, destroy_cb, f); + g_object_unref (f->proxy); + f->proxy = NULL; + } + + if (f->object != NULL) + { + g_object_unref (f->object); + f->object = NULL; + } + + if (f->client_conn != NULL) + { + dbus_connection_close (f->client_conn); + dbus_connection_unref (f->client_conn); + f->client_conn = NULL; + } + + if (f->server_conn != NULL) + { + dbus_connection_close (f->server_conn); + dbus_connection_unref (f->server_conn); + f->server_conn = NULL; + } + + if (f->server != NULL) + { + dbus_server_disconnect (f->server); + dbus_server_unref (f->server); + f->server = NULL; + } +} + +int +main (int argc, + char **argv) +{ + g_test_init (&argc, &argv, NULL); + g_type_init (); + dbus_g_type_specialized_init (); + + g_test_bug_base ("https://bugs.freedesktop.org/show_bug.cgi?id="); + + g_test_add ("/proxy/method", Fixture, "unix:tmpdir=/tmp", setup, + test_method, teardown); + + g_test_add ("/proxy/disconnect", Fixture, "unix:tmpdir=/tmp", setup, + test_disconnect, teardown); + + return g_test_run (); +} diff --git a/test/core/registrations.c b/test/core/registrations.c new file mode 100644 index 0000000..d4e17dd --- /dev/null +++ b/test/core/registrations.c @@ -0,0 +1,444 @@ +/* Regression test for object registration and unregistration + * + * Copyright © 2009 Collabora Ltd. <http://www.collabora.co.uk/> + * Copyright © 2009-2011 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 <config.h> + +#include <dbus/dbus-glib.h> +#include <dbus/dbus-glib-lowlevel.h> + +#include "my-object.h" + +GMainLoop *loop = NULL; + +typedef struct { + DBusError dbus_error; + DBusGConnection *bus; + DBusGConnection *bus2; + GObject *object; + DBusMessage *frobnicate1_message; + DBusMessage *frobnicate2_message; + gboolean received_objectified; +} Fixture; + +#define assert_no_error(e) _assert_no_error (e, __FILE__, __LINE__) +static void +_assert_no_error (const DBusError *e, + const char *file, + int line) +{ + if (G_UNLIKELY (dbus_error_is_set (e))) + g_error ("%s:%d: expected success but got error: %s: %s", + file, line, e->name, e->message); +} + +static void +setup (Fixture *f, + gconstpointer path_to_use) +{ + dbus_error_init (&f->dbus_error); + + f->bus = dbus_g_bus_get_private (DBUS_BUS_SESSION, NULL, NULL); + g_assert (f->bus != NULL); + + f->bus2 = dbus_g_bus_get_private (DBUS_BUS_SESSION, NULL, NULL); + g_assert (f->bus2 != NULL); + + f->object = g_object_new (MY_TYPE_OBJECT, NULL); + g_assert (MY_IS_OBJECT (f->object)); +} + +static void +teardown (Fixture *f, + gconstpointer test_data G_GNUC_UNUSED) +{ + /* we close the connection before releasing the object, to test fd.o #5688 + * in test_lookup() */ + if (f->bus != NULL) + { + dbus_connection_close (dbus_g_connection_get_connection (f->bus)); + dbus_g_connection_unref (f->bus); + } + + if (f->bus2 != NULL) + { + dbus_connection_close (dbus_g_connection_get_connection (f->bus2)); + dbus_g_connection_unref (f->bus2); + } + + if (f->object != NULL) + { + g_object_unref (f->object); + } + + /* This is safe to call on an initialized-but-unset DBusError, a bit like + * g_clear_error */ + dbus_error_free (&f->dbus_error); +} + +static void +test_lookup (Fixture *f, + gconstpointer test_data G_GNUC_UNUSED) +{ + /* teardown() closes the connection before f->object is destroyed, which + * used to be broken */ + g_test_bug ("5688"); + + dbus_g_connection_register_g_object (f->bus, "/foo", f->object); + g_assert (dbus_g_connection_lookup_g_object (f->bus, "/foo") == + f->object); + /* this was briefly broken while fixing fd.o#5688 */ + g_assert (dbus_g_connection_lookup_g_object (f->bus, "/bar") == NULL); +} + +static void +test_unregister (Fixture *f, + gconstpointer test_data G_GNUC_UNUSED) +{ + /* feature test: objects can be unregistered */ + g_test_bug ("21219"); + + dbus_g_connection_register_g_object (f->bus, "/foo", f->object); + g_assert (dbus_g_connection_lookup_g_object (f->bus, "/foo") == + f->object); + dbus_g_connection_unregister_g_object (f->bus, f->object); + g_assert (dbus_g_connection_lookup_g_object (f->bus, "/foo") == NULL); +} + +static void +test_unregister_on_last_unref (Fixture *f, + gconstpointer test_data G_GNUC_UNUSED) +{ + gpointer weak_pointer; + + weak_pointer = f->object; + g_object_add_weak_pointer (weak_pointer, &weak_pointer); + + dbus_g_connection_register_g_object (f->bus, "/foo", f->object); + g_assert (dbus_g_connection_lookup_g_object (f->bus, "/foo") == + f->object); + /* implicit unregistration by the last-unref of the object */ + g_object_unref (f->object); + f->object = NULL; + + g_assert (weak_pointer == NULL); + + g_assert (dbus_g_connection_lookup_g_object (f->bus, "/foo") == NULL); +} + +static void +test_unregister_on_forced_dispose (Fixture *f, + gconstpointer test_data G_GNUC_UNUSED) +{ + dbus_g_connection_register_g_object (f->bus, "/foo", f->object); + g_assert (dbus_g_connection_lookup_g_object (f->bus, "/foo") == + f->object); + /* implicit unregistration by dispose() of the object (don't try + * this at home) */ + g_object_run_dispose (f->object); + + g_assert (dbus_g_connection_lookup_g_object (f->bus, "/foo") == NULL); +} + +static void +test_reregister (Fixture *f, + gconstpointer test_data G_GNUC_UNUSED) +{ + dbus_g_connection_register_g_object (f->bus, "/foo", f->object); + g_assert (dbus_g_connection_lookup_g_object (f->bus, "/foo") == + f->object); + + /* Before 0.82, re-registering the same object path was leaky but successful. + * 0.82 disallowed this behaviour. Since 0.84 it was meant to be allowed + * again, and a no-op, but it actually had the effect of removing all + * record of the registrations (while leaving the object registered with + * libdbus). */ + dbus_g_connection_register_g_object (f->bus, "/foo", f->object); + g_assert (dbus_g_connection_lookup_g_object (f->bus, "/foo") == + f->object); + + /* This would critical in 0.84. */ + dbus_g_connection_unregister_g_object (f->bus, f->object); + g_assert (dbus_g_connection_lookup_g_object (f->bus, "/foo") == NULL); +} + +static DBusHandlerResult +frobnicate_cb (DBusConnection *conn, + DBusMessage *message, + void *user_data) +{ + Fixture *f = user_data; + + if (dbus_message_is_signal (message, + "org.freedesktop.DBus.GLib.Tests.MyObject", "Frobnicate")) + { + const char *sender = dbus_message_get_sender (message); + const char *path = dbus_message_get_path (message); + + g_assert (sender != NULL); + g_assert (path != NULL); + + if (g_strcmp0 (path, "/foo") == 0) + { + g_assert_cmpstr (sender, ==, dbus_bus_get_unique_name ( + dbus_g_connection_get_connection (f->bus))); + + g_assert (f->frobnicate1_message == NULL); + f->frobnicate1_message = dbus_message_ref (message); + } + else + { + g_assert_cmpstr (path, ==, "/bar"); + g_assert_cmpstr (sender, ==, dbus_bus_get_unique_name ( + dbus_g_connection_get_connection (f->bus2))); + + g_assert (f->frobnicate2_message == NULL); + f->frobnicate2_message = dbus_message_ref (message); + } + } + + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; +} + +static void +test_twice (Fixture *f, + gconstpointer test_data G_GNUC_UNUSED) +{ + dbus_bool_t mem; + + g_test_bug ("32087"); + + dbus_g_connection_register_g_object (f->bus, "/foo", f->object); + + dbus_g_connection_register_g_object (f->bus2, "/bar", f->object); + + g_assert (dbus_g_connection_lookup_g_object (f->bus, "/foo") == + f->object); + g_assert (dbus_g_connection_lookup_g_object (f->bus2, "/bar") == + f->object); + + dbus_bus_add_match (dbus_g_connection_get_connection (f->bus), + "type='signal'", &f->dbus_error); + assert_no_error (&f->dbus_error); + mem = dbus_connection_add_filter (dbus_g_connection_get_connection (f->bus), + frobnicate_cb, f, NULL); + g_assert (mem); + + my_object_emit_frobnicate ((MyObject *) f->object, NULL); + + /* The object should emit the signal once onto each connection, + * from the appropriate location */ + while (f->frobnicate1_message == NULL || f->frobnicate2_message == NULL) + g_main_context_iteration (NULL, TRUE); + + dbus_message_unref (f->frobnicate1_message); + f->frobnicate1_message = NULL; + dbus_message_unref (f->frobnicate2_message); + f->frobnicate2_message = NULL; + + /* try again, to catch any extra emissions, but first unregister one of the + * object's locations */ + dbus_g_connection_unregister_g_object (f->bus, f->object); + my_object_emit_frobnicate ((MyObject *) f->object, NULL); + + while (f->frobnicate2_message == NULL) + g_main_context_iteration (NULL, TRUE); + + g_assert (f->frobnicate1_message == NULL); + dbus_message_unref (f->frobnicate2_message); + f->frobnicate2_message = NULL; +} + +static void +test_clean_slate (Fixture *f, + gconstpointer test_data G_GNUC_UNUSED) +{ + DBusError e; + dbus_bool_t mem; + + dbus_bus_add_match (dbus_g_connection_get_connection (f->bus), + "type='signal'", &f->dbus_error); + assert_no_error (&f->dbus_error); + mem = dbus_connection_add_filter (dbus_g_connection_get_connection (f->bus), + frobnicate_cb, f, NULL); + g_assert (mem); + + dbus_g_connection_register_g_object (f->bus, "/foo", f->object); + g_assert (dbus_g_connection_lookup_g_object (f->bus, "/foo") == + f->object); + + my_object_emit_frobnicate ((MyObject *) f->object, NULL); + + while (f->frobnicate1_message == NULL) + g_main_context_iteration (NULL, TRUE); + + dbus_message_unref (f->frobnicate1_message); + f->frobnicate1_message = NULL; + + /* unregister the object from its last object path, then put it back + * in the same location */ + dbus_g_connection_unregister_g_object (f->bus, f->object); + dbus_g_connection_register_g_object (f->bus, "/foo", f->object); + g_assert (dbus_g_connection_lookup_g_object (f->bus, "/foo") == + f->object); + + /* bug: in 0.92, this would be emitted twice because the hook was added + * twice */ + my_object_emit_frobnicate ((MyObject *) f->object, NULL); + + while (f->frobnicate1_message == NULL) + g_main_context_iteration (NULL, TRUE); + + dbus_message_unref (f->frobnicate1_message); + f->frobnicate1_message = NULL; + + /* unregister the object from its last object path, then put it back + * at a different location */ + dbus_g_connection_unregister_g_object (f->bus, f->object); + dbus_g_connection_register_g_object (f->bus2, "/bar", f->object); + g_assert (dbus_g_connection_lookup_g_object (f->bus2, "/bar") == + f->object); + + my_object_emit_frobnicate ((MyObject *) f->object, NULL); + + while (f->frobnicate2_message == NULL) + g_main_context_iteration (NULL, TRUE); + + /* check that this wasn't received anyway, which would indicate that + * either unregistration from /foo was unsuccessful, or the double + * emission mentioned above was seen */ + g_assert (f->frobnicate1_message == NULL); + + dbus_message_unref (f->frobnicate2_message); + f->frobnicate2_message = NULL; +} + +static DBusHandlerResult +objectified_cb (DBusConnection *conn, + DBusMessage *message, + void *user_data) +{ + Fixture *f = user_data; + + if (dbus_message_is_signal (message, + "org.freedesktop.DBus.GLib.Tests.MyObject", "Objectified")) + { + const char *sender = dbus_message_get_sender (message); + const char *path = dbus_message_get_path (message); + dbus_bool_t ok; + DBusError e; + + dbus_error_init (&e); + + g_assert (sender != NULL); + g_assert (path != NULL); + + g_assert_cmpstr (path, ==, "/foo"); + g_assert_cmpstr (sender, ==, dbus_bus_get_unique_name ( + dbus_g_connection_get_connection (f->bus))); + + path = NULL; + ok = dbus_message_get_args (message, &e, + DBUS_TYPE_OBJECT_PATH, &path, + DBUS_TYPE_INVALID); + + if (dbus_error_is_set (&e)) + g_error ("%s: %s", e.name, e.message); + + g_assert (ok); + g_assert_cmpstr (path, ==, "/foo"); + + f->received_objectified = TRUE; + } + + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; +} + +static void +test_marshal_object (Fixture *f, + gconstpointer test_data G_GNUC_UNUSED) +{ + dbus_bool_t mem; + + g_test_bug ("37852"); + + dbus_g_connection_register_g_object (f->bus, "/foo", f->object); + g_assert (dbus_g_connection_lookup_g_object (f->bus, "/foo") == + f->object); + + dbus_bus_add_match (dbus_g_connection_get_connection (f->bus), + "type='signal'", &f->dbus_error); + assert_no_error (&f->dbus_error); + mem = dbus_connection_add_filter (dbus_g_connection_get_connection (f->bus), + objectified_cb, f, NULL); + g_assert (mem); + + my_object_emit_objectified ((MyObject *) f->object, f->object); + + while (!f->received_objectified) + g_main_context_iteration (NULL, TRUE); +} + +int +main (int argc, char **argv) +{ + loop = g_main_loop_new (NULL, FALSE); + + g_type_init (); + g_log_set_always_fatal (G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL); + dbus_g_type_specialized_init (); + g_test_bug_base ("https://bugs.freedesktop.org/show_bug.cgi?id="); + g_test_init (&argc, &argv, NULL); + + g_test_add ("/registrations/lookup", Fixture, NULL, + setup, test_lookup, teardown); + g_test_add ("/registrations/unregister", Fixture, NULL, + setup, test_unregister, teardown); + g_test_add ("/registrations/unregister-on-last-unref", Fixture, NULL, + setup, test_unregister_on_last_unref, teardown); + g_test_add ("/registrations/unregister-on-forced-dispose", Fixture, NULL, + setup, test_unregister_on_forced_dispose, teardown); + g_test_add ("/registrations/reregister", Fixture, NULL, + setup, test_reregister, teardown); + g_test_add ("/registrations/twice", Fixture, NULL, + setup, test_twice, teardown); + g_test_add ("/registrations/clean-slate", Fixture, NULL, + setup, test_clean_slate, teardown); + g_test_add ("/registrations/marshal-object", Fixture, NULL, + setup, test_marshal_object, teardown); + + return g_test_run (); +} diff --git a/test/core/run-peer-test.sh b/test/core/run-peer-test.sh new file mode 100755 index 0000000..10d9528 --- /dev/null +++ b/test/core/run-peer-test.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +set -e + +# The peer server writes its address over stdout, which the client reads +${DBUS_TOP_BUILDDIR}/libtool --mode=execute ./peer-server | ${DBUS_TOP_BUILDDIR}/libtool --mode=execute ./peer-client diff --git a/test/core/run-test.sh b/test/core/run-test.sh new file mode 100755 index 0000000..daf1061 --- /dev/null +++ b/test/core/run-test.sh @@ -0,0 +1,54 @@ +#! /bin/sh + +SCRIPTNAME=$0 +MODE=$1 + +die() +{ + echo $@ 1>&2 + exit 1 +} + +## so the tests can complain if you fail to use the script to launch them +DBUS_TEST_GLIB_RUN_TEST_SCRIPT=1 +export DBUS_TEST_GLIB_RUN_TEST_SCRIPT +DBUS_TOP_SRCDIR=`dirname "$0"`/../.. +export DBUS_TOP_SRCDIR +# Rerun ourselves with tmp session bus if we're not already +if test -z "$DBUS_TEST_GLIB_IN_RUN_TEST"; then + DBUS_TEST_GLIB_IN_RUN_TEST=1 + export DBUS_TEST_GLIB_IN_RUN_TEST + exec $DBUS_TOP_SRCDIR/tools/run-with-tmp-session-bus.sh $SCRIPTNAME $MODE +fi + +if test x$MODE = xprofile ; then + echo "profiling type $PROFILE_TYPE" + sleep 2 ## this lets the bus get started so its startup time doesn't affect the profile too much + if test x$PROFILE_TYPE = x ; then + PROFILE_TYPE=all + fi + ${DBUS_TOP_BUILDDIR}/libtool --mode=execute $DEBUG $DBUS_TOP_BUILDDIR/test/core/test-profile $PROFILE_TYPE || die "test-profile failed" +elif test x$MODE = xviewer ; then + echo "Launching dbus-viewer" + ARGS= + if test x$DEBUG = x ; then + ARGS="--services org.freedesktop.DBus org.freedesktop.DBus.GLib.TestService" + fi + ${DBUS_TOP_BUILDDIR}/libtool --mode=execute $DEBUG $DBUS_TOP_BUILDDIR/tools/dbus-viewer $ARGS || die "could not run dbus-viewer" +elif test x$MODE = xwait ; then + echo "Waiting DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS" + sleep 86400 +else + echo "running test-dbus-glib" + if test x$DBUS_TEST_MONITOR != x; then + dbus-monitor --session & + 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-registrations || die "test-registrations 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" + ${DBUS_TOP_BUILDDIR}/libtool --mode=execute $DEBUG $DBUS_TOP_BUILDDIR/test/core/test-gvariant || die "test-gvariant failed" + ${DBUS_TOP_BUILDDIR}/libtool --mode=execute $DEBUG $DBUS_TOP_BUILDDIR/test/core/test-30574 || die "test-30574 failed" + ${DBUS_TOP_BUILDDIR}/libtool --mode=execute $DEBUG $DBUS_TOP_BUILDDIR/test/core/test-error-mapping || die "test-error-mapping failed" + ${DBUS_TOP_BUILDDIR}/libtool --mode=execute $DEBUG $DBUS_TOP_BUILDDIR/test/core/test-peer-on-bus || die "test-peer-on-bus failed" +fi diff --git a/test/core/test-dbus-glib.c b/test/core/test-dbus-glib.c new file mode 100644 index 0000000..ffc2ae9 --- /dev/null +++ b/test/core/test-dbus-glib.c @@ -0,0 +1,2377 @@ +/* General tests for dbus-glib. Please make new tests into a standalone + * binary using GTest instead, where feasible. + * + * Copyright © 2006-2010 Red Hat, Inc. + * Copyright © 2006-2010 Collabora Ltd. + * Copyright © 2006-2011 Nokia Corporation + * Copyright © 2006 Steve Frécinaux + * + * 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> + +/* -*- mode: C; c-file-style: "gnu" -*- */ +#include <dbus/dbus-glib.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include "test-service-glib-bindings.h" +#include <dbus/dbus-gidl.h> +#include <dbus/dbus-gparser.h> +#include <glib.h> +#include <glib-object.h> +#include "my-object.h" + +GMainLoop *loop = NULL; + +static const char *await_terminating_service = NULL; +static int n_times_foo_received = 0; +static int n_times_frobnicate_received = 0; +static int n_times_frobnicate_received_2 = 0; +static int n_times_compat_frobnicate_received = 0; +static int n_times_sig0_received = 0; +static int n_times_sig1_received = 0; +static int n_times_sig2_received = 0; +static guint exit_timeout = 0; +static gboolean proxy_destroyed = FALSE; +static gboolean proxy_destroy_and_nameowner = FALSE; +static gboolean proxy_destroy_and_nameowner_complete = FALSE; + +static DBusGProxy *test_terminate_proxy1 = NULL; +static DBusGProxy *test_terminate_proxy2 = NULL; + +#define lose(...) g_error (__VA_ARGS__) + +static void lose_gerror (const char *prefix, GError *error) G_GNUC_NORETURN; + +static void +unset_and_free_gvalue (gpointer val) +{ + g_value_unset (val); + g_free (val); +} + +static gboolean +timed_exit (gpointer loop) +{ + g_print ("timed exit!\n"); + g_main_loop_quit (loop); + return TRUE; +} + +static void +proxy_destroyed_cb (DBusGProxy *proxy, gpointer user_data) +{ + proxy_destroyed = TRUE; + if (proxy_destroy_and_nameowner && !proxy_destroy_and_nameowner_complete && await_terminating_service == NULL) + { + g_source_remove (exit_timeout); + g_main_loop_quit (loop); + proxy_destroy_and_nameowner_complete = TRUE; + } +} + +static void +test_terminate_proxy1_destroyed_cb (DBusGProxy *proxy, gpointer user_data) +{ + proxy_destroyed = TRUE; + if (proxy_destroy_and_nameowner && !proxy_destroy_and_nameowner_complete && await_terminating_service == NULL) + { + g_object_unref(test_terminate_proxy2); + test_terminate_proxy2 = NULL; + g_source_remove (exit_timeout); + g_main_loop_quit (loop); + proxy_destroy_and_nameowner_complete = TRUE; + } +} + + +static void +name_owner_changed (DBusGProxy *proxy, + const char *name, + const char *prev_owner, + const char *new_owner, + gpointer user_data) +{ + g_print ("(signal NameOwnerChanged) name owner changed for %s from %s to %s\n", + name, prev_owner, new_owner); + if (await_terminating_service && + !strcmp (name, await_terminating_service) + && !strcmp ("", new_owner)) + { + g_print ("Caught expected ownership loss for %s\n", name); + await_terminating_service = NULL; + if (proxy_destroy_and_nameowner && !proxy_destroy_and_nameowner_complete && proxy_destroyed) + { + g_source_remove (exit_timeout); + g_main_loop_quit (loop); + proxy_destroy_and_nameowner_complete = TRUE; + } + else if (!proxy_destroy_and_nameowner) + { + g_source_remove (exit_timeout); + g_main_loop_quit (loop); + } + } +} + +static void +foo_signal_handler (DBusGProxy *proxy, + double d, + void *user_data) +{ + n_times_foo_received += 1; + + g_print ("Got Foo signal\n"); + + g_main_loop_quit (loop); + g_source_remove (exit_timeout); +} + +static void +frobnicate_signal_handler (DBusGProxy *proxy, + int val, + void *user_data) +{ + n_times_frobnicate_received += 1; + + g_assert (val == 42); + g_print ("Got Frobnicate signal\n"); + + g_main_loop_quit (loop); + g_source_remove (exit_timeout); +} + +static void +frobnicate_signal_handler_2 (DBusGProxy *proxy, + int val, + void *user_data) +{ + n_times_frobnicate_received_2 += 1; + + g_assert (val == 42); + g_print ("Got Frobnicate signal (again)\n"); +} + +static void +frobnicate_signal_handler_compat (DBusGProxy *proxy, + int val, + void *user_data) +{ + n_times_compat_frobnicate_received += 1; + + g_assert (val == 42); + g_print ("Got Frobnicate signal (compat)\n"); + + g_main_loop_quit (loop); + g_source_remove (exit_timeout); +} + +static void +sig0_signal_handler (DBusGProxy *proxy, + const char *str0, + int val, + const char *str1, + void *user_data) +{ + n_times_sig0_received += 1; + + g_assert (!strcmp (str0, "foo")); + + g_assert (val == 22); + + g_assert (!strcmp (str1, "moo")); + + g_print ("Got Sig0 signal\n"); + + g_main_loop_quit (loop); + g_source_remove (exit_timeout); +} + +static void +sig1_signal_handler (DBusGProxy *proxy, + const char *str0, + GValue *value, + void *user_data) +{ + n_times_sig1_received += 1; + + g_assert (!strcmp (str0, "baz")); + + g_assert (G_VALUE_HOLDS_STRING (value)); + + g_assert (!strcmp (g_value_get_string (value), "bar")); + + g_print ("Got Sig1 signal\n"); + + g_main_loop_quit (loop); + g_source_remove (exit_timeout); +} + +static void +sig2_signal_handler (DBusGProxy *proxy, + GHashTable *table, + void *user_data) +{ + n_times_sig2_received += 1; + + g_assert (g_hash_table_size (table) == 2); + + g_assert (g_hash_table_lookup (table, "baz") != NULL); + g_assert (!strcmp (g_hash_table_lookup (table, "baz"), "cow")); + g_assert (g_hash_table_lookup (table, "bar") != NULL); + g_assert (!strcmp (g_hash_table_lookup (table, "bar"), "foo")); + + g_print ("Got Sig2 signal\n"); + + g_main_loop_quit (loop); + g_source_remove (exit_timeout); +} + +static DBusGProxyCall *echo_call; +static guint n_times_echo_cb_entered; +static void +echo_received_cb (DBusGProxy *proxy, + DBusGProxyCall *call, + gpointer data) +{ + GError *error; + char *echo_data; + + g_assert (call == echo_call); + g_assert (data == NULL); + + error = NULL; + echo_data = NULL; + n_times_echo_cb_entered++; + + if (!dbus_g_proxy_end_call (proxy, call, &error, + G_TYPE_STRING, + &echo_data, + G_TYPE_INVALID)) + lose_gerror ("Failed to complete async Echo", error); + g_assert (echo_data != NULL); + g_print ("Async echo gave \"%s\"\n", echo_data); + g_free (echo_data); + g_main_loop_quit (loop); + g_source_remove (exit_timeout); +} + +static void +increment_received_cb (DBusGProxy *proxy, + DBusGProxyCall *call, + gpointer data) +{ + GError *error; + guint val; + + g_assert (!strcmp (data, "moo")); + + error = NULL; + if (!dbus_g_proxy_end_call (proxy, call, &error, + G_TYPE_UINT, &val, + G_TYPE_INVALID)) + lose_gerror ("Failed to complete (async) Increment call", error); + + if (val != 43) + lose ("Increment call returned %d, should be 43", val); + + g_print ("Async increment gave \"%d\"\n", val); + g_main_loop_quit (loop); + g_source_remove (exit_timeout); +} + +static void +increment_async_cb (DBusGProxy *proxy, guint val, GError *error, gpointer data) +{ + if (error) + lose_gerror ("Failed to complete (wrapped async) Increment call", error); + + if (data != NULL) + lose ("(wrapped async) Increment call gave unexpected data"); + if (val != 43) + lose ("(wrapped async) Increment call returned %d, should be 43", val); + + g_print ("(wrapped async) increment gave \"%d\"\n", val); + g_main_loop_quit (loop); + g_source_remove (exit_timeout); +} + +#define DBUS_TYPE_G_MAP_OF_VARIANT (dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE)) +static gboolean +test_base_class_get_all (DBusGConnection *connection, + const char *object_path, + const char *expected_string_value) +{ + DBusGProxy *proxy; + GError *error = NULL; + GHashTable *hash = NULL; + + /* g_test_bug (19145); */ + + g_assert (expected_string_value != NULL); + g_assert (object_path != NULL); + + /* Test GetAll with interfaces on the base class */ + + proxy = dbus_g_proxy_new_for_name (connection, + "org.freedesktop.DBus.GLib.TestService", + object_path, + DBUS_INTERFACE_PROPERTIES); + g_assert (proxy != NULL); + + g_print ("%s: Calling GetAll for unknown interface\n", object_path); + { + if (dbus_g_proxy_call (proxy, "GetAll", &error, + G_TYPE_STRING, "org.freedesktop.DBus.foobar.blahblah", + G_TYPE_INVALID, + DBUS_TYPE_G_MAP_OF_VARIANT, &hash, G_TYPE_INVALID)) + lose ("Unexpected success for GetAll call of unknown interface\n"); + g_clear_error (&error); + hash = NULL; + } + + g_print ("%s: Calling GetAll for base class interface\n", object_path); + { + GValue *value; + const char *foo = NULL; + + if (!dbus_g_proxy_call (proxy, "GetAll", &error, + G_TYPE_STRING, "org.freedesktop.DBus.GLib.Tests.MyObject", + G_TYPE_INVALID, + DBUS_TYPE_G_MAP_OF_VARIANT, &hash, G_TYPE_INVALID)) + lose_gerror ("Unexpected error for GetProperty call of base class interface", error); + g_clear_error (&error); + + if (!hash) + { + lose ("%s: Unexpected NULL hash table returned for GetAll call of base " + "class interface", object_path); + } + + if (g_hash_table_size (hash) != 3) + { + lose ("%s: Unexpected hash table size %d (expected 3) returned for GetAll " + " call of base class interface", object_path, g_hash_table_size (hash)); + } + value = g_hash_table_lookup (hash, "this_is_a_string"); + if (!value) + { + lose ("%s: Unexpected missing 'this_is_a_string' property for GetAll " + "call of base class interface", object_path); + } + if (!G_VALUE_HOLDS_STRING (value)) + { + lose ("%s: Unexpected wrong type for 'this_is_a_string' property for " + "GetAll call of base class interface", object_path); + } + foo = g_value_get_string (value); + if (!foo || strcmp (foo, expected_string_value)) + { + lose ("%s: Unexpected value for 'this_is_a_string' property for GetAll " + "call of base class interface", object_path); + } + + value = g_hash_table_lookup (hash, "no-touching"); + if (!value) + lose ("%s: Unexpected missing 'no-touching' property for GetAll " + "call of base class interface", object_path); + if (!G_VALUE_HOLDS_UINT (value)) + lose ("%s: Unexpected wrong type for 'no-touching' property for " + "GetAll call of base class interface", object_path); + if (g_value_get_uint (value) != 42) + lose ("%s: Unexpected wrong value \"%d\" for 'no-touching' property for " + "GetAll call of base class interface", object_path, g_value_get_uint (value)); + g_hash_table_destroy (hash); + hash = NULL; + } + + g_object_unref (proxy); + return TRUE; +} + +static gboolean +test_subclass_get_all (DBusGConnection *connection, + const char *object_path) +{ + DBusGProxy *proxy; + GError *error = NULL; + GHashTable *hash = NULL; + + /* g_test_bug (19145); */ + + g_assert (object_path != NULL); + + /* Test GetAll with interfaces on the subclass */ + + proxy = dbus_g_proxy_new_for_name (connection, + "org.freedesktop.DBus.GLib.TestService", + object_path, + DBUS_INTERFACE_PROPERTIES); + g_assert (proxy != NULL); + + g_print ("%s: Calling GetAll for subclass interface\n", object_path); + { + GValue *value; + const char *string = NULL; + guint num = 0; + + if (!dbus_g_proxy_call (proxy, "GetAll", &error, + G_TYPE_STRING, "org.freedesktop.DBus.GLib.Tests.MyObjectSubclass", + G_TYPE_INVALID, + DBUS_TYPE_G_MAP_OF_VARIANT, &hash, G_TYPE_INVALID)) + lose_gerror ("Unexpected error for GetProperty call of base subclass interface\n", error); + g_clear_error (&error); + + if (!hash) + { + lose ("%s: Unexpected NULL hash table returned for GetAll call of " + "subclass interface\n", object_path); + } + + if (g_hash_table_size (hash) != 2) + { + lose ("%s: Unexpected hash table size %d (expected 2) returned for GetAll " + " call of subclass interface\n", object_path, g_hash_table_size (hash)); + } + + /* Test the string property */ + value = g_hash_table_lookup (hash, "this_is_a_subclass_string"); + if (!value) + { + lose ("%s: Unexpected missing 'this_is_a_subclass_string' property for " + "GetAll call of subclass interface\n", object_path); + } + if (!G_VALUE_HOLDS_STRING (value)) + { + lose ("%s: Unexpected wrong type for 'this_is_a_subclass_string' " + "property for GetAll call of subclass interface\n", object_path); + } + string = g_value_get_string (value); + if (!string || strcmp (string, "default subclass value")) + { + lose ("%s: Unexpected value for 'this_is_a_subclass_string' property " + "for GetAll call of subclass interface\n", object_path); + } + + /* Test the uint property */ + value = g_hash_table_lookup (hash, "this_is_a_subclass_uint"); + if (!value) + { + lose ("%s: Unexpected missing 'this_is_a_subclass_uint' property for " + "GetAll call of subclass interface\n", object_path); + } + if (!G_VALUE_HOLDS_UINT (value)) + { + lose ("%s: Unexpected wrong type for 'this_is_a_subclass_uint' " + "property for GetAll call of subclass interface\n", object_path); + } + num = g_value_get_uint (value); + if (num != 1234567) + { + lose ("%s: Unexpected value for 'this_is_a_subclass_uint' property " + "for GetAll call of subclass interface\n", object_path); + } + + g_hash_table_destroy (hash); + hash = NULL; + } + + g_object_unref (proxy); + return TRUE; +} + +static void +lose_gerror (const char *prefix, GError *error) +{ + if (error->domain == DBUS_GERROR && error->code == DBUS_GERROR_REMOTE_EXCEPTION) + lose ("%s (%s): %s", prefix, dbus_g_error_get_name (error), + error->message); + else + lose ("%s: %s#%d: %s", prefix, g_quark_to_string (error->domain), + error->code, error->message); +} + +static void +run_mainloop (void) +{ + GMainContext *ctx; + + ctx = g_main_loop_get_context (loop); + + while (g_main_context_pending (ctx)) + g_main_context_iteration (ctx, FALSE); +} + +int +main (int argc, char **argv) +{ + DBusGConnection *connection; + GError *error; + DBusGProxy *driver; + DBusGProxy *proxy; + DBusGProxy *proxy2; + DBusGProxy *property_proxy; + char **name_list; + guint name_list_len; + guint i; + DBusGProxyCall *call; + guint32 result; + char *v_STRING_2; + guint32 v_UINT32_2; + double v_DOUBLE_2; + + g_type_init (); + + g_log_set_always_fatal (G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL); + + loop = g_main_loop_new (NULL, FALSE); + + error = NULL; + connection = dbus_g_bus_get (DBUS_BUS_SESSION, + &error); + if (connection == NULL) + lose_gerror ("Failed to open connection to bus", error); + + /* should always get the same one */ + g_assert (connection == dbus_g_bus_get (DBUS_BUS_SESSION, NULL)); + g_assert (connection == dbus_g_bus_get (DBUS_BUS_SESSION, NULL)); + g_assert (connection == dbus_g_bus_get (DBUS_BUS_SESSION, NULL)); + + /* Create a proxy object for the "bus driver" */ + + driver = dbus_g_proxy_new_for_name (connection, + DBUS_SERVICE_DBUS, + DBUS_PATH_DBUS, + DBUS_INTERFACE_DBUS); + + dbus_g_proxy_add_signal (driver, + "NameOwnerChanged", + G_TYPE_STRING, + G_TYPE_STRING, + G_TYPE_STRING, + G_TYPE_INVALID); + + dbus_g_proxy_connect_signal (driver, + "NameOwnerChanged", + G_CALLBACK (name_owner_changed), + NULL, + NULL); + /* Call ListNames method */ + + error = NULL; + if (!dbus_g_proxy_call (driver, "ListNames", &error, + G_TYPE_INVALID, + G_TYPE_STRV, &name_list, + G_TYPE_INVALID)) + lose_gerror ("Failed to complete ListNames call", error); + + g_print ("Names on the message bus:\n"); + i = 0; + name_list_len = g_strv_length (name_list); + while (i < name_list_len) + { + g_assert (name_list[i] != NULL); + g_print (" %s\n", name_list[i]); + ++i; + } + g_assert (name_list[i] == NULL); + + g_strfreev (name_list); + + g_print ("calling ThisMethodDoesNotExist\n"); + /* Test handling of unknown method */ + if (dbus_g_proxy_call (driver, "ThisMethodDoesNotExist", &error, + G_TYPE_STRING, + "blah blah blah blah blah", + G_TYPE_INT, + 10, + G_TYPE_INVALID, G_TYPE_INVALID) != FALSE) + lose ("Calling nonexistent method succeeded!"); + + g_print ("Got EXPECTED error from calling unknown method: %s\n", error->message); + g_clear_error (&error); + + run_mainloop (); + + /* Activate a service */ + g_print ("Activating echo service\n"); + if (!dbus_g_proxy_call (driver, "StartServiceByName", &error, + G_TYPE_STRING, + "org.freedesktop.DBus.GLib.TestEchoService", + G_TYPE_UINT, 0, + G_TYPE_INVALID, + G_TYPE_UINT, &result, + G_TYPE_INVALID)) + lose_gerror ("Failed to complete Activate call", error); + + g_print ("Starting echo service result = 0x%x\n", result); + + /* Activate a service again */ + g_print ("Activating echo service again\n"); + if (!dbus_g_proxy_call (driver, "StartServiceByName", &error, + G_TYPE_STRING, + "org.freedesktop.DBus.GLib.TestEchoService", + G_TYPE_UINT, + 0, + G_TYPE_INVALID, + G_TYPE_UINT, &result, + G_TYPE_INVALID)) + lose_gerror ("Failed to complete Activate call", error); + + g_print ("Duplicate start of echo service = 0x%x\n", result); + + /* Talk to the new service */ + + g_print ("Creating proxy for echo service\n"); + proxy = dbus_g_proxy_new_for_name_owner (connection, + "org.freedesktop.DBus.GLib.TestEchoService", + "/org/freedesktop/DBus/GLib/TestSuite", + "org.freedesktop.DBus.GLib.TestSuite", + &error); + + if (proxy == NULL) + lose_gerror ("Failed to create proxy for name owner", error); + + run_mainloop (); + + g_print ("Calling Echo\n"); + if (!dbus_g_proxy_call (proxy, "Echo", &error, + G_TYPE_STRING, "my string hello", + G_TYPE_INVALID, + G_TYPE_STRING, &v_STRING_2, + G_TYPE_INVALID)) + lose_gerror ("Failed to complete Echo call", error); + + g_print ("String echoed = \"%s\"\n", v_STRING_2); + g_free (v_STRING_2); + + g_print ("Calling Echo (async)\n"); + echo_call = dbus_g_proxy_begin_call (proxy, "Echo", + echo_received_cb, NULL, NULL, + G_TYPE_STRING, "my string hello", + G_TYPE_INVALID); + dbus_g_connection_flush (connection); + exit_timeout = g_timeout_add (5000, timed_exit, loop); + g_main_loop_run (loop); + + /* Exercise invalid number/type of return values */ + + g_print ("Invalid args; calling Echo\n"); + if (dbus_g_proxy_call (proxy, "Echo", &error, + G_TYPE_STRING, "my string hello", + G_TYPE_INVALID, + G_TYPE_INVALID)) + lose ("Unexpected success for invalid Echo return values"); + g_clear_error (&error); + + g_print ("Invalid args 2; calling Echo\n"); + if (dbus_g_proxy_call (proxy, "Echo", &error, + G_TYPE_STRING, "my string hello", + G_TYPE_INVALID, + G_TYPE_UINT, &v_UINT32_2, + G_TYPE_INVALID)) + lose ("Unexpected success for invalid Echo return values"); + g_clear_error (&error); + + g_print ("Invalid args 3; calling Echo\n"); + if (dbus_g_proxy_call (proxy, "Echo", &error, + G_TYPE_STRING, "my string hello", + G_TYPE_INVALID, + G_TYPE_STRING, &v_STRING_2, + G_TYPE_UINT, &v_UINT32_2, + G_TYPE_INVALID)) + lose ("Unexpected success for invalid Echo return values"); + g_clear_error (&error); + + /* Test oneway call and signal handling */ + + g_print ("Testing Foo emission\n"); + dbus_g_proxy_add_signal (proxy, "Foo", G_TYPE_DOUBLE, G_TYPE_INVALID); + + dbus_g_proxy_connect_signal (proxy, "Foo", + G_CALLBACK (foo_signal_handler), + NULL, NULL); + + dbus_g_proxy_call_no_reply (proxy, "EmitFoo", + G_TYPE_INVALID); + + dbus_g_connection_flush (connection); + exit_timeout = g_timeout_add (5000, timed_exit, loop); + g_main_loop_run (loop); + + if (n_times_foo_received != 1) + lose ("Foo signal received %d times, should have been 1", n_times_foo_received); + + /* Activate test servie */ + g_print ("Activating GLib.TestService\n"); + error = NULL; + if (!dbus_g_proxy_call (driver, "StartServiceByName", &error, + G_TYPE_STRING, + "org.freedesktop.DBus.GLib.TestService", + G_TYPE_UINT, + 0, + G_TYPE_INVALID, + G_TYPE_UINT, &result, + G_TYPE_INVALID)) { + lose_gerror ("Failed to complete Activate call", error); + } + + g_print ("GLib.TestService activated\n"); + + if (getenv ("DBUS_GLIB_TEST_SLEEP_AFTER_ACTIVATION")) + g_usleep (8 * G_USEC_PER_SEC); + + g_object_unref (G_OBJECT (proxy)); + + run_mainloop (); + + proxy = dbus_g_proxy_new_for_name_owner (connection, + "org.freedesktop.DBus.GLib.TestService", + "/org/freedesktop/DBus/GLib/Tests/MyTestObject", + "org.freedesktop.DBus.GLib.Tests.MyObject", + &error); + + if (proxy == NULL) + lose_gerror ("Failed to create proxy for name owner", error); + + g_print ("Calling DoNothing\n"); + if (!dbus_g_proxy_call (proxy, "DoNothing", &error, + G_TYPE_INVALID, G_TYPE_INVALID)) + lose_gerror ("Failed to complete DoNothing call", error); + + g_print ("Calling Increment\n"); + error = NULL; + if (!dbus_g_proxy_call (proxy, "Increment", &error, + G_TYPE_UINT, 42, + G_TYPE_INVALID, + G_TYPE_UINT, &v_UINT32_2, + G_TYPE_INVALID)) + lose_gerror ("Failed to complete Increment call", error); + if (v_UINT32_2 != 43) + lose ("Increment call returned %d, should be 43", v_UINT32_2); + + v_UINT32_2 = 0; + g_print ("Calling Increment (async)\n"); + call = dbus_g_proxy_begin_call (proxy, "Increment", + increment_received_cb, g_strdup ("moo"), g_free, + G_TYPE_UINT, 42, + G_TYPE_INVALID); + if (call == NULL) + lose ("Failed to begin Increment call"); + + dbus_g_connection_flush (connection); + exit_timeout = g_timeout_add (5000, timed_exit, loop); + g_main_loop_run (loop); + + g_print ("Calling IncrementRetval\n"); + error = NULL; + v_UINT32_2 = 0; + if (!dbus_g_proxy_call (proxy, "IncrementRetval", &error, + G_TYPE_UINT, 42, + G_TYPE_INVALID, + G_TYPE_UINT, &v_UINT32_2, + G_TYPE_INVALID)) + lose_gerror ("Failed to complete Increment call", error); + if (v_UINT32_2 != 43) + lose ("IncrementRetval call returned %d, should be 43", v_UINT32_2); + + g_print ("Calling IncrementRetvalError\n"); + error = NULL; + v_UINT32_2 = 0; + if (!dbus_g_proxy_call (proxy, "IncrementRetvalError", &error, + G_TYPE_UINT, 5, + G_TYPE_INVALID, + G_TYPE_UINT, &v_UINT32_2, + G_TYPE_INVALID)) + lose_gerror ("Failed to complete Increment call", error); + if (v_UINT32_2 != 6) + lose ("IncrementRetval call returned %d, should be 6", v_UINT32_2); + + g_print ("Calling ThrowError\n"); + if (dbus_g_proxy_call (proxy, "ThrowError", &error, + G_TYPE_INVALID, G_TYPE_INVALID) != FALSE) + lose ("ThrowError call unexpectedly succeeded!"); + + if (!dbus_g_error_has_name (error, "org.freedesktop.DBus.GLib.Tests.MyObject.Foo")) + lose ("ThrowError call returned unexpected error \"%s\": %s", dbus_g_error_get_name (error), + error->message); + + g_print ("ThrowError failed (as expected) returned error: %s\n", error->message); + g_clear_error (&error); + + g_print ("Calling IncrementRetvalError (for error)\n"); + error = NULL; + v_UINT32_2 = 0; + if (dbus_g_proxy_call (proxy, "IncrementRetvalError", &error, + G_TYPE_UINT, 20, + G_TYPE_INVALID, + G_TYPE_UINT, &v_UINT32_2, + G_TYPE_INVALID) != FALSE) + lose ("IncrementRetvalError call unexpectedly succeeded!"); + if (!dbus_g_error_has_name (error, "org.freedesktop.DBus.GLib.Tests.MyObject.Foo")) + lose ("IncrementRetvalError call returned unexpected error \"%s\": %s", dbus_g_error_get_name (error), error->message); + g_clear_error (&error); + + error = NULL; + g_print ("Calling Uppercase\n"); + if (!dbus_g_proxy_call (proxy, "Uppercase", &error, + G_TYPE_STRING, "foobar", + G_TYPE_INVALID, + G_TYPE_STRING, &v_STRING_2, + G_TYPE_INVALID)) + lose_gerror ("Failed to complete Uppercase call", error); + if (strcmp ("FOOBAR", v_STRING_2) != 0) + lose ("Uppercase call returned unexpected string %s", v_STRING_2); + g_free (v_STRING_2); + + run_mainloop (); + + g_print ("Calling ManyArgs\n"); + if (!dbus_g_proxy_call (proxy, "ManyArgs", &error, + G_TYPE_UINT, 26, + G_TYPE_STRING, "bazwhee", + G_TYPE_DOUBLE, G_PI, + G_TYPE_INVALID, + G_TYPE_DOUBLE, &v_DOUBLE_2, + G_TYPE_STRING, &v_STRING_2, + G_TYPE_INVALID)) + lose_gerror ("Failed to complete ManyArgs call", error); + if (v_DOUBLE_2 < 55 || v_DOUBLE_2 > 56) + lose ("ManyArgs call returned unexpected double value %f", v_DOUBLE_2); + if (strcmp ("BAZWHEE", v_STRING_2) != 0) + lose ("ManyArgs call returned unexpected string %s", v_STRING_2); + g_free (v_STRING_2); + + g_print ("Calling (wrapped) do_nothing\n"); + if (!org_freedesktop_DBus_GLib_Tests_MyObject_do_nothing (proxy, &error)) + lose_gerror ("Failed to complete (wrapped) DoNothing call", error); + + g_print ("Calling (wrapped) increment\n"); + if (!org_freedesktop_DBus_GLib_Tests_MyObject_increment (proxy, 42, &v_UINT32_2, &error)) + lose_gerror ("Failed to complete (wrapped) Increment call", error); + + if (v_UINT32_2 != 43) + lose ("(wrapped) increment call returned %d, should be 43", v_UINT32_2); + + g_print ("Calling (wrapped async) increment\n"); + if (!org_freedesktop_DBus_GLib_Tests_MyObject_increment_async (proxy, 42, increment_async_cb, NULL)) + lose_gerror ("Failed to complete (wrapped) Increment call", error); + dbus_g_connection_flush (connection); + exit_timeout = g_timeout_add (5000, timed_exit, loop); + g_main_loop_run (loop); + + v_UINT32_2 = 0; + if (!org_freedesktop_DBus_GLib_Tests_MyObject_async_increment (proxy, 42, &v_UINT32_2, &error)) + lose_gerror ("Failed to complete (wrapped) AsyncIncrement call", error); + + if (v_UINT32_2 != 43) + lose ("(wrapped) async increment call returned %d, should be 43", v_UINT32_2); + + g_print ("Calling (wrapped) throw_error\n"); + if (org_freedesktop_DBus_GLib_Tests_MyObject_throw_error (proxy, &error) != FALSE) + lose ("(wrapped) ThrowError call unexpectedly succeeded!"); + + g_print ("(wrapped) ThrowError failed (as expected) returned error: %s\n", error->message); + g_clear_error (&error); + + g_print ("Calling (wrapped) uppercase\n"); + if (!org_freedesktop_DBus_GLib_Tests_MyObject_uppercase (proxy, "foobar", &v_STRING_2, &error)) + lose_gerror ("Failed to complete (wrapped) Uppercase call", error); + if (strcmp ("FOOBAR", v_STRING_2) != 0) + lose ("(wrapped) Uppercase call returned unexpected string %s", v_STRING_2); + g_free (v_STRING_2); + + g_print ("Calling (wrapped) many_args\n"); + if (!org_freedesktop_DBus_GLib_Tests_MyObject_many_args (proxy, 26, "bazwhee", G_PI, + &v_DOUBLE_2, &v_STRING_2, &error)) + lose_gerror ("Failed to complete (wrapped) ManyArgs call", error); + + if (v_DOUBLE_2 < 55 || v_DOUBLE_2 > 56) + + lose ("(wrapped) ManyArgs call returned unexpected double value %f", v_DOUBLE_2); + + if (strcmp ("BAZWHEE", v_STRING_2) != 0) + lose ("(wrapped) ManyArgs call returned unexpected string %s", v_STRING_2); + g_free (v_STRING_2); + + { + guint32 arg0; + char *arg1; + gint32 arg2; + guint32 arg3; + guint32 arg4; + char *arg5; + + g_print ("Calling (wrapped) many_return\n"); + if (!org_freedesktop_DBus_GLib_Tests_MyObject_many_return (proxy, &arg0, &arg1, &arg2, &arg3, &arg4, &arg5, &error)) + lose_gerror ("Failed to complete (wrapped) ManyReturn call", error); + + if (arg0 != 42) + lose ("(wrapped) ManyReturn call returned unexpected guint32 value %u", arg0); + + if (strcmp ("42", arg1) != 0) + lose ("(wrapped) ManyReturn call returned unexpected string %s", arg1); + g_free (arg1); + + if (arg2 != -67) + lose ("(wrapped) ManyReturn call returned unexpected gint32 value %u", arg2); + + if (arg3 != 2) + lose ("(wrapped) ManyReturn call returned unexpected guint32 value %u", arg3); + + if (arg4 != 26) + lose ("(wrapped) ManyReturn call returned unexpected guint32 value %u", arg4); + + if (strcmp ("hello world", arg5)) + lose ("(wrapped) ManyReturn call returned unexpected string %s", arg5); + g_free (arg5); + } + + run_mainloop (); + + { + GValue value = {0, }; + + g_value_init (&value, G_TYPE_STRING); + g_value_set_string (&value, "foo"); + + g_print ("Calling (wrapped) stringify, with string\n"); + if (!org_freedesktop_DBus_GLib_Tests_MyObject_stringify (proxy, + &value, + &v_STRING_2, + &error)) + lose_gerror ("Failed to complete (wrapped) stringify call", error); + if (strcmp ("foo", v_STRING_2) != 0) + lose ("(wrapped) stringify call returned unexpected string %s", v_STRING_2); + g_free (v_STRING_2); + + g_value_unset (&value); + g_value_init (&value, G_TYPE_INT); + g_value_set_int (&value, 42); + + g_print ("Calling (wrapped) stringify, with int\n"); + if (!org_freedesktop_DBus_GLib_Tests_MyObject_stringify (proxy, + &value, + &v_STRING_2, + &error)) + lose_gerror ("Failed to complete (wrapped) stringify call 2", error); + if (strcmp ("42", v_STRING_2) != 0) + lose ("(wrapped) stringify call 2 returned unexpected string %s", v_STRING_2); + g_value_unset (&value); + g_free (v_STRING_2); + + g_value_init (&value, G_TYPE_INT); + g_value_set_int (&value, 88); + g_print ("Calling (wrapped) stringify, with another int\n"); + if (!org_freedesktop_DBus_GLib_Tests_MyObject_stringify (proxy, + &value, + NULL, + &error)) + lose_gerror ("Failed to complete (wrapped) stringify call 3", error); + g_value_unset (&value); + + g_print ("Calling (wrapped) unstringify, for string\n"); + if (!org_freedesktop_DBus_GLib_Tests_MyObject_unstringify (proxy, + "foo", + &value, + &error)) + lose_gerror ("Failed to complete (wrapped) unstringify call", error); + if (!G_VALUE_HOLDS_STRING (&value)) + lose ("(wrapped) unstringify call returned unexpected value type %d", (int) G_VALUE_TYPE (&value)); + if (strcmp (g_value_get_string (&value), "foo")) + lose ("(wrapped) unstringify call returned unexpected string %s", + g_value_get_string (&value)); + + g_value_unset (&value); + + g_print ("Calling (wrapped) unstringify, for int\n"); + if (!org_freedesktop_DBus_GLib_Tests_MyObject_unstringify (proxy, + "10", + &value, + &error)) + lose_gerror ("Failed to complete (wrapped) unstringify call", error); + if (!G_VALUE_HOLDS_INT (&value)) + lose ("(wrapped) unstringify call returned unexpected value type %d", (int) G_VALUE_TYPE (&value)); + if (g_value_get_int (&value) != 10) + lose ("(wrapped) unstringify call returned unexpected integer %d", + g_value_get_int (&value)); + + g_value_unset (&value); + } + + run_mainloop (); + + { + GArray *array; + guint32 arraylen; + + array = g_array_new (FALSE, TRUE, sizeof (guint32)); + + arraylen = 0; + g_print ("Calling (wrapped) zero-length recursive1\n"); + if (!org_freedesktop_DBus_GLib_Tests_MyObject_recursive1 (proxy, array, + &arraylen, &error)) + lose_gerror ("Failed to complete (wrapped) zero-length recursive1 call", error); + if (arraylen != 0) + lose ("(wrapped) zero-length recursive1 call returned invalid length %u", arraylen); + } + + { + GArray *array; + guint32 val; + guint32 arraylen; + + array = g_array_new (FALSE, TRUE, sizeof (guint32)); + val = 42; + g_array_append_val (array, val); + val = 69; + g_array_append_val (array, val); + val = 88; + g_array_append_val (array, val); + val = 26; + g_array_append_val (array, val); + val = 2; + g_array_append_val (array, val); + + arraylen = 0; + g_print ("Calling (wrapped) recursive1\n"); + if (!org_freedesktop_DBus_GLib_Tests_MyObject_recursive1 (proxy, array, + &arraylen, &error)) + lose_gerror ("Failed to complete (wrapped) recursive1 call", error); + if (arraylen != 5) + lose ("(wrapped) recursive1 call returned invalid length %u", arraylen); + } + + { + GArray *array = NULL; + guint32 *arrayvals; + + g_print ("Calling (wrapped) recursive2\n"); + if (!org_freedesktop_DBus_GLib_Tests_MyObject_recursive2 (proxy, 2, &array, &error)) + lose_gerror ("Failed to complete (wrapped) Recursive2 call", error); + + if (array == NULL) + lose ("(wrapped) Recursive2 call returned NULL"); + if (array->len != 5) + lose ("(wrapped) Recursive2 call returned unexpected array length %u", array->len); + + arrayvals = (guint32*) array->data; + if (arrayvals[0] != 42) + lose ("(wrapped) Recursive2 call returned unexpected value %d in position 0", arrayvals[0]); + if (arrayvals[1] != 26) + lose ("(wrapped) Recursive2 call returned unexpected value %d in position 1", arrayvals[1]); + if (arrayvals[4] != 2) + lose ("(wrapped) Recursive2 call returned unexpected value %d in position 4", arrayvals[4]); + + g_array_free (array, TRUE); + } + + run_mainloop (); + + { + const char *strs[] = { "hello", "HellO", "HELLO", NULL }; + char **strs_ret; + + strs_ret = NULL; + g_print ("Calling (wrapped) many_uppercase\n"); + if (!org_freedesktop_DBus_GLib_Tests_MyObject_many_uppercase (proxy, strs, &strs_ret, &error)) + lose_gerror ("Failed to complete (wrapped) ManyUppercase call", error); + g_assert (strs_ret != NULL); + if (strcmp ("HELLO", strs_ret[0]) != 0) + lose ("(wrapped) ManyUppercase call returned unexpected string %s", strs_ret[0]); + if (strcmp ("HELLO", strs_ret[1]) != 0) + lose ("(wrapped) ManyUppercase call returned unexpected string %s", strs_ret[1]); + if (strcmp ("HELLO", strs_ret[2]) != 0) + lose ("(wrapped) ManyUppercase call returned unexpected string %s", strs_ret[2]); + + g_strfreev (strs_ret); + } + + { + GHashTable *table; + guint len; + + table = g_hash_table_new (g_str_hash, g_str_equal); + g_hash_table_insert (table, "moooo", "b"); + g_hash_table_insert (table, "xxx", "cow!"); + + len = 0; + g_print ("Calling (wrapped) str_hash_len\n"); + if (!org_freedesktop_DBus_GLib_Tests_MyObject_str_hash_len (proxy, table, &len, &error)) + lose_gerror ("(wrapped) StrHashLen call failed", error); + if (len != 13) + lose ("(wrapped) StrHashLen returned unexpected length %u", len); + g_hash_table_destroy (table); + } + + { + GHashTable *table; + const char *val; + + g_print ("Calling (wrapped) get_hash\n"); + if (!org_freedesktop_DBus_GLib_Tests_MyObject_get_hash (proxy, &table, &error)) + lose_gerror ("(wrapped) GetHash call failed", error); + val = g_hash_table_lookup (table, "foo"); + if (val == NULL || strcmp ("bar", val)) + lose ("(wrapped) StrHashLen returned invalid value %s for key \"foo\"", + val ? val : "(null)"); + val = g_hash_table_lookup (table, "baz"); + if (val == NULL || strcmp ("whee", val)) + lose ("(wrapped) StrHashLen returned invalid value %s for key \"whee\"", + val ? val : "(null)"); + val = g_hash_table_lookup (table, "cow"); + if (val == NULL || strcmp ("crack", val)) + lose ("(wrapped) StrHashLen returned invalid value %s for key \"cow\"", + val ? val : "(null)"); + if (g_hash_table_size (table) != 3) + lose ("(wrapped) StrHashLen returned unexpected hash size %u", + g_hash_table_size (table)); + + g_hash_table_destroy (table); + } + + run_mainloop (); + + { + GValueArray *vals; + GValueArray *vals_ret; + GValue *val; + + vals = g_value_array_new (3); + + g_value_array_append (vals, NULL); + g_value_init (g_value_array_get_nth (vals, vals->n_values - 1), G_TYPE_STRING); + g_value_set_string (g_value_array_get_nth (vals, 0), "foo"); + + g_value_array_append (vals, NULL); + g_value_init (g_value_array_get_nth (vals, vals->n_values - 1), G_TYPE_UINT); + g_value_set_uint (g_value_array_get_nth (vals, vals->n_values - 1), 42); + + g_value_array_append (vals, NULL); + g_value_init (g_value_array_get_nth (vals, vals->n_values - 1), G_TYPE_VALUE); + val = g_new0 (GValue, 1); + g_value_init (val, G_TYPE_UCHAR); + g_value_set_uchar (val, '!'); + g_value_set_boxed (g_value_array_get_nth (vals, vals->n_values - 1), val); + + vals_ret = NULL; + g_print ("Calling SendCar\n"); + if (!dbus_g_proxy_call (proxy, "SendCar", &error, + G_TYPE_VALUE_ARRAY, vals, + G_TYPE_INVALID, + G_TYPE_VALUE_ARRAY, &vals_ret, + G_TYPE_INVALID)) + lose_gerror ("Failed to complete SendCar call", error); + + g_assert (vals_ret != NULL); + g_assert (vals_ret->n_values == 2); + + g_assert (G_VALUE_HOLDS_UINT (g_value_array_get_nth (vals_ret, 0))); + g_assert (g_value_get_uint (g_value_array_get_nth (vals_ret, 0)) == 43); + + g_assert (G_VALUE_TYPE (g_value_array_get_nth (vals_ret, 1)) == DBUS_TYPE_G_OBJECT_PATH); + g_assert (!strcmp ("/org/freedesktop/DBus/GLib/Tests/MyTestObject2", + g_value_get_boxed (g_value_array_get_nth (vals_ret, 1)))); + + g_free (val); + g_value_array_free (vals); + g_value_array_free (vals_ret); + } + + { + const gchar *in_sig = "a(iou)sq"; + gchar *out_sig = NULL; + + g_print ("Calling EchoSignature: %s\n", in_sig); + if (!org_freedesktop_DBus_GLib_Tests_MyObject_echo_signature (proxy, + in_sig, &out_sig, &error)) + lose_gerror ("Failed to complete EchoSignature call", error); + + if (out_sig == NULL) + lose ("EchoSignature returned NULL"); + if (strcmp (in_sig, out_sig) != 0) + lose ("EchoSignature changed the signature"); + + g_print ("EchoSignature returned: %s\n", out_sig); + + g_free (out_sig); + } + + { + GValue *val; + GHashTable *table; + GHashTable *ret_table; + + table = g_hash_table_new_full (g_str_hash, g_str_equal, + g_free, unset_and_free_gvalue); + + val = g_new0 (GValue, 1); + g_value_init (val, G_TYPE_UINT); + g_value_set_uint (val, 42); + g_hash_table_insert (table, g_strdup ("foo"), val); + + val = g_new0 (GValue, 1); + g_value_init (val, G_TYPE_STRING); + g_value_set_string (val, "hello"); + g_hash_table_insert (table, g_strdup ("bar"), val); + + ret_table = NULL; + g_print ("Calling ManyStringify\n"); + if (!dbus_g_proxy_call (proxy, "ManyStringify", &error, + dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE), table, + G_TYPE_INVALID, + dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE), &ret_table, + G_TYPE_INVALID)) + lose_gerror ("Failed to complete ManyStringify call", error); + + g_assert (ret_table != NULL); + g_assert (g_hash_table_size (ret_table) == 2); + + val = g_hash_table_lookup (ret_table, "foo"); + g_assert (val != NULL); + g_assert (G_VALUE_HOLDS_STRING (val)); + g_assert (!strcmp ("42", g_value_get_string (val))); + + val = g_hash_table_lookup (ret_table, "bar"); + g_assert (val != NULL); + g_assert (G_VALUE_HOLDS_STRING (val)); + g_assert (!strcmp ("hello", g_value_get_string (val))); + + g_hash_table_destroy (table); + g_hash_table_destroy (ret_table); + } + + { + GPtrArray *in_array; + GPtrArray *out_array; + char **strs; + GArray *uints; + + in_array = g_ptr_array_new (); + + strs = g_new0 (char *, 3); + strs[0] = "foo"; + strs[1] = "bar"; + strs[2] = NULL; + g_ptr_array_add (in_array, strs); + + strs = g_new0 (char *, 4); + strs[0] = "baz"; + strs[1] = "whee"; + strs[2] = "moo"; + strs[3] = NULL; + g_ptr_array_add (in_array, strs); + + out_array = NULL; + g_print ("Calling RecArrays\n"); + if (!dbus_g_proxy_call (proxy, "RecArrays", &error, + dbus_g_type_get_collection ("GPtrArray", G_TYPE_STRV), in_array, + G_TYPE_INVALID, + dbus_g_type_get_collection ("GPtrArray", + dbus_g_type_get_collection ("GPtrArray", + G_TYPE_UINT)), &out_array, + G_TYPE_INVALID)) + lose_gerror ("Failed to complete RecArrays call", error); + g_free (g_ptr_array_index (in_array, 0)); + g_free (g_ptr_array_index (in_array, 1)); + + g_assert (out_array); + g_assert (out_array->len == 2); + uints = g_ptr_array_index (out_array, 0); + g_assert (uints); + g_assert (uints->len == 3); + g_assert (g_array_index (uints, guint, 0) == 10); + g_assert (g_array_index (uints, guint, 1) == 42); + g_assert (g_array_index (uints, guint, 2) == 27); + g_array_free (uints, TRUE); + uints = g_ptr_array_index (out_array, 1); + g_assert (uints); + g_assert (uints->len == 1); + g_assert (g_array_index (uints, guint, 0) == 30); + g_array_free (uints, TRUE); + g_ptr_array_free (out_array, TRUE); + } + + { + guint val; + char *ret_path; + DBusGProxy *ret_proxy; + + g_print ("Calling (wrapped) objpath\n"); + if (!dbus_g_proxy_call (proxy, "Objpath", &error, + DBUS_TYPE_G_PROXY, proxy, G_TYPE_INVALID, + DBUS_TYPE_G_PROXY, &ret_proxy, G_TYPE_INVALID)) + lose_gerror ("Failed to complete Objpath call", error); + if (strcmp ("/org/freedesktop/DBus/GLib/Tests/MyTestObject2", + dbus_g_proxy_get_path (ret_proxy)) != 0) + lose ("(wrapped) objpath call returned unexpected proxy %s", + dbus_g_proxy_get_path (ret_proxy)); + + g_print ("Doing get/increment val tests\n"); + val = 1; + if (!org_freedesktop_DBus_GLib_Tests_MyObject_get_val (ret_proxy, &val, &error)) + lose_gerror ("Failed to complete (wrapped) GetVal call", error); + if (val != 0) + lose ("(wrapped) GetVal returned invalid value %d", val); + + if (!org_freedesktop_DBus_GLib_Tests_MyObject_increment_val (ret_proxy, &error)) + lose_gerror ("Failed to complete (wrapped) IncrementVal call", error); + + if (!org_freedesktop_DBus_GLib_Tests_MyObject_increment_val (ret_proxy, &error)) + lose_gerror ("Failed to complete (wrapped) IncrementVal call", error); + + if (!org_freedesktop_DBus_GLib_Tests_MyObject_increment_val (ret_proxy, &error)) + lose_gerror ("Failed to complete (wrapped) IncrementVal call", error); + + if (!org_freedesktop_DBus_GLib_Tests_MyObject_get_val (ret_proxy, &val, &error)) + lose_gerror ("Failed to complete (wrapped) GetVal call", error); + if (val != 3) + lose ("(wrapped) GetVal returned invalid value %d", val); + + if (!org_freedesktop_DBus_GLib_Tests_MyObject_get_val (proxy, &val, &error)) + lose_gerror ("Failed to complete (wrapped) GetVal call", error); + if (val != 0) + lose ("(wrapped) GetVal returned invalid value %d", val); + + if (!org_freedesktop_DBus_GLib_Tests_MyObject_increment_val (proxy, &error)) + lose_gerror ("Failed to complete (wrapped) IncrementVal call", error); + + if (!org_freedesktop_DBus_GLib_Tests_MyObject_get_val (proxy, &val, &error)) + lose_gerror ("Failed to complete (wrapped) GetVal call", error); + if (val != 1) + lose ("(wrapped) GetVal returned invalid value %d", val); + + if (!org_freedesktop_DBus_GLib_Tests_MyObject_get_val (ret_proxy, &val, &error)) + lose_gerror ("Failed to complete (wrapped) GetVal call", error); + if (val != 3) + lose ("(wrapped) GetVal returned invalid value %d", val); + + g_object_unref (G_OBJECT (ret_proxy)); + + g_print ("Calling objpath again\n"); + ret_proxy = NULL; + + if (!dbus_g_proxy_call (proxy, "Objpath", &error, + DBUS_TYPE_G_OBJECT_PATH, + dbus_g_proxy_get_path (proxy), + G_TYPE_INVALID, + DBUS_TYPE_G_OBJECT_PATH, + &ret_path, + G_TYPE_INVALID)) + lose_gerror ("Failed to complete Objpath call 2", error); + if (strcmp ("/org/freedesktop/DBus/GLib/Tests/MyTestObject2", ret_path) != 0) + lose ("Objpath call 2 returned unexpected path %s", + ret_path); + + ret_proxy = dbus_g_proxy_new_for_name_owner (connection, + "org.freedesktop.DBus.GLib.TestService", + ret_path, + "org.freedesktop.DBus.GLib.Tests.FooObject", + &error); + g_free (ret_path); + + val = 0; + if (!org_freedesktop_DBus_GLib_Tests_FooObject_get_value (ret_proxy, &val, &error)) + lose_gerror ("Failed to complete (wrapped) GetValue call", error); + if (val != 3) + lose ("(wrapped) GetValue returned invalid value %d", val); + } + + run_mainloop (); + + { + GPtrArray *objs; + guint i; + + g_print ("Calling GetObjs\n"); + + if (!dbus_g_proxy_call (proxy, "GetObjs", &error, G_TYPE_INVALID, + dbus_g_type_get_collection ("GPtrArray", DBUS_TYPE_G_OBJECT_PATH), + &objs, + G_TYPE_INVALID)) + lose_gerror ("Failed to complete GetObjs call", error); + if (objs->len != 2) + lose ("GetObjs call returned unexpected number of objects %d, expected 2", + objs->len); + + if (strcmp ("/org/freedesktop/DBus/GLib/Tests/MyTestObject", + g_ptr_array_index (objs, 0)) != 0) + lose ("GetObjs call returned unexpected path \"%s\" in position 0; expected /org/freedesktop/DBus/GLib/Tests/MyTestObject", (char*) g_ptr_array_index (objs, 0)); + + if (strcmp ("/org/freedesktop/DBus/GLib/Tests/MyTestObject2", + g_ptr_array_index (objs, 1)) != 0) + lose ("GetObjs call returned unexpected path \"%s\" in position 1; expected /org/freedesktop/DBus/GLib/Tests/MyTestObject2", (char*) g_ptr_array_index (objs, 1)); + + for (i = 0; i < objs->len; i++) + g_free (g_ptr_array_index (objs, i)); + g_ptr_array_free (objs, TRUE); + } + + { + GValue *variant; + GArray *array; + gint i; + + g_print ("Calling ProcessVariantOfArrayOfInts123\n"); + + array = g_array_sized_new (FALSE, FALSE, sizeof(gint), 3); + i = 1; + g_array_append_val (array, i); + i++; + g_array_append_val (array, i); + i++; + g_array_append_val (array, i); + + variant = g_new0 (GValue, 1); + g_value_init (variant, dbus_g_type_get_collection ("GArray", G_TYPE_INT)); + g_value_take_boxed (variant, array); + + if (!dbus_g_proxy_call (proxy, "ProcessVariantOfArrayOfInts123", &error, + G_TYPE_VALUE, variant, + G_TYPE_INVALID, + G_TYPE_INVALID)) + lose_gerror ("Failed to send a vairant of array of ints 1, 2 and 3!", error); + + g_value_unset (variant); + g_free (variant); + } + + for (i=0; i<3; i++) + { + gchar *val; + GHashTable *table; + GHashTable *subtable; + GHashTable *ret_table; + + table = g_hash_table_new_full (g_str_hash, g_str_equal, + (GDestroyNotify) (g_free), + (GDestroyNotify) (g_hash_table_destroy)); + + subtable = g_hash_table_new_full (g_str_hash, g_str_equal, + (GDestroyNotify) (g_free), + (GDestroyNotify) (g_free)); + g_hash_table_insert (subtable, g_strdup ("foo"), g_strdup("1")); + g_hash_table_insert (subtable, g_strdup ("bar"), g_strdup("2")); + g_hash_table_insert (subtable, g_strdup ("baz"), g_strdup("3")); + + g_hash_table_insert (table, g_strdup("dict1"), subtable); + + subtable = g_hash_table_new_full (g_str_hash, g_str_equal, + (GDestroyNotify) (g_free), + (GDestroyNotify) (g_free)); + g_hash_table_insert (subtable, g_strdup ("foo"), g_strdup("4")); + g_hash_table_insert (subtable, g_strdup ("bar"), g_strdup("5")); + g_hash_table_insert (subtable, g_strdup ("baz"), g_strdup("6")); + + g_hash_table_insert (table, g_strdup("dict2"), subtable); + + subtable = NULL; + + ret_table = NULL; + + g_print ("Calling DictOfDicts\n"); + if (!dbus_g_proxy_call (proxy, "DictOfDicts", &error, + dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, + dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, + G_TYPE_STRING)), table, + G_TYPE_INVALID, + dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, + dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, + G_TYPE_STRING)), &ret_table, + G_TYPE_INVALID)) + lose_gerror ("Failed to complete DictOfDicts call", error); + + g_assert (ret_table != NULL); + g_assert (g_hash_table_size (ret_table) == 2); + + subtable = g_hash_table_lookup (ret_table, "dict1"); + g_assert(subtable); + g_assert (g_hash_table_size (subtable) == 3); + + val = g_hash_table_lookup (subtable, "foo"); + g_assert (val != NULL); + g_assert (!strcmp ("dict1 1", val)); + + val = g_hash_table_lookup (subtable, "bar"); + g_assert (val != NULL); + g_assert (!strcmp ("dict1 2", val)); + + val = g_hash_table_lookup (subtable, "baz"); + g_assert (val != NULL); + g_assert (!strcmp ("dict1 3", val)); + + subtable = g_hash_table_lookup (ret_table, "dict2"); + g_assert(subtable); + g_assert (g_hash_table_size (subtable) == 3); + + val = g_hash_table_lookup (subtable, "foo"); + g_assert (val != NULL); + g_assert (!strcmp ("dict2 4", val)); + + val = g_hash_table_lookup (subtable, "bar"); + g_assert (val != NULL); + g_assert (!strcmp ("dict2 5", val)); + + val = g_hash_table_lookup (subtable, "baz"); + g_assert (val != NULL); + g_assert (!strcmp ("dict2 6", val)); + + g_hash_table_destroy (table); + g_hash_table_destroy (ret_table); + + g_mem_profile (); + } + + for (i=0; i<3; i++) + { + GHashTable *table; + GHashTable *ret_table = NULL; + const gchar *foo[] = { "foo", NULL }; + const gchar *bar[] = { "bar", "baz", NULL }; + const gchar **ret_foo = NULL, **ret_bar = NULL; + + table = g_hash_table_new (g_str_hash, g_str_equal); + g_hash_table_insert (table, "dub", foo); + g_hash_table_insert (table, "sox", bar); + + g_print ("Calling DictOfSigs\n"); + + if (!org_freedesktop_DBus_GLib_Tests_MyObject_dict_of_sigs (proxy, table, + &ret_table, &error)) + lose_gerror ("Failed to complete DictOfSigs call", error); + + if (ret_table == NULL) + lose ("DictOfSigs didn't return a hash table"); + + if (g_hash_table_size (ret_table) != 2) + lose ("DictOfSigs has too many entries"); + + ret_foo = g_hash_table_lookup (ret_table, "dub"); + ret_bar = g_hash_table_lookup (ret_table, "sox"); + + if (ret_foo == NULL || ret_bar == NULL) + lose ("DictOfSigs is missing entries"); + + if (ret_foo[0] == NULL || + ret_foo[1] != NULL || + strcmp (ret_foo[0], "foo") != 0) + lose ("DictOfSigs mangled foo"); + + if (ret_bar[0] == NULL || + ret_bar[1] == NULL || + ret_bar[2] != NULL || + strcmp (ret_bar[0], "bar") != 0 || + strcmp (ret_bar[1], "baz") != 0) + lose ("DictOfSigs mangled bar"); + + g_hash_table_destroy (table); + g_hash_table_destroy (ret_table); + + g_mem_profile (); + } + + for (i=0; i<3; i++) + { + GHashTable *table; + GHashTable *ret_table = NULL; + GPtrArray *foo, *bar; + GPtrArray *ret_foo = NULL, *ret_bar = NULL; + + foo = g_ptr_array_new (); + g_ptr_array_add (foo, "/foo"); + + bar = g_ptr_array_new (); + g_ptr_array_add (bar, "/bar"); + g_ptr_array_add (bar, "/baz"); + + table = g_hash_table_new (g_str_hash, g_str_equal); + g_hash_table_insert (table, "/foo", foo); + g_hash_table_insert (table, "/bar", bar); + + g_print ("Calling DictOfObjs\n"); + + if (!org_freedesktop_DBus_GLib_Tests_MyObject_dict_of_objs (proxy, table, + &ret_table, &error)) + lose_gerror ("Failed to complete DictOfObjs call", error); + + g_ptr_array_free (foo, TRUE); + g_ptr_array_free (bar, TRUE); + g_hash_table_destroy (table); + + if (ret_table == NULL) + lose ("DictOfObjs didn't return a hash table"); + + if (g_hash_table_size (ret_table) != 2) + lose ("DictOfObjs has too many entries"); + + ret_foo = g_hash_table_lookup (ret_table, "/foo"); + ret_bar = g_hash_table_lookup (ret_table, "/bar"); + + if (ret_foo == NULL || ret_bar == NULL) + lose ("DictOfObjs is missing entries"); + + if (ret_foo->len != 1 || + strcmp (g_ptr_array_index (ret_foo, 0), "/foo") != 0) + lose ("DictOfObjs mangled /foo"); + + if (ret_bar->len != 2 || + strcmp (g_ptr_array_index (ret_bar, 0), "/bar") != 0 || + strcmp (g_ptr_array_index (ret_bar, 1), "/baz") != 0) + lose ("DictOfObjs mangled /bar"); + + g_boxed_free (dbus_g_type_get_map ("GHashTable", DBUS_TYPE_G_OBJECT_PATH, + dbus_g_type_get_collection ("GPtrArray", DBUS_TYPE_G_OBJECT_PATH)), ret_table); + + g_mem_profile (); + } + + + + /* Signal handling tests */ + + g_print ("Testing signal handling\n"); + dbus_g_proxy_add_signal (proxy, "Frobnicate", G_TYPE_INT, G_TYPE_INVALID); + + dbus_g_proxy_connect_signal (proxy, "Frobnicate", + G_CALLBACK (frobnicate_signal_handler), + NULL, NULL); + + g_print ("Calling EmitFrobnicate\n"); + if (!dbus_g_proxy_call (proxy, "EmitFrobnicate", &error, + G_TYPE_INVALID, G_TYPE_INVALID)) + lose_gerror ("Failed to complete EmitFrobnicate call", error); + + + dbus_g_connection_flush (connection); + exit_timeout = g_timeout_add (5000, timed_exit, loop); + g_main_loop_run (loop); + + if (n_times_frobnicate_received != 1) + lose ("Frobnicate signal received %d times, should have been 1", n_times_frobnicate_received); + + g_print ("Calling EmitFrobnicate again\n"); + if (!dbus_g_proxy_call (proxy, "EmitFrobnicate", &error, + G_TYPE_INVALID, G_TYPE_INVALID)) + lose_gerror ("Failed to complete EmitFrobnicate call", error); + + dbus_g_connection_flush (connection); + exit_timeout = g_timeout_add (5000, timed_exit, loop); + g_main_loop_run (loop); + + if (n_times_frobnicate_received != 2) + lose ("Frobnicate signal received %d times, should have been 2", n_times_frobnicate_received); + + g_object_unref (G_OBJECT (proxy)); + + run_mainloop (); + + g_print ("Creating proxy for FooObject interface\n"); + proxy = dbus_g_proxy_new_for_name_owner (connection, + "org.freedesktop.DBus.GLib.TestService", + "/org/freedesktop/DBus/GLib/Tests/MyTestObject", + "org.freedesktop.DBus.GLib.Tests.FooObject", + &error); + + if (proxy == NULL) + lose_gerror ("Failed to create proxy for name owner", error); + + my_object_register_marshallers (); + + dbus_g_proxy_add_signal (proxy, "Sig0", G_TYPE_STRING, G_TYPE_INT, G_TYPE_STRING, G_TYPE_INVALID); + dbus_g_proxy_add_signal (proxy, "Sig1", G_TYPE_STRING, G_TYPE_VALUE, G_TYPE_INVALID); + dbus_g_proxy_add_signal (proxy, "Sig2", DBUS_TYPE_G_STRING_STRING_HASHTABLE, G_TYPE_INVALID); + + dbus_g_proxy_connect_signal (proxy, "Sig0", + G_CALLBACK (sig0_signal_handler), + NULL, NULL); + dbus_g_proxy_connect_signal (proxy, "Sig1", + G_CALLBACK (sig1_signal_handler), + NULL, NULL); + dbus_g_proxy_connect_signal (proxy, "Sig2", + G_CALLBACK (sig2_signal_handler), + NULL, NULL); + + g_print ("Calling FooObject EmitSignals\n"); + dbus_g_proxy_call_no_reply (proxy, "EmitSignals", G_TYPE_INVALID); + + dbus_g_connection_flush (connection); + exit_timeout = g_timeout_add (5000, timed_exit, loop); + g_main_loop_run (loop); + exit_timeout = g_timeout_add (5000, timed_exit, loop); + g_main_loop_run (loop); + + if (n_times_sig0_received != 1) + lose ("Sig0 signal received %d times, should have been 1", n_times_sig0_received); + if (n_times_sig1_received != 1) + lose ("Sig1 signal received %d times, should have been 1", n_times_sig1_received); + + g_print ("Calling FooObject EmitSignals and EmitSignal2\n"); + dbus_g_proxy_call_no_reply (proxy, "EmitSignal2", G_TYPE_INVALID); + dbus_g_connection_flush (connection); + + exit_timeout = g_timeout_add (5000, timed_exit, loop); + g_main_loop_run (loop); + + if (n_times_sig2_received != 1) + lose ("Sig2 signal received %d times, should have been 1", n_times_sig2_received); + + g_print ("Calling FooObject EmitSignals two more times\n"); + dbus_g_proxy_call_no_reply (proxy, "EmitSignals", G_TYPE_INVALID); + dbus_g_proxy_call_no_reply (proxy, "EmitSignals", G_TYPE_INVALID); + + dbus_g_connection_flush (connection); + exit_timeout = g_timeout_add (5000, timed_exit, loop); + g_main_loop_run (loop); + exit_timeout = g_timeout_add (5000, timed_exit, loop); + g_main_loop_run (loop); + exit_timeout = g_timeout_add (5000, timed_exit, loop); + g_main_loop_run (loop); + exit_timeout = g_timeout_add (5000, timed_exit, loop); + g_main_loop_run (loop); + + if (n_times_sig0_received != 3) + lose ("Sig0 signal received %d times, should have been 3", n_times_sig0_received); + if (n_times_sig1_received != 3) + lose ("Sig1 signal received %d times, should have been 3", n_times_sig1_received); + + /* Terminate again */ + g_print ("Terminating service\n"); + await_terminating_service = "org.freedesktop.DBus.GLib.TestService"; + dbus_g_proxy_call_no_reply (proxy, "Terminate", G_TYPE_INVALID); + + proxy_destroyed = FALSE; + proxy_destroy_and_nameowner = TRUE; + proxy_destroy_and_nameowner_complete = FALSE; + + g_signal_connect (G_OBJECT (proxy), + "destroy", + G_CALLBACK (proxy_destroyed_cb), + NULL); + + dbus_g_connection_flush (connection); + exit_timeout = g_timeout_add (5000, timed_exit, loop); + g_main_loop_run (loop); + + if (await_terminating_service != NULL) + lose ("Didn't see name loss for \"org.freedesktop.DBus.GLib.TestService\""); + if (!proxy_destroyed) + lose ("Didn't get proxy_destroyed"); + g_print ("Proxy destroyed successfully\n"); + + /* Don't need to unref, proxy was destroyed */ + + run_mainloop (); + + /* Create a new proxy for the name; should not be associated */ + proxy = dbus_g_proxy_new_for_name (connection, + "org.freedesktop.DBus.GLib.TestService", + "/org/freedesktop/DBus/GLib/Tests/MyTestObject", + "org.freedesktop.DBus.GLib.Tests.MyObject"); + g_assert (proxy != NULL); + + proxy_destroyed = FALSE; + proxy_destroy_and_nameowner = FALSE; + proxy_destroy_and_nameowner_complete = FALSE; + + g_signal_connect (G_OBJECT (proxy), + "destroy", + G_CALLBACK (proxy_destroyed_cb), + NULL); + + if (!dbus_g_proxy_call (driver, "GetNameOwner", &error, + G_TYPE_STRING, + "org.freedesktop.DBus.GLib.TestService", + G_TYPE_INVALID, + G_TYPE_STRING, + &v_STRING_2, + G_TYPE_INVALID)) { + if (error->domain == DBUS_GERROR && error->code == DBUS_GERROR_NAME_HAS_NO_OWNER) + g_print ("Got expected error \"org.freedesktop.DBus.Error.NameHasNoOwner\"\n"); + else + lose_gerror ("Unexpected error from GetNameOwner", error); + } else + lose ("GetNameOwner unexpectedly succeeded!"); + g_clear_error (&error); + + /* This will have the side-effect of activating the service, thus + * causing a NameOwnerChanged, which should let our name proxy + * get signals + */ + g_print ("Calling Uppercase for name proxy\n"); + if (!dbus_g_proxy_call (proxy, "Uppercase", &error, + G_TYPE_STRING, "bazwhee", + G_TYPE_INVALID, + G_TYPE_STRING, &v_STRING_2, + G_TYPE_INVALID)) + lose_gerror ("Failed to complete Uppercase call", error); + g_free (v_STRING_2); + + if (getenv ("DBUS_GLIB_TEST_SLEEP_AFTER_ACTIVATION1")) + g_usleep (8 * G_USEC_PER_SEC); + + dbus_g_proxy_add_signal (proxy, "Frobnicate", G_TYPE_INT, G_TYPE_INVALID); + + dbus_g_proxy_connect_signal (proxy, "Frobnicate", + G_CALLBACK (frobnicate_signal_handler), + NULL, NULL); + + g_print ("Calling EmitFrobnicate\n"); + if (!dbus_g_proxy_call (proxy, "EmitFrobnicate", &error, + G_TYPE_INVALID, G_TYPE_INVALID)) + lose_gerror ("Failed to complete EmitFrobnicate call", error); + + n_times_frobnicate_received = 0; + + dbus_g_connection_flush (connection); + exit_timeout = g_timeout_add (5000, timed_exit, loop); + g_main_loop_run (loop); + + if (n_times_frobnicate_received != 1) + lose ("Frobnicate signal received %d times, should have been 1", n_times_frobnicate_received); + + /* Now terminate the service, then start it again (implicitly) and wait for signals */ + g_print ("Terminating service (2)\n"); + await_terminating_service = "org.freedesktop.DBus.GLib.TestService"; + dbus_g_proxy_call_no_reply (proxy, "Terminate", G_TYPE_INVALID); + dbus_g_connection_flush (connection); + exit_timeout = g_timeout_add (5000, timed_exit, loop); + g_main_loop_run (loop); + if (await_terminating_service != NULL) + lose ("Didn't see name loss for \"org.freedesktop.DBus.GLib.TestService\""); + + if (proxy_destroyed) + lose ("Unexpectedly got proxy_destroyed!"); + + n_times_frobnicate_received = 0; + + g_print ("Calling EmitFrobnicate (2)\n"); + if (!dbus_g_proxy_call (proxy, "EmitFrobnicate", &error, + G_TYPE_INVALID, G_TYPE_INVALID)) + lose_gerror ("Failed to complete EmitFrobnicate call", error); + + if (getenv ("DBUS_GLIB_TEST_SLEEP_AFTER_ACTIVATION2")) + g_usleep (8 * G_USEC_PER_SEC); + + dbus_g_connection_flush (connection); + exit_timeout = g_timeout_add (5000, timed_exit, loop); + g_main_loop_run (loop); + + if (n_times_frobnicate_received != 1) + lose ("Frobnicate signal received %d times, should have been 1", n_times_frobnicate_received); + + if (proxy_destroyed) + lose ("Unexpectedly got proxy_destroyed!"); + + /* Create another proxy for the name; should be associated immediately */ + proxy2 = dbus_g_proxy_new_for_name (connection, + "org.freedesktop.DBus.GLib.TestService", + "/org/freedesktop/DBus/GLib/Tests/MyTestObject", + "org.freedesktop.DBus.GLib.Tests.MyObject"); + g_assert (proxy2 != NULL); + + dbus_g_proxy_add_signal (proxy2, "Frobnicate", G_TYPE_INT, G_TYPE_INVALID); + + dbus_g_proxy_connect_signal (proxy2, "Frobnicate", + G_CALLBACK (frobnicate_signal_handler_2), + NULL, NULL); + + g_print ("Calling EmitFrobnicate (3)\n"); + if (!dbus_g_proxy_call (proxy, "EmitFrobnicate", &error, + G_TYPE_INVALID, G_TYPE_INVALID)) + lose_gerror ("Failed to complete EmitFrobnicate call", error); + + dbus_g_connection_flush (connection); + exit_timeout = g_timeout_add (5000, timed_exit, loop); + g_main_loop_run (loop); + + if (n_times_frobnicate_received != 2) + lose ("Frobnicate signal received %d times for 1st proxy, should have been 2", n_times_frobnicate_received); + if (n_times_frobnicate_received_2 != 1) + lose ("Frobnicate signal received %d times for 2nd proxy, should have been 1", n_times_frobnicate_received_2); + + g_object_unref (G_OBJECT (proxy)); + g_object_unref (G_OBJECT (proxy2)); + + run_mainloop (); + + /* Tests for a "compatibilty" object path. This is the same object as above, just + * at a different path. + */ + proxy = dbus_g_proxy_new_for_name_owner (connection, + "org.freedesktop.DBus.GLib.TestService", + "/org/freedesktop/DBus/GLib/Tests/Compat/MyTestObjectCompat", + "org.freedesktop.DBus.GLib.Tests.MyObject", + &error); + dbus_g_proxy_add_signal (proxy, "Frobnicate", G_TYPE_INT, G_TYPE_INVALID); + + dbus_g_proxy_connect_signal (proxy, "Frobnicate", + G_CALLBACK (frobnicate_signal_handler_compat), + NULL, NULL); + + g_print ("Calling EmitFrobnicate (compat)\n"); + if (!dbus_g_proxy_call (proxy, "EmitFrobnicate", &error, + G_TYPE_INVALID, G_TYPE_INVALID)) + lose_gerror ("Failed to complete EmitFrobnicate call on compat proxy", error); + + g_main_loop_run (loop); + + if (n_times_compat_frobnicate_received != 1) + lose ("Frobnicate signal received %d times for compat proxy, should have been 1", n_times_compat_frobnicate_received); + + g_object_unref (proxy); + + /* Test introspection */ + proxy = dbus_g_proxy_new_for_name_owner (connection, + "org.freedesktop.DBus.GLib.TestService", + "/org/freedesktop/DBus/GLib/Tests/MyTestObject", + "org.freedesktop.DBus.Introspectable", + &error); + if (proxy == NULL) + lose_gerror ("Failed to create proxy for name owner", error); + + g_print ("Testing introspect\n"); + if (!dbus_g_proxy_call (proxy, "Introspect", &error, + G_TYPE_INVALID, + G_TYPE_STRING, &v_STRING_2, + G_TYPE_INVALID)) + lose_gerror ("Failed to complete Introspect call", error); + + /* Could just do strcmp(), but that seems more fragile */ + { + NodeInfo *node; + GSList *elt; + gboolean found_introspectable; + gboolean found_properties; + gboolean found_myobject; + gboolean found_fooobject; + + node = description_load_from_string (v_STRING_2, strlen (v_STRING_2), &error); + if (!node) + lose_gerror ("Failed to parse introspection data: %s", error); + + found_introspectable = FALSE; + found_properties = FALSE; + found_myobject = FALSE; + found_fooobject = FALSE; + for (elt = node_info_get_interfaces (node); elt ; elt = elt->next) + { + InterfaceInfo *iface = elt->data; + + if (!found_introspectable && strcmp (interface_info_get_name (iface), "org.freedesktop.DBus.Introspectable") == 0) + found_introspectable = TRUE; + else if (!found_properties && strcmp (interface_info_get_name (iface), "org.freedesktop.DBus.Properties") == 0) + found_properties = TRUE; + else if (!found_myobject && strcmp (interface_info_get_name (iface), "org.freedesktop.DBus.GLib.Tests.MyObject") == 0) + { + GSList *elt; + gboolean found_manyargs; + gboolean found_no_touching = FALSE; + + found_myobject = TRUE; + + found_manyargs = FALSE; + for (elt = interface_info_get_methods (iface); elt; elt = elt->next) + { + MethodInfo *method; + + method = elt->data; + if (strcmp (method_info_get_name (method), "ManyArgs") == 0) + { + found_manyargs = TRUE; + break; + } + } + if (!found_manyargs) + lose ("Missing method org.freedesktop.DBus.GLib.Tests.MyObject.ManyArgs"); + for (elt = interface_info_get_properties (iface); elt; elt = elt->next) + { + PropertyInfo *prop = elt->data; + + if (strcmp (property_info_get_name (prop), "no-touching") == 0) + { + if (property_info_get_access (prop) != PROPERTY_READ) + lose ("property no-touching had incorrect access %d", property_info_get_access (prop)); + else + { + found_no_touching = TRUE; + break; + } + } + } + if (!found_no_touching) + lose ("didn't find property \"no-touching\" in org.freedesktop.DBus.GLib.Tests.MyObject"); + } + else if (!found_fooobject && strcmp (interface_info_get_name (iface), "org.freedesktop.DBus.GLib.Tests.FooObject") == 0) + found_fooobject = TRUE; + else + lose ("Unexpected or duplicate interface %s", interface_info_get_name (iface)); + } + + if (!(found_introspectable && found_myobject && found_properties)) + lose ("Missing interface"); + g_free (node); + } + g_free (v_STRING_2); + + /* Properties tests */ + property_proxy = dbus_g_proxy_new_from_proxy (proxy, DBUS_INTERFACE_PROPERTIES, NULL); + g_object_unref (proxy); + proxy = NULL; + + g_print ("Calling GetProperty (1)\n"); + { + GValue value = {0,}; + if (!dbus_g_proxy_call (property_proxy, "Get", &error, + G_TYPE_STRING, "org.freedesktop.DBus.GLib.Tests.MyObject", + G_TYPE_STRING, "this_is_a_string", + G_TYPE_INVALID, + G_TYPE_VALUE, &value, G_TYPE_INVALID)) + lose_gerror ("Failed to complete GetProperty call", error); + g_assert (G_VALUE_HOLDS (&value, G_TYPE_STRING)); + g_assert (!strcmp (g_value_get_string (&value), "")); + g_value_unset (&value); + } + + g_print ("Calling SetProperty (1)\n"); + { + GValue value = {0,}; + g_value_init (&value, G_TYPE_STRING); + g_value_set_string (&value, "testing value"); + if (!dbus_g_proxy_call (property_proxy, "Set", &error, + G_TYPE_STRING, "org.freedesktop.DBus.GLib.Tests.MyObject", + G_TYPE_STRING, "this_is_a_string", + G_TYPE_VALUE, &value, G_TYPE_INVALID, G_TYPE_INVALID)) + lose_gerror ("Failed to complete SetProperty call", error); + g_value_unset (&value); + } + + g_print ("Calling GetProperty of read-only property\n"); + { + GValue value = {0,}; + if (!dbus_g_proxy_call (property_proxy, "Get", &error, + G_TYPE_STRING, "org.freedesktop.DBus.GLib.Tests.MyObject", + G_TYPE_STRING, "no-touching", + G_TYPE_INVALID, + G_TYPE_VALUE, &value, G_TYPE_INVALID)) + lose_gerror ("Failed to complete GetProperty no-touching call", error); + g_assert (G_VALUE_HOLDS (&value, G_TYPE_UINT)); + g_assert (g_value_get_uint (&value) == 42); + g_value_unset (&value); + } + + g_print ("Calling SetProperty (1)\n"); + { + GValue value = {0,}; + g_value_init (&value, G_TYPE_UINT); + g_value_set_uint (&value, 40); + if (dbus_g_proxy_call (property_proxy, "Set", &error, + G_TYPE_STRING, "org.freedesktop.DBus.GLib.Tests.MyObject", + G_TYPE_STRING, "no-touching", + G_TYPE_VALUE, &value, G_TYPE_INVALID, G_TYPE_INVALID)) + lose ("Unexpected success from SetProperty call for read-only value \"no-touching\""); + g_clear_error (&error); + g_value_unset (&value); + } + + g_print ("Calling GetProperty of read-only property (again)\n"); + { + GValue value = {0,}; + if (!dbus_g_proxy_call (property_proxy, "Get", &error, + G_TYPE_STRING, "org.freedesktop.DBus.GLib.Tests.MyObject", + G_TYPE_STRING, "no-touching", + G_TYPE_INVALID, + G_TYPE_VALUE, &value, G_TYPE_INVALID)) + lose_gerror ("Failed to complete GetProperty call", error); + g_assert (G_VALUE_HOLDS (&value, G_TYPE_UINT)); + g_assert (g_value_get_uint (&value) == 42); + g_value_unset (&value); + } + + g_print ("Calling GetProperty (2)\n"); + { + GValue value = {0,}; + if (!dbus_g_proxy_call (property_proxy, "Get", &error, + G_TYPE_STRING, "org.freedesktop.DBus.GLib.Tests.MyObject", + G_TYPE_STRING, "this_is_a_string", + G_TYPE_INVALID, + G_TYPE_VALUE, &value, G_TYPE_INVALID)) + lose_gerror ("Failed to complete GetProperty call", error); + g_assert (G_VALUE_HOLDS (&value, G_TYPE_STRING)); + g_assert (!strcmp (g_value_get_string (&value), "testing value")); + g_value_unset (&value); + } + + g_print ("Calling GetProperty: SuperStudly\n"); + { + GValue value = {0,}; + if (!dbus_g_proxy_call (property_proxy, "Get", &error, + G_TYPE_STRING, "org.freedesktop.DBus.GLib.Tests.MyObject", + G_TYPE_STRING, "SuperStudly", + G_TYPE_INVALID, + G_TYPE_VALUE, &value, G_TYPE_INVALID)) + lose_gerror ("Failed to complete GetProperty call", error); + g_assert (G_VALUE_HOLDS (&value, G_TYPE_DOUBLE)); + g_value_unset (&value); + } + + g_print ("Calling GetProperty: super-studly\n"); + { + GValue value = {0,}; + if (!dbus_g_proxy_call (property_proxy, "Get", &error, + G_TYPE_STRING, "org.freedesktop.DBus.GLib.Tests.MyObject", + G_TYPE_STRING, "super-studly", + G_TYPE_INVALID, + G_TYPE_VALUE, &value, G_TYPE_INVALID)) + lose_gerror ("Failed to complete GetProperty call", error); + g_assert (G_VALUE_HOLDS (&value, G_TYPE_DOUBLE)); + g_value_unset (&value); + } + + g_print ("Calling GetProperty: super_studly\n"); + { + GValue value = {0,}; + if (!dbus_g_proxy_call (property_proxy, "Get", &error, + G_TYPE_STRING, "org.freedesktop.DBus.GLib.Tests.MyObject", + G_TYPE_STRING, "super_studly", + G_TYPE_INVALID, + G_TYPE_VALUE, &value, G_TYPE_INVALID)) + lose_gerror ("Failed to complete GetProperty call", error); + g_assert (G_VALUE_HOLDS (&value, G_TYPE_DOUBLE)); + g_value_unset (&value); + } + + g_print ("Calling GetProperty on unknown property\n"); + { + GValue value = {0,}; + if (dbus_g_proxy_call (property_proxy, "Get", &error, + G_TYPE_STRING, "org.freedesktop.DBus.GLib.Tests.MyObject", + G_TYPE_STRING, "SomeUnknownProperty", + G_TYPE_INVALID, + G_TYPE_VALUE, &value, G_TYPE_INVALID)) + lose ("Unexpected success for GetProperty call of unknown property"); + + g_clear_error (&error); + } + + /* These two are expected to pass unless we call disable_legacy_property_access */ + + g_print ("Calling GetProperty on not-exported property (legacy enabled)\n"); + { + GValue value = {0,}; + if (!dbus_g_proxy_call (property_proxy, "Get", &error, + G_TYPE_STRING, "org.freedesktop.DBus.GLib.Tests.MyObject", + G_TYPE_STRING, "should-be-hidden", + G_TYPE_INVALID, + G_TYPE_VALUE, &value, G_TYPE_INVALID)) + lose_gerror ("Failed GetProperty call of \"should-be-hidden\" property", error); + g_assert (G_VALUE_HOLDS_BOOLEAN (&value)); + g_assert (g_value_get_boolean (&value) == FALSE); + g_value_unset (&value); + } + + g_print ("Calling GetProperty on not-exported property (legacy enabled)\n"); + { + GValue value = {0,}; + if (!dbus_g_proxy_call (property_proxy, "Get", &error, + G_TYPE_STRING, "org.freedesktop.DBus.GLib.Tests.MyObject", + G_TYPE_STRING, "ShouldBeHidden", + G_TYPE_INVALID, + G_TYPE_VALUE, &value, G_TYPE_INVALID)) + lose_gerror ("Failed GetProperty call of \"ShouldBeHidden\" property", error); + + g_value_unset (&value); + } + + g_print ("Calling SetProperty on not-exported property (legacy enabled)\n"); + { + GValue value = {0,}; + g_value_init (&value, G_TYPE_BOOLEAN); + g_value_set_boolean (&value, TRUE); + if (dbus_g_proxy_call (property_proxy, "Set", &error, + G_TYPE_STRING, "org.freedesktop.DBus.GLib.Tests.MyObject", + G_TYPE_STRING, "should-be-hidden", + G_TYPE_VALUE, &value, + G_TYPE_INVALID, G_TYPE_INVALID)) + lose ("Unexpected success from SetProperty call of \"should-be-hidden\" property"); + g_value_unset (&value); + g_clear_error (&error); + } + + g_print ("Calling GetProperty on not-exported property (legacy enabled)\n"); + { + GValue value = {0,}; + if (!dbus_g_proxy_call (property_proxy, "Get", &error, + G_TYPE_STRING, "org.freedesktop.DBus.GLib.Tests.MyObject", + G_TYPE_STRING, "should-be-hidden", + G_TYPE_INVALID, + G_TYPE_VALUE, &value, G_TYPE_INVALID)) + lose_gerror ("Failed GetProperty call of \"should-be-hidden\" property", error); + g_assert (G_VALUE_HOLDS_BOOLEAN (&value)); + g_assert (g_value_get_boolean (&value) == FALSE); + g_value_unset (&value); + } + + /* Test GetAll */ + /* 'testing value' set earlier by the SetProperty tests */ + test_base_class_get_all (connection, + "/org/freedesktop/DBus/GLib/Tests/MyTestObject", + "testing value"); + + /* "" is base class default for this_is_a_string property since the + * property isn't marked with G_PARAM_CONSTRUT. + */ + test_base_class_get_all (connection, + "/org/freedesktop/DBus/GLib/Tests/MyTestObjectSubclass", + ""); + + /* Finally test GetAll of a subclass on a different interface to ensure that + * the right properties are returned (fdo #19145) + */ + test_subclass_get_all (connection, "/org/freedesktop/DBus/GLib/Tests/MyTestObjectSubclass"); + + /* Now, call disable_legacy_property_access */ + + g_assert (proxy == NULL); + proxy = dbus_g_proxy_new_for_name_owner (connection, + "org.freedesktop.DBus.GLib.TestService", + "/org/freedesktop/DBus/GLib/Tests/MyTestObject", + "org.freedesktop.DBus.GLib.Tests.MyObject", + &error); + + if (!dbus_g_proxy_call (proxy, "UnsafeDisableLegacyPropertyAccess", &error, + G_TYPE_INVALID, G_TYPE_INVALID)) + lose_gerror ("Failed to invoke UnsafeDisableLegacyPropertyAccess", error); + + g_object_unref (proxy); + proxy = NULL; + + g_print ("Calling GetProperty on not-exported property (legacy *disabled*)\n"); + { + GValue value = {0,}; + if (dbus_g_proxy_call (property_proxy, "Get", &error, + G_TYPE_STRING, "org.freedesktop.DBus.GLib.Tests.MyObject", + G_TYPE_STRING, "should-be-hidden", + G_TYPE_INVALID, + G_TYPE_VALUE, &value, G_TYPE_INVALID)) + lose ("Unexpected success from GetProperty call of \"should-be-hidden\" property"); + g_clear_error (&error); + } + + g_print ("Calling GetProperty on not-exported property (legacy *disabled*)\n"); + { + GValue value = {0,}; + if (dbus_g_proxy_call (property_proxy, "Get", &error, + G_TYPE_STRING, "org.freedesktop.DBus.GLib.Tests.MyObject", + G_TYPE_STRING, "ShouldBeHidden", + G_TYPE_INVALID, + G_TYPE_VALUE, &value, G_TYPE_INVALID)) + lose ("Unexpected success from GetProperty call of \"ShouldBeHidden\" property"); + g_clear_error (&error); + } + + g_print ("Calling SetProperty on not-exported property (legacy *disabled*)\n"); + { + GValue value = {0,}; + g_value_init (&value, G_TYPE_BOOLEAN); + g_value_set_boolean (&value, FALSE); + if (dbus_g_proxy_call (property_proxy, "Set", &error, + G_TYPE_STRING, "org.freedesktop.DBus.GLib.Tests.MyObject", + G_TYPE_STRING, "should-be-hidden", + G_TYPE_VALUE, &value, + G_TYPE_INVALID, G_TYPE_INVALID)) + lose ("Unexpected success from SetProperty call of \"should-be-hidden\" property"); + g_value_unset (&value); + g_clear_error (&error); + } + + g_object_unref (property_proxy); + property_proxy = NULL; + + test_terminate_proxy1 = dbus_g_proxy_new_for_name_owner (connection, + "org.freedesktop.DBus.GLib.TestService", + "/org/freedesktop/DBus/GLib/Tests/MyTestObject", + "org.freedesktop.DBus.GLib.Tests.MyObject", + &error); + + if (test_terminate_proxy1 == NULL) + lose_gerror ("Failed to create proxy for name owner", error); + + test_terminate_proxy2 = dbus_g_proxy_new_for_name_owner (connection, + "org.freedesktop.DBus.GLib.TestService", + "/org/freedesktop/DBus/GLib/Tests/MyTestObject", + "org.freedesktop.DBus.GLib.Tests.MyObject", + &error); + + if (test_terminate_proxy2 == NULL) + lose_gerror ("Failed to create proxy for name owner", error); + + g_print ("Testing duplicate proxy destruction\n"); + await_terminating_service = "org.freedesktop.DBus.GLib.TestService"; + dbus_g_proxy_call_no_reply (test_terminate_proxy1, "Terminate", G_TYPE_INVALID); + + proxy_destroyed = FALSE; + proxy_destroy_and_nameowner = TRUE; + proxy_destroy_and_nameowner_complete = FALSE; + + g_signal_connect (G_OBJECT (test_terminate_proxy1), + "destroy", + G_CALLBACK (test_terminate_proxy1_destroyed_cb), + NULL); + + dbus_g_connection_flush (connection); + exit_timeout = g_timeout_add (5000, timed_exit, loop); + g_main_loop_run (loop); + + if (await_terminating_service != NULL) + lose ("Didn't see name loss for \"org.freedesktop.DBus.GLib.TestService\""); + if (!proxy_destroyed) + lose ("Didn't get proxy_destroyed"); + if (test_terminate_proxy2) + lose ("Duplicate proxy wasn'tdestroyed"); + + g_print ("Proxy and duplicate destroyed successfully\n"); + + g_print ("Beginning private connection tests\n"); + + { + DBusGConnection *privconn = dbus_g_bus_get_private (DBUS_BUS_SESSION, NULL, &error); + + if (privconn == NULL) + lose_gerror ("Failed to open private connection to bus", error); + g_assert (privconn != connection); + + proxy = dbus_g_proxy_new_for_name (privconn, + "org.freedesktop.DBus.GLib.TestService", + "/org/freedesktop/DBus/GLib/Tests/MyTestObject", + "org.freedesktop.DBus.GLib.Tests.MyObject"); + + g_print ("[private connection] Calling (wrapped) do_nothing\n"); + if (!org_freedesktop_DBus_GLib_Tests_MyObject_do_nothing (proxy, &error)) + lose_gerror ("Failed to complete (wrapped) DoNothing call", error); + + g_object_unref (G_OBJECT (proxy)); + } + + g_object_unref (G_OBJECT (driver)); + + g_print ("Successfully completed %s\n", argv[0]); + + return 0; +} diff --git a/test/core/test-gvariant.c b/test/core/test-gvariant.c new file mode 100644 index 0000000..fc1406e --- /dev/null +++ b/test/core/test-gvariant.c @@ -0,0 +1,956 @@ +/* GVariant to dbus-glib escape hatch + * + * Copyright © 2010 Collabora Ltd. <http://www.collabora.co.uk/> + * + * 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. + * + * Alternatively, at your option, you can redistribute and/or modify + * this single file under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 of + * that 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 <dbus/dbus-glib.h> +#include <gio/gio.h> + +/** + * test_g_variant_equivalent: + * + * The function g_variant_equal() cannot be used for dictionaries because it + * cares about the ordering of dictionaries, which breaks our tests. + */ +static gboolean +test_g_variant_equivalent (GVariant *one, + GVariant *two) +{ + if (!g_variant_type_equal ( + g_variant_get_type (one), + g_variant_get_type (two))) + { + return FALSE; + } + else if (g_variant_is_of_type (one, G_VARIANT_TYPE_DICTIONARY) && + g_variant_is_of_type (two, G_VARIANT_TYPE_DICTIONARY)) + { + GHashTable *hash; + GVariantIter iter; + GVariant *child; + gboolean equal = TRUE; + + if (g_variant_n_children (one) != g_variant_n_children (two)) + return FALSE; + + /* pack @one into a hash table */ + hash = g_hash_table_new_full (g_variant_hash, g_variant_equal, + (GDestroyNotify) g_variant_unref, (GDestroyNotify) g_variant_unref); + + g_variant_iter_init (&iter, one); + while ((child = g_variant_iter_next_value (&iter))) + { + g_hash_table_insert (hash, + g_variant_get_child_value (child, 0), + g_variant_get_child_value (child, 1)); + g_variant_unref (child); + } + + /* now iterate @two to check for the keys in @hash */ + g_variant_iter_init (&iter, two); + while (equal && (child = g_variant_iter_next_value (&iter))) + { + GVariant *k, *v1, *v2; + + k = g_variant_get_child_value (child, 0); + v1 = g_variant_get_child_value (child, 1); + + v2 = g_hash_table_lookup (hash, k); + + if (v2 == NULL || !test_g_variant_equivalent (v1, v2)) + equal = FALSE; + else + g_hash_table_remove (hash, k); + + g_variant_unref (k); + g_variant_unref (v1); + g_variant_unref (child); + } + + if (g_hash_table_size (hash) > 0) + equal = FALSE; + + g_hash_table_destroy (hash); + + return equal; + } + else if (g_variant_is_container (one) && + g_variant_is_container (two)) + { + guint i, size; + gboolean equal = TRUE; + + if (g_variant_n_children (one) != g_variant_n_children (two)) + return FALSE; + + size = g_variant_n_children (one); + for (i = 0; equal && i < size; i++) + { + GVariant *child1, *child2; + + child1 = g_variant_get_child_value (one, i); + child2 = g_variant_get_child_value (two, i); + + equal = test_g_variant_equivalent (child1, child2); + + g_variant_unref (child1); + g_variant_unref (child2); + } + + return equal; + } + else + { + return g_variant_equal (one, two); + } +} + +#define assert_g_variant_equivalent(a,e) \ + assert_g_variant_equivalent_internal (__FILE__, __LINE__, \ + #a, a, #e, e) + +static void +assert_g_variant_equivalent_internal ( + const gchar *file, gint line, + const gchar *actual_name, GVariant *actual, + const gchar *expected_name, GVariant *expected); + +static void +assert_g_variant_equivalent_internal (const gchar *file, + gint line, + const gchar *actual_name, + GVariant *actual, + const gchar *expected_name, + GVariant *expected) +{ + if (!test_g_variant_equivalent (actual, expected)) + { + gchar *a = g_variant_print (actual, TRUE); + gchar *e = g_variant_print (expected, TRUE); + + g_error ("%s:%d: Variants should have been equal:\n" + "%s = %s\n" + "%s = %s", file, line, actual_name, a, expected_name, e); + /* no point in freeing the strings, we've just crashed anyway */ + } +} + +/* test_g_variant_equivalent tests */ +static void +test_simple_equiv (void) +{ + GVariant *v1, *v2; + + v1 = g_variant_new_int32 (1984); + v2 = g_variant_new_int32 (1984); + + g_assert (test_g_variant_equivalent (v1, v2)); + + g_variant_unref (v1); + g_variant_unref (v2); +} + +static void +test_simple_not_equiv (void) +{ + GVariant *v1, *v2; + + v1 = g_variant_new_int32 (1982); + v2 = g_variant_new_int32 (1984); + + g_assert (!test_g_variant_equivalent (v1, v2)); + + g_variant_unref (v1); + g_variant_unref (v2); +} + +static void +test_array_not_equiv (void) +{ + GVariantBuilder b; + GVariant *v1, *v2; + + g_variant_builder_init (&b, G_VARIANT_TYPE ("av")); + g_variant_builder_add (&b, "v", g_variant_new_int32 (1984)); + g_variant_builder_add (&b, "v", g_variant_new_string ("Orwell")); + g_variant_builder_add (&b, "v", g_variant_new_object_path ("/cats/escher")); + v1 = g_variant_builder_end (&b); + + g_variant_builder_init (&b, G_VARIANT_TYPE ("av")); + /* note the order has changed */ + g_variant_builder_add (&b, "v", g_variant_new_string ("Orwell")); + g_variant_builder_add (&b, "v", g_variant_new_int32 (1984)); + g_variant_builder_add (&b, "v", g_variant_new_object_path ("/cats/escher")); + v2 = g_variant_builder_end (&b); + + g_assert (!test_g_variant_equivalent (v1, v2)); + + g_variant_unref (v1); + g_variant_unref (v2); +} + +static void +test_map_equiv (void) +{ + GVariantBuilder b; + GVariant *v1, *v2; + + g_variant_builder_init (&b, G_VARIANT_TYPE ("a{os}")); + g_variant_builder_add (&b, "{os}", "/cats/escher", "Escher Moonbeam"); + g_variant_builder_add (&b, "{os}", "/cats/harvey", "Harvey Nomcat"); + g_variant_builder_add (&b, "{os}", "/cats/josh", "Josh Smith"); + v1 = g_variant_builder_end (&b); + + g_variant_builder_init (&b, G_VARIANT_TYPE ("a{os}")); + /* note the order has changed */ + g_variant_builder_add (&b, "{os}", "/cats/harvey", "Harvey Nomcat"); + g_variant_builder_add (&b, "{os}", "/cats/escher", "Escher Moonbeam"); + g_variant_builder_add (&b, "{os}", "/cats/josh", "Josh Smith"); + v2 = g_variant_builder_end (&b); + + g_assert (test_g_variant_equivalent (v1, v2)); + + g_variant_unref (v1); + g_variant_unref (v2); +} + +static void +test_map_not_equiv1 (void) +{ + GVariantBuilder b; + GVariant *v1, *v2; + + g_variant_builder_init (&b, G_VARIANT_TYPE ("a{os}")); + g_variant_builder_add (&b, "{os}", "/cats/escher", "Escher Moonbeam"); + g_variant_builder_add (&b, "{os}", "/cats/harvey", "Harvey Nomcat"); + g_variant_builder_add (&b, "{os}", "/cats/josh", "Josh Smith"); + v1 = g_variant_builder_end (&b); + + g_variant_builder_init (&b, G_VARIANT_TYPE ("a{os}")); + g_variant_builder_add (&b, "{os}", "/cats/escher", "Escher Moonbeam"); + g_variant_builder_add (&b, "{os}", "/cats/harvey", "Harvey Nomcat"); + g_variant_builder_add (&b, "{os}", "/cats/josh", "Josh Smith"); + g_variant_builder_add (&b, "{os}", "/cats/rory", "Rory Cat"); + v2 = g_variant_builder_end (&b); + + g_assert (!test_g_variant_equivalent (v1, v2)); + + g_variant_unref (v1); + g_variant_unref (v2); +} + +static void +test_map_not_equiv2 (void) +{ + GVariantBuilder b; + GVariant *v1, *v2; + + g_variant_builder_init (&b, G_VARIANT_TYPE ("a{os}")); + g_variant_builder_add (&b, "{os}", "/cats/escher", "Escher Moonbeam"); + g_variant_builder_add (&b, "{os}", "/cats/harvey", "Harvey Nomcat"); + g_variant_builder_add (&b, "{os}", "/cats/josh", "Josh Smith"); + v1 = g_variant_builder_end (&b); + + g_variant_builder_init (&b, G_VARIANT_TYPE ("a{os}")); + g_variant_builder_add (&b, "{os}", "/cats/escher", "Escher Moonbeam"); + g_variant_builder_add (&b, "{os}", "/cats/harvey", "Harvey Nomcat"); + g_variant_builder_add (&b, "{os}", "/cats/josh", "Josh Cat"); + v2 = g_variant_builder_end (&b); + + g_assert (!test_g_variant_equivalent (v1, v2)); + + g_variant_unref (v1); + g_variant_unref (v2); +} + +/* dbus_g_value_build_g_variant tests */ +static void +test_i (void) +{ + GValue v = { 0, }; + GVariant *var, *varc; + + g_value_init (&v, G_TYPE_INT); + g_value_set_int (&v, 1984); + + var = dbus_g_value_build_g_variant (&v); + g_value_unset (&v); + + varc = g_variant_new_int32 (1984); + + g_assert (test_g_variant_equivalent (var, varc)); + + g_variant_unref (var); + g_variant_unref (varc); +} + +static void +test_s (void) +{ + GValue v = { 0, }; + GVariant *var, *varc; + + g_value_init (&v, G_TYPE_STRING); + g_value_set_static_string (&v, "Orwell"); + + var = dbus_g_value_build_g_variant (&v); + g_value_unset (&v); + + varc = g_variant_new_string ("Orwell"); + + g_assert (test_g_variant_equivalent (var, varc)); + + g_variant_unref (var); + g_variant_unref (varc); +} + +static void +test_o (void) +{ + GValue v = { 0, }; + GVariant *var, *varc; + + g_value_init (&v, DBUS_TYPE_G_OBJECT_PATH); + g_value_set_boxed (&v, "/cats/escher"); + + var = dbus_g_value_build_g_variant (&v); + g_value_unset (&v); + + varc = g_variant_new_object_path ("/cats/escher"); + + g_assert (test_g_variant_equivalent (var, varc)); + + g_variant_unref (var); + g_variant_unref (varc); +} + +static void +test_us (void) +{ + GValue v = { 0, }; + GVariant *var, *varc; + GType us = dbus_g_type_get_struct ("GValueArray", + G_TYPE_UINT, + G_TYPE_STRING, + G_TYPE_INVALID); + + g_value_init (&v, us); + g_value_take_boxed (&v, dbus_g_type_specialized_construct (us)); + dbus_g_type_struct_set (&v, + 0, 1984, + 1, "Orwell", + G_MAXUINT); + + var = dbus_g_value_build_g_variant (&v); + g_value_unset (&v); + + varc = g_variant_new ("(us)", 1984, "Orwell"); + + g_assert (test_g_variant_equivalent (var, varc)); + + g_variant_unref (var); + g_variant_unref (varc); +} + +static void +test_a_os (void) +{ + GValue v = { 0, }; + GHashTable *map; + GVariantBuilder b; + GVariant *var, *varc; + GType a_os = dbus_g_type_get_map ("GHashTable", + DBUS_TYPE_G_OBJECT_PATH, + G_TYPE_STRING); + + g_value_init (&v, a_os); + map = dbus_g_type_specialized_construct (a_os); + + g_hash_table_insert (map, + g_strdup ("/cats/escher"), g_strdup ("Escher Moonbeam")); + g_hash_table_insert (map, + g_strdup ("/cats/harvey"), g_strdup ("Harvey Nomcat")); + g_hash_table_insert (map, + g_strdup ("/cats/josh"), g_strdup ("Josh Smith")); + g_value_take_boxed (&v, map); + + var = dbus_g_value_build_g_variant (&v); + g_value_unset (&v); + + g_variant_builder_init (&b, G_VARIANT_TYPE ("a{os}")); + g_variant_builder_add (&b, "{os}", "/cats/escher", "Escher Moonbeam"); + g_variant_builder_add (&b, "{os}", "/cats/harvey", "Harvey Nomcat"); + g_variant_builder_add (&b, "{os}", "/cats/josh", "Josh Smith"); + varc = g_variant_builder_end (&b); + + g_assert (test_g_variant_equivalent (var, varc)); + + g_variant_unref (var); + g_variant_unref (varc); +} + +static void +test_av (void) +{ + GValue v = { 0, }, *v2; + GVariantBuilder b; + GVariant *var, *varc; + GType av = dbus_g_type_get_collection ("GPtrArray", G_TYPE_VALUE); + GPtrArray *array; + + g_value_init (&v, av); + array = dbus_g_type_specialized_construct (av); + + v2 = g_new0 (GValue, 1); + g_value_init (v2, G_TYPE_INT); + g_value_set_int (v2, 1984); + g_ptr_array_add (array, v2); + + v2 = g_new0 (GValue, 1); + g_value_init (v2, G_TYPE_STRING); + g_value_set_static_string (v2, "Orwell"); + g_ptr_array_add (array, v2); + + v2 = g_new0 (GValue, 1); + g_value_init (v2, DBUS_TYPE_G_OBJECT_PATH); + g_value_set_boxed (v2, "/cats/escher"); + g_ptr_array_add (array, v2); + + g_value_take_boxed (&v, array); + + var = dbus_g_value_build_g_variant (&v); + g_value_unset (&v); + + g_variant_builder_init (&b, G_VARIANT_TYPE ("av")); + g_variant_builder_add (&b, "v", g_variant_new_int32 (1984)); + g_variant_builder_add (&b, "v", g_variant_new_string ("Orwell")); + g_variant_builder_add (&b, "v", g_variant_new_object_path ("/cats/escher")); + varc = g_variant_builder_end (&b); + + g_assert (test_g_variant_equivalent (var, varc)); + + g_variant_unref (var); + g_variant_unref (varc); +} + +static void +test_ab (void) +{ + GValue v = { 0, }; + gboolean bools[] = { TRUE, FALSE }; + GVariantBuilder b; + GVariant *var, *varc; + GType ab = dbus_g_type_get_collection ("GArray", G_TYPE_BOOLEAN); + GArray *array; + + g_value_init (&v, ab); + array = dbus_g_type_specialized_construct (ab); + + g_array_append_vals (array, bools, 2); + g_assert_cmpint (g_array_index (array, gboolean, 0), ==, TRUE); + g_assert_cmpint (g_array_index (array, gboolean, 1), ==, FALSE); + + g_value_take_boxed (&v, array); + + var = dbus_g_value_build_g_variant (&v); + g_value_unset (&v); + + g_variant_builder_init (&b, G_VARIANT_TYPE ("ab")); + g_variant_builder_add (&b, "b", TRUE); + g_variant_builder_add (&b, "b", FALSE); + varc = g_variant_builder_end (&b); + + g_assert (test_g_variant_equivalent (var, varc)); + + g_variant_unref (var); + g_variant_unref (varc); +} + +static void +test_ai (void) +{ + GValue v = { 0, }; + gint ints[] = { 1984, 1066 }; + GVariantBuilder b; + GVariant *var, *varc; + GType ai = dbus_g_type_get_collection ("GArray", G_TYPE_INT); + GArray *array; + + g_value_init (&v, ai); + array = dbus_g_type_specialized_construct (ai); + + g_array_append_vals (array, ints, 2); + g_assert_cmpint (g_array_index (array, gint, 0), ==, 1984); + g_assert_cmpint (g_array_index (array, gint, 1), ==, 1066); + + g_value_take_boxed (&v, array); + + var = dbus_g_value_build_g_variant (&v); + g_value_unset (&v); + + g_variant_builder_init (&b, G_VARIANT_TYPE ("ai")); + g_variant_builder_add (&b, "i", 1984); + g_variant_builder_add (&b, "i", 1066); + varc = g_variant_builder_end (&b); + + g_assert (test_g_variant_equivalent (var, varc)); + + g_variant_unref (var); + g_variant_unref (varc); +} + +static void +test_au (void) +{ + GValue v = { 0, }; + guint uints[] = { 1984, 1066 }; + GVariantBuilder b; + GVariant *var, *varc; + GType au = dbus_g_type_get_collection ("GArray", G_TYPE_UINT); + GArray *array; + + g_value_init (&v, au); + array = dbus_g_type_specialized_construct (au); + + g_array_append_vals (array, uints, 2); + g_assert_cmpuint (g_array_index (array, guint, 0), ==, 1984); + g_assert_cmpuint (g_array_index (array, guint, 1), ==, 1066); + + g_value_take_boxed (&v, array); + + var = dbus_g_value_build_g_variant (&v); + g_value_unset (&v); + + g_variant_builder_init (&b, G_VARIANT_TYPE ("au")); + g_variant_builder_add (&b, "u", 1984); + g_variant_builder_add (&b, "u", 1066); + varc = g_variant_builder_end (&b); + + g_assert (test_g_variant_equivalent (var, varc)); + + g_variant_unref (var); + g_variant_unref (varc); +} + +static void +test_ax (void) +{ + GValue v = { 0, }; + gint64 ints[] = { G_GINT64_CONSTANT (-0xAAABBBBCCCCDDDD), 1066 }; + GVariantBuilder b; + GVariant *var, *varc; + GType ax = dbus_g_type_get_collection ("GArray", G_TYPE_INT64); + GArray *array; + + g_value_init (&v, ax); + array = dbus_g_type_specialized_construct (ax); + + g_array_append_vals (array, ints, 2); + g_assert_cmpint ((g_array_index (array, gint64, 0) + / G_GINT64_CONSTANT (0x100000000)), ==, + -0xAAABBBB); + g_assert_cmpuint ((-(g_array_index (array, gint64, 0))) + % G_GINT64_CONSTANT (0x100000000), ==, 0xCCCCDDDDu); + g_assert_cmpint ((g_array_index (array, gint64, 1) + / G_GINT64_CONSTANT (0x100000000)), ==, 0); + g_assert_cmpuint ((g_array_index (array, gint64, 1)) + % G_GINT64_CONSTANT (0x100000000), ==, 1066); + + g_value_take_boxed (&v, array); + + var = dbus_g_value_build_g_variant (&v); + g_value_unset (&v); + + g_variant_builder_init (&b, G_VARIANT_TYPE ("ax")); + g_variant_builder_add (&b, "x", G_GINT64_CONSTANT (-0xAAABBBBCCCCDDDD)); + g_variant_builder_add (&b, "x", G_GINT64_CONSTANT (1066)); + varc = g_variant_builder_end (&b); + + g_assert (test_g_variant_equivalent (var, varc)); + + g_variant_unref (var); + g_variant_unref (varc); +} + +static void +test_at (void) +{ + GValue v = { 0, }; + guint64 uints[] = { G_GUINT64_CONSTANT (0xAAAABBBBCCCCDDDD), 1066 }; + GVariantBuilder b; + GVariant *var, *varc; + GType at = dbus_g_type_get_collection ("GArray", G_TYPE_UINT64); + GArray *array; + + g_value_init (&v, at); + array = dbus_g_type_specialized_construct (at); + + g_array_append_vals (array, uints, 2); + g_assert_cmpuint ((g_array_index (array, guint64, 0) + / G_GUINT64_CONSTANT (0x100000000)), ==, 0xAAAABBBBu); + g_assert_cmpuint ((g_array_index (array, guint64, 0) + % G_GUINT64_CONSTANT (0x100000000)), ==, 0xCCCCDDDDu); + g_assert_cmpuint ((g_array_index (array, guint64, 1) + / G_GUINT64_CONSTANT (0x100000000)), ==, 0); + g_assert_cmpuint ((g_array_index (array, guint64, 1) + % G_GUINT64_CONSTANT (0x100000000)), ==, 1066); + + g_value_take_boxed (&v, array); + + var = dbus_g_value_build_g_variant (&v); + g_value_unset (&v); + + g_variant_builder_init (&b, G_VARIANT_TYPE ("at")); + g_variant_builder_add (&b, "t", G_GUINT64_CONSTANT (0xAAAABBBBCCCCDDDD)); + g_variant_builder_add (&b, "t", G_GUINT64_CONSTANT (1066)); + varc = g_variant_builder_end (&b); + + g_assert (test_g_variant_equivalent (var, varc)); + + g_variant_unref (var); + g_variant_unref (varc); +} + +static void +test_ay (void) +{ + GValue v = { 0, }; + guchar bytes[] = { 23, 42 }; + GVariantBuilder b; + GVariant *var, *varc; + GType ay = dbus_g_type_get_collection ("GArray", G_TYPE_UCHAR); + GArray *array; + + g_value_init (&v, ay); + array = dbus_g_type_specialized_construct (ay); + + g_array_append_vals (array, bytes, 2); + g_assert_cmpint (g_array_index (array, guchar, 0), ==, 23); + g_assert_cmpint (g_array_index (array, guchar, 1), ==, 42); + + g_value_take_boxed (&v, array); + + var = dbus_g_value_build_g_variant (&v); + g_value_unset (&v); + + g_variant_builder_init (&b, G_VARIANT_TYPE ("ay")); + g_variant_builder_add (&b, "y", 23); + g_variant_builder_add (&b, "y", 42); + varc = g_variant_builder_end (&b); + + g_assert (test_g_variant_equivalent (var, varc)); + + g_variant_unref (var); + g_variant_unref (varc); +} + +static void +test_g (void) +{ + GValue v = { 0, }; + GVariant *var, *varc; + + g_value_init (&v, DBUS_TYPE_G_SIGNATURE); + g_value_set_boxed (&v, "a{u(ua{sa{sv}})}"); + + var = dbus_g_value_build_g_variant (&v); + g_value_unset (&v); + + varc = g_variant_new_signature ("a{u(ua{sa{sv}})}"); + + g_assert (test_g_variant_equivalent (var, varc)); + + g_variant_unref (var); + g_variant_unref (varc); +} + +static void +test_roundtrip (gconstpointer user_data) +{ + const gchar *text = user_data; + GVariant *before, *after; + GValue v = { 0 }; + + before = g_variant_new_parsed (text); + dbus_g_value_parse_g_variant (before, &v); + after = dbus_g_value_build_g_variant (&v); + g_value_unset (&v); + assert_g_variant_equivalent (before, after); + g_variant_unref (before); + g_variant_unref (after); +} + +static void +test_parse_basic (void) +{ + GVariant *variant; + GValue v = { 0 }; + + variant = g_variant_new_parsed ("'o hai'"); + dbus_g_value_parse_g_variant (variant, &v); + g_assert_cmpstr (G_VALUE_TYPE_NAME (&v), ==, g_type_name (G_TYPE_STRING)); + g_assert_cmpstr (g_value_get_string (&v), ==, "o hai"); + g_value_unset (&v); + g_variant_unref (variant); + + variant = g_variant_new_parsed ("objectpath '/hello/world'"); + dbus_g_value_parse_g_variant (variant, &v); + g_assert_cmpstr (G_VALUE_TYPE_NAME (&v), ==, + g_type_name (DBUS_TYPE_G_OBJECT_PATH)); + g_assert_cmpstr ((gchar *) g_value_get_boxed (&v), ==, "/hello/world"); + g_value_unset (&v); + g_variant_unref (variant); + + variant = g_variant_new_parsed ("signature 'a{sv}'"); + dbus_g_value_parse_g_variant (variant, &v); + g_assert_cmpstr (G_VALUE_TYPE_NAME (&v), ==, + g_type_name (DBUS_TYPE_G_SIGNATURE)); + g_assert_cmpstr ((gchar *) g_value_get_boxed (&v), ==, "a{sv}"); + g_value_unset (&v); + g_variant_unref (variant); + + variant = g_variant_new_parsed ("23.5"); + dbus_g_value_parse_g_variant (variant, &v); + g_assert_cmpstr (G_VALUE_TYPE_NAME (&v), ==, g_type_name (G_TYPE_DOUBLE)); + /* this is chosen to be exactly representable in binary; we use inequalities + * to work around -Wfloat-equal */ + g_assert_cmpfloat (g_value_get_double (&v), >=, 23.5); + g_assert_cmpfloat (g_value_get_double (&v), <=, 23.5); + g_value_unset (&v); + g_variant_unref (variant); + + variant = g_variant_new_parsed ("byte 42"); + dbus_g_value_parse_g_variant (variant, &v); + g_assert_cmpstr (G_VALUE_TYPE_NAME (&v), ==, g_type_name (G_TYPE_UCHAR)); + g_assert_cmpuint (g_value_get_uchar (&v), ==, 42); + g_value_unset (&v); + g_variant_unref (variant); + + variant = g_variant_new_parsed ("uint16 16"); + dbus_g_value_parse_g_variant (variant, &v); + g_assert_cmpstr (G_VALUE_TYPE_NAME (&v), ==, g_type_name (G_TYPE_UINT)); + g_assert_cmpuint (g_value_get_uint (&v), ==, 16); + g_value_unset (&v); + g_variant_unref (variant); + + variant = g_variant_new_parsed ("uint32 32"); + dbus_g_value_parse_g_variant (variant, &v); + g_assert_cmpstr (G_VALUE_TYPE_NAME (&v), ==, g_type_name (G_TYPE_UINT)); + g_assert_cmpuint (g_value_get_uint (&v), ==, 32); + g_value_unset (&v); + g_variant_unref (variant); + + variant = g_variant_new_parsed ("uint64 64"); + dbus_g_value_parse_g_variant (variant, &v); + g_assert_cmpstr (G_VALUE_TYPE_NAME (&v), ==, g_type_name (G_TYPE_UINT64)); + g_assert_cmpuint ((guint) g_value_get_uint64 (&v), ==, 64); + g_value_unset (&v); + g_variant_unref (variant); + + variant = g_variant_new_parsed ("int16 -16"); + dbus_g_value_parse_g_variant (variant, &v); + g_assert_cmpstr (G_VALUE_TYPE_NAME (&v), ==, g_type_name (G_TYPE_INT)); + g_assert_cmpint (g_value_get_int (&v), ==, -16); + g_value_unset (&v); + g_variant_unref (variant); + + variant = g_variant_new_parsed ("int32 -32"); + dbus_g_value_parse_g_variant (variant, &v); + g_assert_cmpstr (G_VALUE_TYPE_NAME (&v), ==, g_type_name (G_TYPE_INT)); + g_assert_cmpint (g_value_get_int (&v), ==, -32); + g_value_unset (&v); + g_variant_unref (variant); + + variant = g_variant_new_parsed ("int64 -64"); + dbus_g_value_parse_g_variant (variant, &v); + g_assert_cmpstr (G_VALUE_TYPE_NAME (&v), ==, g_type_name (G_TYPE_INT64)); + g_assert_cmpint ((gint) g_value_get_int64 (&v), ==, -64); + g_value_unset (&v); + g_variant_unref (variant); +} + +static void +test_parse_array (void) +{ + GVariant *variant; + GValue v = { 0 }; + GArray *a; + + /* We can't test the 16-bit cases via a round-trip, because information is + * lost. */ + + variant = g_variant_new_parsed ("[uint16 16, uint16 1600]"); + dbus_g_value_parse_g_variant (variant, &v); + g_assert_cmpstr (G_VALUE_TYPE_NAME (&v), ==, + g_type_name (DBUS_TYPE_G_UINT_ARRAY)); + a = g_value_get_boxed (&v); + g_assert_cmpuint (a->len, ==, 2); + g_assert_cmpuint (g_array_index (a, guint, 0), ==, 16); + g_assert_cmpuint (g_array_index (a, guint, 1), ==, 1600); + g_value_unset (&v); + g_variant_unref (variant); + + variant = g_variant_new_parsed ("[int16 -16, int16 -1600]"); + dbus_g_value_parse_g_variant (variant, &v); + g_assert_cmpstr (G_VALUE_TYPE_NAME (&v), ==, + g_type_name (DBUS_TYPE_G_INT_ARRAY)); + a = g_value_get_boxed (&v); + g_assert_cmpuint (a->len, ==, 2); + g_assert_cmpint (g_array_index (a, gint, 0), ==, -16); + g_assert_cmpint (g_array_index (a, gint, 1), ==, -1600); + g_value_unset (&v); + g_variant_unref (variant); + + variant = g_variant_new_parsed ("@aq []"); + dbus_g_value_parse_g_variant (variant, &v); + g_assert_cmpstr (G_VALUE_TYPE_NAME (&v), ==, + g_type_name (DBUS_TYPE_G_UINT_ARRAY)); + a = g_value_get_boxed (&v); + g_assert_cmpuint (a->len, ==, 0); + g_value_unset (&v); + g_variant_unref (variant); + + variant = g_variant_new_parsed ("@an []"); + dbus_g_value_parse_g_variant (variant, &v); + g_assert_cmpstr (G_VALUE_TYPE_NAME (&v), ==, + g_type_name (DBUS_TYPE_G_INT_ARRAY)); + a = g_value_get_boxed (&v); + g_assert_cmpuint (a->len, ==, 0); + g_value_unset (&v); + g_variant_unref (variant); +} + +static void +test_parse_string_hash (void) +{ + GVariant *variant; + GHashTable *h; + GValue v = { 0 }; + + variant = g_variant_new_parsed ("@a{ss} {'foo': 'bar'}"); + dbus_g_value_parse_g_variant (variant, &v); + g_assert_cmpstr (G_VALUE_TYPE_NAME (&v), ==, + g_type_name (DBUS_TYPE_G_STRING_STRING_HASHTABLE)); + h = g_value_get_boxed (&v); + g_assert_cmpuint (g_hash_table_size (h), ==, 1); + g_assert_cmpstr (g_hash_table_lookup (h, "foo"), ==, "bar"); + g_value_unset (&v); + g_variant_unref (variant); +} + +int +main (int argc, + char **argv) +{ + g_type_init (); + dbus_g_type_specialized_init (); + + g_test_init (&argc, &argv, NULL); + + /* test_g_variant_equivalent tests */ + g_test_add_func ("/test_g_variant_equivalent/test_simple_equiv", + test_simple_equiv); + g_test_add_func ("/test_g_variant_equivalent/test_simple_not_equiv", + test_simple_not_equiv); + g_test_add_func ("/test_g_variant_equivalent/test_array_not_equiv", + test_array_not_equiv); + g_test_add_func ("/test_g_variant_equivalent/test_map_equiv", + test_map_equiv); + g_test_add_func ("/test_g_variant_equivalent/test_map_not_equiv1", + test_map_not_equiv1); + g_test_add_func ("/test_g_variant_equivalent/test_map_not_equiv2", + test_map_not_equiv2); + + /* dbus_g_value_build_g_variant tests */ + g_test_add_func ("/gvalue-to-gvariant/i", test_i); + g_test_add_func ("/gvalue-to-gvariant/s", test_s); + g_test_add_func ("/gvalue-to-gvariant/o", test_o); + g_test_add_func ("/gvalue-to-gvariant/us", test_us); + g_test_add_func ("/gvalue-to-gvariant/a{os}", test_a_os); + g_test_add_func ("/gvalue-to-gvariant/av", test_av); + g_test_add_func ("/gvalue-to-gvariant/ab", test_ab); + g_test_add_func ("/gvalue-to-gvariant/ai", test_ai); + g_test_add_func ("/gvalue-to-gvariant/au", test_au); + g_test_add_func ("/gvalue-to-gvariant/ax", test_ax); + g_test_add_func ("/gvalue-to-gvariant/at", test_at); + g_test_add_func ("/gvalue-to-gvariant/ay", test_ay); + g_test_add_func ("/gvalue-to-gvariant/g", test_g); + + /* dbus_g_value_parse_g_variant tests */ + g_test_add_func ("/parse-gvariant/basic", test_parse_basic); + g_test_add_func ("/parse-gvariant/array", test_parse_array); + g_test_add_func ("/parse-gvariant/string_hash", test_parse_string_hash); + + /* round-trips */ + g_test_add_data_func ("/parse-gvariant/roundtrip/u", + "@u 42", test_roundtrip); + g_test_add_data_func ("/parse-gvariant/roundtrip/non_empty_array", + "@ai [23, 42]", test_roundtrip); + g_test_add_data_func ("/roundtrip/empty_array", "@ai []", test_roundtrip); + g_test_add_data_func ("/roundtrip/aav", "[[<'bees'>]]", test_roundtrip); + g_test_add_data_func ("/roundtrip/aau", "[[uint32 666]]", test_roundtrip); + g_test_add_data_func ("/roundtrip/aax", "[[int64 666]]", test_roundtrip); + g_test_add_data_func ("/roundtrip/aat", "[[uint64 666]]", test_roundtrip); + g_test_add_data_func ("/roundtrip/aas", "[['a', 'b']]", test_roundtrip); + g_test_add_data_func ("/roundtrip/aao", + "[[objectpath '/a', objectpath '/b']]", test_roundtrip); + g_test_add_data_func ("/roundtrip/aag", "[[signature 'ab', signature 'g']]", + test_roundtrip); + g_test_add_data_func ("/roundtrip/aad", "[[5.25, 3.5]]", test_roundtrip); + g_test_add_data_func ("/roundtrip/aay", "@aay [[1, 2]]", test_roundtrip); + g_test_add_data_func ("/roundtrip/empty_aay", "@aay [[]]", test_roundtrip); + g_test_add_data_func ("/roundtrip/aab", "[[true, false]]", test_roundtrip); + g_test_add_data_func ("/roundtrip/empty_aab", "@aab [[]]", test_roundtrip); + g_test_add_data_func ("/roundtrip/aa_asv", "[[@a{sv} {'x': <'y'>}]]", + test_roundtrip); + g_test_add_data_func ("/roundtrip/empty_av", "@av []", test_roundtrip); + g_test_add_data_func ("/roundtrip/empty_hash", "@a{uu} {}", test_roundtrip); + g_test_add_data_func ("/roundtrip/easy_string_hash", + "@a{ss} {'foo': 'bar'}", test_roundtrip); + g_test_add_data_func ("/roundtrip/non_empty_asv", + "@a{sv} {'badger': <42>, 'mushroom': <objectpath '/'>, 'snake': <''>}", + test_roundtrip); + g_test_add_data_func ("/roundtrip/variant_nesting", "<<<42>>>", + test_roundtrip); + g_test_add_data_func ("/roundtrip/tuple", "(23, 42, true)", + test_roundtrip); + g_test_add_data_func ("/roundtrip/nested", "[[[(1, 2)]]]", test_roundtrip); + g_test_add_data_func ("/roundtrip/empty_aaa", "@aaav [[]]", + test_roundtrip); + g_test_add_data_func ("/roundtrip/empty_aa_asv", "@aaa{sv} [[]]", + test_roundtrip); + g_test_add_data_func ("/roundtrip/empty_aa_struct", "@aa(us) [[]]", + test_roundtrip); + g_test_add_data_func ("/roundtrip/empty_aaas", "@aaas [[]]", test_roundtrip); + g_test_add_data_func ("/roundtrip/empty_aax", "@aax [[]]", test_roundtrip); + g_test_add_data_func ("/roundtrip/empty_aat", "@aat [[]]", test_roundtrip); + g_test_add_data_func ("/roundtrip/empty_aad", "@aad [[]]", test_roundtrip); + g_test_add_data_func ("/roundtrip/empty_aao", "@aao [[]]", test_roundtrip); + g_test_add_data_func ("/roundtrip/empty_aag", "@aag [[]]", test_roundtrip); + + return g_test_run (); +} diff --git a/test/core/test-profile.c b/test/core/test-profile.c new file mode 100644 index 0000000..10baa0b --- /dev/null +++ b/test/core/test-profile.c @@ -0,0 +1,1160 @@ +/* -*- mode: C; c-file-style: "gnu" -*- */ +/* test-profile.c Program that does basic message-response for timing; doesn't really use glib bindings + * + * Copyright (C) 2003, 2004 Red Hat Inc. + * + * 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 <glib.h> + +/* This test uses Unix-specific facilities */ +#ifdef G_OS_WIN32 +#define TEST_PROFILE_DISABLED +#endif + +#ifndef TEST_PROFILE_DISABLED + +#include <dbus/dbus-glib-lowlevel.h> +#include <stdlib.h> +#include <unistd.h> + +#include <errno.h> +#include <fcntl.h> +#include <sys/socket.h> +#include <sys/un.h> +#include <netinet/in.h> +#include <string.h> +#include <sys/time.h> +#include <sys/stat.h> +#ifndef HAVE_SOCKLEN_T +#define socklen_t int +#endif + +#define _DBUS_ZERO(object) (memset (&(object), '\0', sizeof ((object)))) +#define _DBUS_MAX_SUN_PATH_LENGTH 99 + +/* Note that if you set threads > 1 you get a bogus profile since the + * clients start blocking on the server, so the client write() will go + * higher in the profile the larger the number of threads. + */ +#define N_CLIENT_THREADS 1 +/* It seems like at least 750000 or so iterations reduces the variability to sane levels */ +#define N_ITERATIONS 2000 +#define N_PROGRESS_UPDATES 20 +/* Don't make PAYLOAD_SIZE too huge because it gets used as a static buffer size */ +#define PAYLOAD_SIZE 0 + +#define ECHO_SERVICE "org.freedesktop.DBus.GLib.EchoTestServer" +#define ECHO_PATH "/org/freedesktop/DBus/GLib/EchoTest" +#define ECHO_INTERFACE "org.freedesktop.DBus.GLib.EchoTest" +#define ECHO_PING_METHOD "Ping" + +static const char *messages_address; +static const char *plain_sockets_address; +static unsigned char *payload; +static int echo_call_size; +static int echo_return_size; + +typedef struct ProfileRunVTable ProfileRunVTable; + +typedef struct +{ + const ProfileRunVTable *vtable; + int iterations; + GMainLoop *loop; +} ClientData; + +typedef struct +{ + const ProfileRunVTable *vtable; + int handled; + GMainLoop *loop; + int n_clients; +} ServerData; + +struct ProfileRunVTable +{ + const char *name; + gboolean fake_malloc_overhead; + void* (* init_server) (ServerData *sd); + void (* stop_server) (ServerData *sd, + void *server); + void* (* client_thread_func) (void *data); /* Data has to be the vtable */ + + /* this is so different runs show up in the profiler with + * different backtrace + */ + void (* main_loop_run_func) (GMainLoop *loop); +}; + +/* Note, this is all crack-a-rific; it isn't using DBusGProxy and thus is + * a major pain + */ +static void +send_echo_method_call (DBusConnection *connection) +{ + DBusMessage *message; + const char *hello = "Hello World!"; + dbus_int32_t i32 = 123456; + + message = dbus_message_new_method_call (ECHO_SERVICE, + ECHO_PATH, + ECHO_INTERFACE, + ECHO_PING_METHOD); + dbus_message_append_args (message, + DBUS_TYPE_STRING, &hello, + DBUS_TYPE_INT32, &i32, +#if PAYLOAD_SIZE > 0 + DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, + &payload, PAYLOAD_SIZE, +#endif + DBUS_TYPE_INVALID); + + dbus_connection_send (connection, message, NULL); + dbus_message_unref (message); + dbus_connection_flush (connection); +} + +static void +send_echo_method_return (DBusConnection *connection, + DBusMessage *call_message) +{ + DBusMessage *message; + + message = dbus_message_new_method_return (call_message); + + dbus_connection_send (connection, message, NULL); + dbus_message_unref (message); + dbus_connection_flush (connection); +} + +static DBusHandlerResult +with_or_without_bus_client_filter (DBusConnection *connection, + DBusMessage *message, + ClientData *cd) +{ + if (dbus_message_is_signal (message, + DBUS_INTERFACE_LOCAL, + "Disconnected")) + { + g_printerr ("Client thread disconnected\n"); + exit (1); + } + else if (dbus_message_get_type (message) == DBUS_MESSAGE_TYPE_METHOD_RETURN) + { + cd->iterations += 1; + if (cd->iterations >= N_ITERATIONS) + { + g_printerr ("\nCompleted %d iterations\n", N_ITERATIONS); + g_main_loop_quit (cd->loop); + } + else if (cd->iterations % (N_ITERATIONS/N_PROGRESS_UPDATES) == 0) + { + g_printerr ("%d%% ", (int) (cd->iterations/(double)N_ITERATIONS * 100.0)); + } + + send_echo_method_call (connection); + return DBUS_HANDLER_RESULT_HANDLED; + } + + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; +} + +static DBusHandlerResult +no_bus_client_filter (DBusConnection *connection, + DBusMessage *message, + void *user_data) +{ + ClientData *cd = user_data; + + return with_or_without_bus_client_filter (connection, message, cd); +} + +static void* +no_bus_thread_func (void *data) +{ + DBusError error; + GMainContext *context; + DBusConnection *connection; + ClientData cd; + + g_printerr ("Starting client thread %p\n", g_thread_self()); + + dbus_error_init (&error); + connection = dbus_connection_open_private (messages_address, &error); + if (connection == NULL) + { + g_printerr ("could not open connection: %s\n", error.message); + dbus_error_free (&error); + exit (1); + } + + context = g_main_context_new (); + + cd.iterations = 1; + cd.loop = g_main_loop_new (context, FALSE); + + if (!dbus_connection_add_filter (connection, + no_bus_client_filter, &cd, NULL)) + g_error ("no memory"); + + + dbus_connection_setup_with_g_main (connection, context); + + g_printerr ("Client thread sending message to prime pingpong\n"); + send_echo_method_call (connection); + g_printerr ("Client thread sent message\n"); + + g_printerr ("Client thread entering main loop\n"); + g_main_loop_run (cd.loop); + g_printerr ("Client thread %p exiting main loop\n", + g_thread_self()); + + dbus_connection_close (connection); + + g_main_loop_unref (cd.loop); + g_main_context_unref (context); + + return NULL; +} + +static DBusHandlerResult +no_bus_server_filter (DBusConnection *connection, + DBusMessage *message, + void *user_data) +{ + ServerData *sd = user_data; + + if (dbus_message_is_signal (message, + DBUS_INTERFACE_LOCAL, + "Disconnected")) + { + g_printerr ("Client disconnected from server\n"); + sd->n_clients -= 1; + if (sd->n_clients == 0) + g_main_loop_quit (sd->loop); + } + else if (dbus_message_is_method_call (message, + ECHO_INTERFACE, + ECHO_PING_METHOD)) + { + sd->handled += 1; + send_echo_method_return (connection, message); + return DBUS_HANDLER_RESULT_HANDLED; + } + + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; +} + +static void +no_bus_new_connection_callback (DBusServer *server, + DBusConnection *new_connection, + void *user_data) +{ + ServerData *sd = user_data; + + dbus_connection_ref (new_connection); + dbus_connection_setup_with_g_main (new_connection, NULL); + + if (!dbus_connection_add_filter (new_connection, + no_bus_server_filter, sd, NULL)) + g_error ("no memory"); + + sd->n_clients += 1; + + /* FIXME we leak the handler */ +} + +static void* +no_bus_init_server (ServerData *sd) +{ + DBusServer *server; + DBusError error; + + dbus_error_init (&error); + server = dbus_server_listen ("unix:tmpdir="DBUS_TEST_SOCKET_DIR, + &error); + if (server == NULL) + { + g_printerr ("Could not start server: %s\n", + error.message); + exit (1); + } + + messages_address = dbus_server_get_address (server); + + dbus_server_set_new_connection_function (server, + no_bus_new_connection_callback, + sd, NULL); + + dbus_server_setup_with_g_main (server, NULL); + + return server; +} + +static void +no_bus_stop_server (ServerData *sd, + void *server) +{ + dbus_server_disconnect (server); + dbus_server_unref (server); +} + +static void +no_bus_main_loop_run (GMainLoop *loop) +{ + g_main_loop_run (loop); +} + +static const ProfileRunVTable no_bus_vtable = { + "dbus direct without bus", + FALSE, + no_bus_init_server, + no_bus_stop_server, + no_bus_thread_func, + no_bus_main_loop_run +}; + +typedef struct +{ + const ProfileRunVTable *vtable; + ServerData *sd; + GHashTable *client_names; + DBusConnection *connection; +} WithBusServer; + +static DBusHandlerResult +with_bus_client_filter (DBusConnection *connection, + DBusMessage *message, + void *user_data) +{ + ClientData *cd = user_data; + + return with_or_without_bus_client_filter (connection, message, cd); +} + +static void* +with_bus_thread_func (void *data) +{ + DBusError error; + DBusConnection *connection; + ClientData cd; + const char *address; + GMainContext *context; + + g_printerr ("Starting client thread %p\n", g_thread_self()); + + address = g_getenv ("DBUS_SESSION_BUS_ADDRESS"); + if (address == NULL) + { + g_printerr ("DBUS_SESSION_BUS_ADDRESS not set\n"); + exit (1); + } + + dbus_error_init (&error); + connection = dbus_connection_open_private (address, &error); + if (connection == NULL) + { + g_printerr ("could not open connection to bus: %s\n", error.message); + dbus_error_free (&error); + exit (1); + } + + if (!dbus_bus_register (connection, &error)) + { + g_printerr ("could not register with bus: %s\n", error.message); + dbus_error_free (&error); + exit (1); + } + + context = g_main_context_new (); + + cd.iterations = 1; + cd.loop = g_main_loop_new (context, FALSE); + + if (!dbus_connection_add_filter (connection, + with_bus_client_filter, &cd, NULL)) + g_error ("no memory"); + + dbus_connection_setup_with_g_main (connection, context); + + g_printerr ("Client thread sending message to prime pingpong\n"); + send_echo_method_call (connection); + g_printerr ("Client thread sent message\n"); + + g_printerr ("Client thread entering main loop\n"); + g_main_loop_run (cd.loop); + g_printerr ("Client thread %p exiting main loop\n", + g_thread_self()); + + dbus_connection_close (connection); + + g_main_loop_unref (cd.loop); + g_main_context_unref (context); + + return NULL; +} + +static DBusHandlerResult +with_bus_server_filter (DBusConnection *connection, + DBusMessage *message, + void *user_data) +{ + WithBusServer *server = user_data; + + if (dbus_message_is_signal (message, + DBUS_INTERFACE_LOCAL, + "Disconnected")) + { + g_printerr ("Server disconnected from message bus\n"); + exit (1); + } + else if (dbus_message_has_sender (message, + DBUS_SERVICE_DBUS) && + dbus_message_is_signal (message, + DBUS_INTERFACE_DBUS, + "NameOwnerChanged")) + { + const char *name, *old_owner, *new_owner; + DBusError error; + + name = NULL; + old_owner = NULL; + new_owner = NULL; + + dbus_error_init (&error); + if (!dbus_message_get_args (message, + &error, + DBUS_TYPE_STRING, &name, + DBUS_TYPE_STRING, &old_owner, + DBUS_TYPE_STRING, &new_owner, + DBUS_TYPE_INVALID)) + { + g_printerr ("dbus_message_get_args(): %s\n", error.message); + exit (1); + } + + if (g_hash_table_lookup (server->client_names, + name) && + *old_owner != '\0' && + *new_owner == '\0') + { + g_hash_table_remove (server->client_names, + name); + server->sd->n_clients -= 1; + if (server->sd->n_clients == 0) + g_main_loop_quit (server->sd->loop); + } + } + else if (dbus_message_is_method_call (message, + ECHO_INTERFACE, + ECHO_PING_METHOD)) + { + const char *sender; + + sender = dbus_message_get_sender (message); + + if (!g_hash_table_lookup (server->client_names, + sender)) + { + g_printerr ("First message from new client %s on bus\n", sender); + + g_hash_table_replace (server->client_names, + g_strdup (sender), + GINT_TO_POINTER (1)); + server->sd->n_clients += 1; + } + + server->sd->handled += 1; + send_echo_method_return (connection, message); + return DBUS_HANDLER_RESULT_HANDLED; + } + + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; +} + +static void* +with_bus_init_server (ServerData *sd) +{ + DBusGConnection *gconnection; + DBusConnection *connection; + GError *gerror; + const char *s; + WithBusServer *server; + char *rule; + + server = g_new0 (WithBusServer, 1); + + server->vtable = sd->vtable; + server->sd = sd; + + s = g_getenv ("DBUS_TEST_GLIB_RUN_TEST_SCRIPT"); + if (s == NULL || + *s != '1') + { + g_printerr ("You have to run with_bus mode with the run-test.sh script\n"); + exit (1); + } + + /* Note that we use the standard global bus connection for the + * server, and the clients open their own connections so they can + * have their own main loops and because I'm not sure "talking to + * yourself" really works yet + */ + gerror = NULL; + gconnection = dbus_g_bus_get (DBUS_BUS_SESSION, &gerror); + if (gconnection == NULL) + { + g_printerr ("could not open connection to bus: %s\n", gerror->message); + g_error_free (gerror); + exit (1); + } + + server->client_names = g_hash_table_new_full (g_str_hash, g_str_equal, + g_free, NULL); + + connection = dbus_g_connection_get_connection (gconnection); + + dbus_bus_request_name (connection, + ECHO_SERVICE, + 0, NULL); /* ignore errors because we suck */ + + rule = g_strdup_printf ("type='signal',sender='%s',member='%s'", + DBUS_SERVICE_DBUS, + "NameOwnerChanged"); + + /* ignore errors because we suck */ + dbus_bus_add_match (connection, rule, NULL); + + g_free (rule); + + if (!dbus_connection_add_filter (connection, + with_bus_server_filter, server, NULL)) + g_error ("no memory"); + + server->connection = connection; + server->client_names = g_hash_table_new_full (g_str_hash, g_str_equal, + g_free, NULL); + + return server; +} + +static void +with_bus_stop_server (ServerData *sd, + void *serverv) +{ + WithBusServer *server = serverv; + + dbus_connection_remove_filter (server->connection, + with_bus_server_filter, server); + + g_hash_table_destroy (server->client_names); + dbus_connection_unref (server->connection); + + g_free (server); +} + +static void +with_bus_main_loop_run (GMainLoop *loop) +{ + g_main_loop_run (loop); +} + +static const ProfileRunVTable with_bus_vtable = { + "routing via a bus", + FALSE, + with_bus_init_server, + with_bus_stop_server, + with_bus_thread_func, + with_bus_main_loop_run +}; + + +typedef struct +{ + const ProfileRunVTable *vtable; + int listen_fd; + ServerData *sd; + unsigned int source_id; +} PlainSocketServer; + +static void +read_and_drop_on_floor (int fd, + int count, + gboolean fake_malloc_overhead) +{ + int bytes_read; + int val; + char *buf; + char *allocated; + char not_allocated[512+PAYLOAD_SIZE]; + + g_assert (count < (int) sizeof(not_allocated)); + + if (fake_malloc_overhead) + { + allocated = g_malloc (count); + buf = allocated; + } + else + { + allocated = NULL; + buf = not_allocated; + } + + bytes_read = 0; + + while (bytes_read < count) + { + again: + + val = read (fd, buf + bytes_read, count - bytes_read); + + if (val < 0) + { + if (errno == EINTR) + goto again; + else + { + g_printerr ("read() failed thread %p: %s\n", + g_thread_self(), strerror (errno)); + exit (1); + } + } + else + { + bytes_read += val; + } + } + + if (fake_malloc_overhead) + g_free (allocated); + +#if 0 + g_printerr ("%p read %d bytes from fd %d\n", + g_thread_self(), bytes_read, fd); +#endif +} + +static void +write_junk (int fd, + int count, + gboolean fake_malloc_overhead) +{ + int bytes_written; + int val; + char *buf; + char *allocated; + char not_allocated[512+PAYLOAD_SIZE] = { '\0', }; + + g_assert (count < (int) sizeof(not_allocated)); + + if (fake_malloc_overhead) + { + int i; + + allocated = g_malloc (count); + buf = allocated; + + /* Write some stuff into the allocated buffer to simulate + * creating some sort of data + */ + i = 0; + while (i < count) + { + allocated[i] = (char) i; + ++i; + } + } + else + { + allocated = NULL; + buf = not_allocated; + } + + bytes_written = 0; + + while (bytes_written < count) + { + again: + + val = write (fd, buf + bytes_written, count - bytes_written); + + if (val < 0) + { + if (errno == EINTR) + goto again; + else + { + g_printerr ("write() failed thread %p: %s\n", + g_thread_self(), strerror (errno)); + exit (1); + } + } + else + { + bytes_written += val; + } + } + + if (fake_malloc_overhead) + g_free (allocated); + +#if 0 + g_printerr ("%p wrote %d bytes to fd %d\n", + g_thread_self(), bytes_written, fd); +#endif +} + +static gboolean +plain_sockets_talk_to_client_watch (GIOChannel *source, + GIOCondition condition, + gpointer data) +{ + PlainSocketServer *server = data; + int client_fd = g_io_channel_unix_get_fd (source); + + if (condition & G_IO_HUP) + { + g_printerr ("Client disconnected from server\n"); + server->sd->n_clients -= 1; + if (server->sd->n_clients == 0) + g_main_loop_quit (server->sd->loop); + + return FALSE; /* remove watch */ + } + else if (condition & G_IO_IN) + { + server->sd->handled += 1; + + read_and_drop_on_floor (client_fd, echo_call_size, server->vtable->fake_malloc_overhead); + write_junk (client_fd, echo_return_size, server->vtable->fake_malloc_overhead); + } + else + { + g_printerr ("Unexpected IO condition in server thread\n"); + exit (1); + } + + return TRUE; +} + +static gboolean +plain_sockets_new_client_watch (GIOChannel *source, + GIOCondition condition, + gpointer data) +{ + int client_fd; + struct sockaddr addr; + socklen_t addrlen; + GIOChannel *channel; + PlainSocketServer *server = data; + + if (!(condition & G_IO_IN)) + { + g_printerr ("Unexpected IO condition on server socket\n"); + exit (1); + } + + addrlen = sizeof (addr); + + retry: + client_fd = accept (server->listen_fd, &addr, &addrlen); + + if (client_fd < 0) + { + if (errno == EINTR) + goto retry; + else + { + g_printerr ("Failed to accept() connection from client: %s\n", + strerror (errno)); + exit (1); + } + } + + channel = g_io_channel_unix_new (client_fd); + g_io_add_watch (channel, + G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL | G_IO_PRI, + plain_sockets_talk_to_client_watch, + server); + g_io_channel_unref (channel); + + server->sd->n_clients += 1; + + return TRUE; +} + +static void* +plain_sockets_init_server (ServerData *sd) +{ + PlainSocketServer *server; + struct sockaddr_un addr; + static char path[] = "/tmp/dbus-test-profile-XXXXXX"; + char *p; + GIOChannel *channel; + + server = g_new0 (PlainSocketServer, 1); + server->sd = sd; + server->vtable = sd->vtable; /* for convenience */ + + p = path; + while (*p) + { + if (*p == 'X') + *p = 'a' + (int) (26.0*rand()/(RAND_MAX+1.0)); + ++p; + } + + g_printerr ("Socket is %s\n", path); + + server->listen_fd = socket (PF_UNIX, SOCK_STREAM, 0); + + if (server->listen_fd < 0) + { + g_printerr ("Failed to create socket: %s", + strerror (errno)); + exit (1); + } + + _DBUS_ZERO (addr); + addr.sun_family = AF_UNIX; + +#ifdef HAVE_ABSTRACT_SOCKETS + /* remember that abstract names aren't nul-terminated so we rely + * on sun_path being filled in with zeroes above. + */ + addr.sun_path[0] = '\0'; /* this is what says "use abstract" */ + strncpy (&addr.sun_path[1], path, _DBUS_MAX_SUN_PATH_LENGTH - 2); + /* _dbus_verbose_bytes (addr.sun_path, sizeof (addr.sun_path)); */ +#else /* HAVE_ABSTRACT_SOCKETS */ + { + struct stat sb; + + if (stat (path, &sb) == 0 && + S_ISSOCK (sb.st_mode)) + unlink (path); + } + + strncpy (addr.sun_path, path, _DBUS_MAX_SUN_PATH_LENGTH - 1); +#endif /* ! HAVE_ABSTRACT_SOCKETS */ + + if (bind (server->listen_fd, (struct sockaddr*) &addr, sizeof (addr)) < 0) + { + g_printerr ("Failed to bind socket \"%s\": %s", + path, strerror (errno)); + exit (1); + } + + if (listen (server->listen_fd, 30 /* backlog */) < 0) + { + g_printerr ("Failed to listen on socket \"%s\": %s", + path, strerror (errno)); + exit (1); + } + + plain_sockets_address = path; + + channel = g_io_channel_unix_new (server->listen_fd); + server->source_id = + g_io_add_watch (channel, + G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL | G_IO_PRI, + plain_sockets_new_client_watch, + server); + g_io_channel_unref (channel); + + return server; +} + +static void +plain_sockets_stop_server (ServerData *sd, + void *server_v) +{ + PlainSocketServer *server = server_v; + + g_source_remove (server->source_id); + + close (server->listen_fd); + g_free (server); + + { + struct stat sb; + + if (stat (plain_sockets_address, &sb) == 0 && + S_ISSOCK (sb.st_mode)) + unlink (plain_sockets_address); + } +} + +static gboolean +plain_sockets_client_side_watch (GIOChannel *source, + GIOCondition condition, + gpointer data) +{ + ClientData *cd = data; + int fd = g_io_channel_unix_get_fd (source); + + if (condition & G_IO_IN) + { + read_and_drop_on_floor (fd, echo_return_size, cd->vtable->fake_malloc_overhead); + } + else if (condition & G_IO_OUT) + { + cd->iterations += 1; + if (cd->iterations >= N_ITERATIONS) + { + g_printerr ("\nCompleted %d iterations\n", N_ITERATIONS); + g_main_loop_quit (cd->loop); + } + else if (cd->iterations % (N_ITERATIONS/N_PROGRESS_UPDATES) == 0) + { + g_printerr ("%d%% ", (int) (cd->iterations/(double)N_ITERATIONS * 100.0)); + } + + write_junk (fd, echo_call_size, cd->vtable->fake_malloc_overhead); + } + else + { + g_printerr ("Unexpected IO condition in client thread\n"); + exit (1); + } + + return TRUE; +} + +static void* +plain_sockets_thread_func (void *data) +{ + GMainContext *context; + ClientData cd; + int fd; + struct sockaddr_un addr; + GIOChannel *channel; + GSource *gsource; + + g_printerr ("Starting client thread %p\n", + g_thread_self()); + + fd = socket (PF_UNIX, SOCK_STREAM, 0); + + if (fd < 0) + { + g_printerr ("Failed to create socket: %s", + strerror (errno)); + exit (1); + } + + _DBUS_ZERO (addr); + addr.sun_family = AF_UNIX; + +#ifdef HAVE_ABSTRACT_SOCKETS + /* remember that abstract names aren't nul-terminated so we rely + * on sun_path being filled in with zeroes above. + */ + addr.sun_path[0] = '\0'; /* this is what says "use abstract" */ + strncpy (&addr.sun_path[1], plain_sockets_address, _DBUS_MAX_SUN_PATH_LENGTH - 2); + /* _dbus_verbose_bytes (addr.sun_path, sizeof (addr.sun_path)); */ +#else /* HAVE_ABSTRACT_SOCKETS */ + strncpy (addr.sun_path, plain_sockets_address, _DBUS_MAX_SUN_PATH_LENGTH - 1); +#endif /* ! HAVE_ABSTRACT_SOCKETS */ + + if (connect (fd, (struct sockaddr*) &addr, sizeof (addr)) < 0) + { + g_printerr ("Failed to connect to socket %s: %s", + plain_sockets_address, strerror (errno)); + exit (1); + } + + context = g_main_context_new (); + + cd.iterations = 1; + cd.loop = g_main_loop_new (context, FALSE); + cd.vtable = data; + + channel = g_io_channel_unix_new (fd); + + gsource = g_io_create_watch (channel, + G_IO_IN | G_IO_OUT | + G_IO_ERR | G_IO_HUP | G_IO_NVAL | G_IO_PRI); + + g_source_set_callback (gsource, + (GSourceFunc)plain_sockets_client_side_watch, + &cd, NULL); + + g_source_attach (gsource, context); + + g_io_channel_unref (channel); + + g_printerr ("Client thread writing to prime pingpong\n"); + write_junk (fd, echo_call_size, cd.vtable->fake_malloc_overhead); + g_printerr ("Client thread done writing primer\n"); + + g_printerr ("Client thread entering main loop\n"); + g_main_loop_run (cd.loop); + g_printerr ("Client thread %p exiting main loop\n", + g_thread_self()); + + g_source_destroy (gsource); + + close (fd); + + g_main_loop_unref (cd.loop); + g_main_context_unref (context); + + return NULL; +} + +static void +plain_sockets_main_loop_run (GMainLoop *loop) +{ + g_main_loop_run (loop); +} + +static const ProfileRunVTable plain_sockets_vtable = { + "plain sockets", + FALSE, + plain_sockets_init_server, + plain_sockets_stop_server, + plain_sockets_thread_func, + plain_sockets_main_loop_run +}; + +static const ProfileRunVTable plain_sockets_with_malloc_vtable = { + "plain sockets with malloc overhead", + TRUE, + plain_sockets_init_server, + plain_sockets_stop_server, + plain_sockets_thread_func, + plain_sockets_main_loop_run +}; + +static double +do_profile_run (const ProfileRunVTable *vtable) +{ + GTimer *timer; + int i; + double secs; + ServerData sd; + void *server; + + g_printerr ("Profiling %s\n", vtable->name); + + sd.handled = 0; + sd.n_clients = 0; + sd.loop = g_main_loop_new (NULL, FALSE); + sd.vtable = vtable; + + server = (* vtable->init_server) (&sd); + + for (i = 0; i < N_CLIENT_THREADS; i++) + { + g_thread_create (vtable->client_thread_func, (void*) vtable, FALSE, NULL); + } + + timer = g_timer_new (); + + g_printerr ("Server thread %p entering main loop\n", + g_thread_self()); + (* vtable->main_loop_run_func) (sd.loop); + g_printerr ("Server thread %p exiting main loop\n", + g_thread_self()); + + secs = g_timer_elapsed (timer, NULL); + g_timer_destroy (timer); + + g_printerr ("%s: %g seconds, %d round trips, %f seconds per pingpong\n", + vtable->name, secs, sd.handled, secs/sd.handled); + + (* vtable->stop_server) (&sd, server); + + g_main_loop_unref (sd.loop); + + return secs; +} + +static void +print_result (const ProfileRunVTable *vtable, + double seconds, + double baseline) +{ + g_printerr (" %g times slower for %s (%g seconds, %f per iteration)\n", + seconds/baseline, vtable->name, + seconds, seconds / N_ITERATIONS); +} +#endif + +int +main (int argc, char *argv[]) +{ +#ifndef TEST_PROFILE_DISABLED + g_thread_init (NULL); + dbus_g_thread_init (); + +#ifndef DBUS_DISABLE_ASSERT + g_printerr ("You should probably --disable-asserts before you profile as they have noticeable overhead\n"); +#endif + +#if DBUS_ENABLE_VERBOSE_MODE + g_printerr ("You should probably --disable-verbose-mode before you profile as verbose has noticeable overhead\n"); +#endif + + payload = g_malloc (PAYLOAD_SIZE); + + /* The actual size of the DBusMessage on the wire, as of Nov 23 2004, + * without the payload + */ + echo_call_size = 140 + PAYLOAD_SIZE; + echo_return_size = 32; + + if (argc > 1 && strcmp (argv[1], "plain_sockets") == 0) + do_profile_run (&plain_sockets_vtable); + else if (argc > 1 && strcmp (argv[1], "plain_sockets_with_malloc") == 0) + do_profile_run (&plain_sockets_with_malloc_vtable); + else if (argc > 1 && strcmp (argv[1], "no_bus") == 0) + do_profile_run (&no_bus_vtable); + else if (argc > 1 && strcmp (argv[1], "with_bus") == 0) + do_profile_run (&with_bus_vtable); + else if (argc > 1 && strcmp (argv[1], "all") == 0) + { + double e1, e2, e3, e4; + + e1 = do_profile_run (&plain_sockets_vtable); + e2 = do_profile_run (&plain_sockets_with_malloc_vtable); + e3 = do_profile_run (&no_bus_vtable); + e4 = do_profile_run (&with_bus_vtable); + + g_printerr ("Baseline plain sockets time %g seconds for %d iterations\n", + e1, N_ITERATIONS); + print_result (&plain_sockets_vtable, e1, e1); + print_result (&plain_sockets_with_malloc_vtable, e2, e1); + print_result (&no_bus_vtable, e3, e1); + print_result (&with_bus_vtable, e4, e1); + } + else + { + g_printerr ("Specify profile type plain_sockets, plain_sockets_with_malloc, no_bus, with_bus, all\n"); + exit (1); + } + + /* Make valgrind happy */ + dbus_shutdown (); +#endif /* TEST_PROFILE_DISABLED */ + return 0; +} diff --git a/test/core/test-service-glib-subclass.xml b/test/core/test-service-glib-subclass.xml new file mode 100644 index 0000000..ffa34de --- /dev/null +++ b/test/core/test-service-glib-subclass.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<node name="/org/freedesktop/DBus/GLib/Tests/MyTestObjectSubclass"> + <interface name="org.freedesktop.DBus.GLib.Tests.MyObjectSubclass"> + <property name="this_is_a_subclass_string" type="s" access="readwrite"/> + <property name="this_is_a_subclass_uint" type="u" access="readwrite"/> + </interface> +</node> diff --git a/test/core/test-service-glib.c b/test/core/test-service-glib.c new file mode 100644 index 0000000..0568e40 --- /dev/null +++ b/test/core/test-service-glib.c @@ -0,0 +1,112 @@ +#include <config.h> + +/* -*- mode: C; c-file-style: "gnu" -*- */ +#include <dbus/dbus-glib.h> +/* NOTE - outside of D-BUS core this would be + * include <dbus/dbus-glib-bindings.h> + */ +#include "tools/dbus-glib-bindings.h" +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <glib/gi18n.h> +#include <glib-object.h> + +#include "my-object.h" +#include "my-object-subclass.h" + +static GObject *obj; +static GObject *obj2; +static GObject *subobj; +GMainLoop *loop; + +#define TEST_SERVICE_NAME "org.freedesktop.DBus.GLib.TestService" + +int +main (int argc, char **argv) +{ + DBusGConnection *connection; + GError *error; + DBusGProxy *driver_proxy; + guint32 request_name_ret; + + g_type_init (); + g_thread_init (NULL); dbus_g_thread_init (); + + dbus_g_error_domain_register (MY_OBJECT_ERROR, + NULL, + MY_TYPE_ERROR); + + g_printerr ("Launching test-service-glib\n"); + + loop = g_main_loop_new (NULL, FALSE); + + { + GLogLevelFlags fatal_mask; + + fatal_mask = g_log_set_always_fatal (G_LOG_FATAL_MASK); + fatal_mask |= G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL; + g_log_set_always_fatal (fatal_mask); + } + + error = NULL; + connection = dbus_g_bus_get (DBUS_BUS_STARTER, + &error); + if (connection == NULL) + { + g_printerr ("Failed to open connection to bus: %s\n", + error->message); + g_error_free (error); + exit (1); + } + + obj = g_object_new (MY_TYPE_OBJECT, NULL); + obj2 = g_object_new (MY_TYPE_OBJECT, NULL); + subobj = g_object_new (MY_TYPE_OBJECT_SUBCLASS, NULL); + + dbus_g_connection_register_g_object (connection, + "/org/freedesktop/DBus/GLib/Tests/MyTestObject", + obj); + /* Register a second time; we want the object to also be reachable through this interface */ + dbus_g_connection_register_g_object (connection, + "/org/freedesktop/DBus/GLib/Tests/Compat/MyTestObjectCompat", + obj); + dbus_g_connection_register_g_object (connection, + "/org/freedesktop/DBus/GLib/Tests/MyTestObject2", + obj2); + + dbus_g_connection_register_g_object (connection, + "/org/freedesktop/DBus/GLib/Tests/MyTestObjectSubclass", + subobj); + + driver_proxy = dbus_g_proxy_new_for_name (connection, + DBUS_SERVICE_DBUS, + DBUS_PATH_DBUS, + DBUS_INTERFACE_DBUS); + + if (!org_freedesktop_DBus_request_name (driver_proxy, + TEST_SERVICE_NAME, + 0, &request_name_ret, &error)) + { + g_assert (error != NULL); + g_printerr ("Failed to get name: %s\n", + error->message); + g_clear_error (&error); + exit (1); + } + + if (!(request_name_ret == DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER)) + { + g_printerr ("Got result code %u from requesting name\n", request_name_ret); + exit (1); + } + + g_printerr ("GLib test service has name '%s'\n", TEST_SERVICE_NAME); + g_printerr ("GLib test service entering main loop\n"); + + g_main_loop_run (loop); + + g_printerr ("Successfully completed %s\n", argv[0]); + + return 0; +} diff --git a/test/core/test-service-glib.xml b/test/core/test-service-glib.xml new file mode 100644 index 0000000..d91620c --- /dev/null +++ b/test/core/test-service-glib.xml @@ -0,0 +1,210 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<node name="/org/freedesktop/DBus/GLib/Tests/MyTestObject"> + <interface name="org.freedesktop.DBus.GLib.Tests.MyObject"> + <property name="this_is_a_string" type="s" access="readwrite"/> + <property name="no-touching" type="u" access="read"/> + <property name="SuperStudly" type="d" access="readwrite"/> + + <method name="DoNothing"> + </method> + + <method name="Increment"> + <arg type="u" name="x" /> + <arg type="u" direction="out" /> + </method> + + <method name="IncrementRetval"> + <arg type="u" name="x" /> + <arg type="u" direction="out"> + <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/> + </arg> + </method> + + <method name="IncrementRetvalError"> + <arg type="u" name="x" /> + <arg type="u" direction="out"> + <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value="error"/> + </arg> + </method> + + <method name="ThrowError"> + </method> + + <method name="ThrowUnregisteredError"> + </method> + + <method name="Uppercase"> + <arg type="s" direction="in" /> + <arg type="s" direction="out" /> + </method> + + <method name="ManyArgs"> + <arg type="u" name="x" direction="in" /> + <arg type="s" name="str" direction="in" /> + <arg type="d" name="trouble" direction="in" /> + <arg type="d" name="d_ret" direction="out" /> + <arg type="s" name="str_ret" direction="out" /> + </method> + + <method name="ManyReturn"> + <arg type="u" direction="out" /> + <arg type="s" direction="out" /> + <arg type="i" direction="out" /> + <arg type="u" direction="out" /> + <arg type="u" direction="out" /> + <arg type="s" direction="out"> + <annotation name="org.freedesktop.DBus.GLib.Const" value=""/> + </arg> + </method> + + <method name="Stringify"> + <arg type="v" name="val" direction="in"/> + <arg type="s" direction="out"/> + </method> + + <method name="Unstringify"> + <arg type="s" name="val" direction="in"/> + <arg type="v" direction="out"/> + </method> + + <method name="Recursive1"> + <arg type="au" direction="in"/> + <arg type="u" direction="out"/> + </method> + + <method name="Recursive2"> + <arg type="u" direction="in"/> + <arg type="au" direction="out"/> + </method> + + <method name="ManyUppercase"> + <arg type="as" direction="in"/> + <arg type="as" direction="out"/> + </method> + + <method name="StrHashLen"> + <arg type="a{ss}" direction="in"/> + <arg type="u" direction="out"/> + </method> + + <method name="SendCar"> + <arg type="(suv)" direction="in"/> + <arg type="(uo)" direction="out"/> + </method> + + <method name="GetHash"> + <arg type="a{ss}" direction="out"/> + </method> + + <method name="RecArrays"> + <arg type="aas" name="val" direction="in"/> + <arg type="aau" direction="out"/> + </method> + + <method name="Objpath"> + <arg type="o" direction="in"/> + <arg type="o" direction="out"> + <annotation name="org.freedesktop.DBus.GLib.Const" value=""/> + </arg> + </method> + + <method name="GetObjs"> + <arg type="ao" direction="out"/> + </method> + + <method name="IncrementVal"> + </method> + + <method name="AsyncIncrement"> + <annotation name="org.freedesktop.DBus.GLib.Async" value=""/> + <arg type="u" name="x" /> + <arg type="u" direction="out" /> + </method> + + <method name="AsyncThrowError"> + <annotation name="org.freedesktop.DBus.GLib.Async" value=""/> + </method> + + <method name="GetVal"> + <arg type="u" direction="out" /> + </method> + + <method name="ManyStringify"> + <arg type="a{sv}" direction="in"/> + <arg type="a{sv}" direction="out"/> + </method> + + <method name="EchoVariant"> + <arg type="v" direction="in" /> + <arg type="v" direction="out" /> + </method> + + <method name="EchoSignature"> + <arg type="g" direction="in" /> + <arg type="g" direction="out" /> + </method> + + <method name="ProcessVariantOfArrayOfInts123"> + <arg type="v" direction="in" /> + </method> + + <method name="DictOfDicts"> + <arg type="a{sa{ss}}" direction="in"/> + <arg type="a{sa{ss}}" direction="out"/> + </method> + + <method name="DictOfSigs"> + <annotation name="org.freedesktop.DBus.GLib.Async" value=""/> + <arg type="a{gas}" direction="in" /> + <arg type="a{gas}" direction="out" /> + </method> + + <method name="DictOfObjs"> + <annotation name="org.freedesktop.DBus.GLib.Async" value=""/> + <arg type="a{oao}" direction="in" /> + <arg type="a{oao}" direction="out" /> + </method> + + <method name="EmitFrobnicate"> + </method> + + <method name="UnsafeDisableLegacyPropertyAccess"> + </method> + + <!-- Export signals --> + <signal name="Frobnicate"/> + + <signal name="Objectified"> + <arg type="o"/> + </signal> + + <method name="Terminate"> + </method> + </interface> + + <!-- Test multiple interfaces on the same object --> + + <interface name="org.freedesktop.DBus.GLib.Tests.FooObject"> + <method name="GetValue"> + <arg type="u" direction="out" /> + </method> + + <method name="EmitSignals"> + </method> + + <signal name="Sig0"/> + + <signal name="Sig1"/> + + <method name="EmitSignal2"> + </method> + + <signal name="Sig2"/> + + <method name="Terminate"> + </method> + + </interface> + +</node> diff --git a/test/core/test-thread-client.c b/test/core/test-thread-client.c new file mode 100644 index 0000000..ef8a3ef --- /dev/null +++ b/test/core/test-thread-client.c @@ -0,0 +1,100 @@ +#include <config.h> + +#include <glib.h> +#include <dbus/dbus-glib-lowlevel.h> +#include <stdio.h> +#include <string.h> +#include <unistd.h> + +#include "test-thread.h" + +DBusConnection *connection; + +static gpointer +thread_func (gpointer data) +{ + gint32 threadnr = GPOINTER_TO_INT (data); + guint32 counter = 0; + DBusMessageIter iter; + DBusMessage *message; + char *str; + + while (1) + { + message = dbus_message_new_method_call (NULL, + "/org/freedesktop/DBus/GLib/ThreadTest", + "org.freedesktop.DBus.GLib.ThreadTest", + "TestMethod"); + + dbus_message_iter_init_append (message, &iter); + + if (!dbus_message_iter_append_basic (&iter, DBUS_TYPE_INT32, &threadnr)) + { + g_print ("thread %d: append threadnr failed\n", threadnr); + } + + if (!dbus_message_iter_append_basic (&iter, DBUS_TYPE_INT32, &counter)) + { + g_print ("thread %d: append counter (%d) failed\n", threadnr, counter); + } + + str = g_strdup_printf ("Thread %d-%d\n", threadnr, counter); + if (!dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &str)) + { + g_print ("thread %d: append string (%s) failed\n", threadnr, str); + } + g_free (str); + + if (!dbus_connection_send (connection, + message, + NULL)) + { + g_print ("thread %d: send message failed\n", threadnr); + } + + dbus_message_unref (message); + + counter ++; + } + + return NULL; +} + +int +main (int argc, char *argv[]) +{ + GMainLoop *loop; + DBusError error; + int i; + + g_thread_init (NULL); + dbus_g_thread_init (); + + if(argc < 2) + { + g_error("Need an address as argv[1]\n"); + return 1; + } + + dbus_error_init (&error); + connection = dbus_connection_open (argv[1], &error); + if (connection == NULL) + { + g_printerr ("could not open connection: %s\n", error.message); + dbus_error_free (&error); + return 1; + } + + dbus_connection_setup_with_g_main (connection, NULL); + + for (i = 0; i < N_TEST_THREADS; i++) + { + g_thread_create (thread_func, GINT_TO_POINTER (i), FALSE, NULL); + } + + loop = g_main_loop_new (NULL, FALSE); + g_main_loop_run (loop); + + return 0; +} + diff --git a/test/core/test-thread-server.c b/test/core/test-thread-server.c new file mode 100644 index 0000000..578b66d --- /dev/null +++ b/test/core/test-thread-server.c @@ -0,0 +1,212 @@ +#include <config.h> + +#include <glib.h> +#include <dbus/dbus-glib-lowlevel.h> +#include <stdio.h> +#include <string.h> + +#include "test-thread.h" + +typedef struct { + guint32 counters[N_TEST_THREADS]; +} ThreadTestData; + +static ThreadTestData * +thread_test_data_new (void) +{ + ThreadTestData *data; + + data = g_new0 (ThreadTestData, 1); + + return data; +} + +static void +thread_test_data_free (ThreadTestData *data) +{ + g_free (data); +} + +static DBusHandlerResult +filter_test_message (DBusConnection *connection, + DBusMessage *message, + void *user_data) +{ + ThreadTestData *data = user_data; + DBusMessageIter iter; + gint32 threadnr; + guint32 counter; + const char *str; + char *expected_str; + GString *counter_str; + int i; + + if (!dbus_message_is_method_call (message, "org.freedesktop.DBus.GLib.ThreadTest", + "TestMethod")) + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + + dbus_message_iter_init (message, &iter); + + if (dbus_message_iter_get_arg_type (&iter) != DBUS_TYPE_INT32) + { + g_print ("First arg not right type\n"); + goto out; + } + dbus_message_iter_get_basic (&iter, &threadnr); + if (threadnr < 0 || threadnr >= N_TEST_THREADS) + { + g_print ("Invalid thread nr\n"); + goto out; + } + + if (! dbus_message_iter_next (&iter)) + { + g_print ("Couldn't get second arg\n"); + goto out; + } + + if (dbus_message_iter_get_arg_type (&iter) != DBUS_TYPE_INT32) + { + g_print ("Second arg not right type\n"); + goto out; + } + + dbus_message_iter_get_basic (&iter, &counter); + + if (counter != data->counters[threadnr]) + { + g_print ("Thread %d, counter %d, expected %d\n", threadnr, counter, data->counters[threadnr]); + goto out; + } + data->counters[threadnr]++; + + if (! dbus_message_iter_next (&iter)) + { + g_print ("Couldn't get third arg\n"); + goto out; + } + + if (dbus_message_iter_get_arg_type (&iter) != DBUS_TYPE_STRING) + { + g_print ("Third arg not right type\n"); + goto out; + } + + dbus_message_iter_get_basic (&iter, &str); + + if (str == NULL) + { + g_print ("No third arg\n"); + goto out; + } + + expected_str = g_strdup_printf ("Thread %d-%d\n", threadnr, counter); + if (strcmp (expected_str, str) != 0) + { + g_print ("Wrong string '%s', expected '%s'\n", str, expected_str); + g_free (expected_str); + goto out; + } + g_free (expected_str); + + if (dbus_message_iter_next (&iter)) + { + g_print ("Extra args on end of message\n"); + goto out; + } + + dbus_connection_flush (connection); + + counter_str = g_string_new (""); + for (i = 0; i < N_TEST_THREADS; i++) + { + g_string_append_printf (counter_str, "%d ", data->counters[i]); + } + g_print ("%s\r", counter_str->str); + g_string_free (counter_str, TRUE); + + out: + return DBUS_HANDLER_RESULT_HANDLED; +} + +static DBusHandlerResult +filter_disconnect (DBusConnection *connection, + DBusMessage *message, + void *user_data) +{ + if (!dbus_message_is_signal (message, DBUS_INTERFACE_LOCAL, + "Disconnected")) + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + + g_print ("connection disconnected\n"); + dbus_connection_unref (connection); + + return DBUS_HANDLER_RESULT_HANDLED; +} + +static void +new_connection_callback (DBusServer *server, + DBusConnection *new_connection, + void *user_data) +{ + ThreadTestData * data; + + g_print ("new_connection_callback\n"); + + dbus_connection_ref (new_connection); + dbus_connection_setup_with_g_main (new_connection, NULL); + + data = thread_test_data_new (); + + if (!dbus_connection_add_filter (new_connection, + filter_test_message, data, + (DBusFreeFunction) thread_test_data_free)) + goto nomem; + + if (!dbus_connection_add_filter (new_connection, + filter_disconnect, NULL, NULL)) + goto nomem; + + return; + + nomem: + g_error ("no memory to setup new connection"); +} + +int +main (int argc, char *argv[]) +{ + GMainLoop *loop; + DBusServer *server; + DBusError error; + + g_thread_init (NULL); + dbus_g_thread_init (); + + if (argc < 2) + { + fprintf (stderr, "Give the server address as an argument\n"); + return 1; + } + + dbus_error_init (&error); + server = dbus_server_listen (argv[1], &error); + if (server == NULL) + { + fprintf (stderr, "Failed to start server on %s: %s\n", + argv[1], error.message); + dbus_error_free (&error); + return 1; + } + + dbus_server_set_new_connection_function (server, + new_connection_callback, + NULL, NULL); + + dbus_server_setup_with_g_main (server, NULL); + + loop = g_main_loop_new (NULL, FALSE); + g_main_loop_run (loop); + + return 0; +} diff --git a/test/core/test-thread.h b/test/core/test-thread.h new file mode 100644 index 0000000..8c78fba --- /dev/null +++ b/test/core/test-thread.h @@ -0,0 +1 @@ +#define N_TEST_THREADS 5 diff --git a/test/core/test-types.c b/test/core/test-types.c new file mode 100644 index 0000000..c6c6dd3 --- /dev/null +++ b/test/core/test-types.c @@ -0,0 +1,50 @@ +#include <config.h> + +#include <stdio.h> +#include <stdlib.h> +#include <dbus-glib.h> +#include <dbus-glib-lowlevel.h> + +static void +lose (const char *str, ...) +{ + va_list args; + + va_start (args, str); + + vfprintf (stderr, str, args); + fputc ('\n', stderr); + + va_end (args); + + exit (1); +} + +int +main (int argc, char **argv) +{ + DBusError derror; + GError *gerror = NULL; + DBusGConnection *gconn, *gconn2; + DBusConnection *conn; + + g_type_init (); + dbus_error_init (&derror); + + /* Check DBusGConnection -> DBusConnection -> DBusGConnection */ + gconn = dbus_g_bus_get (DBUS_BUS_SESSION, &gerror); + if (!gconn) + lose ("Cannot get connection: %s", gerror->message); + + conn = dbus_g_connection_get_connection (gconn); + if (!conn) + lose ("Cannot get DBusConnection from DBusGConnection"); + + gconn2 = dbus_connection_get_g_connection (conn); + if (gconn != gconn2) + lose ("Retrieved DBusGConection != original DBusGConnection"); + + dbus_g_connection_unref (gconn); + + return 0; +} diff --git a/test/core/test-variant-recursion.c b/test/core/test-variant-recursion.c new file mode 100644 index 0000000..4229c2b --- /dev/null +++ b/test/core/test-variant-recursion.c @@ -0,0 +1,93 @@ +#include <config.h> + +/* -*- mode: C; c-file-style: "gnu" -*- */ +#include <dbus/dbus-glib.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <glib.h> +#include <glib-object.h> + +static gboolean +make_recursive_stringify_call (int recursion_depth, + DBusGProxy *proxy, + GError **error) +{ + char *out_str; + + int i; + GValue *vals = g_new0 (GValue, recursion_depth+1); + + for (i = recursion_depth-1; i >= 0; i--) + { + GValue *curval = &(vals[i]); + g_value_init (curval, G_TYPE_VALUE); + } + for (i = 0; i < recursion_depth; i++) + { + GValue *curval = &(vals[i]); + GValue *nextval = &(vals[i+1]); + g_value_take_boxed (curval, nextval); + } + g_value_init (&(vals[recursion_depth]), G_TYPE_STRING); + g_value_set_string (&(vals[recursion_depth]), "end of the line"); + return dbus_g_proxy_call (proxy, "Stringify", error, + G_TYPE_VALUE, &(vals[0]), + G_TYPE_INVALID, + G_TYPE_STRING, &out_str, + G_TYPE_INVALID); +} + +int +main (int argc, char **argv) +{ + DBusGConnection *connection; + GError *error = NULL; + DBusGProxy *proxy; + GMainLoop *loop; + + g_type_init (); + + g_log_set_always_fatal (G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL); + + loop = g_main_loop_new (NULL, FALSE); + + connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error); + if (connection == NULL) + g_error ("Failed to open connection to bus: %s", error->message); + + proxy = dbus_g_proxy_new_for_name (connection, + "org.freedesktop.DBus.GLib.TestService", + "/org/freedesktop/DBus/GLib/Tests/MyTestObject", + "org.freedesktop.DBus.GLib.Tests.MyObject"); + + if (proxy == NULL) + g_error ("Failed to create proxy for name owner: %s", error->message); + + /* Do an echo to be sure it started */ + if (!dbus_g_proxy_call (proxy, "DoNothing", &error, + G_TYPE_INVALID, + G_TYPE_INVALID)) + g_error ("Failed to complete DoNothing call: %s", error->message); + + /* Fewer than the current internal limit (16) */ + if (make_recursive_stringify_call (10, proxy, &error)) + g_error ("Unexpected success code from 10 recursive variant call: %s", error->message); + if (error->code != DBUS_GERROR_REMOTE_EXCEPTION) + g_error ("Error code was not remote exception: %s", error->message); + g_printerr ("Got expected error %d: \"%s\" from recursive variant call\n", error->code, error->message); + g_clear_error (&error); + /* More than the current internal limit (16) */ + if (make_recursive_stringify_call (50, proxy, &error)) + g_error ("Unexpected success code from 50 recursive variant call: %s", error->message); + if (error->code != DBUS_GERROR_REMOTE_EXCEPTION) + g_error ("Error code was not remote exception: %s", error->message); + g_printerr ("Got expected error %d: \"%s\" from recursive variant call\n", error->code, error->message); + g_clear_error (&error); + + g_object_unref (G_OBJECT (proxy)); + + g_main_loop_unref (loop); + + return 0; +} diff --git a/test/data/nested-introspect.xml b/test/data/nested-introspect.xml new file mode 100644 index 0000000..6a88b31 --- /dev/null +++ b/test/data/nested-introspect.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!-- http://bugs.freedesktop.org/show_bug.cgi?id=19065 --> +<node name="/"> + <node name="org"> + <interface name="org.dummy"> + <method name="mycall"> + </method> + </interface> + </node> +</node> diff --git a/test/data/valid-service-files/debug-echo.service.in b/test/data/valid-service-files/debug-echo.service.in new file mode 100644 index 0000000..735a98a --- /dev/null +++ b/test/data/valid-service-files/debug-echo.service.in @@ -0,0 +1,3 @@ +[D-BUS Service] +Name=org.freedesktop.DBus.GLib.TestEchoService +Exec=@TEST_SERVICE_BINARY@ diff --git a/test/data/valid-service-files/debug-glib.service.in b/test/data/valid-service-files/debug-glib.service.in new file mode 100644 index 0000000..d0d3761 --- /dev/null +++ b/test/data/valid-service-files/debug-glib.service.in @@ -0,0 +1,3 @@ +[D-BUS Service] +Name=org.freedesktop.DBus.GLib.TestService +Exec=@TEST_CORE_SERVICE_BINARY@ diff --git a/test/data/valid-service-files/interfaces-test.service.in b/test/data/valid-service-files/interfaces-test.service.in new file mode 100644 index 0000000..8710d5c --- /dev/null +++ b/test/data/valid-service-files/interfaces-test.service.in @@ -0,0 +1,3 @@ +[D-BUS Service] +Name=org.freedesktop.DBus.GLib.Test.Interfaces +Exec=@TEST_INTERFACES_SERVICE_BINARY@ diff --git a/test/interfaces/Makefile.am b/test/interfaces/Makefile.am new file mode 100644 index 0000000..3e83482 --- /dev/null +++ b/test/interfaces/Makefile.am @@ -0,0 +1,120 @@ +INCLUDES = \ + -I$(top_srcdir) \ + -I$(top_builddir) \ + -I$(top_builddir)/dbus \ + $(DBUS_CFLAGS) \ + $(DBUS_GLIB_CFLAGS) \ + -DDBUS_COMPILATION + +LDADD = $(DBUS_GLIB_LIBS) \ + $(top_builddir)/dbus/libdbus-glib-1.la \ + $(top_builddir)/dbus/libdbus-gtool.la \ + $(top_builddir)/test/lib/libtest.la \ + $(NULL) + +## 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 +if DBUS_BUILD_TESTS +TESTS_ENVIRONMENT = \ + DBUS_TOP_BUILDDIR=$(ABSOLUTE_TOP_BUILDDIR) \ + DBUS_BINDING_TOOL=$(DBUS_BINDING_TOOL) \ + $(NULL) +TESTS=run-test.sh +else +TESTS= +endif + +EXTRA_DIST = \ + invalid-annotated-node.xml \ + invalid-nested-annotation.xml \ + run-test.sh \ + test-goodbye.xml \ + test-hello.xml \ + test-song.xml \ + test-dup-prop-a.xml \ + test-dup-prop-b.xml \ + valid-annotations.xml \ + $(NULL) + +if DBUS_BUILD_TESTS + +## we use noinst_PROGRAMS not check_PROGRAMS for TESTS so that we +## build even when not doing "make check" +noinst_PROGRAMS = test-service test-client + +test_service_SOURCES = \ + test-interfaces.c \ + test-interfaces.h \ + test-dup-prop.c \ + test-dup-prop.h \ + test-objects.c \ + test-objects.h \ + test-server.c + +test_client_SOURCES = \ + test-client.c + +BUILT_SOURCES = \ + test-song-glue.h \ + test-hello-glue.h \ + test-goodbye-glue.h \ + test-dup-prop-a-glue.h \ + test-dup-prop-b-glue.h \ + test-song-bindings.h \ + test-hello-bindings.h \ + test-goodbye-bindings.h \ + test-dup-prop-a-bindings.h \ + test-dup-prop-a-bindings.h \ + test-dup-prop-b-bindings.h \ + test-dup-prop-b-bindings.h \ + valid-annotations-glue.h \ + valid-annotations-bindings.h \ + $(NULL) + +test-song-glue.h: test-song.xml $(top_builddir)/dbus/dbus-binding-tool$(EXEEXT) + $(DBUS_BINDING_TOOL) --prefix=test_song --mode=glib-server --output=test-song-glue.h $(srcdir)/test-song.xml + +test-song-bindings.h: test-song.xml $(top_builddir)/dbus/dbus-binding-tool$(EXEEXT) + $(DBUS_BINDING_TOOL) --prefix=test_song --mode=glib-client --output=test-song-bindings.h $(srcdir)/test-song.xml + +test-hello-glue.h: test-hello.xml $(top_builddir)/dbus/dbus-binding-tool$(EXEEXT) + $(DBUS_BINDING_TOOL) --prefix=test_hello --mode=glib-server --output=test-hello-glue.h $(srcdir)/test-hello.xml + +test-hello-bindings.h: test-hello.xml $(top_builddir)/dbus/dbus-binding-tool$(EXEEXT) + $(DBUS_BINDING_TOOL) --prefix=test_hello --mode=glib-client --output=test-hello-bindings.h $(srcdir)/test-hello.xml + +test-goodbye-glue.h: test-goodbye.xml $(top_builddir)/dbus/dbus-binding-tool$(EXEEXT) + $(DBUS_BINDING_TOOL) --prefix=test_goodbye --mode=glib-server --output=test-goodbye-glue.h $(srcdir)/test-goodbye.xml + +test-goodbye-bindings.h: test-goodbye.xml $(top_builddir)/dbus/dbus-binding-tool$(EXEEXT) + $(DBUS_BINDING_TOOL) --prefix=test_goodbye --mode=glib-client --output=test-goodbye-bindings.h $(srcdir)/test-goodbye.xml + +test-dup-prop-a-glue.h: test-dup-prop-a.xml $(top_builddir)/dbus/dbus-binding-tool$(EXEEXT) + $(DBUS_BINDING_TOOL) --prefix=test_dup_prop_a --mode=glib-server --output=test-dup-prop-a-glue.h $(srcdir)/test-dup-prop-a.xml + +test-dup-prop-a-bindings.h: test-dup-prop-a.xml $(top_builddir)/dbus/dbus-binding-tool$(EXEEXT) + $(DBUS_BINDING_TOOL) --prefix=test_dup_prop_a --mode=glib-client --output=test-dup-prop-a-bindings.h $(srcdir)/test-dup-prop-a.xml + +test-dup-prop-b-glue.h: test-dup-prop-b.xml $(top_builddir)/dbus/dbus-binding-tool$(EXEEXT) + $(DBUS_BINDING_TOOL) --prefix=test_dup_prop_b --mode=glib-server --output=test-dup-prop-b-glue.h $(srcdir)/test-dup-prop-b.xml + +test-dup-prop-b-bindings.h: test-dup-prop-b.xml $(top_builddir)/dbus/dbus-binding-tool$(EXEEXT) + $(DBUS_BINDING_TOOL) --prefix=test_dup_prop_b --mode=glib-client --output=test-dup-prop-b-bindings.h $(srcdir)/test-dup-prop-b.xml + +valid-annotations-glue.h: valid-annotations.xml $(top_builddir)/dbus/dbus-binding-tool$(EXEEXT) + $(DBUS_BINDING_TOOL) --prefix=test_annotated --mode=glib-server --output=$@ $< + +valid-annotations-bindings.h: valid-annotations.xml $(top_builddir)/dbus/dbus-binding-tool$(EXEEXT) + $(DBUS_BINDING_TOOL) --prefix=test_annotated --mode=glib-client --output=$@ $< + +CLEANFILES = \ + $(BUILT_SOURCES) \ + run-with-tmp-session-bus.conf + +else +### not building tests + + +endif + diff --git a/test/interfaces/Makefile.in b/test/interfaces/Makefile.in new file mode 100644 index 0000000..ec1f870 --- /dev/null +++ b/test/interfaces/Makefile.in @@ -0,0 +1,785 @@ +# Makefile.in generated by automake 1.11.5 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software +# Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +VPATH = @srcdir@ +am__make_dryrun = \ + { \ + am__dry=no; \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \ + | grep '^AM OK$$' >/dev/null || am__dry=yes;; \ + *) \ + for am__flg in $$MAKEFLAGS; do \ + case $$am__flg in \ + *=*|--*) ;; \ + *n*) am__dry=yes; break;; \ + esac; \ + done;; \ + esac; \ + test $$am__dry = yes; \ + } +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +@DBUS_BUILD_TESTS_TRUE@TESTS = run-test.sh +@DBUS_BUILD_TESTS_TRUE@noinst_PROGRAMS = test-service$(EXEEXT) \ +@DBUS_BUILD_TESTS_TRUE@ test-client$(EXEEXT) +subdir = test/interfaces +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/gtk-doc.m4 \ + $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ + $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ + $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +PROGRAMS = $(noinst_PROGRAMS) +am__test_client_SOURCES_DIST = test-client.c +@DBUS_BUILD_TESTS_TRUE@am_test_client_OBJECTS = test-client.$(OBJEXT) +test_client_OBJECTS = $(am_test_client_OBJECTS) +test_client_LDADD = $(LDADD) +am__DEPENDENCIES_1 = +test_client_DEPENDENCIES = $(am__DEPENDENCIES_1) \ + $(top_builddir)/dbus/libdbus-glib-1.la \ + $(top_builddir)/dbus/libdbus-gtool.la \ + $(top_builddir)/test/lib/libtest.la +AM_V_lt = $(am__v_lt_@AM_V@) +am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) +am__v_lt_0 = --silent +am__test_service_SOURCES_DIST = test-interfaces.c test-interfaces.h \ + test-dup-prop.c test-dup-prop.h test-objects.c test-objects.h \ + test-server.c +@DBUS_BUILD_TESTS_TRUE@am_test_service_OBJECTS = \ +@DBUS_BUILD_TESTS_TRUE@ test-interfaces.$(OBJEXT) \ +@DBUS_BUILD_TESTS_TRUE@ test-dup-prop.$(OBJEXT) \ +@DBUS_BUILD_TESTS_TRUE@ test-objects.$(OBJEXT) \ +@DBUS_BUILD_TESTS_TRUE@ test-server.$(OBJEXT) +test_service_OBJECTS = $(am_test_service_OBJECTS) +test_service_LDADD = $(LDADD) +test_service_DEPENDENCIES = $(am__DEPENDENCIES_1) \ + $(top_builddir)/dbus/libdbus-glib-1.la \ + $(top_builddir)/dbus/libdbus-gtool.la \ + $(top_builddir)/test/lib/libtest.la +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CFLAGS) $(CFLAGS) +AM_V_CC = $(am__v_CC_@AM_V@) +am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) +am__v_CC_0 = @echo " CC " $@; +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ +CCLD = $(CC) +LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +AM_V_CCLD = $(am__v_CCLD_@AM_V@) +am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) +am__v_CCLD_0 = @echo " CCLD " $@; +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; +SOURCES = $(test_client_SOURCES) $(test_service_SOURCES) +DIST_SOURCES = $(am__test_client_SOURCES_DIST) \ + $(am__test_service_SOURCES_DIST) +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +ETAGS = etags +CTAGS = ctags +am__tty_colors = \ +red=; grn=; lgn=; blu=; std= +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ABSOLUTE_TOP_BUILDDIR = @ABSOLUTE_TOP_BUILDDIR@ +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DBUS_BINDING_TOOL = @DBUS_BINDING_TOOL@ +DBUS_CFLAGS = @DBUS_CFLAGS@ +DBUS_GLIB_CFLAGS = @DBUS_GLIB_CFLAGS@ +DBUS_GLIB_LIBS = @DBUS_GLIB_LIBS@ +DBUS_GLIB_THREADS_CFLAGS = @DBUS_GLIB_THREADS_CFLAGS@ +DBUS_GLIB_THREADS_LIBS = @DBUS_GLIB_THREADS_LIBS@ +DBUS_GLIB_TOOL_CFLAGS = @DBUS_GLIB_TOOL_CFLAGS@ +DBUS_GLIB_TOOL_LIBS = @DBUS_GLIB_TOOL_LIBS@ +DBUS_LIBS = @DBUS_LIBS@ +DBUS_PATH_OR_ABSTRACT = @DBUS_PATH_OR_ABSTRACT@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +EXPANDED_BINDIR = @EXPANDED_BINDIR@ +EXPANDED_DATADIR = @EXPANDED_DATADIR@ +EXPANDED_LIBDIR = @EXPANDED_LIBDIR@ +EXPANDED_LOCALSTATEDIR = @EXPANDED_LOCALSTATEDIR@ +EXPANDED_SYSCONFDIR = @EXPANDED_SYSCONFDIR@ +FGREP = @FGREP@ +GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ +GREP = @GREP@ +GTKDOC_CHECK = @GTKDOC_CHECK@ +GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@ +GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@ +GTKDOC_MKPDF = @GTKDOC_MKPDF@ +GTKDOC_REBASE = @GTKDOC_REBASE@ +HTML_DIR = @HTML_DIR@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +LT_AGE = @LT_AGE@ +LT_CURRENT = @LT_CURRENT@ +LT_REVISION = @LT_REVISION@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ +MKDIR_P = @MKDIR_P@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PKG_CONFIG = @PKG_CONFIG@ +PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ +PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +TEST_CORE_SERVICE_BINARY = @TEST_CORE_SERVICE_BINARY@ +TEST_EXIT_BINARY = @TEST_EXIT_BINARY@ +TEST_INTERFACES_SERVICE_BINARY = @TEST_INTERFACES_SERVICE_BINARY@ +TEST_SEGFAULT_BINARY = @TEST_SEGFAULT_BINARY@ +TEST_SERVICE_BINARY = @TEST_SERVICE_BINARY@ +TEST_SERVICE_DIR = @TEST_SERVICE_DIR@ +TEST_SHELL_SERVICE_BINARY = @TEST_SHELL_SERVICE_BINARY@ +TEST_SLEEP_FOREVER_BINARY = @TEST_SLEEP_FOREVER_BINARY@ +TEST_SOCKET_DIR = @TEST_SOCKET_DIR@ +VERSION = @VERSION@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +INCLUDES = \ + -I$(top_srcdir) \ + -I$(top_builddir) \ + -I$(top_builddir)/dbus \ + $(DBUS_CFLAGS) \ + $(DBUS_GLIB_CFLAGS) \ + -DDBUS_COMPILATION + +LDADD = $(DBUS_GLIB_LIBS) \ + $(top_builddir)/dbus/libdbus-glib-1.la \ + $(top_builddir)/dbus/libdbus-gtool.la \ + $(top_builddir)/test/lib/libtest.la \ + $(NULL) + +@DBUS_BUILD_TESTS_TRUE@TESTS_ENVIRONMENT = \ +@DBUS_BUILD_TESTS_TRUE@ DBUS_TOP_BUILDDIR=$(ABSOLUTE_TOP_BUILDDIR) \ +@DBUS_BUILD_TESTS_TRUE@ DBUS_BINDING_TOOL=$(DBUS_BINDING_TOOL) \ +@DBUS_BUILD_TESTS_TRUE@ $(NULL) + +EXTRA_DIST = \ + invalid-annotated-node.xml \ + invalid-nested-annotation.xml \ + run-test.sh \ + test-goodbye.xml \ + test-hello.xml \ + test-song.xml \ + test-dup-prop-a.xml \ + test-dup-prop-b.xml \ + valid-annotations.xml \ + $(NULL) + +@DBUS_BUILD_TESTS_TRUE@test_service_SOURCES = \ +@DBUS_BUILD_TESTS_TRUE@ test-interfaces.c \ +@DBUS_BUILD_TESTS_TRUE@ test-interfaces.h \ +@DBUS_BUILD_TESTS_TRUE@ test-dup-prop.c \ +@DBUS_BUILD_TESTS_TRUE@ test-dup-prop.h \ +@DBUS_BUILD_TESTS_TRUE@ test-objects.c \ +@DBUS_BUILD_TESTS_TRUE@ test-objects.h \ +@DBUS_BUILD_TESTS_TRUE@ test-server.c + +@DBUS_BUILD_TESTS_TRUE@test_client_SOURCES = \ +@DBUS_BUILD_TESTS_TRUE@ test-client.c + +@DBUS_BUILD_TESTS_TRUE@BUILT_SOURCES = \ +@DBUS_BUILD_TESTS_TRUE@ test-song-glue.h \ +@DBUS_BUILD_TESTS_TRUE@ test-hello-glue.h \ +@DBUS_BUILD_TESTS_TRUE@ test-goodbye-glue.h \ +@DBUS_BUILD_TESTS_TRUE@ test-dup-prop-a-glue.h \ +@DBUS_BUILD_TESTS_TRUE@ test-dup-prop-b-glue.h \ +@DBUS_BUILD_TESTS_TRUE@ test-song-bindings.h \ +@DBUS_BUILD_TESTS_TRUE@ test-hello-bindings.h \ +@DBUS_BUILD_TESTS_TRUE@ test-goodbye-bindings.h \ +@DBUS_BUILD_TESTS_TRUE@ test-dup-prop-a-bindings.h \ +@DBUS_BUILD_TESTS_TRUE@ test-dup-prop-a-bindings.h \ +@DBUS_BUILD_TESTS_TRUE@ test-dup-prop-b-bindings.h \ +@DBUS_BUILD_TESTS_TRUE@ test-dup-prop-b-bindings.h \ +@DBUS_BUILD_TESTS_TRUE@ valid-annotations-glue.h \ +@DBUS_BUILD_TESTS_TRUE@ valid-annotations-bindings.h \ +@DBUS_BUILD_TESTS_TRUE@ $(NULL) + +@DBUS_BUILD_TESTS_TRUE@CLEANFILES = \ +@DBUS_BUILD_TESTS_TRUE@ $(BUILT_SOURCES) \ +@DBUS_BUILD_TESTS_TRUE@ run-with-tmp-session-bus.conf + +all: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu test/interfaces/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu test/interfaces/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): + +clean-noinstPROGRAMS: + @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \ + echo " rm -f" $$list; \ + rm -f $$list || exit $$?; \ + test -n "$(EXEEXT)" || exit 0; \ + list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f" $$list; \ + rm -f $$list +test-client$(EXEEXT): $(test_client_OBJECTS) $(test_client_DEPENDENCIES) $(EXTRA_test_client_DEPENDENCIES) + @rm -f test-client$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_client_OBJECTS) $(test_client_LDADD) $(LIBS) +test-service$(EXEEXT): $(test_service_OBJECTS) $(test_service_DEPENDENCIES) $(EXTRA_test_service_DEPENDENCIES) + @rm -f test-service$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_service_OBJECTS) $(test_service_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-client.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-dup-prop.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-interfaces.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-objects.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-server.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + set x; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +check-TESTS: $(TESTS) + @failed=0; all=0; xfail=0; xpass=0; skip=0; \ + srcdir=$(srcdir); export srcdir; \ + list=' $(TESTS) '; \ + $(am__tty_colors); \ + if test -n "$$list"; then \ + for tst in $$list; do \ + if test -f ./$$tst; then dir=./; \ + elif test -f $$tst; then dir=; \ + else dir="$(srcdir)/"; fi; \ + if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *[\ \ ]$$tst[\ \ ]*) \ + xpass=`expr $$xpass + 1`; \ + failed=`expr $$failed + 1`; \ + col=$$red; res=XPASS; \ + ;; \ + *) \ + col=$$grn; res=PASS; \ + ;; \ + esac; \ + elif test $$? -ne 77; then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *[\ \ ]$$tst[\ \ ]*) \ + xfail=`expr $$xfail + 1`; \ + col=$$lgn; res=XFAIL; \ + ;; \ + *) \ + failed=`expr $$failed + 1`; \ + col=$$red; res=FAIL; \ + ;; \ + esac; \ + else \ + skip=`expr $$skip + 1`; \ + col=$$blu; res=SKIP; \ + fi; \ + echo "$${col}$$res$${std}: $$tst"; \ + done; \ + if test "$$all" -eq 1; then \ + tests="test"; \ + All=""; \ + else \ + tests="tests"; \ + All="All "; \ + fi; \ + if test "$$failed" -eq 0; then \ + if test "$$xfail" -eq 0; then \ + banner="$$All$$all $$tests passed"; \ + else \ + if test "$$xfail" -eq 1; then failures=failure; else failures=failures; fi; \ + banner="$$All$$all $$tests behaved as expected ($$xfail expected $$failures)"; \ + fi; \ + else \ + if test "$$xpass" -eq 0; then \ + banner="$$failed of $$all $$tests failed"; \ + else \ + if test "$$xpass" -eq 1; then passes=pass; else passes=passes; fi; \ + banner="$$failed of $$all $$tests did not behave as expected ($$xpass unexpected $$passes)"; \ + fi; \ + fi; \ + dashes="$$banner"; \ + skipped=""; \ + if test "$$skip" -ne 0; then \ + if test "$$skip" -eq 1; then \ + skipped="($$skip test was not run)"; \ + else \ + skipped="($$skip tests were not run)"; \ + fi; \ + test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \ + dashes="$$skipped"; \ + fi; \ + report=""; \ + if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \ + report="Please report to $(PACKAGE_BUGREPORT)"; \ + test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \ + dashes="$$report"; \ + fi; \ + dashes=`echo "$$dashes" | sed s/./=/g`; \ + if test "$$failed" -eq 0; then \ + col="$$grn"; \ + else \ + col="$$red"; \ + fi; \ + echo "$${col}$$dashes$${std}"; \ + echo "$${col}$$banner$${std}"; \ + test -z "$$skipped" || echo "$${col}$$skipped$${std}"; \ + test -z "$$report" || echo "$${col}$$report$${std}"; \ + echo "$${col}$$dashes$${std}"; \ + test "$$failed" -eq 0; \ + else :; fi + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am + $(MAKE) $(AM_MAKEFLAGS) check-TESTS +check: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) check-am +all-am: Makefile $(PROGRAMS) +installdirs: +install: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." + -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) +clean: clean-am + +clean-am: clean-generic clean-libtool clean-noinstPROGRAMS \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: all check check-am install install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-TESTS check-am clean \ + clean-generic clean-libtool clean-noinstPROGRAMS ctags \ + distclean distclean-compile distclean-generic \ + distclean-libtool distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-dvi install-dvi-am install-exec \ + install-exec-am install-html install-html-am install-info \ + install-info-am install-man install-pdf install-pdf-am \ + install-ps install-ps-am install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags uninstall uninstall-am + + +@DBUS_BUILD_TESTS_TRUE@test-song-glue.h: test-song.xml $(top_builddir)/dbus/dbus-binding-tool$(EXEEXT) +@DBUS_BUILD_TESTS_TRUE@ $(DBUS_BINDING_TOOL) --prefix=test_song --mode=glib-server --output=test-song-glue.h $(srcdir)/test-song.xml + +@DBUS_BUILD_TESTS_TRUE@test-song-bindings.h: test-song.xml $(top_builddir)/dbus/dbus-binding-tool$(EXEEXT) +@DBUS_BUILD_TESTS_TRUE@ $(DBUS_BINDING_TOOL) --prefix=test_song --mode=glib-client --output=test-song-bindings.h $(srcdir)/test-song.xml + +@DBUS_BUILD_TESTS_TRUE@test-hello-glue.h: test-hello.xml $(top_builddir)/dbus/dbus-binding-tool$(EXEEXT) +@DBUS_BUILD_TESTS_TRUE@ $(DBUS_BINDING_TOOL) --prefix=test_hello --mode=glib-server --output=test-hello-glue.h $(srcdir)/test-hello.xml + +@DBUS_BUILD_TESTS_TRUE@test-hello-bindings.h: test-hello.xml $(top_builddir)/dbus/dbus-binding-tool$(EXEEXT) +@DBUS_BUILD_TESTS_TRUE@ $(DBUS_BINDING_TOOL) --prefix=test_hello --mode=glib-client --output=test-hello-bindings.h $(srcdir)/test-hello.xml + +@DBUS_BUILD_TESTS_TRUE@test-goodbye-glue.h: test-goodbye.xml $(top_builddir)/dbus/dbus-binding-tool$(EXEEXT) +@DBUS_BUILD_TESTS_TRUE@ $(DBUS_BINDING_TOOL) --prefix=test_goodbye --mode=glib-server --output=test-goodbye-glue.h $(srcdir)/test-goodbye.xml + +@DBUS_BUILD_TESTS_TRUE@test-goodbye-bindings.h: test-goodbye.xml $(top_builddir)/dbus/dbus-binding-tool$(EXEEXT) +@DBUS_BUILD_TESTS_TRUE@ $(DBUS_BINDING_TOOL) --prefix=test_goodbye --mode=glib-client --output=test-goodbye-bindings.h $(srcdir)/test-goodbye.xml + +@DBUS_BUILD_TESTS_TRUE@test-dup-prop-a-glue.h: test-dup-prop-a.xml $(top_builddir)/dbus/dbus-binding-tool$(EXEEXT) +@DBUS_BUILD_TESTS_TRUE@ $(DBUS_BINDING_TOOL) --prefix=test_dup_prop_a --mode=glib-server --output=test-dup-prop-a-glue.h $(srcdir)/test-dup-prop-a.xml + +@DBUS_BUILD_TESTS_TRUE@test-dup-prop-a-bindings.h: test-dup-prop-a.xml $(top_builddir)/dbus/dbus-binding-tool$(EXEEXT) +@DBUS_BUILD_TESTS_TRUE@ $(DBUS_BINDING_TOOL) --prefix=test_dup_prop_a --mode=glib-client --output=test-dup-prop-a-bindings.h $(srcdir)/test-dup-prop-a.xml + +@DBUS_BUILD_TESTS_TRUE@test-dup-prop-b-glue.h: test-dup-prop-b.xml $(top_builddir)/dbus/dbus-binding-tool$(EXEEXT) +@DBUS_BUILD_TESTS_TRUE@ $(DBUS_BINDING_TOOL) --prefix=test_dup_prop_b --mode=glib-server --output=test-dup-prop-b-glue.h $(srcdir)/test-dup-prop-b.xml + +@DBUS_BUILD_TESTS_TRUE@test-dup-prop-b-bindings.h: test-dup-prop-b.xml $(top_builddir)/dbus/dbus-binding-tool$(EXEEXT) +@DBUS_BUILD_TESTS_TRUE@ $(DBUS_BINDING_TOOL) --prefix=test_dup_prop_b --mode=glib-client --output=test-dup-prop-b-bindings.h $(srcdir)/test-dup-prop-b.xml + +@DBUS_BUILD_TESTS_TRUE@valid-annotations-glue.h: valid-annotations.xml $(top_builddir)/dbus/dbus-binding-tool$(EXEEXT) +@DBUS_BUILD_TESTS_TRUE@ $(DBUS_BINDING_TOOL) --prefix=test_annotated --mode=glib-server --output=$@ $< + +@DBUS_BUILD_TESTS_TRUE@valid-annotations-bindings.h: valid-annotations.xml $(top_builddir)/dbus/dbus-binding-tool$(EXEEXT) +@DBUS_BUILD_TESTS_TRUE@ $(DBUS_BINDING_TOOL) --prefix=test_annotated --mode=glib-client --output=$@ $< + +### not building tests + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/test/interfaces/invalid-annotated-node.xml b/test/interfaces/invalid-annotated-node.xml new file mode 100644 index 0000000..4759b1f --- /dev/null +++ b/test/interfaces/invalid-annotated-node.xml @@ -0,0 +1,8 @@ +<?xml version="1.0"?><!-- ex:set et ts=2: --> +<node name="/org/freedesktop/DBus/GLib/Test/Interfaces"> + <annotation name="com.example.Invalid" value="not allowed here!"/> + + <interface name="org.freedesktop.DBus.GLib.Test.Interfaces.Annotated"> + <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="test_annotated"/> + </interface> +</node> diff --git a/test/interfaces/invalid-nested-annotation.xml b/test/interfaces/invalid-nested-annotation.xml new file mode 100644 index 0000000..8d98836 --- /dev/null +++ b/test/interfaces/invalid-nested-annotation.xml @@ -0,0 +1,8 @@ +<?xml version="1.0"?><!-- ex:set et ts=2: --> +<node name="/org/freedesktop/DBus/GLib/Test/Interfaces"> + <interface name="org.freedesktop.DBus.GLib.Test.Interfaces.Annotated"> + <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="test_annotated"> + <annotation name="com.example.Invalid" value="can't nest annotations"/> + </annotation> + </interface> +</node> diff --git a/test/interfaces/run-test.sh b/test/interfaces/run-test.sh new file mode 100755 index 0000000..71b27c1 --- /dev/null +++ b/test/interfaces/run-test.sh @@ -0,0 +1,37 @@ +#! /bin/sh + +SCRIPTNAME=$0 +MODE=$1 + +## so the tests can complain if you fail to use the script to launch them +DBUS_TEST_GLIB_RUN_TEST_SCRIPT=1 +export DBUS_TEST_GLIB_RUN_TEST_SCRIPT +srcdir=`dirname "$0"` +DBUS_TOP_SRCDIR="$srcdir/../.." +export DBUS_TOP_SRCDIR +# Rerun ourselves with tmp session bus if we're not already +if test -z "$DBUS_TEST_GLIB_IN_RUN_TEST"; then + DBUS_TEST_GLIB_IN_RUN_TEST=1 + export DBUS_TEST_GLIB_IN_RUN_TEST + exec $DBUS_TOP_SRCDIR/tools/run-with-tmp-session-bus.sh $SCRIPTNAME $MODE +fi + +for x in annotated-node nested-annotation; do + if ! test -f $srcdir/invalid-$x.xml; then + echo "invalid-$x.xml missing">&2 + exit 1 + fi + + if $DBUS_BINDING_TOOL --prefix=test_invalid --mode=glib-server \ + --output=invalid-glue.h $srcdir/invalid-$x.xml || + $DBUS_BINDING_TOOL --prefix=test_invalid --mode=glib-client \ + --output=invalid-bindings.h $srcdir/invalid-$x.xml; then + echo "invalid-$x.xml should not have been processed successfully!">&2 + exit 1 + else + echo "invalid-$x.xml failed, as expected">&2 + fi +done + +echo "running test-client" +${DBUS_TOP_BUILDDIR}/libtool --mode=execute $DEBUG $DBUS_TOP_BUILDDIR/test/interfaces/test-client || die "test-client failed" diff --git a/test/interfaces/test-client.c b/test/interfaces/test-client.c new file mode 100644 index 0000000..ae974ae --- /dev/null +++ b/test/interfaces/test-client.c @@ -0,0 +1,273 @@ +#include <config.h> + +#include <stdlib.h> +#include <string.h> +#include "dbus/dbus-gparser.h" +#include "test-song-bindings.h" +#include "test-hello-bindings.h" +#include "test-goodbye-bindings.h" +#include "test-dup-prop-a-bindings.h" +#include "test-dup-prop-b-bindings.h" + +#define TEST_NAMESPACE "org.freedesktop.DBus.GLib.Test.Interfaces" +#define TEST_OBJECT_PATH "/org/freedesktop/DBus/GLib/Test/Interfaces" +#define TEST_DP_OBJECT_PATH "/org/freedesktop/DBus/GLib/Test/DupPropInterfaces" + +#define TEST_DP_IFACE_A "org.freedesktop.DBus.GLib.Test.Interfaces.A" +#define TEST_DP_IFACE_B "org.freedesktop.DBus.GLib.Test.Interfaces.B" + +static void +test_dp_property (DBusGProxy *proxy, + const char *detail, + const char *iface, + guint expected, + gboolean get_only) +{ + GError *error = NULL; + gboolean success; + GValue get_value = {0,}; + + if (!get_only) + { + GValue set_value = {0,}; + + g_value_init (&set_value, G_TYPE_UINT); + g_value_set_uint (&set_value, expected); + success = dbus_g_proxy_call (proxy, "Set", &error, + G_TYPE_STRING, iface, + G_TYPE_STRING, "Foobar", + G_TYPE_VALUE, &set_value, + G_TYPE_INVALID, + G_TYPE_INVALID); + g_value_unset (&set_value); + if (!success) + { + g_print ("Error while setting DupProp Interface %s property: %s\n", detail, error->message); + g_error_free (error); + exit(1); + } + else + g_print ("Set DupProp Interface %s property with success\n", detail); + } + + success = dbus_g_proxy_call (proxy, "Get", &error, + G_TYPE_STRING, iface, + G_TYPE_STRING, "Foobar", + G_TYPE_INVALID, + G_TYPE_VALUE, &get_value, + G_TYPE_INVALID); + if (!success) + { + g_print ("Error while getting DupProp Interface %s property: %s\n", detail, error->message); + g_error_free (error); + exit(1); + } + else + g_print ("Got DupProp Interface %s property with success\n", detail); + + if (!G_VALUE_HOLDS_UINT (&get_value)) + { + g_print ("Error comparing DupProp %s Interface property: unexpected type %s\n", + detail, G_VALUE_TYPE_NAME (&get_value)); + g_error_free (error); + exit(1); + } + else if (g_value_get_uint (&get_value) != expected) + { + g_print ("Error comparing DupProp %s Interface property: expected %d, got %d\n", + detail, expected, g_value_get_uint (&get_value)); + g_error_free (error); + exit(1); + } + else + g_print ("Got DupProp Interface %s property value matched expected\n", detail); +} + +int +main (int argc, + char **argv) +{ + DBusGConnection *connection; + DBusGProxy *proxy; + GError *error = NULL; + gchar *str; + gboolean success; + DBusGProxy *dp_proxy; + + g_type_init (); + + connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error); + if (connection == NULL) + { + g_error ("Failed to make connection to session bus: %s", error->message); + g_error_free (error); + exit(1); + } + + proxy = dbus_g_proxy_new_for_name (connection, TEST_NAMESPACE, TEST_OBJECT_PATH, + "org.freedesktop.DBus.GLib.Test.Interfaces.Song"); + success = org_freedesktop_DBus_GLib_Test_Interfaces_Song_get_title (proxy, &str, &error); + g_object_unref (proxy); + + if (!success) + { + g_print ("Error while calling Parent object method: %s\n", error->message); + g_error_free (error); + exit(1); + } + else + { + g_free (str); + g_print ("Called Parent object method with success\n"); + } + + proxy = dbus_g_proxy_new_for_name (connection, TEST_NAMESPACE, TEST_OBJECT_PATH, + "org.freedesktop.DBus.GLib.Test.Interfaces.Hello"); + g_assert (proxy != NULL); + success = org_freedesktop_DBus_GLib_Test_Interfaces_Hello_say_hello (proxy, &str, &error); + g_object_unref (proxy); + + if (!success) + { + g_print ("Error while calling Parent Interface object method: %s\n", error->message); + g_error_free (error); + exit(1); + } + else + { + g_free (str); + g_print ("Called Parent Interface object method with success\n"); + } + + proxy = dbus_g_proxy_new_for_name (connection, TEST_NAMESPACE, TEST_OBJECT_PATH, + "org.freedesktop.DBus.GLib.Test.Interfaces.Goodbye"); + success = org_freedesktop_DBus_GLib_Test_Interfaces_Goodbye_say_goodbye (proxy, &str, &error); + g_object_unref (proxy); + + if (!success) + { + g_print ("Error while calling Object Interface object method: %s\n", error->message); + g_error_free (error); + exit(1); + } + else + { + g_free (str); + g_print ("Called Object Interface object method with success\n"); + } + + /* Test interfaces with conflicting property names on the same GObject */ + dp_proxy = dbus_g_proxy_new_for_name (connection, TEST_NAMESPACE, TEST_DP_OBJECT_PATH, + "org.freedesktop.DBus.Properties"); + + /* test that setting the property and reading it back works */ + test_dp_property (dp_proxy, "A", TEST_DP_IFACE_A, 235235, FALSE); + test_dp_property (dp_proxy, "B", TEST_DP_IFACE_B, 11981241, FALSE); + + /* Test that setting A does not change B */ + test_dp_property (dp_proxy, "B", TEST_DP_IFACE_B, 11981241, FALSE); + test_dp_property (dp_proxy, "A", TEST_DP_IFACE_A, 235235, FALSE); + test_dp_property (dp_proxy, "B", TEST_DP_IFACE_B, 11981241, TRUE); + + /* And test that setting B does not change A */ + test_dp_property (dp_proxy, "A", TEST_DP_IFACE_A, 235235, FALSE); + test_dp_property (dp_proxy, "B", TEST_DP_IFACE_B, 11981241, FALSE); + test_dp_property (dp_proxy, "A", TEST_DP_IFACE_A, 235235, TRUE); + + g_object_unref (dp_proxy); + + /* Ensure the properties are introspectable */ + dp_proxy = dbus_g_proxy_new_for_name (connection, TEST_NAMESPACE, TEST_DP_OBJECT_PATH, + "org.freedesktop.DBus.Introspectable"); + + g_print ("Testing duplicate property name introspection\n"); + if (!dbus_g_proxy_call (dp_proxy, "Introspect", &error, + G_TYPE_INVALID, + G_TYPE_STRING, &str, + G_TYPE_INVALID)) + { + g_print ("Error while introspecting duplicate properties: %s\n", error->message); + g_error_free (error); + exit(1); + } + else + g_print ("Introspected duplicate properties with success\n"); + + { + NodeInfo *node; + GSList *elt; + gboolean found_introspectable = FALSE; + gboolean found_properties = FALSE; + gboolean found_iface_a = FALSE; + gboolean found_iface_a_prop = FALSE; + gboolean found_iface_b = FALSE; + gboolean found_iface_b_prop = FALSE; + + node = description_load_from_string (str, strlen (str), &error); + if (!node) + { + g_print ("Failed to parse introspection data: %s\n", error->message); + g_error_free (error); + exit(1); + } + + for (elt = node_info_get_interfaces (node); elt ; elt = elt->next) + { + InterfaceInfo *iface = elt->data; + + if (!found_introspectable && strcmp (interface_info_get_name (iface), "org.freedesktop.DBus.Introspectable") == 0) + found_introspectable = TRUE; + else if (!found_properties && strcmp (interface_info_get_name (iface), "org.freedesktop.DBus.Properties") == 0) + found_properties = TRUE; + else if (!found_iface_a && strcmp (interface_info_get_name (iface), "org.freedesktop.DBus.GLib.Test.Interfaces.A") == 0) + { + GSList *elt; + + found_iface_a = TRUE; + + for (elt = interface_info_get_properties (iface); elt; elt = elt->next) + { + PropertyInfo *prop; + + prop = elt->data; + if (strcmp (property_info_get_name (prop), "Foobar") == 0) + { + found_iface_a_prop = TRUE; + break; + } + } + } + else if (!found_iface_b && strcmp (interface_info_get_name (iface), "org.freedesktop.DBus.GLib.Test.Interfaces.B") == 0) + { + GSList *elt; + + found_iface_b = TRUE; + + for (elt = interface_info_get_properties (iface); elt; elt = elt->next) + { + PropertyInfo *prop; + + prop = elt->data; + if (strcmp (property_info_get_name (prop), "Foobar") == 0) + { + found_iface_b_prop = TRUE; + break; + } + } + } + } + g_free (str); + + if (!found_iface_a_prop || !found_iface_b_prop) + { + g_print ("Failed to find Foobar properties in introspection data\n"); + g_error_free (error); + exit(1); + } + } + + exit(0); +} + +/* ex:ts=2:et: */ + diff --git a/test/interfaces/test-dup-prop-a.xml b/test/interfaces/test-dup-prop-a.xml new file mode 100644 index 0000000..f3ebf33 --- /dev/null +++ b/test/interfaces/test-dup-prop-a.xml @@ -0,0 +1,6 @@ +<?xml version="1.0"?><!-- ex:set et ts=2: --> +<node name="/org/freedesktop/DBus/GLib/Test/Interfaces"> + <interface name="org.freedesktop.DBus.GLib.Test.Interfaces.A"> + <property name="Foobar" type="u" access="readwrite"/> + </interface> +</node> diff --git a/test/interfaces/test-dup-prop-b.xml b/test/interfaces/test-dup-prop-b.xml new file mode 100644 index 0000000..596cb54 --- /dev/null +++ b/test/interfaces/test-dup-prop-b.xml @@ -0,0 +1,6 @@ +<?xml version="1.0"?><!-- ex:set et ts=2: --> +<node name="/org/freedesktop/DBus/GLib/Test/Interfaces"> + <interface name="org.freedesktop.DBus.GLib.Test.Interfaces.B"> + <property name="Foobar" type="u" access="readwrite"/> + </interface> +</node> diff --git a/test/interfaces/test-dup-prop.c b/test/interfaces/test-dup-prop.c new file mode 100644 index 0000000..467ac4b --- /dev/null +++ b/test/interfaces/test-dup-prop.c @@ -0,0 +1,192 @@ +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif +#include "test-dup-prop.h" + +#include "test-dup-prop-a-glue.h" +#include "test-dup-prop-b-glue.h" + +#define TEST_A_FOOBAR "a-foobar" +#define TEST_B_FOOBAR "b-foobar" + +static void +test_a_class_init (gpointer g_iface) +{ + GType iface_type = G_TYPE_FROM_INTERFACE (g_iface); + + g_object_interface_install_property (g_iface, + g_param_spec_uint (TEST_A_FOOBAR, + "A Foobar", + "A description of something", + 0, G_MAXUINT, 0, + G_PARAM_READWRITE)); + + dbus_g_object_type_install_info (iface_type, + &dbus_glib_test_dup_prop_a_object_info); + dbus_g_object_type_register_shadow_property (iface_type, + "Foobar", + TEST_A_FOOBAR); +} + +GType +test_a_get_type (void) +{ + static GType the_type = 0; + + if (G_UNLIKELY (the_type == 0)) { + static const GTypeInfo info = { + sizeof (TestAIface), + NULL, NULL, + (GClassInitFunc) test_a_class_init, + NULL, NULL, 0, 0, NULL + }; + + the_type = g_type_register_static (G_TYPE_INTERFACE, + "TestA", + &info, 0); + g_type_interface_add_prerequisite (the_type, G_TYPE_OBJECT); + } + return the_type; +} + + +static void +test_b_class_init (gpointer g_iface) +{ + GType iface_type = G_TYPE_FROM_INTERFACE (g_iface); + + g_object_interface_install_property (g_iface, + g_param_spec_uint (TEST_B_FOOBAR, + "B Foobar", + "A description of something", + 0, G_MAXUINT, 0, + G_PARAM_READWRITE)); + + dbus_g_object_type_install_info (iface_type, + &dbus_glib_test_dup_prop_b_object_info); + dbus_g_object_type_register_shadow_property (iface_type, + "Foobar", + TEST_B_FOOBAR); +} + +GType +test_b_get_type (void) +{ + static GType the_type = 0; + + if (G_UNLIKELY (the_type == 0)) { + static const GTypeInfo info = { + sizeof (TestBIface), + NULL, NULL, + (GClassInitFunc) test_b_class_init, + NULL, NULL, 0, 0, NULL + }; + + the_type = g_type_register_static (G_TYPE_INTERFACE, + "TestB", + &info, 0); + g_type_interface_add_prerequisite (the_type, G_TYPE_OBJECT); + } + return the_type; +} + + + +static void test_a_init (TestAIface *a_class); +static void test_b_init (TestBIface *b_class); + +G_DEFINE_TYPE_EXTENDED (TestDpObj, test_dp_obj, G_TYPE_OBJECT, 0, + G_IMPLEMENT_INTERFACE (TEST_TYPE_A, test_a_init) + G_IMPLEMENT_INTERFACE (TEST_TYPE_B, test_b_init)) + +#define TEST_DP_OBJ_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TEST_TYPE_DP_OBJ, TestDpObjPrivate)) + +enum { + PROP_0, + PROP_A_FOOBAR, + PROP_B_FOOBAR +}; + +typedef struct { + guint32 a_foobar; + guint32 b_foobar; +} TestDpObjPrivate; + +TestDpObj * +test_dp_obj_new (void) +{ + return TEST_DP_OBJ (g_object_new (TEST_TYPE_DP_OBJ, NULL)); +} + +static void +test_a_init (TestAIface *a_class) +{ +} + +static void +test_b_init (TestBIface *b_class) +{ +} + +static void +test_dp_obj_init (TestDpObj *self) +{ +} + +static void +set_property (GObject *object, guint prop_id, + const GValue *value, GParamSpec *pspec) +{ + TestDpObjPrivate *priv = TEST_DP_OBJ_GET_PRIVATE (object); + + switch (prop_id) { + case PROP_A_FOOBAR: + priv->a_foobar = g_value_get_uint (value); + break; + case PROP_B_FOOBAR: + priv->b_foobar = g_value_get_uint (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +get_property (GObject *object, guint prop_id, + GValue *value, GParamSpec *pspec) +{ + TestDpObjPrivate *priv = TEST_DP_OBJ_GET_PRIVATE (object); + + switch (prop_id) { + case PROP_A_FOOBAR: + g_value_set_uint (value, priv->a_foobar); + break; + case PROP_B_FOOBAR: + g_value_set_uint (value, priv->b_foobar); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +test_dp_obj_class_init (TestDpObjClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + g_type_class_add_private (object_class, sizeof (TestDpObjPrivate)); + + object_class->get_property = get_property; + object_class->set_property = set_property; + + /* Properties */ + g_object_class_override_property (object_class, + PROP_A_FOOBAR, + TEST_A_FOOBAR); + + g_object_class_override_property (object_class, + PROP_B_FOOBAR, + TEST_B_FOOBAR); +} diff --git a/test/interfaces/test-dup-prop.h b/test/interfaces/test-dup-prop.h new file mode 100644 index 0000000..cc20ea7 --- /dev/null +++ b/test/interfaces/test-dup-prop.h @@ -0,0 +1,60 @@ +#ifndef __TEST_DUP_PROP_H__ +#define __TEST_DUP_PROP_H__ + +#include <glib-object.h> + +#define TEST_TYPE_A (test_a_get_type ()) +#define TEST_A(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TEST_TYPE_A, TestA)) +#define TEST_A_IFACE(obj) (G_TYPE_CHECK_CLASS_CAST ((obj), TEST_TYPE_A, TestAIface)) +#define TEST_IS_IFACE_A(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TEST_TYPE_A)) +#define TEST_A_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), TEST_TYPE_A, TestAIface)) + +#define TEST_TYPE_B (test_b_get_type ()) +#define TEST_B(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TEST_TYPE_B, TestB)) +#define TEST_B_IFACE(obj) (G_TYPE_CHECK_CLASS_CAST ((obj), TEST_TYPE_B, TestBIface)) +#define TEST_IS_B(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TEST_TYPE_B)) +#define TEST_B_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), TEST_TYPE_B, TestBIface)) + +#define TEST_TYPE_DP_OBJ (test_dp_obj_get_type ()) +#define TEST_DP_OBJ(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TEST_TYPE_DP_OBJ, TestDpObj)) +#define TEST_DP_OBJ_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TEST_TYPE_DP_OBJ, TestDpObjClass)) +#define TEST_IS_DP_OBJ(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TEST_TYPE_DP_OBJ)) +#define TEST_IS_DP_OBJ_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TEST_TYPE_DP_OBJ)) +#define TEST_DP_OBJ_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TEST_TYPE_DP_OBJ, TestDpObjClass)) + + +typedef struct _TestA TestA; /* dummy */ +typedef struct _TestAIface TestAIface; + +typedef struct _TestB TestB; /* dummy */ +typedef struct _TestBIface TestBIface; + +typedef struct _TestDpObj TestDpObj; +typedef struct _TestDpObjClass TestDpObjClass; + +struct _TestAIface { + GTypeInterface interface; +}; + +struct _TestBIface { + GTypeInterface interface; +}; + +struct _TestDpObj { + GObject parent; +}; + +struct _TestDpObjClass { + GObjectClass parent; +}; + + +GType test_a_get_type (void) G_GNUC_CONST; + +GType test_b_get_type (void) G_GNUC_CONST; + +GType test_dp_obj_get_type (void) G_GNUC_CONST; + +TestDpObj *test_dp_obj_new (void); + +#endif diff --git a/test/interfaces/test-goodbye.xml b/test/interfaces/test-goodbye.xml new file mode 100644 index 0000000..c4590ed --- /dev/null +++ b/test/interfaces/test-goodbye.xml @@ -0,0 +1,9 @@ +<?xml version="1.0"?><!-- ex:set et ts=2: --> +<node name="/org/freedesktop/DBus/GLib/Test/Interfaces"> + <interface name="org.freedesktop.DBus.GLib.Test.Interfaces.Goodbye"> + <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="test_goodbye_dbus"/> + <method name="SayGoodbye"> + <arg name="message" type="s" direction="out" /> + </method> + </interface> +</node> diff --git a/test/interfaces/test-hello.xml b/test/interfaces/test-hello.xml new file mode 100644 index 0000000..28f82bd --- /dev/null +++ b/test/interfaces/test-hello.xml @@ -0,0 +1,10 @@ +<?xml version="1.0"?><!-- ex:set et ts=2: --> +<node name="/org/freedesktop/DBus/GLib/Test/Interfaces"> + <interface name="org.freedesktop.DBus.GLib.Test.Interfaces.Hello"> + <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="test_hello_dbus"/> + <method name="SayHello"> + <arg name="message" type="s" direction="out" /> + </method> + <signal name="Greetings" /> + </interface> +</node> diff --git a/test/interfaces/test-interfaces.c b/test/interfaces/test-interfaces.c new file mode 100644 index 0000000..2cb4f91 --- /dev/null +++ b/test/interfaces/test-interfaces.c @@ -0,0 +1,126 @@ +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif +#include "test-interfaces.h" + +static gboolean +test_hello_dbus_say_hello (TestHello *hello, + gchar **message, + GError **error) +{ + *message = test_hello_say_hello (hello); + return TRUE; +} + +static gboolean +test_goodbye_dbus_say_goodbye (TestGoodbye *goodbye, + gchar **message, + GError **error) +{ + *message = test_goodbye_say_goodbye (goodbye); + return TRUE; +} + +#include "test-hello-glue.h" +#include "test-goodbye-glue.h" + +enum { + GREETINGS, + LAST_SIGNAL +}; + +static guint signals[LAST_SIGNAL]; + +static void +test_hello_class_init (gpointer g_iface) +{ + GType iface_type = G_TYPE_FROM_INTERFACE (g_iface); + + signals[GREETINGS] = + g_signal_new ("greetings", + iface_type, + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (TestHelloIface, greetings), + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, + 0); + + dbus_g_object_type_install_info (iface_type, + &dbus_glib_test_hello_object_info); +} + +GType +test_hello_get_type (void) +{ + static GType the_type = 0; + + if (G_UNLIKELY (the_type == 0)) { + static const GTypeInfo info = { + sizeof (TestHelloIface), + NULL, NULL, + (GClassInitFunc) test_hello_class_init, + NULL, NULL, 0, 0, NULL + }; + + the_type = g_type_register_static (G_TYPE_INTERFACE, + "TestHello", + &info, 0); + g_type_interface_add_prerequisite (the_type, G_TYPE_OBJECT); + } + return the_type; +} + +gchar * +test_hello_say_hello (TestHello *hello) +{ + g_return_val_if_fail (TEST_IS_HELLO (hello), NULL); + + return (* TEST_HELLO_GET_IFACE (hello)->say_hello) (hello); +} + +void +test_hello_greetings (TestHello *hello) +{ + g_return_if_fail (TEST_IS_HELLO (hello)); + + g_signal_emit (hello, signals[GREETINGS], 0); +} + +static void +test_goodbye_class_init (gpointer g_iface) +{ + GType iface_type = G_TYPE_FROM_INTERFACE (g_iface); + + dbus_g_object_type_install_info (iface_type, + &dbus_glib_test_goodbye_object_info); +} + +GType +test_goodbye_get_type (void) +{ + static GType the_type = 0; + + if (G_UNLIKELY (the_type == 0)) { + static const GTypeInfo info = { + sizeof (TestGoodbyeIface), + NULL, NULL, + (GClassInitFunc) test_goodbye_class_init, + NULL, NULL, 0, 0, NULL + }; + + the_type = g_type_register_static (G_TYPE_INTERFACE, + "TestGoodbye", + &info, 0); + g_type_interface_add_prerequisite (the_type, G_TYPE_OBJECT); + } + return the_type; +} + +gchar * +test_goodbye_say_goodbye (TestGoodbye *goodbye) +{ + g_return_val_if_fail (TEST_IS_GOODBYE (goodbye), NULL); + + return (* TEST_GOODBYE_GET_IFACE (goodbye)->say_goodbye) (goodbye); +} diff --git a/test/interfaces/test-interfaces.h b/test/interfaces/test-interfaces.h new file mode 100644 index 0000000..7a2b81d --- /dev/null +++ b/test/interfaces/test-interfaces.h @@ -0,0 +1,48 @@ +#ifndef __TEST_INTERFACES_H__ +#define __TEST_INTERFACES_H__ + +#include <glib-object.h> + +#define TEST_TYPE_HELLO (test_hello_get_type ()) +#define TEST_HELLO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TEST_TYPE_HELLO, TestHello)) +#define TEST_HELLO_IFACE(obj) (G_TYPE_CHECK_CLASS_CAST ((obj), TEST_TYPE_HELLO, TestHelloIface)) +#define TEST_IS_HELLO(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TEST_TYPE_HELLO)) +#define TEST_HELLO_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), TEST_TYPE_HELLO, TestHelloIface)) + +#define TEST_TYPE_GOODBYE (test_goodbye_get_type ()) +#define TEST_GOODBYE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TEST_TYPE_GOODBYE, TestGoodbye)) +#define TEST_GOODBYE_IFACE(obj) (G_TYPE_CHECK_CLASS_CAST ((obj), TEST_TYPE_GOODBYE, TestGoodbyeIface)) +#define TEST_IS_GOODBYE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TEST_TYPE_GOODBYE)) +#define TEST_GOODBYE_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), TEST_TYPE_GOODBYE, TestGoodbyeIface)) + +typedef struct _TestHello TestHello; /* dummy */ +typedef struct _TestHelloIface TestHelloIface; + +typedef struct _TestGoodbye TestGoodbye; /* dummy */ +typedef struct _TestGoodbyeIface TestGoodbyeIface; + +struct _TestHelloIface { + GTypeInterface interface; + + /* VTable */ + gchar *(* say_hello) (TestHello *hello); + + /* Signals */ + void (* greetings) (TestHello *hello); +}; + +struct _TestGoodbyeIface { + GTypeInterface interface; + + /* VTable */ + gchar *(* say_goodbye) (TestGoodbye *goodbye); +}; + +GType test_hello_get_type (void) G_GNUC_CONST; +gchar *test_hello_say_hello (TestHello *hello); +void test_hello_greetings (TestHello *hello); + +GType test_goodbye_get_type (void) G_GNUC_CONST; +gchar *test_goodbye_say_goodbye (TestGoodbye *goodbye); + +#endif diff --git a/test/interfaces/test-objects.c b/test/interfaces/test-objects.c new file mode 100644 index 0000000..e82fa08 --- /dev/null +++ b/test/interfaces/test-objects.c @@ -0,0 +1,75 @@ +#include <config.h> + +#include "test-objects.h" +#include "test-interfaces.h" + +static gboolean +test_song_dbus_get_title (TestSong *song, + gchar **title, + GError **error) +{ + *title = g_strdup ("Hello, Goodbye"); + return TRUE; +} + +#include "test-song-glue.h" + +static gchar * +test_song_say_hello (TestHello *hello) +{ + return g_strdup ("Hello, hello..."); +} + +static void +test_song_init (TestSong *song) +{ +} + +static void +test_song_hello_init (TestHelloIface *iface) +{ + iface->say_hello = test_song_say_hello; +} + + +static void +test_song_class_init (TestSongClass *klass) +{ + dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (klass), + &dbus_glib_test_song_object_info); +} + +G_DEFINE_TYPE_WITH_CODE (TestSong, test_song, G_TYPE_OBJECT, + G_IMPLEMENT_INTERFACE (TEST_TYPE_HELLO, test_song_hello_init)) + +static gchar * +test_beatles_song_say_goodbye (TestGoodbye *goodbye) +{ + return g_strdup ("I don't know why you say goodbye, I say hello."); +} + +static void +test_beatles_song_init (TestBeatlesSong *song) +{ +} + +static void +test_beatles_song_goodbye_init (TestGoodbyeIface *iface) +{ + iface->say_goodbye = test_beatles_song_say_goodbye; +} + +static void +test_beatles_song_class_init (TestBeatlesSongClass *klass) +{ +} + +G_DEFINE_TYPE_WITH_CODE (TestBeatlesSong, test_beatles_song, TEST_TYPE_SONG, + G_IMPLEMENT_INTERFACE (TEST_TYPE_GOODBYE, test_beatles_song_goodbye_init)) + + +TestBeatlesSong * +test_beatles_song_new (void) +{ + return TEST_BEATLES_SONG (g_object_new (TEST_TYPE_BEATLES_SONG, NULL)); +} diff --git a/test/interfaces/test-objects.h b/test/interfaces/test-objects.h new file mode 100644 index 0000000..b7bf438 --- /dev/null +++ b/test/interfaces/test-objects.h @@ -0,0 +1,31 @@ +#ifndef __TEST_OBJECTS_H__ +#define __TEST_OBJECTS_H__ + +#include <glib-object.h> + +#define TEST_TYPE_SONG (test_song_get_type ()) +#define TEST_SONG(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TEST_TYPE_SONG, TestSong)) +#define TEST_SONG_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), TEST_TYPE_SONG, TestSongClass)) +#define TEST_IS_SONG(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), TEST_TYPE_SONG)) +#define TEST_IS_SONG_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), TEST_TYPE_SONG)) +#define TEST_SONG_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), TEST_TYPE_SONG, TestSongClass)) + +#define TEST_TYPE_BEATLES_SONG (test_beatles_song_get_type ()) +#define TEST_BEATLES_SONG(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TEST_TYPE_BEATLES_SONG, TestBeatlesSong)) +#define TEST_BEATLES_SONG_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), TEST_TYPE_BEATLES_SONG, TestBeatlesSongClass)) +#define TEST_IS_BEATLES_SONG(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), TEST_TYPE_BEATLES_SONG)) +#define TEST_IS_BEATLES_SONG_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), TEST_TYPE_BEATLES_SONG)) +#define TEST_BEATLES_SONG_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), TEST_TYPE_BEATLES_SONG, TestBeatlesSongClass)) + +typedef GObject TestSong; +typedef GObjectClass TestSongClass; + +typedef TestSong TestBeatlesSong; +typedef TestSongClass TestBeatlesSongClass; + +GType test_song_get_type (void); + +GType test_beatles_song_get_type (void); +TestSong *test_beatles_song_new (void); + +#endif diff --git a/test/interfaces/test-server.c b/test/interfaces/test-server.c new file mode 100644 index 0000000..d9c1d91 --- /dev/null +++ b/test/interfaces/test-server.c @@ -0,0 +1,68 @@ +#include <config.h> + +#include <stdlib.h> +#include "dbus/dbus-glib.h" +#include "tools/dbus-glib-bindings.h" +#include "test-objects.h" +#include "test-dup-prop.h" + +#define TEST_NAMESPACE "org.freedesktop.DBus.GLib.Test.Interfaces" +#define TEST_OBJECT_PATH "/org/freedesktop/DBus/GLib/Test/Interfaces" +#define TEST_DP_OBJECT_PATH "/org/freedesktop/DBus/GLib/Test/DupPropInterfaces" + +static GMainLoop *loop = NULL; + +int +main (int argc, + char **argv) +{ + DBusGConnection *connection; + DBusGProxy *proxy; + GError *error = NULL; + guint32 ret; + TestBeatlesSong *song; + TestDpObj *dp_obj; + + g_type_init (); + + /* Get the connection and ensure the name is not used yet */ + connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error); + if (connection == NULL) { + g_warning ("Failed to make connection to session bus: %s", + error->message); + g_error_free (error); + exit(1); + } + + proxy = dbus_g_proxy_new_for_name (connection, DBUS_SERVICE_DBUS, + DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS); + if (!org_freedesktop_DBus_request_name (proxy, TEST_NAMESPACE, + 0, &ret, &error)) { + g_warning ("There was an error requesting the name: %s", + error->message); + g_error_free (error); + exit(1); + } + + if (ret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) { + /* Someone else registered the name before us */ + exit(1); + } + + song = test_beatles_song_new (); + + /* Register the app on the bus */ + dbus_g_connection_register_g_object (connection, + TEST_OBJECT_PATH, + G_OBJECT (song)); + + dp_obj = test_dp_obj_new (); + dbus_g_connection_register_g_object (connection, + TEST_DP_OBJECT_PATH, + G_OBJECT (dp_obj)); + + loop = g_main_loop_new (NULL, FALSE); + g_main_loop_run (loop); + + return 0; +} diff --git a/test/interfaces/test-song.xml b/test/interfaces/test-song.xml new file mode 100644 index 0000000..9a57dbc --- /dev/null +++ b/test/interfaces/test-song.xml @@ -0,0 +1,9 @@ +<?xml version="1.0"?><!-- ex:set et ts=2: --> +<node name="/org/freedesktop/DBus/GLib/Test/Interfaces"> + <interface name="org.freedesktop.DBus.GLib.Test.Interfaces.Song"> + <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="test_song_dbus"/> + <method name="GetTitle"> + <arg name="title" type="s" direction="out" /> + </method> + </interface> +</node> diff --git a/test/interfaces/valid-annotations.xml b/test/interfaces/valid-annotations.xml new file mode 100644 index 0000000..38115b0 --- /dev/null +++ b/test/interfaces/valid-annotations.xml @@ -0,0 +1,27 @@ +<?xml version="1.0"?><!-- ex:set et ts=2: --> +<node name="/org/freedesktop/DBus/GLib/Test/Interfaces"> + <interface name="org.freedesktop.DBus.GLib.Test.Interfaces.Annotated"> + <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="test_annotated"/> + <annotation name="com.example.Annotatable" value="yes"/> + + <method name="DoThings"> + <annotation name="com.example.Annotatable" value="yeah"/> + <arg name="message" type="s" direction="out"> + <annotation name="com.example.MaybeAnnotatable" + value="strictly speaking this isn't meant to be allowed"/> + </arg> + </method> + + <signal name="ThingsDone"> + <annotation name="com.example.Annotatable" value="fd.o#27598 says so"/> + <arg name="message" type="s"> + <annotation name="com.example.MaybeAnnotatable" + value="strictly speaking this isn't meant to be allowed"/> + </arg> + </signal> + + <property name="Things" type="s" access="read"> + <annotation name="com.example.Annotatable" value="hopefully"/> + </property> + </interface> +</node> diff --git a/test/lib/Makefile.am b/test/lib/Makefile.am new file mode 100644 index 0000000..8a2670b --- /dev/null +++ b/test/lib/Makefile.am @@ -0,0 +1,19 @@ +AM_CPPFLAGS = \ + -I$(top_srcdir) \ + -I$(top_builddir) \ + $(DBUS_CFLAGS) \ + $(DBUS_GLIB_CFLAGS) \ + $(NULL) + +noinst_LTLIBRARIES = libtest.la + +libtest_la_SOURCES = \ + util.c \ + util.h \ + $(NULL) + +libtest_la_LIBADD = \ + $(top_builddir)/dbus/libdbus-glib-1.la \ + $(DBUS_LIBS) \ + $(DBUS_GLIB_LIBS) \ + $(NULL) diff --git a/test/lib/Makefile.in b/test/lib/Makefile.in new file mode 100644 index 0000000..cc8e99d --- /dev/null +++ b/test/lib/Makefile.in @@ -0,0 +1,570 @@ +# Makefile.in generated by automake 1.11.5 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software +# Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +VPATH = @srcdir@ +am__make_dryrun = \ + { \ + am__dry=no; \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \ + | grep '^AM OK$$' >/dev/null || am__dry=yes;; \ + *) \ + for am__flg in $$MAKEFLAGS; do \ + case $$am__flg in \ + *=*|--*) ;; \ + *n*) am__dry=yes; break;; \ + esac; \ + done;; \ + esac; \ + test $$am__dry = yes; \ + } +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = test/lib +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/gtk-doc.m4 \ + $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ + $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ + $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +LTLIBRARIES = $(noinst_LTLIBRARIES) +am__DEPENDENCIES_1 = +libtest_la_DEPENDENCIES = $(top_builddir)/dbus/libdbus-glib-1.la \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) +am_libtest_la_OBJECTS = util.lo +libtest_la_OBJECTS = $(am_libtest_la_OBJECTS) +AM_V_lt = $(am__v_lt_@AM_V@) +am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) +am__v_lt_0 = --silent +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CFLAGS) $(CFLAGS) +AM_V_CC = $(am__v_CC_@AM_V@) +am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) +am__v_CC_0 = @echo " CC " $@; +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ +CCLD = $(CC) +LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +AM_V_CCLD = $(am__v_CCLD_@AM_V@) +am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) +am__v_CCLD_0 = @echo " CCLD " $@; +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; +SOURCES = $(libtest_la_SOURCES) +DIST_SOURCES = $(libtest_la_SOURCES) +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ABSOLUTE_TOP_BUILDDIR = @ABSOLUTE_TOP_BUILDDIR@ +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DBUS_BINDING_TOOL = @DBUS_BINDING_TOOL@ +DBUS_CFLAGS = @DBUS_CFLAGS@ +DBUS_GLIB_CFLAGS = @DBUS_GLIB_CFLAGS@ +DBUS_GLIB_LIBS = @DBUS_GLIB_LIBS@ +DBUS_GLIB_THREADS_CFLAGS = @DBUS_GLIB_THREADS_CFLAGS@ +DBUS_GLIB_THREADS_LIBS = @DBUS_GLIB_THREADS_LIBS@ +DBUS_GLIB_TOOL_CFLAGS = @DBUS_GLIB_TOOL_CFLAGS@ +DBUS_GLIB_TOOL_LIBS = @DBUS_GLIB_TOOL_LIBS@ +DBUS_LIBS = @DBUS_LIBS@ +DBUS_PATH_OR_ABSTRACT = @DBUS_PATH_OR_ABSTRACT@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +EXPANDED_BINDIR = @EXPANDED_BINDIR@ +EXPANDED_DATADIR = @EXPANDED_DATADIR@ +EXPANDED_LIBDIR = @EXPANDED_LIBDIR@ +EXPANDED_LOCALSTATEDIR = @EXPANDED_LOCALSTATEDIR@ +EXPANDED_SYSCONFDIR = @EXPANDED_SYSCONFDIR@ +FGREP = @FGREP@ +GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ +GREP = @GREP@ +GTKDOC_CHECK = @GTKDOC_CHECK@ +GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@ +GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@ +GTKDOC_MKPDF = @GTKDOC_MKPDF@ +GTKDOC_REBASE = @GTKDOC_REBASE@ +HTML_DIR = @HTML_DIR@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +LT_AGE = @LT_AGE@ +LT_CURRENT = @LT_CURRENT@ +LT_REVISION = @LT_REVISION@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ +MKDIR_P = @MKDIR_P@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PKG_CONFIG = @PKG_CONFIG@ +PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ +PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +TEST_CORE_SERVICE_BINARY = @TEST_CORE_SERVICE_BINARY@ +TEST_EXIT_BINARY = @TEST_EXIT_BINARY@ +TEST_INTERFACES_SERVICE_BINARY = @TEST_INTERFACES_SERVICE_BINARY@ +TEST_SEGFAULT_BINARY = @TEST_SEGFAULT_BINARY@ +TEST_SERVICE_BINARY = @TEST_SERVICE_BINARY@ +TEST_SERVICE_DIR = @TEST_SERVICE_DIR@ +TEST_SHELL_SERVICE_BINARY = @TEST_SHELL_SERVICE_BINARY@ +TEST_SLEEP_FOREVER_BINARY = @TEST_SLEEP_FOREVER_BINARY@ +TEST_SOCKET_DIR = @TEST_SOCKET_DIR@ +VERSION = @VERSION@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +AM_CPPFLAGS = \ + -I$(top_srcdir) \ + -I$(top_builddir) \ + $(DBUS_CFLAGS) \ + $(DBUS_GLIB_CFLAGS) \ + $(NULL) + +noinst_LTLIBRARIES = libtest.la +libtest_la_SOURCES = \ + util.c \ + util.h \ + $(NULL) + +libtest_la_LIBADD = \ + $(top_builddir)/dbus/libdbus-glib-1.la \ + $(DBUS_LIBS) \ + $(DBUS_GLIB_LIBS) \ + $(NULL) + +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu test/lib/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu test/lib/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): + +clean-noinstLTLIBRARIES: + -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) + @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test "$$dir" != "$$p" || dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done +libtest.la: $(libtest_la_OBJECTS) $(libtest_la_DEPENDENCIES) $(EXTRA_libtest_la_DEPENDENCIES) + $(AM_V_CCLD)$(LINK) $(libtest_la_OBJECTS) $(libtest_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/util.Plo@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + set x; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LTLIBRARIES) +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libtool clean-noinstLTLIBRARIES ctags distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ + pdf pdf-am ps ps-am tags uninstall uninstall-am + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/test/lib/util.c b/test/lib/util.c new file mode 100644 index 0000000..ec879b5 --- /dev/null +++ b/test/lib/util.c @@ -0,0 +1,69 @@ +/* Regression test utilities + * + * Copyright © 2009 Collabora Ltd. <http://www.collabora.co.uk/> + * Copyright © 2009-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 "util.h" + +static void +destroy_cb (DBusGProxy *proxy G_GNUC_UNUSED, + gpointer user_data) +{ + gboolean *disconnected = user_data; + + *disconnected = TRUE; +} + +void +test_run_until_disconnected (DBusGConnection *connection, + GMainContext *context) +{ + gboolean disconnected = FALSE; + DBusGProxy *proxy; + + g_printerr ("Disconnecting... "); + + dbus_connection_set_exit_on_disconnect (dbus_g_connection_get_connection (connection), + FALSE); + + /* low-level tests might not have called this yet */ + g_type_init (); + + proxy = dbus_g_proxy_new_for_peer (connection, "/", + "org.freedesktop.DBus.Peer"); + g_signal_connect (G_OBJECT (proxy), "destroy", G_CALLBACK (destroy_cb), + &disconnected); + + dbus_connection_close (dbus_g_connection_get_connection (connection)); + + while (!disconnected) + { + g_printerr ("."); + g_main_context_iteration (context, TRUE); + } + + g_signal_handlers_disconnect_by_func (proxy, destroy_cb, &disconnected); + g_object_unref (proxy); + + g_printerr (" disconnected\n"); +} diff --git a/test/lib/util.h b/test/lib/util.h new file mode 100644 index 0000000..bc6fa60 --- /dev/null +++ b/test/lib/util.h @@ -0,0 +1,32 @@ +/* Regression test utilities + * + * Copyright © 2009 Collabora Ltd. <http://www.collabora.co.uk/> + * Copyright © 2009-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 + */ + +#ifndef DBUS_GLIB_TEST_UTIL_H + +#include <dbus/dbus-glib.h> +#include <dbus/dbus-glib-lowlevel.h> + +void test_run_until_disconnected (DBusGConnection *connection, + GMainContext *context); + +#endif diff --git a/test/manual/Makefile.am b/test/manual/Makefile.am new file mode 100644 index 0000000..b028b6c --- /dev/null +++ b/test/manual/Makefile.am @@ -0,0 +1,32 @@ +AM_CPPFLAGS = \ + -I$(top_srcdir) \ + -I$(top_builddir) \ + -I$(top_srcdir)/test/core \ + -I$(top_builddir)/test/core \ + $(DBUS_CFLAGS) \ + $(DBUS_GLIB_CFLAGS) \ + $(NULL) + +LDADD = \ + $(top_builddir)/dbus/libdbus-glib-1.la \ + $(DBUS_LIBS) \ + $(DBUS_GLIB_LIBS) \ + $(NULL) + +noinst_PROGRAMS = \ + $(NULL) + +if DBUS_BUILD_TESTS +noinst_PROGRAMS += \ + test-invalid-usage \ + $(NULL) +endif + +# This "test" exercises invalid usage. It is deliberately not run in +# TESTS, because it's (by design) full of bugs. +test_invalid_usage_SOURCES = \ + ../core/my-object-marshal.c \ + ../core/my-object-marshal.h \ + ../core/my-object.c \ + ../core/my-object.h \ + invalid-usage.c diff --git a/test/manual/Makefile.in b/test/manual/Makefile.in new file mode 100644 index 0000000..04dbf4d --- /dev/null +++ b/test/manual/Makefile.in @@ -0,0 +1,616 @@ +# Makefile.in generated by automake 1.11.5 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software +# Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +VPATH = @srcdir@ +am__make_dryrun = \ + { \ + am__dry=no; \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \ + | grep '^AM OK$$' >/dev/null || am__dry=yes;; \ + *) \ + for am__flg in $$MAKEFLAGS; do \ + case $$am__flg in \ + *=*|--*) ;; \ + *n*) am__dry=yes; break;; \ + esac; \ + done;; \ + esac; \ + test $$am__dry = yes; \ + } +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +noinst_PROGRAMS = $(am__EXEEXT_1) +@DBUS_BUILD_TESTS_TRUE@am__append_1 = \ +@DBUS_BUILD_TESTS_TRUE@ test-invalid-usage \ +@DBUS_BUILD_TESTS_TRUE@ $(NULL) + +subdir = test/manual +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/gtk-doc.m4 \ + $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ + $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ + $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +@DBUS_BUILD_TESTS_TRUE@am__EXEEXT_1 = test-invalid-usage$(EXEEXT) +PROGRAMS = $(noinst_PROGRAMS) +am_test_invalid_usage_OBJECTS = my-object-marshal.$(OBJEXT) \ + my-object.$(OBJEXT) invalid-usage.$(OBJEXT) +test_invalid_usage_OBJECTS = $(am_test_invalid_usage_OBJECTS) +test_invalid_usage_LDADD = $(LDADD) +am__DEPENDENCIES_1 = +test_invalid_usage_DEPENDENCIES = \ + $(top_builddir)/dbus/libdbus-glib-1.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) +AM_V_lt = $(am__v_lt_@AM_V@) +am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) +am__v_lt_0 = --silent +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CFLAGS) $(CFLAGS) +AM_V_CC = $(am__v_CC_@AM_V@) +am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) +am__v_CC_0 = @echo " CC " $@; +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ +CCLD = $(CC) +LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +AM_V_CCLD = $(am__v_CCLD_@AM_V@) +am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) +am__v_CCLD_0 = @echo " CCLD " $@; +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; +SOURCES = $(test_invalid_usage_SOURCES) +DIST_SOURCES = $(test_invalid_usage_SOURCES) +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ABSOLUTE_TOP_BUILDDIR = @ABSOLUTE_TOP_BUILDDIR@ +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DBUS_BINDING_TOOL = @DBUS_BINDING_TOOL@ +DBUS_CFLAGS = @DBUS_CFLAGS@ +DBUS_GLIB_CFLAGS = @DBUS_GLIB_CFLAGS@ +DBUS_GLIB_LIBS = @DBUS_GLIB_LIBS@ +DBUS_GLIB_THREADS_CFLAGS = @DBUS_GLIB_THREADS_CFLAGS@ +DBUS_GLIB_THREADS_LIBS = @DBUS_GLIB_THREADS_LIBS@ +DBUS_GLIB_TOOL_CFLAGS = @DBUS_GLIB_TOOL_CFLAGS@ +DBUS_GLIB_TOOL_LIBS = @DBUS_GLIB_TOOL_LIBS@ +DBUS_LIBS = @DBUS_LIBS@ +DBUS_PATH_OR_ABSTRACT = @DBUS_PATH_OR_ABSTRACT@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +EXPANDED_BINDIR = @EXPANDED_BINDIR@ +EXPANDED_DATADIR = @EXPANDED_DATADIR@ +EXPANDED_LIBDIR = @EXPANDED_LIBDIR@ +EXPANDED_LOCALSTATEDIR = @EXPANDED_LOCALSTATEDIR@ +EXPANDED_SYSCONFDIR = @EXPANDED_SYSCONFDIR@ +FGREP = @FGREP@ +GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ +GREP = @GREP@ +GTKDOC_CHECK = @GTKDOC_CHECK@ +GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@ +GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@ +GTKDOC_MKPDF = @GTKDOC_MKPDF@ +GTKDOC_REBASE = @GTKDOC_REBASE@ +HTML_DIR = @HTML_DIR@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +LT_AGE = @LT_AGE@ +LT_CURRENT = @LT_CURRENT@ +LT_REVISION = @LT_REVISION@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ +MKDIR_P = @MKDIR_P@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PKG_CONFIG = @PKG_CONFIG@ +PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ +PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +TEST_CORE_SERVICE_BINARY = @TEST_CORE_SERVICE_BINARY@ +TEST_EXIT_BINARY = @TEST_EXIT_BINARY@ +TEST_INTERFACES_SERVICE_BINARY = @TEST_INTERFACES_SERVICE_BINARY@ +TEST_SEGFAULT_BINARY = @TEST_SEGFAULT_BINARY@ +TEST_SERVICE_BINARY = @TEST_SERVICE_BINARY@ +TEST_SERVICE_DIR = @TEST_SERVICE_DIR@ +TEST_SHELL_SERVICE_BINARY = @TEST_SHELL_SERVICE_BINARY@ +TEST_SLEEP_FOREVER_BINARY = @TEST_SLEEP_FOREVER_BINARY@ +TEST_SOCKET_DIR = @TEST_SOCKET_DIR@ +VERSION = @VERSION@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +AM_CPPFLAGS = \ + -I$(top_srcdir) \ + -I$(top_builddir) \ + -I$(top_srcdir)/test/core \ + -I$(top_builddir)/test/core \ + $(DBUS_CFLAGS) \ + $(DBUS_GLIB_CFLAGS) \ + $(NULL) + +LDADD = \ + $(top_builddir)/dbus/libdbus-glib-1.la \ + $(DBUS_LIBS) \ + $(DBUS_GLIB_LIBS) \ + $(NULL) + + +# This "test" exercises invalid usage. It is deliberately not run in +# TESTS, because it's (by design) full of bugs. +test_invalid_usage_SOURCES = \ + ../core/my-object-marshal.c \ + ../core/my-object-marshal.h \ + ../core/my-object.c \ + ../core/my-object.h \ + invalid-usage.c + +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu test/manual/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu test/manual/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): + +clean-noinstPROGRAMS: + @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \ + echo " rm -f" $$list; \ + rm -f $$list || exit $$?; \ + test -n "$(EXEEXT)" || exit 0; \ + list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f" $$list; \ + rm -f $$list +test-invalid-usage$(EXEEXT): $(test_invalid_usage_OBJECTS) $(test_invalid_usage_DEPENDENCIES) $(EXTRA_test_invalid_usage_DEPENDENCIES) + @rm -f test-invalid-usage$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_invalid_usage_OBJECTS) $(test_invalid_usage_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/invalid-usage.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/my-object-marshal.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/my-object.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< + +my-object-marshal.o: ../core/my-object-marshal.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT my-object-marshal.o -MD -MP -MF $(DEPDIR)/my-object-marshal.Tpo -c -o my-object-marshal.o `test -f '../core/my-object-marshal.c' || echo '$(srcdir)/'`../core/my-object-marshal.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/my-object-marshal.Tpo $(DEPDIR)/my-object-marshal.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../core/my-object-marshal.c' object='my-object-marshal.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o my-object-marshal.o `test -f '../core/my-object-marshal.c' || echo '$(srcdir)/'`../core/my-object-marshal.c + +my-object-marshal.obj: ../core/my-object-marshal.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT my-object-marshal.obj -MD -MP -MF $(DEPDIR)/my-object-marshal.Tpo -c -o my-object-marshal.obj `if test -f '../core/my-object-marshal.c'; then $(CYGPATH_W) '../core/my-object-marshal.c'; else $(CYGPATH_W) '$(srcdir)/../core/my-object-marshal.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/my-object-marshal.Tpo $(DEPDIR)/my-object-marshal.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../core/my-object-marshal.c' object='my-object-marshal.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o my-object-marshal.obj `if test -f '../core/my-object-marshal.c'; then $(CYGPATH_W) '../core/my-object-marshal.c'; else $(CYGPATH_W) '$(srcdir)/../core/my-object-marshal.c'; fi` + +my-object.o: ../core/my-object.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT my-object.o -MD -MP -MF $(DEPDIR)/my-object.Tpo -c -o my-object.o `test -f '../core/my-object.c' || echo '$(srcdir)/'`../core/my-object.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/my-object.Tpo $(DEPDIR)/my-object.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../core/my-object.c' object='my-object.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o my-object.o `test -f '../core/my-object.c' || echo '$(srcdir)/'`../core/my-object.c + +my-object.obj: ../core/my-object.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT my-object.obj -MD -MP -MF $(DEPDIR)/my-object.Tpo -c -o my-object.obj `if test -f '../core/my-object.c'; then $(CYGPATH_W) '../core/my-object.c'; else $(CYGPATH_W) '$(srcdir)/../core/my-object.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/my-object.Tpo $(DEPDIR)/my-object.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../core/my-object.c' object='my-object.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o my-object.obj `if test -f '../core/my-object.c'; then $(CYGPATH_W) '../core/my-object.c'; else $(CYGPATH_W) '$(srcdir)/../core/my-object.c'; fi` + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + set x; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(PROGRAMS) +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool clean-noinstPROGRAMS \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libtool clean-noinstPROGRAMS ctags distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ + pdf pdf-am ps ps-am tags uninstall uninstall-am + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/test/manual/invalid-usage.c b/test/manual/invalid-usage.c new file mode 100644 index 0000000..95a2591 --- /dev/null +++ b/test/manual/invalid-usage.c @@ -0,0 +1,320 @@ +/* Manual test for various invalid usages which should not crash us (in order + * to be nice to fallible programmers), unless checks have been disabled (in + * which case, you asked for it, you got it). + * + * Copyright © 2006-2010 Red Hat, Inc. + * Copyright © 2006-2010 Collabora Ltd. + * Copyright © 2006-2011 Nokia Corporation + * Copyright © 2006 Steve Frécinaux + * + * 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 <glib.h> + +#include <dbus/dbus.h> +#include <dbus/dbus-glib.h> +#include <dbus/dbus-glib-lowlevel.h> + +#include <string.h> + +#include "my-object.h" +#include "test-service-glib-bindings.h" + +/* my-object wants this to exist */ +GMainLoop *loop = NULL; + +typedef struct { + GError *error; + DBusGConnection *conn; + DBusGProxy *proxy; + DBusGProxy *proxy_for_self; + GObject *object; +} Fixture; + +static void +setup (Fixture *f, + gconstpointer context) +{ + /* this test is all about (mostly critical) warnings, so don't crash out on + * programming errors */ + g_setenv ("DBUS_FATAL_WARNINGS", "0", TRUE); + g_log_set_always_fatal (G_LOG_LEVEL_ERROR); + + dbus_g_type_specialized_init (); + + /* This is a bug: you're not meant to register any domain more than + * once. It shouldn't crash, though. */ + dbus_g_error_domain_register (MY_OBJECT_ERROR, NULL, MY_TYPE_ERROR); + + f->conn = dbus_g_bus_get_private (DBUS_BUS_SESSION, NULL, &f->error); + g_assert_no_error (f->error); + g_assert (f->conn != NULL); + + f->proxy = dbus_g_proxy_new_for_name (f->conn, "com.example.Test", + "/com/example/Test/Object", "com.example.Test.Fallible"); + g_assert (f->proxy != NULL); + + f->object = g_object_new (MY_TYPE_OBJECT, NULL); + g_assert (MY_IS_OBJECT (f->object)); + dbus_g_connection_register_g_object (f->conn, "/com/example/Test/Object", + f->object); + + f->proxy_for_self = dbus_g_proxy_new_for_name (f->conn, + dbus_bus_get_unique_name (dbus_g_connection_get_connection (f->conn)), + "/com/example/Test/Object", "org.freedesktop.DBus.GLib.Tests.MyObject"); + g_assert (f->proxy_for_self != NULL); +} + +static void +test_invalid_gtype (Fixture *f, + gconstpointer context) +{ + /* G_TYPE_GTYPE is not handled by the dbus-glib type system (and would make + * no sense anyway) */ + dbus_g_proxy_call_no_reply (f->proxy, "Fail", + G_TYPE_GTYPE, G_TYPE_STRING, + G_TYPE_INVALID); +} + +static void +test_invalid_utf8 (Fixture *f, + gconstpointer context) +{ + g_test_bug ("30171"); + + /* This provokes a libdbus warning, which is fatal-by-default */ + dbus_g_proxy_call_no_reply (f->proxy, "Fail", + G_TYPE_STRING, "\xfe\xfe\xfe", + G_TYPE_INVALID); +} + +static void +test_invalid_bool (Fixture *f, + gconstpointer context) +{ + g_test_bug ("30171"); + + /* This provokes a libdbus warning, which is fatal-by-default */ + dbus_g_proxy_call_no_reply (f->proxy, "Fail", + G_TYPE_BOOLEAN, (gboolean) (-42), + G_TYPE_INVALID); +} + +static void +test_invalid_path (Fixture *f, + gconstpointer context) +{ + g_test_bug ("30171"); + + /* This provokes a libdbus warning, which is fatal-by-default */ + dbus_g_proxy_call_no_reply (f->proxy, "Fail", + DBUS_TYPE_G_OBJECT_PATH, "$%#*!", + G_TYPE_INVALID); +} + +static void +test_invalid_utf8s (Fixture *f, + gconstpointer context) +{ + gchar *bad_strings[] = { "\xfe\xfe\xfe", NULL }; + GStrv bad_strv = bad_strings; + + g_test_bug ("30171"); + + /* This provokes a libdbus warning, which is fatal-by-default */ + dbus_g_proxy_call_no_reply (f->proxy, "Fail", + G_TYPE_STRV, bad_strv, + G_TYPE_INVALID); +} + +static void +test_invalid_bools (Fixture *f, + gconstpointer context) +{ + GArray *array; + gboolean maybe = (gboolean) (-23); + + g_test_bug ("30171"); + + array = g_array_new (FALSE, FALSE, sizeof (gboolean)); + + g_array_append_val (array, maybe); + + /* This provokes a libdbus warning, which is fatal-by-default */ + dbus_g_proxy_call_no_reply (f->proxy, "Fail", + dbus_g_type_get_collection ("GArray", G_TYPE_BOOLEAN), array, + G_TYPE_INVALID); + + g_array_free (array, TRUE); +} + +static void +test_invalid_paths (Fixture *f, + gconstpointer context) +{ + GPtrArray *array; + + g_test_bug ("30171"); + + array = g_ptr_array_new (); + g_ptr_array_add (array, "bees"); + + /* This provokes a libdbus warning, which is fatal-by-default */ + dbus_g_proxy_call_no_reply (f->proxy, "Fail", + dbus_g_type_get_collection ("GPtrArray", DBUS_TYPE_G_OBJECT_PATH), array, + G_TYPE_INVALID); + + g_ptr_array_free (array, TRUE); +} + +static void +throw_error_cb (DBusGProxy *proxy, + GError *error, + gpointer user_data) +{ + GError **error_out = user_data; + + g_assert (error != NULL); + *error_out = g_error_copy (error); +} + +static void +test_error_out_of_range (Fixture *f, + gconstpointer context) +{ + GError *error = NULL; + + g_test_bug ("40151"); + + /* This is a bug: -1 isn't a valid code for the domain. */ + my_object_save_error ((MyObject *) f->object, MY_OBJECT_ERROR, -1, + "stop being so negative"); + + if (!org_freedesktop_DBus_GLib_Tests_MyObject_throw_error_async ( + f->proxy_for_self, throw_error_cb, &error)) + g_error ("Failed to start async ThrowError call"); + + while (error == NULL) + g_main_context_iteration (NULL, TRUE); + + g_assert_error (error, DBUS_GERROR, DBUS_GERROR_REMOTE_EXCEPTION); + g_clear_error (&error); + + /* This is a bug: 666 isn't a valid code for the domain. */ + my_object_save_error ((MyObject *) f->object, MY_OBJECT_ERROR, 666, + "demonic possession detected"); + + if (!org_freedesktop_DBus_GLib_Tests_MyObject_throw_error_async ( + f->proxy_for_self, throw_error_cb, &error)) + g_error ("Failed to start async ThrowError call"); + + while (error == NULL) + g_main_context_iteration (NULL, TRUE); + + g_assert_error (error, DBUS_GERROR, DBUS_GERROR_REMOTE_EXCEPTION); + g_clear_error (&error); +} + +static void +test_error_domain_0 (Fixture *f, + gconstpointer context) +{ + /* This throws an error with domain 0 and code 0, which makes no sense. + * It's programmer error, really: g_error_new() would critical if given + * the same domain and code. See GNOME#660371. + * + * This was added for fd.o #27799, but there's a difference between + * "this is an error domain, but not one registered with dbus-glib" and + * "this isn't even an error domain". */ + g_test_bug ("27799"); + + if (!org_freedesktop_DBus_GLib_Tests_MyObject_throw_unregistered_error_async ( + f->proxy_for_self, throw_error_cb, f)) + g_error ("Failed to start async ThrowUnregisteredError call"); + + while (f->error == NULL) + g_main_context_iteration (NULL, TRUE); + + g_assert_error (f->error, DBUS_GERROR, DBUS_GERROR_REMOTE_EXCEPTION); +} + +static void +teardown (Fixture *f, + gconstpointer context G_GNUC_UNUSED) +{ + g_clear_error (&f->error); + + if (f->proxy != NULL) + { + g_object_unref (f->proxy); + f->proxy = NULL; + } + + if (f->object != NULL) + { + g_object_unref (f->object); + f->object = NULL; + } + + if (f->proxy_for_self != NULL) + { + g_object_unref (f->proxy_for_self); + f->proxy_for_self = NULL; + } + + if (f->conn != NULL) + { + dbus_connection_close (dbus_g_connection_get_connection (f->conn)); + dbus_g_connection_unref (f->conn); + f->conn = NULL; + } +} + +int +main (int argc, + char **argv) +{ + g_test_init (&argc, &argv, NULL); + g_test_bug_base ("https://bugs.freedesktop.org/show_bug.cgi?id="); + + g_type_init (); + + g_test_add ("/invalid/gtype", Fixture, NULL, setup, test_invalid_gtype, + teardown); + g_test_add ("/invalid/utf8", Fixture, NULL, setup, test_invalid_utf8, + teardown); + g_test_add ("/invalid/bool", Fixture, NULL, setup, test_invalid_bool, + teardown); + g_test_add ("/invalid/path", Fixture, NULL, setup, test_invalid_path, + teardown); + g_test_add ("/invalid/utf8s", Fixture, NULL, setup, test_invalid_utf8s, + teardown); + g_test_add ("/invalid/bools", Fixture, NULL, setup, test_invalid_bools, + teardown); + g_test_add ("/invalid/paths", Fixture, NULL, setup, test_invalid_paths, + teardown); + g_test_add ("/invalid/error/out-of-range", Fixture, NULL, setup, + test_error_out_of_range, teardown); + g_test_add ("/invalid/error/domain-0", Fixture, NULL, setup, + test_error_domain_0, teardown); + + return g_test_run (); +} diff --git a/test/test-compile-nested.sh b/test/test-compile-nested.sh new file mode 100755 index 0000000..ebc209c --- /dev/null +++ b/test/test-compile-nested.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +# http://bugs.freedesktop.org/show_bug.cgi?id=19065 +echo ${DEBUG} ${top_builddir}/dbus/dbus-binding-tool --mode=glib-server --prefix=test ${srcdir}/data/nested-introspect.xml +${DEBUG} ${top_builddir}/dbus/dbus-binding-tool --mode=glib-server --prefix=test ${srcdir}/data/nested-introspect.xml >/dev/null
\ No newline at end of file diff --git a/test/test-service.c b/test/test-service.c new file mode 100644 index 0000000..10ef50a --- /dev/null +++ b/test/test-service.c @@ -0,0 +1,375 @@ +#include <config.h> + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <dbus/dbus.h> + +static dbus_bool_t already_quit = FALSE; +static dbus_bool_t hello_from_self_reply_recived = FALSE; + +static void +quit (void) +{ + if (!already_quit) + already_quit = TRUE; +} + +static void +die (const char *message) +{ + fprintf (stderr, "*** test-service: %s", message); + exit (1); +} + +static void +check_hello_from_self_reply (DBusPendingCall *pcall, + void *user_data) +{ + DBusMessage *reply; + DBusMessage *echo_message, *echo_reply; + DBusError error; + DBusConnection *connection; + + int type; + + dbus_error_init (&error); + + connection = dbus_bus_get (DBUS_BUS_STARTER, &error); + if (connection == NULL) + { + fprintf (stderr, "*** Failed to open connection to activating message bus: %s\n", + error.message); + dbus_error_free (&error); + die("no memory"); + } + + + echo_message = (DBusMessage *)user_data; + + reply = dbus_pending_call_steal_reply (pcall); + + type = dbus_message_get_type (reply); + + if (type == DBUS_MESSAGE_TYPE_METHOD_RETURN) + { + const char *s; + printf ("Reply from HelloFromSelf recived\n"); + + if (!dbus_message_get_args (echo_message, + &error, + DBUS_TYPE_STRING, &s, + DBUS_TYPE_INVALID)) + { + echo_reply = dbus_message_new_error (echo_message, + error.name, + error.message); + + if (echo_reply == NULL) + die ("No memory\n"); + + } + else + { + echo_reply = dbus_message_new_method_return (echo_message); + if (echo_reply == NULL) + die ("No memory\n"); + + if (!dbus_message_append_args (echo_reply, + DBUS_TYPE_STRING, &s, + DBUS_TYPE_INVALID)) + die ("No memory"); + } + + if (!dbus_connection_send (connection, echo_reply, NULL)) + die ("No memory\n"); + + dbus_message_unref (echo_reply); + } + else if (type == DBUS_MESSAGE_TYPE_ERROR) + { + dbus_set_error_from_message (&error, reply); + printf ("Error type in reply: %s\n", error.message); + + if (strcmp (error.name, DBUS_ERROR_NO_MEMORY) != 0) + { + echo_reply = dbus_message_new_error (echo_message, + error.name, + error.message); + + if (echo_reply == NULL) + die ("No memory\n"); + + if (!dbus_connection_send (connection, echo_reply, NULL)) + die ("No memory\n"); + + dbus_message_unref (echo_reply); + } + dbus_error_free (&error); + } + + hello_from_self_reply_recived = TRUE; + + dbus_message_unref (reply); + dbus_message_unref (echo_message); + dbus_pending_call_unref (pcall); +} + +static DBusHandlerResult +handle_run_hello_from_self (DBusConnection *connection, + DBusMessage *message) +{ + DBusError error; + DBusMessage *reply, *self_message; + DBusPendingCall *pcall; + char *s; + + dbus_error_init (&error); + + if (!dbus_message_get_args (message, + &error, + DBUS_TYPE_STRING, &s, + DBUS_TYPE_INVALID)) + { + reply = dbus_message_new_error (message, + error.name, + error.message); + + if (reply == NULL) + die ("No memory\n"); + + if (!dbus_connection_send (connection, reply, NULL)) + die ("No memory\n"); + + dbus_message_unref (reply); + + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + } + printf ("Sending HelloFromSelf\n"); + + self_message = dbus_message_new_method_call ("org.freedesktop.DBus.GLib.TestEchoService", + "/org/freedesktop/DBus/GLib/TestSuite", + "org.freedesktop.DBus.GLib.TestSuite", + "HelloFromSelf"); + + if (self_message == NULL) + die ("No memory"); + + if (!dbus_connection_send_with_reply (connection, self_message, &pcall, -1)) + die("No memory"); + + dbus_message_ref (message); + if (!dbus_pending_call_set_notify (pcall, check_hello_from_self_reply, (void *)message, NULL)) + die("No memory"); + + printf ("Sent HelloFromSelf\n"); + return DBUS_HANDLER_RESULT_HANDLED; +} + +static DBusHandlerResult +handle_echo (DBusConnection *connection, + DBusMessage *message) +{ + DBusError error; + DBusMessage *reply; + char *s; + + dbus_error_init (&error); + + if (!dbus_message_get_args (message, + &error, + DBUS_TYPE_STRING, &s, + DBUS_TYPE_INVALID)) + { + reply = dbus_message_new_error (message, + error.name, + error.message); + + if (reply == NULL) + die ("No memory\n"); + + if (!dbus_connection_send (connection, reply, NULL)) + die ("No memory\n"); + + dbus_message_unref (reply); + + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + } + + reply = dbus_message_new_method_return (message); + if (reply == NULL) + die ("No memory\n"); + + if (!dbus_message_append_args (reply, + DBUS_TYPE_STRING, &s, + DBUS_TYPE_INVALID)) + die ("No memory"); + + if (!dbus_connection_send (connection, reply, NULL)) + die ("No memory\n"); + + fprintf (stderr, "Echo service echoed string: \"%s\"\n", s); + + dbus_message_unref (reply); + + return DBUS_HANDLER_RESULT_HANDLED; +} + +static void +path_unregistered_func (DBusConnection *connection, + void *user_data) +{ + /* connection was finalized */ +} + +static DBusHandlerResult +path_message_func (DBusConnection *connection, + DBusMessage *message, + void *user_data) +{ + if (dbus_message_is_method_call (message, + "org.freedesktop.DBus.GLib.TestSuite", + "Echo")) + return handle_echo (connection, message); + else if (dbus_message_is_method_call (message, + "org.freedesktop.DBus.GLib.TestSuite", + "Exit")) + { + dbus_connection_close (connection); + quit (); + return DBUS_HANDLER_RESULT_HANDLED; + } + else if (dbus_message_is_method_call (message, + "org.freedesktop.DBus.GLib.TestSuite", + "EmitFoo")) + { + /* Emit the Foo signal */ + DBusMessage *signal; + double v_DOUBLE; + + signal = dbus_message_new_signal ("/org/freedesktop/DBus/GLib/TestSuite", + "org.freedesktop.DBus.GLib.TestSuite", + "Foo"); + if (signal == NULL) + die ("No memory\n"); + + v_DOUBLE = 42.6; + if (!dbus_message_append_args (signal, + DBUS_TYPE_DOUBLE, &v_DOUBLE, + DBUS_TYPE_INVALID)) + die ("No memory"); + + if (!dbus_connection_send (connection, signal, NULL)) + die ("No memory\n"); + + return DBUS_HANDLER_RESULT_HANDLED; + } + + else if (dbus_message_is_method_call (message, + "org.freedesktop.DBus.GLib.TestSuite", + "RunHelloFromSelf")) + { + return handle_run_hello_from_self (connection, message); + } + else if (dbus_message_is_method_call (message, + "org.freedesktop.DBus.GLib.TestSuite", + "HelloFromSelf")) + { + DBusMessage *reply; + printf ("Recived the HelloFromSelf message\n"); + + reply = dbus_message_new_method_return (message); + if (reply == NULL) + die ("No memory"); + + if (!dbus_connection_send (connection, reply, NULL)) + die ("No memory"); + } + + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; +} + +static DBusObjectPathVTable +echo_vtable = { + path_unregistered_func, + path_message_func, + NULL, +}; + + +static const char* echo_path = "/org/freedesktop/DBus/GLib/TestSuite" ; + +static DBusHandlerResult +filter_func (DBusConnection *connection, + DBusMessage *message, + void *user_data) +{ + if (dbus_message_is_signal (message, + DBUS_INTERFACE_LOCAL, + "Disconnected")) + { + dbus_connection_close (connection); + quit (); + return DBUS_HANDLER_RESULT_HANDLED; + } + else + { + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + } +} + +int +main (int argc, + char **argv) +{ + DBusError error; + DBusConnection *connection; + + dbus_error_init (&error); + connection = dbus_bus_get (DBUS_BUS_STARTER, &error); + if (connection == NULL) + { + fprintf (stderr, "*** Failed to open connection to activating message bus: %s\n", + error.message); + dbus_error_free (&error); + return 1; + } + + if (!dbus_connection_add_filter (connection, + filter_func, NULL, NULL)) + die ("No memory"); + + if (!dbus_connection_register_object_path (connection, + echo_path, + &echo_vtable, + (void*) 0xdeadbeef)) + die ("No memory"); + + { + void *d; + if (!dbus_connection_get_object_path_data (connection, echo_path, &d)) + die ("No memory"); + if (d != (void*) 0xdeadbeef) + die ("dbus_connection_get_object_path_data() doesn't seem to work right\n"); + } + + dbus_bus_request_name (connection, "org.freedesktop.DBus.GLib.TestEchoService", + 0, &error); + if (dbus_error_is_set (&error)) + { + fprintf (stderr, "Error %s\n", error.message); + dbus_error_free (&error); + exit (1); + } + + while (dbus_connection_read_write_dispatch (connection, -1) && !already_quit) + ; + + dbus_connection_remove_filter (connection, filter_func, NULL); + + dbus_connection_unref (connection); + + dbus_shutdown (); + + return 0; +} |