diff options
Diffstat (limited to 'debian/opensync/opensync-0.22/tests/mock-plugin')
5 files changed, 1290 insertions, 0 deletions
diff --git a/debian/opensync/opensync-0.22/tests/mock-plugin/Makefile.am b/debian/opensync/opensync-0.22/tests/mock-plugin/Makefile.am new file mode 100644 index 00000000..675bd581 --- /dev/null +++ b/debian/opensync/opensync-0.22/tests/mock-plugin/Makefile.am @@ -0,0 +1,22 @@ +INCLUDES = @PACKAGE_CFLAGS@ -I$(top_srcdir) + +AM_CFLAGS = -Wall -Werror @XML_CFLAGS@ @GCOV_CFLAGS@ +AM_LDFLAGS = -rpath @libdir@ + +EXTRA_DIST = mock_sync.h Makefile.in + +if ENABLE_TESTS +formatsdir=@OPENSYNC_FORMATSDIR@ +formats_LTLIBRARIES = mockformat.la + +pluginsdir=@OPENSYNC_PLUGINDIR@ +plugins_LTLIBRARIES = mock_sync.la +endif + +mock_sync_la_SOURCES = mock_sync.c +mock_sync_la_LDFLAGS = -avoid-version -export-dynamic -module @GCOV_LDFLAGS@ +mock_sync_la_LIBADD = @PACKAGE_LIBS@ @LIBS@ + +mockformat_la_SOURCES = mock_format.c +mockformat_la_LDFLAGS = -avoid-version -export-dynamic -module @GCOV_LDFLAGS@ +mockformat_la_LIBADD = @PACKAGE_LIBS@ @LIBS@ diff --git a/debian/opensync/opensync-0.22/tests/mock-plugin/Makefile.in b/debian/opensync/opensync-0.22/tests/mock-plugin/Makefile.in new file mode 100644 index 00000000..68394809 --- /dev/null +++ b/debian/opensync/opensync-0.22/tests/mock-plugin/Makefile.in @@ -0,0 +1,554 @@ +# Makefile.in generated by automake 1.9.6 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005 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@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = ../.. +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +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 = tests/mock-plugin +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/configure.in +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; +am__installdirs = "$(DESTDIR)$(formatsdir)" "$(DESTDIR)$(pluginsdir)" +formatsLTLIBRARIES_INSTALL = $(INSTALL) +pluginsLTLIBRARIES_INSTALL = $(INSTALL) +LTLIBRARIES = $(formats_LTLIBRARIES) $(plugins_LTLIBRARIES) +mock_sync_la_DEPENDENCIES = +am_mock_sync_la_OBJECTS = mock_sync.lo +mock_sync_la_OBJECTS = $(am_mock_sync_la_OBJECTS) +@ENABLE_TESTS_TRUE@am_mock_sync_la_rpath = -rpath $(pluginsdir) +mockformat_la_DEPENDENCIES = +am_mockformat_la_OBJECTS = mock_format.lo +mockformat_la_OBJECTS = $(am_mockformat_la_OBJECTS) +@ENABLE_TESTS_TRUE@am_mockformat_la_rpath = -rpath $(formatsdir) +DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +SOURCES = $(mock_sync_la_SOURCES) $(mockformat_la_SOURCES) +DIST_SOURCES = $(mock_sync_la_SOURCES) $(mockformat_la_SOURCES) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ +AMTAR = @AMTAR@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BUILD_ENGINE = @BUILD_ENGINE@ +BUILD_ENGINE_FALSE = @BUILD_ENGINE_FALSE@ +BUILD_ENGINE_TRUE = @BUILD_ENGINE_TRUE@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CHECK_CFLAGS = @CHECK_CFLAGS@ +CHECK_LIBS = @CHECK_LIBS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +ENABLE_DEBUG = @ENABLE_DEBUG@ +ENABLE_PROF_FALSE = @ENABLE_PROF_FALSE@ +ENABLE_PROF_TRUE = @ENABLE_PROF_TRUE@ +ENABLE_TESTS_FALSE = @ENABLE_TESTS_FALSE@ +ENABLE_TESTS_TRUE = @ENABLE_TESTS_TRUE@ +ENABLE_TOOLS_FALSE = @ENABLE_TOOLS_FALSE@ +ENABLE_TOOLS_TRUE = @ENABLE_TOOLS_TRUE@ +ENABLE_TRACE = @ENABLE_TRACE@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +GCOV_CFLAGS = @GCOV_CFLAGS@ +GCOV_LDFLAGS = @GCOV_LDFLAGS@ +GREP = @GREP@ +HAVE_PYTHON_FALSE = @HAVE_PYTHON_FALSE@ +HAVE_PYTHON_TRUE = @HAVE_PYTHON_TRUE@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +OBJEXT = @OBJEXT@ +OPENSYNC_CONFIGDIR = @OPENSYNC_CONFIGDIR@ +OPENSYNC_ENGINEHEADERDIR = @OPENSYNC_ENGINEHEADERDIR@ +OPENSYNC_FORMATSDIR = @OPENSYNC_FORMATSDIR@ +OPENSYNC_HEADERDIR = @OPENSYNC_HEADERDIR@ +OPENSYNC_PLUGINDIR = @OPENSYNC_PLUGINDIR@ +OSPLUGIN = @OSPLUGIN@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_CFLAGS = @PACKAGE_CFLAGS@ +PACKAGE_LIBS = @PACKAGE_LIBS@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PKG_CONFIG = @PKG_CONFIG@ +PYTHON = @PYTHON@ +PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ +PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ +PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ +PYTHON_INCLUDES = @PYTHON_INCLUDES@ +PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ +PYTHON_PLATFORM = @PYTHON_PLATFORM@ +PYTHON_PREFIX = @PYTHON_PREFIX@ +PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ +PYTHON_VERSION = @PYTHON_VERSION@ +RANLIB = @RANLIB@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +SWIG = @SWIG@ +SWIG_LIB = @SWIG_LIB@ +SWIG_PYTHON_CPPFLAGS = @SWIG_PYTHON_CPPFLAGS@ +SWIG_PYTHON_OPT = @SWIG_PYTHON_OPT@ +VERSION = @VERSION@ +XML_CFLAGS = @XML_CFLAGS@ +XML_LIBS = @XML_LIBS@ +YACC = @YACC@ +YFLAGS = @YFLAGS@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +ac_workaround_abs_builddir = @ac_workaround_abs_builddir@ +ac_workaround_abs_srcdir = @ac_workaround_abs_srcdir@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ +am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ +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@ +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@ +pkgpyexecdir = @pkgpyexecdir@ +pkgpythondir = @pkgpythondir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +pyexecdir = @pyexecdir@ +pythondir = @pythondir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +INCLUDES = @PACKAGE_CFLAGS@ -I$(top_srcdir) +AM_CFLAGS = -Wall -Werror @XML_CFLAGS@ @GCOV_CFLAGS@ +AM_LDFLAGS = -rpath @libdir@ +EXTRA_DIST = mock_sync.h Makefile.in +@ENABLE_TESTS_TRUE@formatsdir = @OPENSYNC_FORMATSDIR@ +@ENABLE_TESTS_TRUE@formats_LTLIBRARIES = mockformat.la +@ENABLE_TESTS_TRUE@pluginsdir = @OPENSYNC_PLUGINDIR@ +@ENABLE_TESTS_TRUE@plugins_LTLIBRARIES = mock_sync.la +mock_sync_la_SOURCES = mock_sync.c +mock_sync_la_LDFLAGS = -avoid-version -export-dynamic -module @GCOV_LDFLAGS@ +mock_sync_la_LIBADD = @PACKAGE_LIBS@ @LIBS@ +mockformat_la_SOURCES = mock_format.c +mockformat_la_LDFLAGS = -avoid-version -export-dynamic -module @GCOV_LDFLAGS@ +mockformat_la_LIBADD = @PACKAGE_LIBS@ @LIBS@ +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign tests/mock-plugin/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign tests/mock-plugin/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: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +install-formatsLTLIBRARIES: $(formats_LTLIBRARIES) + @$(NORMAL_INSTALL) + test -z "$(formatsdir)" || $(mkdir_p) "$(DESTDIR)$(formatsdir)" + @list='$(formats_LTLIBRARIES)'; for p in $$list; do \ + if test -f $$p; then \ + f=$(am__strip_dir) \ + echo " $(LIBTOOL) --mode=install $(formatsLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(formatsdir)/$$f'"; \ + $(LIBTOOL) --mode=install $(formatsLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(formatsdir)/$$f"; \ + else :; fi; \ + done + +uninstall-formatsLTLIBRARIES: + @$(NORMAL_UNINSTALL) + @set -x; list='$(formats_LTLIBRARIES)'; for p in $$list; do \ + p=$(am__strip_dir) \ + echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(formatsdir)/$$p'"; \ + $(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(formatsdir)/$$p"; \ + done + +clean-formatsLTLIBRARIES: + -test -z "$(formats_LTLIBRARIES)" || rm -f $(formats_LTLIBRARIES) + @list='$(formats_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 +install-pluginsLTLIBRARIES: $(plugins_LTLIBRARIES) + @$(NORMAL_INSTALL) + test -z "$(pluginsdir)" || $(mkdir_p) "$(DESTDIR)$(pluginsdir)" + @list='$(plugins_LTLIBRARIES)'; for p in $$list; do \ + if test -f $$p; then \ + f=$(am__strip_dir) \ + echo " $(LIBTOOL) --mode=install $(pluginsLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pluginsdir)/$$f'"; \ + $(LIBTOOL) --mode=install $(pluginsLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pluginsdir)/$$f"; \ + else :; fi; \ + done + +uninstall-pluginsLTLIBRARIES: + @$(NORMAL_UNINSTALL) + @set -x; list='$(plugins_LTLIBRARIES)'; for p in $$list; do \ + p=$(am__strip_dir) \ + echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(pluginsdir)/$$p'"; \ + $(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(pluginsdir)/$$p"; \ + done + +clean-pluginsLTLIBRARIES: + -test -z "$(plugins_LTLIBRARIES)" || rm -f $(plugins_LTLIBRARIES) + @list='$(plugins_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 +mock_sync.la: $(mock_sync_la_OBJECTS) $(mock_sync_la_DEPENDENCIES) + $(LINK) $(am_mock_sync_la_rpath) $(mock_sync_la_LDFLAGS) $(mock_sync_la_OBJECTS) $(mock_sync_la_LIBADD) $(LIBS) +mockformat.la: $(mockformat_la_OBJECTS) $(mockformat_la_DEPENDENCIES) + $(LINK) $(am_mockformat_la_rpath) $(mockformat_la_LDFLAGS) $(mockformat_la_OBJECTS) $(mockformat_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mock_format.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mock_sync.Plo@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ if $(LTCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + -rm -f libtool +uninstall-info-am: + +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; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + 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; } \ + END { for (i in files) print i; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + 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; } \ + END { for (i in files) print i; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && 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)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkdir_p) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$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: + for dir in "$(DESTDIR)$(formatsdir)" "$(DESTDIR)$(pluginsdir)"; do \ + test -z "$$dir" || $(mkdir_p) "$$dir"; \ + done +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: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_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-formatsLTLIBRARIES clean-generic clean-libtool \ + clean-pluginsLTLIBRARIES mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-libtool distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: install-formatsLTLIBRARIES install-pluginsLTLIBRARIES + +install-exec-am: + +install-info: install-info-am + +install-man: + +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: uninstall-formatsLTLIBRARIES uninstall-info-am \ + uninstall-pluginsLTLIBRARIES + +.PHONY: CTAGS GTAGS all all-am check check-am clean \ + clean-formatsLTLIBRARIES clean-generic clean-libtool \ + clean-pluginsLTLIBRARIES 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-exec install-exec-am \ + install-formatsLTLIBRARIES install-info install-info-am \ + install-man install-pluginsLTLIBRARIES 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 uninstall-formatsLTLIBRARIES \ + uninstall-info-am uninstall-pluginsLTLIBRARIES + +# 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/debian/opensync/opensync-0.22/tests/mock-plugin/mock_format.c b/debian/opensync/opensync-0.22/tests/mock-plugin/mock_format.c new file mode 100644 index 00000000..f8e34672 --- /dev/null +++ b/debian/opensync/opensync-0.22/tests/mock-plugin/mock_format.c @@ -0,0 +1,137 @@ +/* + * file - A plugin for file objects for the opensync framework + * Copyright (C) 2004-2005 Armin Bauer <armin.bauer@opensync.org> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include <opensync/opensync.h> +#include <glib.h> +#include "mock_sync.h" + +static OSyncConvCmpResult compare_file(OSyncChange *leftchange, OSyncChange *rightchange) +{ + osync_trace(TRACE_ENTRY, "%s(%p, %p)", __func__, leftchange, rightchange); + + osync_bool data_same = FALSE; + osync_bool path_same = FALSE; + + if (!strcmp(osync_change_get_uid(leftchange), osync_change_get_uid(rightchange))) + path_same = TRUE; + + if (osync_change_get_datasize(leftchange) == osync_change_get_datasize(rightchange)) { + if (osync_change_get_data(leftchange) == osync_change_get_data(rightchange)) { + data_same = TRUE; + } else { + if (!memcmp(osync_change_get_data(leftchange), osync_change_get_data(rightchange), osync_change_get_datasize(leftchange))) + data_same = TRUE; + } + } + + if (data_same && path_same) { + osync_trace(TRACE_EXIT, "%s: Same", __func__); + return CONV_DATA_SAME; + } + if (path_same) { + osync_trace(TRACE_EXIT, "%s: Similar", __func__); + return CONV_DATA_SIMILAR; + } + osync_trace(TRACE_EXIT, "%s: Mismatch", __func__); + return CONV_DATA_MISMATCH; +} + +static osync_bool conv_file_to_plain(void *user_data, char *input, int inpsize, char **output, int *outpsize, osync_bool *free_input, OSyncError **error) +{ + osync_debug("FILE", 4, "start: %s", __func__); + + *free_input = FALSE; + *output = input; + *outpsize = inpsize; + return TRUE; +} + +static osync_bool conv_plain_to_file(void *user_data, char *input, int inpsize, char **output, int *outpsize, osync_bool *free_input, OSyncError **error) +{ + osync_debug("FILE", 4, "start: %s", __func__); + + *free_input = FALSE; + *output = input; + *outpsize = inpsize; + return TRUE; +} + +static void destroy_file(char *input, size_t inpsize) +{ + g_free(input); +} + +static void duplicate_file(OSyncChange *change) +{ + osync_debug("FILE", 4, "start: %s", __func__); + char *newuid = g_strdup_printf ("%s-dupe", osync_change_get_uid(change)); + osync_change_set_uid(change, newuid); + g_free(newuid); +} + +static osync_bool copy_file(const char *input, int inpsize, char **output, int *outpsize) +{ + osync_debug("FILE", 4, "start: %s", __func__); + + char *new = NULL; + + if (inpsize) { + new = g_malloc0(inpsize); + memcpy(new, input, inpsize); + } + + *output = new; + *outpsize = inpsize; + return TRUE; +} + +static void create_file(OSyncChange *change) +{ + osync_debug("FILE", 4, "start: %s", __func__); + + char *data = osync_rand_str(g_random_int_range(1, 100)); + osync_change_set_data(change, data, strlen(data) + 1, TRUE); + if (!osync_change_get_uid(change)) + osync_change_set_uid(change, osync_rand_str(6)); +} + +static char *print_file(OSyncChange *change) +{ + osync_debug("FILE", 4, "start: %s", __func__); + + char *printable = g_strdup_printf ("File: %s\nSize: %i", osync_change_get_uid(change), osync_change_get_datasize(change)); + return printable; +} + +void get_info(OSyncEnv *env) +{ + osync_env_register_objtype(env, "data"); + osync_env_register_objformat(env, "data", "mockformat"); + osync_env_format_set_compare_func(env, "mockformat", compare_file); + osync_env_format_set_duplicate_func(env, "mockformat", duplicate_file); + osync_env_format_set_destroy_func(env, "mockformat", destroy_file); + osync_env_format_set_print_func(env, "mockformat", print_file); + osync_env_format_set_copy_func(env, "mockformat", copy_file); + osync_env_format_set_create_func(env, "mockformat", create_file); + + osync_env_format_set_create_func(env, "mockformat", create_file); + osync_env_register_converter(env, CONVERTER_DECAP, "mockformat", "plain", conv_file_to_plain); + osync_env_register_converter(env, CONVERTER_ENCAP, "plain", "mockformat", conv_plain_to_file); +} diff --git a/debian/opensync/opensync-0.22/tests/mock-plugin/mock_sync.c b/debian/opensync/opensync-0.22/tests/mock-plugin/mock_sync.c new file mode 100644 index 00000000..63ec969e --- /dev/null +++ b/debian/opensync/opensync-0.22/tests/mock-plugin/mock_sync.c @@ -0,0 +1,559 @@ +/* + * mock-sync - A mock-plugin for the opensync framework + * Copyright (C) 2004-2005 Armin Bauer <armin.bauer@opensync.org> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "mock_sync.h" + +#define fail(x) abort() + +#define fail_unless(condition, msg) do { \ + if (!condition) fail(msg); \ + } while (0) + +int mock_custom_function(mock_env *env, int input, OSyncError **error) +{ + osync_trace(TRACE_ENTRY, "%s(%p, %i, %p)", __func__, env, input, error); + + fail_unless(input == 1, NULL); + + osync_trace(TRACE_EXIT, "%s", __func__); + return 2; +} + +/*Load the state from a xml file and return it in the conn struct*/ +static osync_bool mock_parse_settings(mock_env *env, char *data, int size, OSyncError **error) +{ + osync_trace(TRACE_ENTRY, "%s(%p, %p, %i)", __func__, env, data, size); + xmlDocPtr doc; + xmlNodePtr cur; + + //set defaults + env->path = NULL; + + doc = xmlParseMemory(data, size); + + if (!doc) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "Unable to parse settings"); + osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); + return FALSE; + } + + cur = xmlDocGetRootElement(doc); + + if (!cur) { + xmlFreeDoc(doc); + osync_error_set(error, OSYNC_ERROR_GENERIC, "Unable to get root element of the settings"); + osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); + return FALSE; + } + + if (xmlStrcmp(cur->name, (xmlChar*)"config")) { + xmlFreeDoc(doc); + osync_error_set(error, OSYNC_ERROR_GENERIC, "Config valid is not valid"); + osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); + return FALSE; + } + + cur = cur->xmlChildrenNode; + + while (cur != NULL) { + char *str = (char*)xmlNodeGetContent(cur); + if (str) { + if (!xmlStrcmp(cur->name, (const xmlChar *)"path")) { + env->path = g_strdup(str); + } + xmlFree(str); + } + cur = cur->next; + } + + xmlFreeDoc(doc); + osync_trace(TRACE_EXIT, "%s", __func__); + return TRUE; +} + +static osync_bool mock_get_error(OSyncMember *member, const char *domain) +{ + const char *env = g_getenv(domain); + if (!env) + return FALSE; + + int num = atoi(env); + int mask = 1 << (osync_member_get_id(member) - 1); + if (num & mask) { + char *chancestr = g_strdup_printf("%s_PROB", domain); + const char *chance = g_getenv(chancestr); + g_free(chancestr); + if (!chance) + return TRUE; + int prob = atoi(chance); + if (prob >= g_random_int_range(0, 100)) + return TRUE; + } + return FALSE; +} + +static void *mock_initialize(OSyncMember *member, OSyncError **error) +{ + osync_trace(TRACE_ENTRY, "%s(%p, %p)", __func__, member, error); + + if (mock_get_error(member, "INIT_NULL")) { + osync_error_set(error, OSYNC_ERROR_EXPECTED, "Triggering INIT_NULL error"); + osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); + return NULL; + } + char *configdata; + int configsize; + mock_env *env = g_malloc0(sizeof(mock_env)); + + if (!osync_member_get_config(member, &configdata, &configsize, error)) { + osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); + return NULL; + } + + if (!mock_parse_settings(env, configdata, configsize, error)) { + g_free(env); + return NULL; + } + + //Rewrite the batch commit functions so we can disable them if necessary + if (!mock_get_error(member, "BATCH_COMMIT")) { + OSyncObjFormatSink *fmtsink = member->format_sinks->data; + osync_trace(TRACE_INTERNAL, "Disabling batch_commit on %p:%s: %i", fmtsink, fmtsink->format ? fmtsink->format->name : "None", g_list_length(member->format_sinks)); + OSyncFormatFunctions *functions = &(fmtsink->functions); + functions->batch_commit = NULL; + } + + env->member = member; + env->hashtable = osync_hashtable_new(); + + osync_trace(TRACE_EXIT, "%s: %p", __func__, env); + return (void *)env; +} + +static void mock_connect(OSyncContext *ctx) +{ + osync_trace(TRACE_ENTRY, "%s(%p)", __func__, ctx); + mock_env *env = (mock_env *)osync_context_get_plugin_data(ctx); + + env->committed_all = TRUE; + + if (mock_get_error(env->member, "CONNECT_ERROR")) { + osync_context_report_error(ctx, OSYNC_ERROR_EXPECTED, "Triggering CONNECT_ERROR error"); + osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, "Triggering CONNECT_ERROR error"); + return; + } + + if (mock_get_error(env->member, "CONNECT_TIMEOUT")) { + osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, "Triggering CONNECT_TIMEOUT error"); + return; + } + + OSyncError *error = NULL; + if (!osync_hashtable_load(env->hashtable, env->member, &error)) { + osync_context_report_osyncerror(ctx, &error); + osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(&error)); + osync_error_free(&error); + return; + } + + if (!osync_anchor_compare(env->member, "path", env->path)) + osync_member_set_slow_sync(env->member, "data", TRUE); + + GError *direrror = NULL; + + env->dir = g_dir_open(env->path, 0, &direrror); + if (direrror) { + //Unable to open directory + osync_context_report_error(ctx, OSYNC_ERROR_FILE_NOT_FOUND, "Unable to open directory %s", env->path); + g_error_free (direrror); + } else { + osync_context_report_success(ctx); + } + + osync_trace(TRACE_EXIT, "%s", __func__); +} + +static char *mock_generate_hash(struct stat *buf) +{ + char *hash = g_strdup_printf("%i-%i", (int)buf->st_mtime, (int)buf->st_ctime); + return hash; +} + +static void mock_get_changeinfo(OSyncContext *ctx) +{ + mock_env *env = (mock_env *)osync_context_get_plugin_data(ctx); + + if (mock_get_error(env->member, "GET_CHANGES_ERROR")) { + osync_context_report_error(ctx, OSYNC_ERROR_EXPECTED, "Triggering GET_CHANGES_ERROR error"); + return; + } + if (mock_get_error(env->member, "GET_CHANGES_TIMEOUT")) + return; + if (mock_get_error(env->member, "GET_CHANGES_TIMEOUT2")) + sleep(8); + + if (osync_member_get_slow_sync(env->member, "data")) { + osync_debug("FILE-SYNC", 3, "Slow sync requested"); + osync_hashtable_set_slow_sync(env->hashtable, "data"); + } + + GDir *dir; + GError *gerror = NULL; + const char *de = NULL; + + dir = g_dir_open(env->path, 0, &gerror); + if (!dir) { + osync_trace(TRACE_EXIT_ERROR, "mock_report_dir: Unable to open directory %s: %s", env->path, gerror ? gerror->message : "None"); + return; + } + while ((de = g_dir_read_name(dir))) { + char *filename = g_build_filename(env->path, de, NULL); + if (g_file_test(filename, G_FILE_TEST_IS_REGULAR)) { + /* Report normal files */ + OSyncChange *change = osync_change_new(); + osync_change_set_member(change, env->member); + osync_change_set_uid(change, de); + + osync_change_set_objformat_string(change, "mockformat"); + + struct stat buf; + stat(filename, &buf); + char *hash = mock_generate_hash(&buf); + osync_change_set_hash(change, hash); + + if (mock_get_error(env->member, "ONLY_INFO")) { + osync_change_set_data(change, NULL, 0, FALSE); + } else { + char *data = NULL; + int size = 0; + OSyncError *error = NULL; + if (!osync_file_read(filename, &data, &size, &error)) { + osync_context_report_osyncerror(ctx, &error); + g_free(filename); + return; + } + + osync_change_set_data(change, data, size, TRUE); + } + + if (mock_get_error(env->member, "SLOW_REPORT")) + sleep(1); + + if (osync_hashtable_detect_change(env->hashtable, change)) { + osync_context_report_change(ctx, change); + osync_hashtable_update_hash(env->hashtable, change); + } + g_free(hash); + + + } + } + g_dir_close(dir); + osync_hashtable_report_deleted(env->hashtable, ctx, "data"); + + fail_unless(env->committed_all == TRUE, NULL); + env->committed_all = FALSE; + + osync_context_report_success(ctx); +} + +static void mock_get_data(OSyncContext *ctx, OSyncChange *change) +{ + mock_env *env = (mock_env *)osync_context_get_plugin_data(ctx); + + if (mock_get_error(env->member, "GET_DATA_ERROR")) { + osync_context_report_error(ctx, OSYNC_ERROR_EXPECTED, "Triggering GET_DATA_ERROR error"); + return; + } + if (mock_get_error(env->member, "GET_DATA_TIMEOUT")) + return; + + char *filename = g_strdup_printf("%s/%s", env->path, osync_change_get_uid(change)); + char *data = NULL; + int size = 0; + OSyncError *error = NULL; + if (!osync_file_read(filename, &data, &size, &error)) { + osync_context_report_osyncerror(ctx, &error); + g_free(filename); + return; + } + + osync_change_set_data(change, data, size, TRUE); + g_free(filename); + + osync_context_report_success(ctx); +} + +static void mock_read(OSyncContext *ctx, OSyncChange *change) +{ + mock_env *env = (mock_env *)osync_context_get_plugin_data(ctx); + + char *filename = g_strdup_printf("%s/%s", env->path, osync_change_get_uid(change)); + + char *data = NULL; + int size = 0; + OSyncError *error = NULL; + if (!osync_file_read(filename, &data, &size, &error)) { + osync_context_report_osyncerror(ctx, &error); + g_free(filename); + return; + } + + osync_change_set_data(change, data, size, TRUE); + + g_free(filename); + + osync_context_report_success(ctx); +} + +static osync_bool mock_access(OSyncContext *ctx, OSyncChange *change) +{ + /*TODO: Create directory for file, if it doesn't exist */ + osync_trace(TRACE_ENTRY, "%s(%p, %p)", __func__, ctx, change); + + mock_env *env = (mock_env *)osync_context_get_plugin_data(ctx); + + char *filename = NULL; + OSyncError *error = NULL; + filename = g_strdup_printf ("%s/%s", env->path, osync_change_get_uid(change)); + + switch (osync_change_get_changetype(change)) { + case CHANGE_DELETED: + if (!remove(filename) == 0) { + osync_debug("FILE-SYNC", 0, "Unable to remove file %s", filename); + osync_context_report_error(ctx, OSYNC_ERROR_FILE_NOT_FOUND, "Unable to write"); + g_free(filename); + osync_trace(TRACE_EXIT_ERROR, "%s: Unable to write", __func__); + return FALSE; + } + break; + case CHANGE_ADDED: + if (g_file_test(filename, G_FILE_TEST_EXISTS)) { + osync_debug("FILE-SYNC", 0, "File %s already exists", filename); + osync_context_report_error(ctx, OSYNC_ERROR_EXISTS, "Entry already exists"); + g_free(filename); + osync_trace(TRACE_EXIT_ERROR, "%s: Entry already exists", __func__); + return FALSE; + } + /* No break. Continue below */ + case CHANGE_MODIFIED: + //FIXME add permission and ownership for file-sync + if (!osync_file_write(filename, osync_change_get_data(change), osync_change_get_datasize(change), 0700, &error)) { + osync_debug("FILE-SYNC", 0, "Unable to write to file %s", filename); + osync_context_report_osyncerror(ctx, &error); + g_free(filename); + osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(&error)); + return FALSE; + } + + struct stat buf; + stat(filename, &buf); + char *hash = mock_generate_hash(&buf); + osync_change_set_hash(change, hash); + break; + default: + fail("no changetype given"); + } + g_free(filename); + + osync_trace(TRACE_EXIT, "%s", __func__); + return TRUE; +} + +static osync_bool mock_commit_change(OSyncContext *ctx, OSyncChange *change) +{ + osync_debug("FILE-SYNC", 4, "start: %s", __func__); + osync_debug("FILE-SYNC", 3, "Writing change %s with changetype %i", osync_change_get_uid(change), osync_change_get_changetype(change)); + mock_env *env = (mock_env *)osync_context_get_plugin_data(ctx); + + fail_unless(env->committed_all == FALSE, NULL); + + if (mock_get_error(env->member, "COMMIT_ERROR")) { + osync_context_report_error(ctx, OSYNC_ERROR_EXPECTED, "Triggering COMMIT_ERROR error"); + return FALSE; + } + if (mock_get_error(env->member, "COMMIT_TIMEOUT")) + return FALSE; + + if (!mock_access(ctx, change)) + return FALSE; + + osync_hashtable_update_hash(env->hashtable, change); + osync_context_report_success(ctx); + osync_debug("FILE-SYNC", 4, "end: %s", __func__); + return TRUE; +} + +static void mock_sync_done(OSyncContext *ctx) +{ + osync_debug("FILE-SYNC", 3, "start: %s", __func__); + mock_env *env = (mock_env *)osync_context_get_plugin_data(ctx); + + if (mock_get_error(env->member, "SYNC_DONE_ERROR")) { + osync_context_report_error(ctx, OSYNC_ERROR_EXPECTED, "Triggering SYNC_DONE_ERROR error"); + return; + } + if (mock_get_error(env->member, "SYNC_DONE_TIMEOUT")) + return; + + osync_anchor_update(env->member, "path", env->path); + osync_context_report_success(ctx); + osync_debug("FILE-SYNC", 3, "end: %s", __func__); +} + +static void mock_disconnect(OSyncContext *ctx) +{ + osync_debug("FILE-SYNC", 3, "start: %s", __func__); + mock_env *env = (mock_env *)osync_context_get_plugin_data(ctx); + + if (!g_getenv("NO_COMMITTED_ALL_CHECK")) + fail_unless(env->committed_all == TRUE, NULL); + env->committed_all = FALSE; + + if (mock_get_error(env->member, "DISCONNECT_ERROR")) { + osync_context_report_error(ctx, OSYNC_ERROR_EXPECTED, "Triggering DISCONNECT_ERROR error"); + return; + } + if (mock_get_error(env->member, "DISCONNECT_TIMEOUT")) + return; + + g_dir_close(env->dir); + osync_hashtable_close(env->hashtable); + osync_context_report_success(ctx); + osync_debug("FILE-SYNC", 3, "end: %s", __func__); +} + +static void mock_finalize(void *data) +{ + osync_debug("FILE-SYNC", 3, "start: %s", __func__); + mock_env *env = (mock_env *)data; + osync_hashtable_free(env->hashtable); + + g_free(env->path); + g_free(env); +} + +static osync_bool mock_is_available(OSyncError **error) +{ + if (g_getenv("IS_NOT_AVAILABLE")) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "file-sync plugin is not available"); + return FALSE; + } + return TRUE; +} + +static void mock_batch_commit(OSyncContext *context, OSyncContext **contexts, OSyncChange **changes) +{ + osync_trace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, context, contexts, changes); + mock_env *env = (mock_env *)osync_context_get_plugin_data(context); + + fail_unless(env->committed_all == FALSE, NULL); + env->committed_all = TRUE; + + int i; + for (i = 0; contexts[i]; i++) { + if (mock_access(contexts[i], changes[i])) { + osync_hashtable_update_hash(env->hashtable, changes[i]); + osync_context_report_success(contexts[i]); + } + } + + if (g_getenv("NUM_BATCH_COMMITS")) { + int req = atoi(g_getenv("NUM_BATCH_COMMITS")); + fail_unless(req == i, NULL); + } + + if (mock_get_error(env->member, "COMMITTED_ALL_ERROR")) { + osync_context_report_error(context, OSYNC_ERROR_EXPECTED, "Triggering COMMITTED_ALL_ERROR error"); + return; + } + + osync_context_report_success(context); + + osync_trace(TRACE_EXIT, "%s", __func__); +} + +static void mock_committed_all(OSyncContext *context) +{ + osync_trace(TRACE_ENTRY, "%s(%p)", __func__, context); + mock_env *env = (mock_env *)osync_context_get_plugin_data(context); + + fail_unless(env->committed_all == FALSE, NULL); + env->committed_all = TRUE; + + if (mock_get_error(env->member, "COMMITTED_ALL_ERROR")) { + osync_context_report_error(context, OSYNC_ERROR_EXPECTED, "Triggering COMMITTED_ALL_ERROR error"); + osync_trace(TRACE_EXIT_ERROR, "%s: Reporting error", __func__); + return; + } + + osync_context_report_success(context); + + osync_trace(TRACE_EXIT, "%s", __func__); +} + +void get_info(OSyncEnv *env) +{ + OSyncPluginInfo *info = osync_plugin_new_info(env); + + info->name = "file-sync"; + info->longname = "Mock Plugin"; + info->description = "Mock Plugin"; + info->version = 1; + + info->functions.initialize = mock_initialize; + info->functions.connect = mock_connect; + info->functions.sync_done = mock_sync_done; + info->functions.disconnect = mock_disconnect; + info->functions.finalize = mock_finalize; + info->functions.get_changeinfo = mock_get_changeinfo; + info->functions.get_data = mock_get_data; + + osync_plugin_accept_objtype(info, "data"); + osync_plugin_accept_objformat(info, "data", "mockformat", NULL); + + osync_plugin_set_access_objformat(info, "data", "mockformat", mock_access); + osync_plugin_set_read_objformat(info, "data", "mockformat", mock_read); + + //Lets reduce the timeouts a bit so the checks work faster + info->timeouts.disconnect_timeout = 5; + info->timeouts.connect_timeout = 5; + info->timeouts.sync_done_timeout = 5; + info->timeouts.get_changeinfo_timeout = 5; + info->timeouts.get_data_timeout = 5; + info->timeouts.commit_timeout = 15; + + + if (g_getenv("NO_TIMEOUTS")) { + info->timeouts.disconnect_timeout = 0; + info->timeouts.connect_timeout = 0; + info->timeouts.sync_done_timeout = 0; + info->timeouts.get_changeinfo_timeout = 0; + info->timeouts.get_data_timeout = 0; + info->timeouts.commit_timeout = 0; + } + + if (g_getenv("IS_AVAILABLE")) + info->functions.is_available = mock_is_available; + + osync_plugin_set_batch_commit_objformat(info, "data", "mockformat", mock_batch_commit); + osync_plugin_set_commit_objformat(info, "data", "mockformat", mock_commit_change); + osync_plugin_set_committed_all_objformat(info, "data", "mockformat", mock_committed_all); +} diff --git a/debian/opensync/opensync-0.22/tests/mock-plugin/mock_sync.h b/debian/opensync/opensync-0.22/tests/mock-plugin/mock_sync.h new file mode 100644 index 00000000..5eb62454 --- /dev/null +++ b/debian/opensync/opensync-0.22/tests/mock-plugin/mock_sync.h @@ -0,0 +1,18 @@ +#include <opensync/opensync.h> +#include <opensync/opensync_internals.h> +#include <sys/stat.h> +#include <stdio.h> +#include <glib.h> +#include <string.h> +#include <config.h> + +#include <libxml/xmlmemory.h> +#include <libxml/parser.h> + +typedef struct mock_env { + char *path; + OSyncMember *member; + GDir *dir; + OSyncHashTable *hashtable; + osync_bool committed_all; +} mock_env; |