diff options
author | Simon McVittie <smcv@debian.org> | 2011-09-21 18:32:41 +0100 |
---|---|---|
committer | Simon McVittie <smcv@debian.org> | 2011-09-21 18:32:41 +0100 |
commit | 179af6d37b9de89aa652bd19ff7424c9f08b55f0 (patch) | |
tree | 0aee07562f29700dc1973ba4fc1048aa547ab0af /test | |
parent | 3ec6cdd0d254d59fa5325753d628de3e9802ea43 (diff) | |
download | dbus-179af6d37b9de89aa652bd19ff7424c9f08b55f0.tar.gz |
Imported Upstream version 1.5.8upstream/1.5.8
Diffstat (limited to 'test')
-rw-r--r-- | test/Makefile.am | 26 | ||||
-rw-r--r-- | test/Makefile.in | 105 | ||||
-rw-r--r-- | test/data/valid-config-files/session.conf | 63 | ||||
-rw-r--r-- | test/data/valid-config-files/system.conf | 83 | ||||
-rw-r--r-- | test/dbus-daemon-eavesdrop.c | 9 | ||||
-rw-r--r-- | test/dbus-daemon.c | 7 | ||||
-rw-r--r-- | test/internals/refs.c | 612 | ||||
-rw-r--r-- | test/internals/syslog.c | 100 | ||||
-rw-r--r-- | test/marshal.c | 1 | ||||
-rw-r--r-- | test/name-test/Makefile.am | 2 | ||||
-rw-r--r-- | test/name-test/Makefile.in | 11 | ||||
-rwxr-xr-x | test/name-test/run-test-systemserver.sh | 5 | ||||
-rwxr-xr-x | test/name-test/run-test.sh | 4 | ||||
-rw-r--r-- | test/name-test/test-privserver-client.c | 1 | ||||
-rw-r--r-- | test/relay.c | 12 | ||||
-rw-r--r-- | test/test-service.c | 9 | ||||
-rw-r--r-- | test/test-shell-service.c | 7 |
17 files changed, 870 insertions, 187 deletions
diff --git a/test/Makefile.am b/test/Makefile.am index 7adb8233..d69e7835 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -13,6 +13,13 @@ AM_CPPFLAGS = \ # improve backtraces from test stuff AM_LDFLAGS = @R_DYNAMIC_LDFLAG@ +static_cppflags = \ + $(AM_CPPFLAGS) \ + -DDBUS_STATIC_BUILD \ + $(NULL) + +libdbus_testutils_la_CPPFLAGS = \ + $(static_cppflags) libdbus_testutils_la_SOURCES = \ test-utils.c \ test-utils.h \ @@ -65,11 +72,6 @@ endif !DBUS_BUILD_TESTS noinst_PROGRAMS= $(TEST_BINARIES) -static_cppflags = \ - $(AM_CPPFLAGS) \ - -DDBUS_STATIC_BUILD \ - $(NULL) - test_service_CPPFLAGS = $(static_cppflags) test_service_LDADD = libdbus-testutils.la test_names_CPPFLAGS = $(static_cppflags) @@ -83,6 +85,14 @@ shell_test_LDADD = libdbus-testutils.la spawn_test_CPPFLAGS = $(static_cppflags) spawn_test_LDADD = $(top_builddir)/dbus/libdbus-internal.la +test_refs_SOURCES = internals/refs.c +test_refs_CPPFLAGS = $(static_cppflags) +test_refs_LDADD = libdbus-testutils.la $(GLIB_LIBS) + +test_syslog_SOURCES = internals/syslog.c +test_syslog_CPPFLAGS = $(static_cppflags) +test_syslog_LDADD = libdbus-testutils.la $(GLIB_LIBS) + EXTRA_DIST = dbus-test-runner testexecdir = $(libdir)/dbus-1.0/test @@ -95,7 +105,9 @@ installable_tests = \ test-dbus-daemon-eavesdrop \ test-loopback \ test-marshal \ + test-refs \ test-relay \ + test-syslog \ $(NULL) installcheck_tests = @@ -251,6 +263,8 @@ clean-local: REVERSEDIRS="$$D $$REVERSEDIRS" ; \ done ; \ for D in $$REVERSEDIRS; do \ - rmdir $(top_builddir)/test/$$D || exit 1 ; \ + rmdir $(top_builddir)/test/$$D || \ + test ! -d $(top_builddir)/test/$$D || \ + exit 1 ; \ done ; \ fi diff --git a/test/Makefile.in b/test/Makefile.in index 76c547a6..57ef02de 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -67,7 +67,7 @@ CONFIG_CLEAN_VPATH_FILES = LTLIBRARIES = $(noinst_LTLIBRARIES) libdbus_testutils_la_DEPENDENCIES = \ $(top_builddir)/dbus/libdbus-internal.la -am_libdbus_testutils_la_OBJECTS = test-utils.lo +am_libdbus_testutils_la_OBJECTS = libdbus_testutils_la-test-utils.lo libdbus_testutils_la_OBJECTS = $(am_libdbus_testutils_la_OBJECTS) AM_V_lt = $(am__v_lt_$(V)) am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY)) @@ -81,7 +81,8 @@ am__v_lt_0 = --silent @DBUS_BUILD_TESTS_TRUE@ test-sleep-forever$(EXEEXT) am__EXEEXT_2 = test-corrupt$(EXEEXT) test-dbus-daemon$(EXEEXT) \ test-dbus-daemon-eavesdrop$(EXEEXT) test-loopback$(EXEEXT) \ - test-marshal$(EXEEXT) test-relay$(EXEEXT) + test-marshal$(EXEEXT) test-refs$(EXEEXT) test-relay$(EXEEXT) \ + test-syslog$(EXEEXT) @DBUS_ENABLE_INSTALLED_TESTS_FALSE@@DBUS_ENABLE_MODULAR_TESTS_TRUE@am__EXEEXT_3 = $(am__EXEEXT_2) @DBUS_ENABLE_INSTALLED_TESTS_TRUE@@DBUS_ENABLE_MODULAR_TESTS_TRUE@am__EXEEXT_4 = $(am__EXEEXT_2) am__installdirs = "$(DESTDIR)$(testexecdir)" @@ -126,6 +127,9 @@ test_marshal_DEPENDENCIES = $(top_builddir)/dbus/libdbus-1.la \ test_names_SOURCES = test-names.c test_names_OBJECTS = test_names-test-names.$(OBJEXT) test_names_DEPENDENCIES = libdbus-testutils.la +am_test_refs_OBJECTS = test_refs-refs.$(OBJEXT) +test_refs_OBJECTS = $(am_test_refs_OBJECTS) +test_refs_DEPENDENCIES = libdbus-testutils.la $(am__DEPENDENCIES_1) am_test_relay_OBJECTS = relay.$(OBJEXT) test_relay_OBJECTS = $(am_test_relay_OBJECTS) test_relay_DEPENDENCIES = $(top_builddir)/dbus/libdbus-1.la \ @@ -143,6 +147,9 @@ test_shell_service_DEPENDENCIES = libdbus-testutils.la test_sleep_forever_SOURCES = test-sleep-forever.c test_sleep_forever_OBJECTS = test-sleep-forever.$(OBJEXT) test_sleep_forever_LDADD = $(LDADD) +am_test_syslog_OBJECTS = test_syslog-syslog.$(OBJEXT) +test_syslog_OBJECTS = $(am_test_syslog_OBJECTS) +test_syslog_DEPENDENCIES = libdbus-testutils.la $(am__DEPENDENCIES_1) DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles @@ -173,15 +180,17 @@ SOURCES = $(libdbus_testutils_la_SOURCES) shell-test.c spawn-test.c \ $(test_corrupt_SOURCES) $(test_dbus_daemon_SOURCES) \ $(test_dbus_daemon_eavesdrop_SOURCES) test-exit.c \ $(test_loopback_SOURCES) $(test_marshal_SOURCES) test-names.c \ - $(test_relay_SOURCES) test-segfault.c test-service.c \ - test-shell-service.c test-sleep-forever.c + $(test_refs_SOURCES) $(test_relay_SOURCES) test-segfault.c \ + test-service.c test-shell-service.c test-sleep-forever.c \ + $(test_syslog_SOURCES) DIST_SOURCES = $(libdbus_testutils_la_SOURCES) shell-test.c \ spawn-test.c $(test_corrupt_SOURCES) \ $(test_dbus_daemon_SOURCES) \ $(test_dbus_daemon_eavesdrop_SOURCES) test-exit.c \ $(test_loopback_SOURCES) $(test_marshal_SOURCES) test-names.c \ - $(test_relay_SOURCES) test-segfault.c test-service.c \ - test-shell-service.c test-sleep-forever.c + $(test_refs_SOURCES) $(test_relay_SOURCES) test-segfault.c \ + test-service.c test-shell-service.c test-sleep-forever.c \ + $(test_syslog_SOURCES) RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ html-recursive info-recursive install-data-recursive \ install-dvi-recursive install-exec-recursive \ @@ -339,6 +348,11 @@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ +PYTHON = @PYTHON@ +PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ +PYTHON_PLATFORM = @PYTHON_PLATFORM@ +PYTHON_PREFIX = @PYTHON_PREFIX@ +PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ RC = @RC@ R_DYNAMIC_LDFLAG = @R_DYNAMIC_LDFLAG@ @@ -414,9 +428,13 @@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ +pkgpyexecdir = @pkgpyexecdir@ +pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +pyexecdir = @pyexecdir@ +pythondir = @pythondir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -437,6 +455,14 @@ AM_CPPFLAGS = \ # improve backtraces from test stuff AM_LDFLAGS = @R_DYNAMIC_LDFLAG@ +static_cppflags = \ + $(AM_CPPFLAGS) \ + -DDBUS_STATIC_BUILD \ + $(NULL) + +libdbus_testutils_la_CPPFLAGS = \ + $(static_cppflags) + libdbus_testutils_la_SOURCES = \ test-utils.c \ test-utils.h \ @@ -459,11 +485,6 @@ noinst_LTLIBRARIES = libdbus-testutils.la @DBUS_BUILD_TESTS_TRUE@ test-sleep-forever \ @DBUS_BUILD_TESTS_TRUE@ $(NULL) -static_cppflags = \ - $(AM_CPPFLAGS) \ - -DDBUS_STATIC_BUILD \ - $(NULL) - test_service_CPPFLAGS = $(static_cppflags) test_service_LDADD = libdbus-testutils.la test_names_CPPFLAGS = $(static_cppflags) @@ -474,6 +495,12 @@ shell_test_CPPFLAGS = $(static_cppflags) shell_test_LDADD = libdbus-testutils.la spawn_test_CPPFLAGS = $(static_cppflags) spawn_test_LDADD = $(top_builddir)/dbus/libdbus-internal.la +test_refs_SOURCES = internals/refs.c +test_refs_CPPFLAGS = $(static_cppflags) +test_refs_LDADD = libdbus-testutils.la $(GLIB_LIBS) +test_syslog_SOURCES = internals/syslog.c +test_syslog_CPPFLAGS = $(static_cppflags) +test_syslog_LDADD = libdbus-testutils.la $(GLIB_LIBS) EXTRA_DIST = dbus-test-runner testexecdir = $(libdir)/dbus-1.0/test installable_tests = \ @@ -482,7 +509,9 @@ installable_tests = \ test-dbus-daemon-eavesdrop \ test-loopback \ test-marshal \ + test-refs \ test-relay \ + test-syslog \ $(NULL) installcheck_tests = $(am__append_3) @@ -678,6 +707,9 @@ test-marshal$(EXEEXT): $(test_marshal_OBJECTS) $(test_marshal_DEPENDENCIES) test-names$(EXEEXT): $(test_names_OBJECTS) $(test_names_DEPENDENCIES) @rm -f test-names$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_names_OBJECTS) $(test_names_LDADD) $(LIBS) +test-refs$(EXEEXT): $(test_refs_OBJECTS) $(test_refs_DEPENDENCIES) + @rm -f test-refs$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_refs_OBJECTS) $(test_refs_LDADD) $(LIBS) test-relay$(EXEEXT): $(test_relay_OBJECTS) $(test_relay_DEPENDENCIES) @rm -f test-relay$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_relay_OBJECTS) $(test_relay_LDADD) $(LIBS) @@ -693,6 +725,9 @@ test-shell-service$(EXEEXT): $(test_shell_service_OBJECTS) $(test_shell_service_ test-sleep-forever$(EXEEXT): $(test_sleep_forever_OBJECTS) $(test_sleep_forever_DEPENDENCIES) @rm -f test-sleep-forever$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_sleep_forever_OBJECTS) $(test_sleep_forever_LDADD) $(LIBS) +test-syslog$(EXEEXT): $(test_syslog_OBJECTS) $(test_syslog_DEPENDENCIES) + @rm -f test-syslog$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_syslog_OBJECTS) $(test_syslog_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) @@ -702,6 +737,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/corrupt.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dbus-daemon.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdbus_testutils_la-test-utils.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/loopback.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/marshal.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/relay.Po@am__quote@ @@ -710,11 +746,12 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-exit.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-segfault.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-sleep-forever.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-utils.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_dbus_daemon_eavesdrop-dbus-daemon-eavesdrop.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_names-test-names.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_refs-refs.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_service-test-service.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_shell_service-test-shell-service.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_syslog-syslog.Po@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @@ -740,6 +777,14 @@ distclean-compile: @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< +libdbus_testutils_la-test-utils.lo: test-utils.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libdbus_testutils_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libdbus_testutils_la-test-utils.lo -MD -MP -MF $(DEPDIR)/libdbus_testutils_la-test-utils.Tpo -c -o libdbus_testutils_la-test-utils.lo `test -f 'test-utils.c' || echo '$(srcdir)/'`test-utils.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libdbus_testutils_la-test-utils.Tpo $(DEPDIR)/libdbus_testutils_la-test-utils.Plo +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='test-utils.c' object='libdbus_testutils_la-test-utils.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libdbus_testutils_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libdbus_testutils_la-test-utils.lo `test -f 'test-utils.c' || echo '$(srcdir)/'`test-utils.c + shell_test-shell-test.o: shell-test.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(shell_test_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT shell_test-shell-test.o -MD -MP -MF $(DEPDIR)/shell_test-shell-test.Tpo -c -o shell_test-shell-test.o `test -f 'shell-test.c' || echo '$(srcdir)/'`shell-test.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/shell_test-shell-test.Tpo $(DEPDIR)/shell_test-shell-test.Po @@ -804,6 +849,22 @@ test_names-test-names.obj: test-names.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_names_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_names-test-names.obj `if test -f 'test-names.c'; then $(CYGPATH_W) 'test-names.c'; else $(CYGPATH_W) '$(srcdir)/test-names.c'; fi` +test_refs-refs.o: internals/refs.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_refs_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_refs-refs.o -MD -MP -MF $(DEPDIR)/test_refs-refs.Tpo -c -o test_refs-refs.o `test -f 'internals/refs.c' || echo '$(srcdir)/'`internals/refs.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_refs-refs.Tpo $(DEPDIR)/test_refs-refs.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='internals/refs.c' object='test_refs-refs.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_refs_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_refs-refs.o `test -f 'internals/refs.c' || echo '$(srcdir)/'`internals/refs.c + +test_refs-refs.obj: internals/refs.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_refs_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_refs-refs.obj -MD -MP -MF $(DEPDIR)/test_refs-refs.Tpo -c -o test_refs-refs.obj `if test -f 'internals/refs.c'; then $(CYGPATH_W) 'internals/refs.c'; else $(CYGPATH_W) '$(srcdir)/internals/refs.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_refs-refs.Tpo $(DEPDIR)/test_refs-refs.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='internals/refs.c' object='test_refs-refs.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_refs_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_refs-refs.obj `if test -f 'internals/refs.c'; then $(CYGPATH_W) 'internals/refs.c'; else $(CYGPATH_W) '$(srcdir)/internals/refs.c'; fi` + test_service-test-service.o: test-service.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_service_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_service-test-service.o -MD -MP -MF $(DEPDIR)/test_service-test-service.Tpo -c -o test_service-test-service.o `test -f 'test-service.c' || echo '$(srcdir)/'`test-service.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_service-test-service.Tpo $(DEPDIR)/test_service-test-service.Po @@ -836,6 +897,22 @@ test_shell_service-test-shell-service.obj: test-shell-service.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_shell_service_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_shell_service-test-shell-service.obj `if test -f 'test-shell-service.c'; then $(CYGPATH_W) 'test-shell-service.c'; else $(CYGPATH_W) '$(srcdir)/test-shell-service.c'; fi` +test_syslog-syslog.o: internals/syslog.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_syslog_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_syslog-syslog.o -MD -MP -MF $(DEPDIR)/test_syslog-syslog.Tpo -c -o test_syslog-syslog.o `test -f 'internals/syslog.c' || echo '$(srcdir)/'`internals/syslog.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_syslog-syslog.Tpo $(DEPDIR)/test_syslog-syslog.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='internals/syslog.c' object='test_syslog-syslog.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_syslog_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_syslog-syslog.o `test -f 'internals/syslog.c' || echo '$(srcdir)/'`internals/syslog.c + +test_syslog-syslog.obj: internals/syslog.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_syslog_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_syslog-syslog.obj -MD -MP -MF $(DEPDIR)/test_syslog-syslog.Tpo -c -o test_syslog-syslog.obj `if test -f 'internals/syslog.c'; then $(CYGPATH_W) 'internals/syslog.c'; else $(CYGPATH_W) '$(srcdir)/internals/syslog.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_syslog-syslog.Tpo $(DEPDIR)/test_syslog-syslog.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='internals/syslog.c' object='test_syslog-syslog.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_syslog_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_syslog-syslog.obj `if test -f 'internals/syslog.c'; then $(CYGPATH_W) 'internals/syslog.c'; else $(CYGPATH_W) '$(srcdir)/internals/syslog.c'; fi` + mostlyclean-libtool: -rm -f *.lo @@ -1323,7 +1400,9 @@ clean-local: REVERSEDIRS="$$D $$REVERSEDIRS" ; \ done ; \ for D in $$REVERSEDIRS; do \ - rmdir $(top_builddir)/test/$$D || exit 1 ; \ + rmdir $(top_builddir)/test/$$D || \ + test ! -d $(top_builddir)/test/$$D || \ + exit 1 ; \ done ; \ fi diff --git a/test/data/valid-config-files/session.conf b/test/data/valid-config-files/session.conf deleted file mode 100644 index dde5ef6b..00000000 --- a/test/data/valid-config-files/session.conf +++ /dev/null @@ -1,63 +0,0 @@ -<!-- This configuration file controls the per-user-login-session message bus. - Add a session-local.conf and edit that rather than changing this - file directly. --> - -<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN" - "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd"> -<busconfig> - <!-- Our well-known bus type, don't change this --> - <type>session</type> - - <!-- If we fork, keep the user's original umask to avoid affecting - the behavior of child processes. --> - <keep_umask/> - - <listen>unix:tmpdir=/tmp</listen> - - <standard_session_servicedirs /> - - <policy context="default"> - <!-- Allow everything to be sent --> - <allow send_destination="*" eavesdrop="true"/> - <!-- Allow everything to be received --> - <allow eavesdrop="true"/> - <!-- Allow anyone to own anything --> - <allow own="*"/> - </policy> - - <!-- Config files are placed here that among other things, - further restrict the above policy for specific services. --> - <includedir>session.d</includedir> - - <!-- This is included last so local configuration can override what's - in this standard file --> - <include ignore_missing="yes">session-local.conf</include> - - <include if_selinux_enabled="yes" selinux_root_relative="yes">contexts/dbus_contexts</include> - - <!-- For the session bus, override the default relatively-low limits - with essentially infinite limits, since the bus is just running - as the user anyway, using up bus resources is not something we need - to worry about. In some cases, we do set the limits lower than - "all available memory" if exceeding the limit is almost certainly a bug, - having the bus enforce a limit is nicer than a huge memory leak. But the - intent is that these limits should never be hit. --> - - <!-- the memory limits are 1G instead of say 4G because they can't exceed 32-bit signed int max --> - <limit name="max_incoming_bytes">1000000000</limit> - <limit name="max_incoming_unix_fds">250000000</limit> - <limit name="max_outgoing_bytes">1000000000</limit> - <limit name="max_outgoing_unix_fds">250000000</limit> - <limit name="max_message_size">1000000000</limit> - <limit name="max_message_unix_fds">4096</limit> - <limit name="service_start_timeout">120000</limit> - <limit name="auth_timeout">240000</limit> - <limit name="max_completed_connections">100000</limit> - <limit name="max_incomplete_connections">10000</limit> - <limit name="max_connections_per_user">100000</limit> - <limit name="max_pending_service_starts">10000</limit> - <limit name="max_names_per_connection">50000</limit> - <limit name="max_match_rules_per_connection">50000</limit> - <limit name="max_replies_per_connection">50000</limit> - -</busconfig> diff --git a/test/data/valid-config-files/system.conf b/test/data/valid-config-files/system.conf deleted file mode 100644 index 828fd032..00000000 --- a/test/data/valid-config-files/system.conf +++ /dev/null @@ -1,83 +0,0 @@ -<!-- This configuration file controls the systemwide message bus. - Add a system-local.conf and edit that rather than changing this - file directly. --> - -<!-- Note that there are any number of ways you can hose yourself - security-wise by screwing up this file; in particular, you - probably don't want to listen on any more addresses, add any more - auth mechanisms, run as a different user, etc. --> - -<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN" - "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd"> -<busconfig> - - <!-- Our well-known bus type, do not change this --> - <type>system</type> - - <!-- Run as special user --> - <user>messagebus</user> - - <!-- Fork into daemon mode --> - <fork/> - - <!-- We use system service launching using a helper --> - <standard_system_servicedirs/> - - <!-- This is a setuid helper that is used to launch system services --> - <servicehelper>/usr/local/libexec/dbus-daemon-launch-helper</servicehelper> - - <!-- Write a pid file --> - <pidfile>/usr/local/var/run/dbus/pid</pidfile> - - <!-- Enable logging to syslog --> - <syslog/> - - <!-- Only allow socket-credentials-based authentication --> - <auth>EXTERNAL</auth> - - <!-- Only listen on a local socket. (abstract=/path/to/socket - means use abstract namespace, don't really create filesystem - file; only Linux supports this. Use path=/whatever on other - systems.) --> - <listen>unix:path=/usr/local/var/run/dbus/system_bus_socket</listen> - - <policy context="default"> - <!-- All users can connect to system bus --> - <allow user="*"/> - - <!-- Holes must be punched in service configuration files for - name ownership and sending method calls --> - <deny own="*"/> - <deny send_type="method_call"/> - - <!-- Signals and reply messages (method returns, errors) are allowed - by default --> - <allow send_type="signal"/> - <allow send_requested_reply="true" send_type="method_return"/> - <allow send_requested_reply="true" send_type="error"/> - - <!-- All messages may be received by default --> - <allow receive_type="method_call"/> - <allow receive_type="method_return"/> - <allow receive_type="error"/> - <allow receive_type="signal"/> - - <!-- Allow anyone to talk to the message bus --> - <allow send_destination="org.freedesktop.DBus"/> - <!-- But disallow some specific bus services --> - <deny send_destination="org.freedesktop.DBus" - send_interface="org.freedesktop.DBus" - send_member="UpdateActivationEnvironment"/> - </policy> - - <!-- Config files are placed here that among other things, punch - holes in the above policy for specific services. --> - <includedir>system.d</includedir> - - <!-- This is included last so local configuration can override what's - in this standard file --> - <include ignore_missing="yes">system-local.conf</include> - - <include if_selinux_enabled="yes" selinux_root_relative="yes">contexts/dbus_contexts</include> - -</busconfig> diff --git a/test/dbus-daemon-eavesdrop.c b/test/dbus-daemon-eavesdrop.c index 6819ec13..0bd923d2 100644 --- a/test/dbus-daemon-eavesdrop.c +++ b/test/dbus-daemon-eavesdrop.c @@ -35,6 +35,7 @@ #include <string.h> #ifdef DBUS_WIN +# include <io.h> # include <windows.h> #else # include <signal.h> @@ -73,7 +74,7 @@ typedef struct { DBusError e; GError *ge; - gint daemon_pid; + GPid daemon_pid; /* eavedrop keyword tests */ DBusConnection *sender; @@ -102,7 +103,7 @@ _assert_no_error (const DBusError *e, static gchar * spawn_dbus_daemon (gchar *binary, gchar *configuration, - gint *daemon_pid) + GPid *daemon_pid) { GError *error = NULL; GString *address; @@ -183,7 +184,6 @@ connect_to_bus (const gchar *address) static DBusHandlerResult sender_send_unicast_to_sender (Fixture *f) { - DBusError error = DBUS_ERROR_INIT; DBusMessage *signal; signal = dbus_message_new_signal (SENDER_PATH, SENDER_IFACE, @@ -206,7 +206,6 @@ sender_send_unicast_to_sender (Fixture *f) static DBusHandlerResult sender_send_unicast_to_receiver (Fixture *f) { - DBusError error = DBUS_ERROR_INIT; DBusMessage *signal; signal = dbus_message_new_signal (SENDER_PATH, SENDER_IFACE, SENDER_SIGNAL_NAME); @@ -226,7 +225,6 @@ sender_send_unicast_to_receiver (Fixture *f) static DBusHandlerResult sender_send_broadcast (Fixture *f) { - DBusError error = DBUS_ERROR_INIT; DBusMessage *signal; signal = dbus_message_new_signal (SENDER_PATH, SENDER_IFACE, SENDER_SIGNAL_NAME); @@ -251,7 +249,6 @@ sender_send_broadcast (Fixture *f) static DBusHandlerResult sender_send_stopper (Fixture *f) { - DBusError error = DBUS_ERROR_INIT; DBusMessage *signal; signal = dbus_message_new_signal (SENDER_PATH, SENDER_IFACE, SENDER_STOPPER_NAME); diff --git a/test/dbus-daemon.c b/test/dbus-daemon.c index c190cb43..cc871530 100644 --- a/test/dbus-daemon.c +++ b/test/dbus-daemon.c @@ -34,6 +34,7 @@ #include <string.h> #ifdef DBUS_WIN +# include <io.h> # include <windows.h> #else # include <signal.h> @@ -46,7 +47,7 @@ typedef struct { DBusError e; GError *ge; - gint daemon_pid; + GPid daemon_pid; DBusConnection *left_conn; @@ -68,7 +69,7 @@ _assert_no_error (const DBusError *e, static gchar * spawn_dbus_daemon (gchar *binary, gchar *configuration, - gint *daemon_pid) + GPid *daemon_pid) { GError *error = NULL; GString *address; @@ -150,8 +151,6 @@ echo_filter (DBusConnection *connection, void *user_data) { DBusMessage *reply; - DBusError error = DBUS_ERROR_INIT; - int *sleep_ms = user_data; if (dbus_message_get_type (message) != DBUS_MESSAGE_TYPE_METHOD_CALL) return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; diff --git a/test/internals/refs.c b/test/internals/refs.c new file mode 100644 index 00000000..bc0884e3 --- /dev/null +++ b/test/internals/refs.c @@ -0,0 +1,612 @@ +/* Regression test for thread-safe reference-counting + * + * 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> + +#define DBUS_COMPILATION /* this test uses libdbus-internal */ +#include <dbus/dbus.h> +#include <dbus/dbus-connection-internal.h> +#include <dbus/dbus-mainloop.h> +#include <dbus/dbus-message-internal.h> +#include <dbus/dbus-pending-call-internal.h> +#include <dbus/dbus-server-protected.h> +#include "test-utils.h" + +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); +} + +#define N_THREADS 200 +#define N_REFS 10000 +G_STATIC_ASSERT (((unsigned) N_THREADS * (unsigned) N_REFS) < G_MAXINT32); + +static dbus_int32_t connection_slot = -1; +static dbus_int32_t server_slot = -1; +static dbus_int32_t message_slot = -1; +static dbus_int32_t pending_call_slot = -1; + +typedef struct { + DBusError e; + DBusLoop *loop; + DBusServer *server; + DBusConnection *connection; + DBusConnection *server_connection; + DBusMessage *message; + GThread *threads[N_THREADS]; + gboolean last_unref; +} Fixture; + +typedef void *(*RefFunc) (void *); +typedef void (*VoidFunc) (void *); + +typedef struct { + void *thing; + RefFunc ref; + VoidFunc ref_void; + VoidFunc unref; + void *mutex; + VoidFunc lock; + VoidFunc unlock; +} Thread; + +static gpointer +ref_thread (gpointer data) +{ + Thread *thread = data; + int i; + + for (i = 0; i < N_REFS; i++) + { + if (thread->lock != NULL) + (thread->lock) (thread->mutex); + + if (thread->ref != NULL) + { + gpointer ret = (thread->ref) (thread->thing); + + g_assert (ret == thread->thing); + } + else + { + (thread->ref_void) (thread->thing); + } + + if (thread->unlock != NULL) + (thread->unlock) (thread->mutex); + } + + return NULL; +} + +static gpointer +cycle_thread (gpointer data) +{ + Thread *thread = data; + int i; + + for (i = 0; i < N_REFS; i++) + { + if (thread->lock != NULL) + (thread->lock) (thread->mutex); + + if (thread->ref != NULL) + { + gpointer ret = (thread->ref) (thread->thing); + + g_assert (ret == thread->thing); + } + else + { + (thread->ref_void) (thread->thing); + } + + (thread->unref) (thread->thing); + + if (thread->unlock != NULL) + (thread->unlock) (thread->mutex); + } + + return NULL; +} + +static gpointer +unref_thread (gpointer data) +{ + Thread *thread = data; + int i; + + for (i = 0; i < N_REFS; i++) + { + if (thread->lock != NULL) + (thread->lock) (thread->mutex); + + (thread->unref) (thread->thing); + + if (thread->unlock != NULL) + (thread->unlock) (thread->mutex); + } + + return NULL; +} + +static void +last_unref (void *data) +{ + Fixture *f = data; + + g_assert (!f->last_unref); + f->last_unref = TRUE; +} + +static void +wait_for_all_threads (Fixture *f) +{ + int i; + + for (i = 0; i < N_THREADS; i++) + g_thread_join (f->threads[i]); +} + +static void +new_conn_cb (DBusServer *server, + DBusConnection *server_connection, + void *data) +{ + Fixture *f = data; + + g_assert (f->server_connection == NULL); + f->server_connection = dbus_connection_ref (server_connection); + + test_connection_setup (f->loop, f->server_connection); +} + +static void +setup (Fixture *f, + gconstpointer data) +{ + if (!dbus_threads_init_default ()) + g_error ("OOM"); + + f->loop = _dbus_loop_new (); + g_assert (f->loop != NULL); + + dbus_error_init (&f->e); + + f->server = dbus_server_listen ("tcp:host=127.0.0.1", &f->e); + assert_no_error (&f->e); + g_assert (f->server != NULL); + + if (!dbus_connection_allocate_data_slot (&connection_slot)) + g_error ("OOM"); + + if (!dbus_server_allocate_data_slot (&server_slot)) + g_error ("OOM"); + + if (!dbus_message_allocate_data_slot (&message_slot)) + g_error ("OOM"); + + if (!dbus_pending_call_allocate_data_slot (&pending_call_slot)) + g_error ("OOM"); +} + +static void +setup_connection (Fixture *f, + gconstpointer data) +{ + char *address; + + setup (f, data); + + dbus_server_set_new_connection_function (f->server, + new_conn_cb, f, NULL); + + if (!test_server_setup (f->loop, f->server)) + g_error ("failed to set up server"); + + address = dbus_server_get_address (f->server); + g_assert (address != NULL); + f->connection = dbus_connection_open_private (address, &f->e); + assert_no_error (&f->e); + g_assert (f->connection != NULL); + dbus_free (address); + + if (!test_connection_setup (f->loop, f->connection)) + g_error ("failed to set up connection"); + + while (f->server_connection == NULL) + _dbus_loop_iterate (f->loop, TRUE); + + test_connection_shutdown (f->loop, f->connection); + test_server_shutdown (f->loop, f->server); +} + +static void +test_connection (Fixture *f, + gconstpointer data) +{ + Thread public_api = { f->connection, + (RefFunc) dbus_connection_ref, + NULL, + (VoidFunc) dbus_connection_unref, + NULL, + NULL, + NULL }; + Thread internal_api = { f->connection, + (RefFunc) _dbus_connection_ref_unlocked, + NULL, + (VoidFunc) _dbus_connection_unref_unlocked, + f->connection, + (VoidFunc) _dbus_connection_lock, + (VoidFunc) _dbus_connection_unlock }; + int i; + + /* Use a slot as a pseudo-weakref */ + if (!dbus_connection_set_data (f->connection, connection_slot, f, + last_unref)) + g_error ("OOM"); + + for (i = 0; i < N_THREADS; i++) + { + if ((i % 2) == 0) + f->threads[i] = g_thread_create (ref_thread, &public_api, TRUE, NULL); + else + f->threads[i] = g_thread_create (ref_thread, &internal_api, TRUE, + NULL); + + g_assert (f->threads[i] != NULL); + } + + wait_for_all_threads (f); + + for (i = 0; i < N_THREADS; i++) + { + if ((i % 2) == 0) + f->threads[i] = g_thread_create (cycle_thread, &public_api, TRUE, + NULL); + else + f->threads[i] = g_thread_create (cycle_thread, &internal_api, TRUE, + NULL); + + g_assert (f->threads[i] != NULL); + } + + wait_for_all_threads (f); + + for (i = 0; i < N_THREADS; i++) + { + if ((i % 2) == 0) + f->threads[i] = g_thread_create (unref_thread, &public_api, TRUE, + NULL); + else + f->threads[i] = g_thread_create (unref_thread, &internal_api, TRUE, + NULL); + + g_assert (f->threads[i] != NULL); + } + + wait_for_all_threads (f); + + /* Destroy the connection. This should be the last-unref. */ + g_assert (!f->last_unref); + dbus_connection_close (f->connection); + dbus_connection_unref (f->connection); + f->connection = NULL; + g_assert (f->last_unref); +} + +static void +server_lock (void *server) +{ + SERVER_LOCK (((DBusServer *) server)); +} + +static void +server_unlock (void *server) +{ + SERVER_UNLOCK (((DBusServer *) server)); +} + +static void +test_server (Fixture *f, + gconstpointer data) +{ + Thread public_api = { f->server, + (RefFunc) dbus_server_ref, + NULL, + (VoidFunc) dbus_server_unref, + NULL, + NULL, + NULL }; + Thread internal_api = { f->server, + NULL, + (VoidFunc) _dbus_server_ref_unlocked, + (VoidFunc) _dbus_server_unref_unlocked, + f->server, + server_lock, + server_unlock }; + int i; + + if (!dbus_server_set_data (f->server, server_slot, f, last_unref)) + g_error ("OOM"); + + for (i = 0; i < N_THREADS; i++) + { + if ((i % 2) == 0) + f->threads[i] = g_thread_create (ref_thread, &public_api, TRUE, NULL); + else + f->threads[i] = g_thread_create (ref_thread, &internal_api, TRUE, + NULL); + + g_assert (f->threads[i] != NULL); + } + + wait_for_all_threads (f); + + for (i = 0; i < N_THREADS; i++) + { + if ((i % 2) == 0) + f->threads[i] = g_thread_create (cycle_thread, &public_api, TRUE, + NULL); + else + f->threads[i] = g_thread_create (cycle_thread, &internal_api, TRUE, + NULL); + + g_assert (f->threads[i] != NULL); + } + + wait_for_all_threads (f); + + for (i = 0; i < N_THREADS; i++) + { + if ((i % 2) == 0) + f->threads[i] = g_thread_create (unref_thread, &public_api, TRUE, + NULL); + else + f->threads[i] = g_thread_create (unref_thread, &internal_api, TRUE, + NULL); + + g_assert (f->threads[i] != NULL); + } + + wait_for_all_threads (f); + + /* Destroy the server. This should be the last-unref. */ + g_assert (!f->last_unref); + dbus_server_disconnect (f->server); + dbus_server_unref (f->server); + f->server = NULL; + g_assert (f->last_unref); +} + +static void +test_message (Fixture *f, + gconstpointer data) +{ + DBusMessage *message = dbus_message_new_signal ("/foo", "foo.bar.baz", + "Foo"); + Thread public_api = { message, + (RefFunc) dbus_message_ref, + NULL, + (VoidFunc) dbus_message_unref, + NULL, + NULL, + NULL }; + int i; + + if (!dbus_message_set_data (message, message_slot, f, last_unref)) + g_error ("OOM"); + + for (i = 0; i < N_THREADS; i++) + { + f->threads[i] = g_thread_create (ref_thread, &public_api, TRUE, NULL); + g_assert (f->threads[i] != NULL); + } + + wait_for_all_threads (f); + + for (i = 0; i < N_THREADS; i++) + { + f->threads[i] = g_thread_create (cycle_thread, &public_api, TRUE, NULL); + g_assert (f->threads[i] != NULL); + } + + wait_for_all_threads (f); + + for (i = 0; i < N_THREADS; i++) + { + f->threads[i] = g_thread_create (unref_thread, &public_api, TRUE, NULL); + g_assert (f->threads[i] != NULL); + } + + wait_for_all_threads (f); + + /* Destroy the server. This should be the last-unref. */ + g_assert (!f->last_unref); + dbus_message_unref (message); + g_assert (f->last_unref); +} + +static void +test_pending_call (Fixture *f, + gconstpointer data) +{ + Thread public_api = { NULL, + (RefFunc) dbus_pending_call_ref, + NULL, + (VoidFunc) dbus_pending_call_unref, + NULL, + NULL, + NULL }; + Thread internal_api = { NULL, + (RefFunc) _dbus_pending_call_ref_unlocked, + NULL, + (VoidFunc) dbus_pending_call_unref, + f->connection, + (VoidFunc) _dbus_connection_lock, + (VoidFunc) _dbus_connection_unlock }; + /* This one can't be used to ref, only to cycle or unref. */ + Thread unref_and_unlock_api = { NULL, + (RefFunc) _dbus_pending_call_ref_unlocked, + NULL, + (VoidFunc) _dbus_pending_call_unref_and_unlock, + f->connection, + (VoidFunc) _dbus_connection_lock, + NULL }; + int i; + DBusPendingCall *pending_call; + + _dbus_connection_lock (f->connection); + pending_call = _dbus_pending_call_new_unlocked (f->connection, + DBUS_TIMEOUT_INFINITE, NULL); + g_assert (pending_call != NULL); + _dbus_connection_unlock (f->connection); + + public_api.thing = pending_call; + internal_api.thing = pending_call; + unref_and_unlock_api.thing = pending_call; + + if (!dbus_pending_call_set_data (pending_call, pending_call_slot, f, + last_unref)) + g_error ("OOM"); + + for (i = 0; i < N_THREADS; i++) + { + if ((i % 2) == 0) + f->threads[i] = g_thread_create (ref_thread, &public_api, TRUE, NULL); + else + f->threads[i] = g_thread_create (ref_thread, &internal_api, TRUE, + NULL); + + g_assert (f->threads[i] != NULL); + } + + wait_for_all_threads (f); + + for (i = 0; i < N_THREADS; i++) + { + switch (i % 3) + { + case 0: + f->threads[i] = g_thread_create (cycle_thread, &public_api, TRUE, + NULL); + break; + case 1: + f->threads[i] = g_thread_create (cycle_thread, &internal_api, TRUE, + NULL); + break; + default: + f->threads[i] = g_thread_create (cycle_thread, + &unref_and_unlock_api, TRUE, NULL); + } + + g_assert (f->threads[i] != NULL); + } + + wait_for_all_threads (f); + + for (i = 0; i < N_THREADS; i++) + { + switch (i % 3) + { + case 0: + f->threads[i] = g_thread_create (unref_thread, &public_api, TRUE, + NULL); + break; + case 1: + f->threads[i] = g_thread_create (unref_thread, &internal_api, TRUE, + NULL); + break; + default: + f->threads[i] = g_thread_create (unref_thread, + &unref_and_unlock_api, TRUE, NULL); + } + + g_assert (f->threads[i] != NULL); + } + + wait_for_all_threads (f); + + /* Destroy the pending call. This should be the last-unref. */ + g_assert (!f->last_unref); + dbus_pending_call_unref (pending_call); + g_assert (f->last_unref); +} + +static void +teardown (Fixture *f, + gconstpointer data) +{ + if (f->server_connection != NULL) + { + dbus_connection_close (f->server_connection); + dbus_connection_unref (f->server_connection); + } + + if (f->connection != NULL) + { + dbus_connection_close (f->connection); + dbus_connection_unref (f->connection); + } + + if (f->server != NULL) + { + dbus_server_disconnect (f->server); + dbus_server_unref (f->server); + } + + dbus_connection_free_data_slot (&connection_slot); + dbus_server_free_data_slot (&server_slot); + dbus_message_free_data_slot (&message_slot); + dbus_pending_call_free_data_slot (&pending_call_slot); + + _dbus_loop_unref (f->loop); + dbus_error_free (&f->e); +} + +int +main (int argc, + char **argv) +{ + g_thread_init (NULL); + g_test_init (&argc, &argv, NULL); + g_test_bug_base ("https://bugs.freedesktop.org/show_bug.cgi?id="); + + g_test_add ("/refs/connection", Fixture, NULL, setup_connection, + test_connection, teardown); + g_test_add ("/refs/message", Fixture, NULL, setup, + test_message, teardown); + g_test_add ("/refs/pending-call", Fixture, NULL, setup_connection, + test_pending_call, teardown); + g_test_add ("/refs/server", Fixture, NULL, setup, + test_server, teardown); + + return g_test_run (); +} diff --git a/test/internals/syslog.c b/test/internals/syslog.c new file mode 100644 index 00000000..4f6b7c22 --- /dev/null +++ b/test/internals/syslog.c @@ -0,0 +1,100 @@ +/* Manual regression test for syslog support + * + * 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 <stdlib.h> + +#include <glib.h> + +#define DBUS_COMPILATION /* this test uses libdbus-internal */ +#include <dbus/dbus.h> +#include <dbus/dbus-sysdeps.h> + +typedef struct { + int dummy; +} Fixture; + +static void +setup (Fixture *f, + gconstpointer data) +{ +} + +/* hopefully clear enough that people don't think these messages in syslog + * are a bug */ +#define MESSAGE "regression test for _dbus_system_log(): " + +static void +test_syslog (Fixture *f, + gconstpointer data) +{ + if (g_test_trap_fork (0, 0)) + { + _dbus_init_system_log (); + _dbus_system_log (DBUS_SYSTEM_LOG_FATAL, MESSAGE "%d", 23); + /* should not be reached: exit 0 so the assertion in the main process + * will fail */ + exit (0); + } + + g_test_trap_assert_failed (); + g_test_trap_assert_stderr ("*" MESSAGE "23\n*"); + + if (g_test_trap_fork (0, 0)) + { + _dbus_init_system_log (); + _dbus_system_log (DBUS_SYSTEM_LOG_INFO, MESSAGE "%d", 42); + _dbus_system_log (DBUS_SYSTEM_LOG_SECURITY, MESSAGE "%d", 666); + exit (0); + } + + g_test_trap_assert_passed (); + g_test_trap_assert_stderr ("*" MESSAGE "42\n*" MESSAGE "666\n*"); + + /* manual test (this is the best we can do on Windows) */ + _dbus_init_system_log (); + _dbus_system_log (DBUS_SYSTEM_LOG_INFO, MESSAGE "%d", 42); + _dbus_system_log (DBUS_SYSTEM_LOG_SECURITY, MESSAGE "%d", 666); +} + +static void +teardown (Fixture *f, + gconstpointer data) +{ +} + +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_test_add ("/syslog", Fixture, NULL, setup, test_syslog, teardown); + + return g_test_run (); +} diff --git a/test/marshal.c b/test/marshal.c index 4cee9412..e9ac7e30 100644 --- a/test/marshal.c +++ b/test/marshal.c @@ -146,7 +146,6 @@ test_endian (Fixture *f, gconstpointer arg) { const gchar *blob = arg; - const gchar *native_blob; char *output; DBusMessage *m; int len; diff --git a/test/name-test/Makefile.am b/test/name-test/Makefile.am index 68fc33ec..6aaf1783 100644 --- a/test/name-test/Makefile.am +++ b/test/name-test/Makefile.am @@ -12,7 +12,7 @@ AM_LDFLAGS = @R_DYNAMIC_LDFLAG@ ## 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=@abs_top_builddir@ DBUS_TOP_SRCDIR=@abs_top_srcdir@ +TESTS_ENVIRONMENT=DBUS_TOP_BUILDDIR=@abs_top_builddir@ DBUS_TOP_SRCDIR=@abs_top_srcdir@ PYTHON=@PYTHON@ TESTS=run-test.sh run-test-systemserver.sh else TESTS= diff --git a/test/name-test/Makefile.in b/test/name-test/Makefile.in index 6544cc97..0fc444ea 100644 --- a/test/name-test/Makefile.in +++ b/test/name-test/Makefile.in @@ -246,6 +246,11 @@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ +PYTHON = @PYTHON@ +PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ +PYTHON_PLATFORM = @PYTHON_PLATFORM@ +PYTHON_PREFIX = @PYTHON_PREFIX@ +PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ RC = @RC@ R_DYNAMIC_LDFLAG = @R_DYNAMIC_LDFLAG@ @@ -321,9 +326,13 @@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ +pkgpyexecdir = @pkgpyexecdir@ +pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +pyexecdir = @pyexecdir@ +pythondir = @pythondir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -344,7 +353,7 @@ AM_CPPFLAGS = \ # if assertions are enabled, improve backtraces AM_LDFLAGS = @R_DYNAMIC_LDFLAG@ -@DBUS_BUILD_TESTS_TRUE@TESTS_ENVIRONMENT = DBUS_TOP_BUILDDIR=@abs_top_builddir@ DBUS_TOP_SRCDIR=@abs_top_srcdir@ +@DBUS_BUILD_TESTS_TRUE@TESTS_ENVIRONMENT = DBUS_TOP_BUILDDIR=@abs_top_builddir@ DBUS_TOP_SRCDIR=@abs_top_srcdir@ PYTHON=@PYTHON@ EXTRA_DIST = run-test.sh run-test-systemserver.sh test-wait-for-echo.py test-activation-forking.py @DBUS_BUILD_TESTS_TRUE@test_pending_call_dispatch_LDADD = $(top_builddir)/dbus/libdbus-internal.la @DBUS_BUILD_TESTS_TRUE@test_pending_call_timeout_LDADD = $(top_builddir)/dbus/libdbus-internal.la diff --git a/test/name-test/run-test-systemserver.sh b/test/name-test/run-test-systemserver.sh index d3b8d557..afd1f045 100755 --- a/test/name-test/run-test-systemserver.sh +++ b/test/name-test/run-test-systemserver.sh @@ -41,10 +41,11 @@ if ! grep -q 'DBus.Error' echo-error-output.tmp; then fi echo "running test echo signal" -if ! python $DBUS_TOP_SRCDIR/test/name-test/test-wait-for-echo.py; then +if test "x$PYTHON" = "x:"; then + echo "Skipped test-echo-signal: Python interpreter not found" +elif ! $PYTHON $DBUS_TOP_SRCDIR/test/name-test/test-wait-for-echo.py; then echo "Failed test-wait-for-echo" exit 1 fi - exit 0 diff --git a/test/name-test/run-test.sh b/test/name-test/run-test.sh index a70055bb..cad5937e 100755 --- a/test/name-test/run-test.sh +++ b/test/name-test/run-test.sh @@ -49,7 +49,9 @@ echo "running test-shutdown" ${DBUS_TOP_BUILDDIR}/libtool --mode=execute $DEBUG $DBUS_TOP_BUILDDIR/test/name-test/test-shutdown || die "test-shutdown failed" echo "running test activation forking" -if ! python $DBUS_TOP_SRCDIR/test/name-test/test-activation-forking.py; then +if test "x$PYTHON" = "x:"; then + echo "Skipped test-activation-forking: Python interpreter not found" +elif ! $PYTHON $DBUS_TOP_SRCDIR/test/name-test/test-activation-forking.py; then echo "Failed test-activation-forking" exit 1 fi diff --git a/test/name-test/test-privserver-client.c b/test/name-test/test-privserver-client.c index 1c43faee..e7f48960 100644 --- a/test/name-test/test-privserver-client.c +++ b/test/name-test/test-privserver-client.c @@ -71,7 +71,6 @@ open_shutdown_private_connection (dbus_bool_t use_guid) DBusMessage *reply; DBusConnection *privconn; char *addr; - char *comma; dbus_bool_t service_died; dbus_bool_t private_conn_lost; diff --git a/test/relay.c b/test/relay.c index bad39f47..f4129d0a 100644 --- a/test/relay.c +++ b/test/relay.c @@ -137,12 +137,15 @@ test_connect (Fixture *f, gconstpointer data G_GNUC_UNUSED) { dbus_bool_t have_mem; + char *address; g_assert (f->left_server_conn == NULL); g_assert (f->right_server_conn == NULL); - f->left_client_conn = dbus_connection_open_private ( - dbus_server_get_address (f->server), &f->e); + address = dbus_server_get_address (f->server); + g_assert (address != NULL); + + f->left_client_conn = dbus_connection_open_private (address, &f->e); assert_no_error (&f->e); g_assert (f->left_client_conn != NULL); dbus_connection_setup_with_g_main (f->left_client_conn, NULL); @@ -153,12 +156,13 @@ test_connect (Fixture *f, g_main_context_iteration (NULL, TRUE); } - f->right_client_conn = dbus_connection_open_private ( - dbus_server_get_address (f->server), &f->e); + f->right_client_conn = dbus_connection_open_private (address, &f->e); assert_no_error (&f->e); g_assert (f->right_client_conn != NULL); dbus_connection_setup_with_g_main (f->right_client_conn, NULL); + dbus_free (address); + while (f->right_server_conn == NULL) { g_print ("."); diff --git a/test/test-service.c b/test/test-service.c index 6627ea75..7181fa38 100644 --- a/test/test-service.c +++ b/test/test-service.c @@ -477,7 +477,14 @@ main (int argc, dbus_error_free (&error); exit (1); } - + + if (result != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) + { + fprintf (stderr, "Unable to acquire service: code %d\n", result); + _dbus_verbose ("*** Failed to acquire service: %d\n", result); + exit (1); + } + _dbus_verbose ("*** Test service entering main loop\n"); _dbus_loop_run (loop); diff --git a/test/test-shell-service.c b/test/test-shell-service.c index 57c16123..32a88329 100644 --- a/test/test-shell-service.c +++ b/test/test-shell-service.c @@ -176,6 +176,13 @@ main (int argc, exit (1); } + if (result != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) + { + fprintf (stderr, "Unable to acquire service: code %d\n", result); + _dbus_verbose ("*** Failed to acquire service: %d\n", result); + exit (1); + } + _dbus_verbose ("*** Test service entering main loop\n"); _dbus_loop_run (loop); |