diff options
Diffstat (limited to 'test/unittest')
-rw-r--r-- | test/unittest/.svn/all-wcprops | 23 | ||||
-rw-r--r-- | test/unittest/.svn/entries | 130 | ||||
-rw-r--r-- | test/unittest/.svn/prop-base/Makefile.am.svn-base | 5 | ||||
-rw-r--r-- | test/unittest/.svn/prop-base/Makefile.in.svn-base | 5 | ||||
-rw-r--r-- | test/unittest/.svn/prop-base/libunit.c.svn-base | 9 | ||||
-rw-r--r-- | test/unittest/.svn/text-base/Makefile.am.svn-base | 22 | ||||
-rw-r--r-- | test/unittest/.svn/text-base/Makefile.in.svn-base | 564 | ||||
-rw-r--r-- | test/unittest/.svn/text-base/libunit.c.svn-base | 615 | ||||
-rw-r--r-- | test/unittest/Makefile.am | 22 | ||||
-rw-r--r-- | test/unittest/Makefile.in | 564 | ||||
-rw-r--r-- | test/unittest/libunit.c | 615 |
11 files changed, 2574 insertions, 0 deletions
diff --git a/test/unittest/.svn/all-wcprops b/test/unittest/.svn/all-wcprops new file mode 100644 index 0000000..3036c48 --- /dev/null +++ b/test/unittest/.svn/all-wcprops @@ -0,0 +1,23 @@ +K 25 +svn:wc:ra_dav:version-url +V 50 +/svnroot/libcaldav/!svn/ver/42/trunk/test/unittest +END +Makefile.in +K 25 +svn:wc:ra_dav:version-url +V 62 +/svnroot/libcaldav/!svn/ver/42/trunk/test/unittest/Makefile.in +END +libunit.c +K 25 +svn:wc:ra_dav:version-url +V 60 +/svnroot/libcaldav/!svn/ver/40/trunk/test/unittest/libunit.c +END +Makefile.am +K 25 +svn:wc:ra_dav:version-url +V 62 +/svnroot/libcaldav/!svn/ver/30/trunk/test/unittest/Makefile.am +END diff --git a/test/unittest/.svn/entries b/test/unittest/.svn/entries new file mode 100644 index 0000000..3756817 --- /dev/null +++ b/test/unittest/.svn/entries @@ -0,0 +1,130 @@ +10 + +dir +42 +https://libcaldav.svn.sourceforge.net/svnroot/libcaldav/trunk/test/unittest +https://libcaldav.svn.sourceforge.net/svnroot/libcaldav + + + +2010-05-29T15:45:56.236020Z +42 +miras + + + + + + + + + + + + + + +6bb92309-7149-0410-b568-bc30dfd0a1d5 + +Makefile.in +file + + + + +2010-05-31T07:07:58.000000Z +b1273950d94bccb8c4248fdd8c4b7a89 +2010-05-29T15:45:56.236020Z +42 +miras +has-props + + + + + + + + + + + + + + + + + + + + +17653 + +libunit.c +file + + + + +2010-05-31T07:07:58.000000Z +6d177ca8a47a1b2aa5d05b3aa65f9df5 +2010-05-23T21:46:08.944313Z +40 +miras +has-props + + + + + + + + + + + + + + + + + + + + +16563 + +Makefile.am +file + + + + +2010-05-31T07:07:58.000000Z +60502f8e62676b65dc3e97abff162887 +2010-04-04T20:17:57.156621Z +30 +miras +has-props + + + + + + + + + + + + + + + + + + + + +337 + diff --git a/test/unittest/.svn/prop-base/Makefile.am.svn-base b/test/unittest/.svn/prop-base/Makefile.am.svn-base new file mode 100644 index 0000000..74fda45 --- /dev/null +++ b/test/unittest/.svn/prop-base/Makefile.am.svn-base @@ -0,0 +1,5 @@ +K 12 +svn:keywords +V 22 +Author Date Id Rev URL +END diff --git a/test/unittest/.svn/prop-base/Makefile.in.svn-base b/test/unittest/.svn/prop-base/Makefile.in.svn-base new file mode 100644 index 0000000..74fda45 --- /dev/null +++ b/test/unittest/.svn/prop-base/Makefile.in.svn-base @@ -0,0 +1,5 @@ +K 12 +svn:keywords +V 22 +Author Date Id Rev URL +END diff --git a/test/unittest/.svn/prop-base/libunit.c.svn-base b/test/unittest/.svn/prop-base/libunit.c.svn-base new file mode 100644 index 0000000..514d003 --- /dev/null +++ b/test/unittest/.svn/prop-base/libunit.c.svn-base @@ -0,0 +1,9 @@ +K 13 +svn:eol-style +V 6 +native +K 12 +svn:keywords +V 22 +Author Date Id Rev URL +END diff --git a/test/unittest/.svn/text-base/Makefile.am.svn-base b/test/unittest/.svn/text-base/Makefile.am.svn-base new file mode 100644 index 0000000..6d09609 --- /dev/null +++ b/test/unittest/.svn/text-base/Makefile.am.svn-base @@ -0,0 +1,22 @@ +AUTOMAKE_OPTIONS = gnu + +if BUILD_UNITTEST +INCLUDES = \ + @CURL_CFLAGS@ \ + @GLIB_CFLAGS@ \ + -I$(top_srcdir) \ + -I$(top_srcdir)/src + +bin_PROGRAMS = unittest + +unittest_SOURCES = \ + libunit.c + +unittest_LDFLAGS = \ + -L$(top_builddir)/src + +unittest_LDADD = \ + @CURL_LIBS@ \ + @GLIB_LIBS@ \ + -lcaldav +endif diff --git a/test/unittest/.svn/text-base/Makefile.in.svn-base b/test/unittest/.svn/text-base/Makefile.in.svn-base new file mode 100644 index 0000000..353f818 --- /dev/null +++ b/test/unittest/.svn/text-base/Makefile.in.svn-base @@ -0,0 +1,564 @@ +# Makefile.in generated by automake 1.11.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, +# Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +target_triplet = @target@ +@BUILD_UNITTEST_TRUE@bin_PROGRAMS = unittest$(EXEEXT) +subdir = test/unittest +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/ax_prog_doxygen.m4 \ + $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ + $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ + $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +am__installdirs = "$(DESTDIR)$(bindir)" +PROGRAMS = $(bin_PROGRAMS) +am__unittest_SOURCES_DIST = libunit.c +@BUILD_UNITTEST_TRUE@am_unittest_OBJECTS = libunit.$(OBJEXT) +unittest_OBJECTS = $(am_unittest_OBJECTS) +unittest_DEPENDENCIES = +unittest_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(unittest_LDFLAGS) \ + $(LDFLAGS) -o $@ +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(unittest_SOURCES) +DIST_SOURCES = $(am__unittest_SOURCES_DIST) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CURL_CFLAGS = @CURL_CFLAGS@ +CURL_LIBS = @CURL_LIBS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DOXYGEN_PAPER_SIZE = @DOXYGEN_PAPER_SIZE@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +DX_CONFIG = @DX_CONFIG@ +DX_DOCDIR = @DX_DOCDIR@ +DX_DOT = @DX_DOT@ +DX_DOXYGEN = @DX_DOXYGEN@ +DX_DVIPS = @DX_DVIPS@ +DX_EGREP = @DX_EGREP@ +DX_ENV = @DX_ENV@ +DX_FLAG_chi = @DX_FLAG_chi@ +DX_FLAG_chm = @DX_FLAG_chm@ +DX_FLAG_doc = @DX_FLAG_doc@ +DX_FLAG_dot = @DX_FLAG_dot@ +DX_FLAG_html = @DX_FLAG_html@ +DX_FLAG_man = @DX_FLAG_man@ +DX_FLAG_pdf = @DX_FLAG_pdf@ +DX_FLAG_ps = @DX_FLAG_ps@ +DX_FLAG_rtf = @DX_FLAG_rtf@ +DX_FLAG_xml = @DX_FLAG_xml@ +DX_HHC = @DX_HHC@ +DX_LATEX = @DX_LATEX@ +DX_MAKEINDEX = @DX_MAKEINDEX@ +DX_PDFLATEX = @DX_PDFLATEX@ +DX_PERL = @DX_PERL@ +DX_PROJECT = @DX_PROJECT@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GLIB_CFLAGS = @GLIB_CFLAGS@ +GLIB_LIBS = @GLIB_LIBS@ +GREP = @GREP@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIBVERSION = @LIBVERSION@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MKDIR_P = @MKDIR_P@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PKG_CONFIG = @PKG_CONFIG@ +PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ +PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +lt_ECHO = @lt_ECHO@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +AUTOMAKE_OPTIONS = gnu +@BUILD_UNITTEST_TRUE@INCLUDES = \ +@BUILD_UNITTEST_TRUE@ @CURL_CFLAGS@ \ +@BUILD_UNITTEST_TRUE@ @GLIB_CFLAGS@ \ +@BUILD_UNITTEST_TRUE@ -I$(top_srcdir) \ +@BUILD_UNITTEST_TRUE@ -I$(top_srcdir)/src + +@BUILD_UNITTEST_TRUE@unittest_SOURCES = \ +@BUILD_UNITTEST_TRUE@ libunit.c + +@BUILD_UNITTEST_TRUE@unittest_LDFLAGS = \ +@BUILD_UNITTEST_TRUE@ -L$(top_builddir)/src + +@BUILD_UNITTEST_TRUE@unittest_LDADD = \ +@BUILD_UNITTEST_TRUE@ @CURL_LIBS@ \ +@BUILD_UNITTEST_TRUE@ @GLIB_LIBS@ \ +@BUILD_UNITTEST_TRUE@ -lcaldav + +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu test/unittest/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu test/unittest/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" + @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ + for p in $$list; do echo "$$p $$p"; done | \ + sed 's/$(EXEEXT)$$//' | \ + while read p p1; do if test -f $$p || test -f $$p1; \ + then echo "$$p"; echo "$$p"; else :; fi; \ + done | \ + sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \ + -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ + sed 'N;N;N;s,\n, ,g' | \ + $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ + { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ + if ($$2 == $$4) files[d] = files[d] " " $$1; \ + else { print "f", $$3 "/" $$4, $$1; } } \ + END { for (d in files) print "f", d, files[d] }' | \ + while read type dir files; do \ + if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ + test -z "$$files" || { \ + echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \ + $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \ + } \ + ; done + +uninstall-binPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ + files=`for p in $$list; do echo "$$p"; done | \ + sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ + -e 's/$$/$(EXEEXT)/' `; \ + test -n "$$list" || exit 0; \ + echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \ + cd "$(DESTDIR)$(bindir)" && rm -f $$files + +clean-binPROGRAMS: + @list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \ + echo " rm -f" $$list; \ + rm -f $$list || exit $$?; \ + test -n "$(EXEEXT)" || exit 0; \ + list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f" $$list; \ + rm -f $$list +unittest$(EXEEXT): $(unittest_OBJECTS) $(unittest_DEPENDENCIES) + @rm -f unittest$(EXEEXT) + $(unittest_LINK) $(unittest_OBJECTS) $(unittest_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libunit.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@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@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@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@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@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 + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + set x; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(PROGRAMS) +installdirs: + for dir in "$(DESTDIR)$(bindir)"; 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) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: install-binPROGRAMS + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-binPROGRAMS + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \ + clean-generic clean-libtool ctags distclean distclean-compile \ + distclean-generic distclean-libtool distclean-tags distdir dvi \ + dvi-am html html-am info info-am install install-am \ + install-binPROGRAMS install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ + pdf pdf-am ps ps-am tags uninstall uninstall-am \ + uninstall-binPROGRAMS + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/test/unittest/.svn/text-base/libunit.c.svn-base b/test/unittest/.svn/text-base/libunit.c.svn-base new file mode 100644 index 0000000..b0be673 --- /dev/null +++ b/test/unittest/.svn/text-base/libunit.c.svn-base @@ -0,0 +1,615 @@ +/* vim: set textwidth=80 tabstop=4: */ + +/* +// libunit.c +// +// Copyright 2010 Michael Rasmussen <mir@datanom.net> +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +// MA 02110-1301, USA. +*/ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include "caldav.h" +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <glib.h> +#include <string.h> +#include <sys/time.h> +#include <string.h> + +static const char* usage[] = { +"unittest is part of libcaldav for claws-mails " +"vcalendar plugin.\nCopyright (C) Michael Rasmussen, 2008.\n" +"This program is free software; you can redistribute it and/or modify\n" +"it under the terms of the GNU General Public License as published by\n" +"the Free Software Foundation; either version 3 of the License, or\n" +"(at your option) any later version.\n" +"\nusage:\n\tunittest [Options]\n" +"\n\tOptions:\n" +"\t\t-h|-?\tusage\n" +"\t\t-a\tURL\n" +"\t\t-d\tEnable debug\n" +"\t\t-l\tDebug library\n" +"\t\t-p\tpassword\n" +"\t\t-u\tusername\n" +}; + +/* + * Options can be given in one of three ways: + * 1) Entered as options on the command line + * 2) Stored in environment variables: + * - LIBCALDAV_UID -> username to use when connection to server + * - LIBCALDAV_PWD -> password, if any, to use when connection to server + * - LIBCALDAV_URL -> complete URL to server. prefixed with either + * http:// or https:// + * 3) Stored in a file found in the same directory as the program: + * [server] + * password=Big secret + * username=username + * url=http[s]://bar.tld/foo + */ + +#define CONFFILE "caldav-unit-settings.conf" + +typedef struct { + gchar* uid; + gchar* pwd; + gchar* url; +} settings; + +typedef enum { + PWD, + UID, + URL +} CONFIG; + +static settings* SETTING = NULL; +gboolean DEBUG = FALSE; +gboolean DEBUG_LIB = FALSE; + +void settings_free(settings** setting) { + settings* s; + + if (! *setting) + return; + s = *setting; + g_free(s->url); + g_free(s->uid); + g_free(s->pwd); + g_free(s); + *setting = s = NULL; +} + +settings* parse_cmdline(int argc, char** argv) { + char c; + settings* setting; + + setting = g_new0(settings, 1); + while ((c = getopt(argc, argv, "ha:dlp:u:?")) != -1) { + switch (c) { + case 'h': + case '?': + fprintf(stdout, "%s", usage[0]); + return 0; + case 'a': + setting->url = g_strdup(optarg); + break; + case 'd': + DEBUG = TRUE; + break; + case 'l': + DEBUG_LIB = TRUE; + break; + case 'p': + setting->pwd = g_strdup(optarg); + break; + case 'u': + setting->uid = g_strdup(optarg); + break; + } + } + if (argv[optind]) { + fprintf(stderr, "No arguments after options expected\n"); + fprintf(stderr, "%s", usage[0]); + settings_free(&setting); + return NULL; + } + + return setting; +} + +void read_file(const gchar* file) { + GKeyFile* keyfile; + + if (! SETTING) { + SETTING = g_new0(settings, 1); + keyfile = g_key_file_new(); + if (g_key_file_load_from_file(keyfile, + file, + G_KEY_FILE_KEEP_COMMENTS, + NULL)) { + SETTING->pwd = g_key_file_get_string(keyfile, + "server", + "password", + NULL); + SETTING->uid = g_key_file_get_string(keyfile, + "server", + "username", + NULL); + SETTING->url = g_key_file_get_string(keyfile, + "server", + "url", + NULL); + } + g_key_file_free(keyfile); + } +} + +const gchar* get_setting_from_file(CONFIG config) { + gchar* cwd; + gchar* path; + gchar* pos; + gchar* setting = NULL; + int step; + + gchar* filename = g_get_prgname(); + if (filename[0] == '/') { + /* absolute path */ + cwd = g_path_get_dirname(filename); + } + else if ((pos = strchr(filename, '/')) != NULL) { + /* relative path */ + if (filename[0] == '.') { + char* tmp = pos; + while (tmp) { + if (strncmp(tmp, "..", 2) == 0) + step = 2; + else + step = 1; + tmp = strchr(pos + step, '/'); + if (tmp) + pos = tmp; + } + if (pos == NULL) { + pos = strchr(filename, '/'); + } + } + path = g_get_current_dir(); + cwd = g_build_filename(path, pos + 1, NULL); + g_free(path); + if (g_file_test(cwd, G_FILE_TEST_IS_REGULAR)) { + pos = strrchr(cwd, '/'); + if (pos) { + path = g_strndup(cwd, pos - cwd); + g_free(cwd); + cwd = g_strdup(path); + g_free(path); + } + } + } + else { + /* find cwd in PATH */ + cwd = g_find_program_in_path(filename); + } + path = g_build_filename(cwd, CONFFILE, NULL); + g_free(cwd); + if (g_file_test(path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) { + read_file(path); + switch (config) { + case UID: setting = SETTING->uid; break; + case PWD: setting = SETTING->pwd; break; + case URL: setting = SETTING->url; break; + } + } + g_free(path); + return setting; +} + +gboolean find_missing(settings** setting) { + settings* s = *setting; + const char* env; + gboolean error = FALSE; + + if (! s) + return TRUE; + + if (! s->uid) { + if ((env = getenv("LIBCALDAV_UID")) == NULL) { + env = get_setting_from_file(UID); + if (env == NULL) + error = TRUE; + } + s->uid = g_strdup(env); + } + if (! s->pwd) { + if ((env = getenv("LIBCALDAV_PWD")) == NULL) { + env = get_setting_from_file(PWD); + if (env == NULL) + error = TRUE; + } + s->pwd = g_strdup(env); + } + if (! s->url) { + if ((env = getenv("LIBCALDAV_URL")) == NULL) { + env = get_setting_from_file(URL); + if (env == NULL) + error = TRUE; + } + s->url = g_strdup(env); + } + settings_free(&SETTING); + return error; +} + +time_t make_time_t(const char* time_elem) { + struct tm datetime = {0,0,0,0,0,0,0,0,0,0,NULL}; + struct tm* tmp; + gchar** elem; + time_t t; + + t = time(NULL); + tmp = localtime(&t); + elem = g_strsplit(time_elem, "/", 3); + datetime.tm_year = atoi(elem[0]) - 1900; + datetime.tm_mon = atoi(elem[1]) - 1; + datetime.tm_mday = atoi(elem[2]); + g_strfreev(elem); + t = mktime(&datetime); + return t; +} + +gboolean compare_freebusy(const gchar* s1, const gchar* s2) { + const char* TOKEN = "FREEBUSY:"; + gchar* pos1; + gchar* pos2; + gchar* id1; + + if (! s1 && ! s2) + return TRUE; + if (! s1 || ! s2) + return FALSE; + pos1 = strstr(s2, TOKEN); + if (! pos1) + return FALSE; + pos1 += strlen(TOKEN); + pos2 = strchr(pos1, '\n'); + if (! pos2) + return FALSE; + if (*(pos2 - 1) == '\r') + pos2--; + id1 = g_strndup(pos1, pos2 - pos1); + int res = strcmp(s1, id1); + g_free(id1); + return (res == 0); +} + +gboolean compare_object(const gchar* TOKEN, const gchar* s1, const gchar* s2) { + gchar* pos1; + gchar* pos2; + gchar* id1; + gchar* id2; + + if (! s1 && ! s2) + return TRUE; + if (! s1 || ! s2) + return FALSE; + pos1 = strstr(s1, TOKEN); + if (! pos1) + return FALSE; + pos1 += strlen(TOKEN) + 1; + pos2 = strchr(pos1, '\n'); + if (! pos2) + return FALSE; + if (*(pos2 - 1) == '\r') + pos2--; + id1 = g_strndup(pos1, pos2 - pos1); + pos2 = strstr(s2, TOKEN); + if (! pos2) { + g_free(id1); + return FALSE; + } + pos2 += strlen(TOKEN) + 1; + pos1 = strchr(pos2, '\n'); + if (! pos1) { + g_free(id1); + return FALSE; + } + if (*(pos1 - 1) == '\r') + pos1--; + id2 = g_strndup(pos2, pos1 - pos2); + int res = strcmp(id1, id2); + g_free(id1); + g_free(id2); + return (res == 0); +} + +void run_tests(settings* s) { + runtime_info* info = caldav_get_runtime_info(); + response* resp = caldav_get_response(); + gchar** parts; + gchar* url; + gchar* object; + + if (DEBUG_LIB) { + info->options->debug = 1; + info->options->trace_ascii = 1; + } + parts = g_strsplit(s->url, "//", 2); + url = g_strconcat( + parts[0], "//", s->uid, ":", s->pwd, "@", parts[1], NULL); + g_strfreev(parts); + fprintf(stdout, "Test caldav_enabled_resource:\t\t\t"); + if (caldav_enabled_resource(url, info)) { + fprintf(stdout, "OK\n"); + if (DEBUG) fprintf(stdout, "caldav enabled server\n"); + } + else { + fprintf(stdout, "FAIL\n"); + if (DEBUG) fprintf(stdout, "%ld: %s\n", info->error->code, info->error->str); + } + fprintf(stdout, "Test caldav_get_displayname:\t\t\t"); + if (caldav_get_displayname(resp, url, info) == OK) { + fprintf(stdout, "OK\n"); + if (DEBUG) fprintf(stdout, "Display Name: %s\n", resp->msg); + } + else { + fprintf(stdout, "FAIL\n"); + if (DEBUG) fprintf(stdout, "%ld: %s\n", info->error->code, info->error->str); + } + g_free(resp->msg); + resp->msg = NULL; + fprintf(stdout, "Test caldav_get_server_options:\t\t\t"); + if ((parts = caldav_get_server_options(url, info)) != NULL) { + fprintf(stdout, "OK\n"); + if (DEBUG) { + char** tmp = parts; + while (*tmp) { + fprintf(stdout, "--> %s\n", *tmp++); + } + } + g_strfreev(parts); + } + else { + fprintf(stdout, "FAIL\n"); + if (DEBUG) fprintf(stdout, "%ld: %s\n", info->error->code, info->error->str); + } + g_file_get_contents("../ics/add.ics", &object, NULL, NULL); + fprintf(stdout, "Test caldav_add_object:\t\t\t\t"); + if (caldav_add_object(object, url, info) == OK) { + fprintf(stdout, "OK\n"); + if (DEBUG) fprintf(stdout, "Added successfully\n"); + } + else { + fprintf(stdout, "FAIL\n"); + if (DEBUG) fprintf(stdout, "%ld: %s\n", info->error->code, info->error->str); + } + fprintf(stdout, "Test if object was added:\t\t\t"); + if (caldav_get_object(resp, make_time_t("2008/04/15"), + make_time_t("2008/04/16"), url, info) == OK) { + if (compare_object("UID", object, resp->msg)) + fprintf(stdout, "OK\n"); + else + fprintf(stdout, "FAIL\n"); + if (DEBUG) fprintf(stdout, "%s\n", resp->msg); + } + else { + fprintf(stdout, "FAIL\n"); + if (DEBUG) fprintf(stdout, "%ld: %s\n", info->error->code, info->error->str); + } + g_free(resp->msg); + resp->msg = NULL; + g_free(object); + fprintf(stdout, "Test FREEBUSY search the same day:\t\t"); + if (caldav_get_freebusy(resp, make_time_t("2008/04/15"), + make_time_t("2008/04/16"), url, info) == OK) { + if (compare_freebusy("20080415T151500Z/20080415T162500", resp->msg)) + fprintf(stdout, "OK\n"); + else + fprintf(stdout, "FAIL\n"); + if (DEBUG) fprintf(stdout, "%s\n", resp->msg); + } + else { + fprintf(stdout, "FAIL\n"); + if (DEBUG) fprintf(stdout, "%ld: %s\n", info->error->code, info->error->str); + } + g_free(resp->msg); + resp->msg = NULL; + g_file_get_contents("../ics/modify.ics", &object, NULL, NULL); + fprintf(stdout, "Test caldav_modify_object:\t\t\t"); + if (caldav_modify_object(object, url, info) == OK) { + fprintf(stdout, "OK\n"); + if (DEBUG) fprintf(stdout, "Modified successfully\n"); + } + else { + fprintf(stdout, "FAIL\n"); + if (DEBUG) fprintf(stdout, "%ld: %s\n", info->error->code, info->error->str); + } + fprintf(stdout, "Test if object was modified:\t\t\t"); + if (caldav_get_object(resp, make_time_t("2008/04/16"), + make_time_t("2008/04/17"), url, info) == OK) { + if (compare_object("DTEND", object, resp->msg)) + fprintf(stdout, "OK\n"); + else + fprintf(stdout, "FAIL\n"); + if (DEBUG) fprintf(stdout, "%s\n", resp->msg); + } + else { + fprintf(stdout, "FAIL\n"); + if (DEBUG) fprintf(stdout, "%ld: %s\n", info->error->code, info->error->str); + } + g_free(resp->msg); + resp->msg = NULL; + fprintf(stdout, "Test caldav_getall_object:\t\t\t"); + if (caldav_getall_object(resp, url, info) == OK) { + fprintf(stdout, "OK\n"); + if (DEBUG) fprintf(stdout, "%s\n", resp->msg); + } + else { + fprintf(stdout, "FAIL\n"); + if (DEBUG) fprintf(stdout, "%ld: %s\n", info->error->code, info->error->str); + } + fprintf(stdout, "Test if object exists:\t\t\t\t"); + if (compare_object("UID", object, resp->msg)) + fprintf(stdout, "FAIL\n"); + else + fprintf(stdout, "OK\n"); + g_free(resp->msg); + resp->msg = NULL; + g_free(object); + g_file_get_contents("../ics/delete.ics", &object, NULL, NULL); + fprintf(stdout, "Test caldav_delete_object:\t\t\t"); + if (caldav_delete_object(object, url, info) == OK) { + fprintf(stdout, "OK\n"); + if (DEBUG) fprintf(stdout, "Deleted successfully\n"); + } + else { + fprintf(stdout, "FAIL\n"); + if (DEBUG) fprintf(stdout, "%ld: %s\n", info->error->code, info->error->str); + } + fprintf(stdout, "Test if object was deleted:\t\t\t"); + if (caldav_get_object(resp, make_time_t("2008/04/16"), + make_time_t("2008/04/17"), url, info) == OK) { + if (compare_object("UID", object, resp->msg)) + fprintf(stdout, "FAIL\n"); + else + fprintf(stdout, "OK\n"); + if (DEBUG) fprintf(stdout, "%s\n", (resp->msg) ? resp->msg : "No object found"); + g_free(resp->msg); + resp->msg = NULL; + } + else { + fprintf(stdout, "FAIL\n"); + if (DEBUG) fprintf(stdout, "%ld: %s\n", info->error->code, info->error->str); + } + g_free(object); + fprintf(stdout, "\nTesting without using locks\n"); + info->options->use_locking = 0; + g_file_get_contents("../ics/add.ics", &object, NULL, NULL); + fprintf(stdout, "Test caldav_add_object:\t\t\t\t"); + if (caldav_add_object(object, url, info) == OK) { + fprintf(stdout, "OK\n"); + if (DEBUG) fprintf(stdout, "Added successfully\n"); + } + else { + fprintf(stdout, "FAIL\n"); + if (DEBUG) fprintf(stdout, "%ld: %s\n", info->error->code, info->error->str); + } + fprintf(stdout, "Test if object was added:\t\t\t"); + if (caldav_get_object(resp, make_time_t("2008/04/15"), + make_time_t("2008/04/16"), url, info) == OK) { + if (compare_object("UID", object, resp->msg)) + fprintf(stdout, "OK\n"); + else + fprintf(stdout, "FAIL\n"); + if (DEBUG) fprintf(stdout, "%s\n", resp->msg); + } + else { + fprintf(stdout, "FAIL\n"); + if (DEBUG) fprintf(stdout, "%ld: %s\n", info->error->code, info->error->str); + } + g_free(resp->msg); + resp->msg = NULL; + g_free(object); +/* fprintf(stdout, "Test FREEBUSY search the same day:\t\t"); + if (caldav_get_freebusy(resp, make_time_t("2008/04/15"), + make_time_t("2008/04/16"), url, info) == OK) { + if (compare_freebusy("20080415T151500Z/20080415T162500", resp->msg)) + fprintf(stdout, "OK\n"); + else + fprintf(stdout, "FAIL\n"); + if (DEBUG) fprintf(stdout, "%s\n", resp->msg); + } + else { + fprintf(stdout, "FAIL\n"); + if (DEBUG) fprintf(stdout, "%ld: %s\n", info->error->code, info->error->str); + } + g_free(resp->msg); + resp->msg = NULL;*/ + g_file_get_contents("../ics/modify.ics", &object, NULL, NULL); + fprintf(stdout, "Test caldav_modify_object:\t\t\t"); + if (caldav_modify_object(object, url, info) == OK) { + fprintf(stdout, "OK\n"); + if (DEBUG) fprintf(stdout, "Modified successfully\n"); + } + else { + fprintf(stdout, "FAIL\n"); + if (DEBUG) fprintf(stdout, "%ld: %s\n", info->error->code, info->error->str); + } + fprintf(stdout, "Test if object was modified:\t\t\t"); + if (caldav_get_object(resp, make_time_t("2008/04/16"), + make_time_t("2008/04/17"), url, info) == OK) { + if (compare_object("DTEND", object, resp->msg)) + fprintf(stdout, "OK\n"); + else + fprintf(stdout, "FAIL\n"); + if (DEBUG) fprintf(stdout, "%s\n", resp->msg); + } + else { + fprintf(stdout, "FAIL\n"); + if (DEBUG) fprintf(stdout, "%ld: %s\n", info->error->code, info->error->str); + } + g_free(resp->msg); + resp->msg = NULL; + g_free(object); + g_file_get_contents("../ics/delete.ics", &object, NULL, NULL); + fprintf(stdout, "Test caldav_delete_object:\t\t\t"); + if (caldav_delete_object(object, url, info) == OK) { + fprintf(stdout, "OK\n"); + if (DEBUG) fprintf(stdout, "Deleted successfully\n"); + } + else { + fprintf(stdout, "FAIL\n"); + if (DEBUG) fprintf(stdout, "%ld: %s\n", info->error->code, info->error->str); + } + fprintf(stdout, "Test if object was deleted:\t\t\t"); + if (caldav_get_object(resp, make_time_t("2008/04/16"), + make_time_t("2008/04/17"), url, info) == OK) { + if (compare_object("UID", object, resp->msg)) + fprintf(stdout, "FAIL\n"); + else + fprintf(stdout, "OK\n"); + if (DEBUG) fprintf(stdout, "%s\n", (resp->msg) ? resp->msg : "No object found"); + g_free(resp->msg); + resp->msg = NULL; + } + else { + fprintf(stdout, "FAIL\n"); + if (DEBUG) fprintf(stdout, "%ld: %s\n", info->error->code, info->error->str); + } + g_free(url); + caldav_free_response(&resp); + caldav_free_runtime_info(&info); +} + +int main(int argc, char** argv) { + settings* setting; + + g_set_prgname(argv[0]); + setting = parse_cmdline(argc, argv); + if (find_missing(&setting)) { + fprintf(stderr, "missing required information\n"); + fprintf(stdout, "%s", usage[0]); + settings_free(&setting); + return 1; + } + run_tests(setting); + settings_free(&setting); + return 0; +} diff --git a/test/unittest/Makefile.am b/test/unittest/Makefile.am new file mode 100644 index 0000000..6d09609 --- /dev/null +++ b/test/unittest/Makefile.am @@ -0,0 +1,22 @@ +AUTOMAKE_OPTIONS = gnu + +if BUILD_UNITTEST +INCLUDES = \ + @CURL_CFLAGS@ \ + @GLIB_CFLAGS@ \ + -I$(top_srcdir) \ + -I$(top_srcdir)/src + +bin_PROGRAMS = unittest + +unittest_SOURCES = \ + libunit.c + +unittest_LDFLAGS = \ + -L$(top_builddir)/src + +unittest_LDADD = \ + @CURL_LIBS@ \ + @GLIB_LIBS@ \ + -lcaldav +endif diff --git a/test/unittest/Makefile.in b/test/unittest/Makefile.in new file mode 100644 index 0000000..353f818 --- /dev/null +++ b/test/unittest/Makefile.in @@ -0,0 +1,564 @@ +# Makefile.in generated by automake 1.11.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, +# Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +target_triplet = @target@ +@BUILD_UNITTEST_TRUE@bin_PROGRAMS = unittest$(EXEEXT) +subdir = test/unittest +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/ax_prog_doxygen.m4 \ + $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ + $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ + $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +am__installdirs = "$(DESTDIR)$(bindir)" +PROGRAMS = $(bin_PROGRAMS) +am__unittest_SOURCES_DIST = libunit.c +@BUILD_UNITTEST_TRUE@am_unittest_OBJECTS = libunit.$(OBJEXT) +unittest_OBJECTS = $(am_unittest_OBJECTS) +unittest_DEPENDENCIES = +unittest_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(unittest_LDFLAGS) \ + $(LDFLAGS) -o $@ +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(unittest_SOURCES) +DIST_SOURCES = $(am__unittest_SOURCES_DIST) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CURL_CFLAGS = @CURL_CFLAGS@ +CURL_LIBS = @CURL_LIBS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DOXYGEN_PAPER_SIZE = @DOXYGEN_PAPER_SIZE@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +DX_CONFIG = @DX_CONFIG@ +DX_DOCDIR = @DX_DOCDIR@ +DX_DOT = @DX_DOT@ +DX_DOXYGEN = @DX_DOXYGEN@ +DX_DVIPS = @DX_DVIPS@ +DX_EGREP = @DX_EGREP@ +DX_ENV = @DX_ENV@ +DX_FLAG_chi = @DX_FLAG_chi@ +DX_FLAG_chm = @DX_FLAG_chm@ +DX_FLAG_doc = @DX_FLAG_doc@ +DX_FLAG_dot = @DX_FLAG_dot@ +DX_FLAG_html = @DX_FLAG_html@ +DX_FLAG_man = @DX_FLAG_man@ +DX_FLAG_pdf = @DX_FLAG_pdf@ +DX_FLAG_ps = @DX_FLAG_ps@ +DX_FLAG_rtf = @DX_FLAG_rtf@ +DX_FLAG_xml = @DX_FLAG_xml@ +DX_HHC = @DX_HHC@ +DX_LATEX = @DX_LATEX@ +DX_MAKEINDEX = @DX_MAKEINDEX@ +DX_PDFLATEX = @DX_PDFLATEX@ +DX_PERL = @DX_PERL@ +DX_PROJECT = @DX_PROJECT@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GLIB_CFLAGS = @GLIB_CFLAGS@ +GLIB_LIBS = @GLIB_LIBS@ +GREP = @GREP@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIBVERSION = @LIBVERSION@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MKDIR_P = @MKDIR_P@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PKG_CONFIG = @PKG_CONFIG@ +PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ +PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +lt_ECHO = @lt_ECHO@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +AUTOMAKE_OPTIONS = gnu +@BUILD_UNITTEST_TRUE@INCLUDES = \ +@BUILD_UNITTEST_TRUE@ @CURL_CFLAGS@ \ +@BUILD_UNITTEST_TRUE@ @GLIB_CFLAGS@ \ +@BUILD_UNITTEST_TRUE@ -I$(top_srcdir) \ +@BUILD_UNITTEST_TRUE@ -I$(top_srcdir)/src + +@BUILD_UNITTEST_TRUE@unittest_SOURCES = \ +@BUILD_UNITTEST_TRUE@ libunit.c + +@BUILD_UNITTEST_TRUE@unittest_LDFLAGS = \ +@BUILD_UNITTEST_TRUE@ -L$(top_builddir)/src + +@BUILD_UNITTEST_TRUE@unittest_LDADD = \ +@BUILD_UNITTEST_TRUE@ @CURL_LIBS@ \ +@BUILD_UNITTEST_TRUE@ @GLIB_LIBS@ \ +@BUILD_UNITTEST_TRUE@ -lcaldav + +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu test/unittest/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu test/unittest/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" + @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ + for p in $$list; do echo "$$p $$p"; done | \ + sed 's/$(EXEEXT)$$//' | \ + while read p p1; do if test -f $$p || test -f $$p1; \ + then echo "$$p"; echo "$$p"; else :; fi; \ + done | \ + sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \ + -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ + sed 'N;N;N;s,\n, ,g' | \ + $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ + { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ + if ($$2 == $$4) files[d] = files[d] " " $$1; \ + else { print "f", $$3 "/" $$4, $$1; } } \ + END { for (d in files) print "f", d, files[d] }' | \ + while read type dir files; do \ + if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ + test -z "$$files" || { \ + echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \ + $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \ + } \ + ; done + +uninstall-binPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ + files=`for p in $$list; do echo "$$p"; done | \ + sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ + -e 's/$$/$(EXEEXT)/' `; \ + test -n "$$list" || exit 0; \ + echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \ + cd "$(DESTDIR)$(bindir)" && rm -f $$files + +clean-binPROGRAMS: + @list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \ + echo " rm -f" $$list; \ + rm -f $$list || exit $$?; \ + test -n "$(EXEEXT)" || exit 0; \ + list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f" $$list; \ + rm -f $$list +unittest$(EXEEXT): $(unittest_OBJECTS) $(unittest_DEPENDENCIES) + @rm -f unittest$(EXEEXT) + $(unittest_LINK) $(unittest_OBJECTS) $(unittest_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libunit.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@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@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@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@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@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 + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + set x; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(PROGRAMS) +installdirs: + for dir in "$(DESTDIR)$(bindir)"; 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) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: install-binPROGRAMS + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-binPROGRAMS + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \ + clean-generic clean-libtool ctags distclean distclean-compile \ + distclean-generic distclean-libtool distclean-tags distdir dvi \ + dvi-am html html-am info info-am install install-am \ + install-binPROGRAMS install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ + pdf pdf-am ps ps-am tags uninstall uninstall-am \ + uninstall-binPROGRAMS + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/test/unittest/libunit.c b/test/unittest/libunit.c new file mode 100644 index 0000000..b0be673 --- /dev/null +++ b/test/unittest/libunit.c @@ -0,0 +1,615 @@ +/* vim: set textwidth=80 tabstop=4: */ + +/* +// libunit.c +// +// Copyright 2010 Michael Rasmussen <mir@datanom.net> +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +// MA 02110-1301, USA. +*/ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include "caldav.h" +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <glib.h> +#include <string.h> +#include <sys/time.h> +#include <string.h> + +static const char* usage[] = { +"unittest is part of libcaldav for claws-mails " +"vcalendar plugin.\nCopyright (C) Michael Rasmussen, 2008.\n" +"This program is free software; you can redistribute it and/or modify\n" +"it under the terms of the GNU General Public License as published by\n" +"the Free Software Foundation; either version 3 of the License, or\n" +"(at your option) any later version.\n" +"\nusage:\n\tunittest [Options]\n" +"\n\tOptions:\n" +"\t\t-h|-?\tusage\n" +"\t\t-a\tURL\n" +"\t\t-d\tEnable debug\n" +"\t\t-l\tDebug library\n" +"\t\t-p\tpassword\n" +"\t\t-u\tusername\n" +}; + +/* + * Options can be given in one of three ways: + * 1) Entered as options on the command line + * 2) Stored in environment variables: + * - LIBCALDAV_UID -> username to use when connection to server + * - LIBCALDAV_PWD -> password, if any, to use when connection to server + * - LIBCALDAV_URL -> complete URL to server. prefixed with either + * http:// or https:// + * 3) Stored in a file found in the same directory as the program: + * [server] + * password=Big secret + * username=username + * url=http[s]://bar.tld/foo + */ + +#define CONFFILE "caldav-unit-settings.conf" + +typedef struct { + gchar* uid; + gchar* pwd; + gchar* url; +} settings; + +typedef enum { + PWD, + UID, + URL +} CONFIG; + +static settings* SETTING = NULL; +gboolean DEBUG = FALSE; +gboolean DEBUG_LIB = FALSE; + +void settings_free(settings** setting) { + settings* s; + + if (! *setting) + return; + s = *setting; + g_free(s->url); + g_free(s->uid); + g_free(s->pwd); + g_free(s); + *setting = s = NULL; +} + +settings* parse_cmdline(int argc, char** argv) { + char c; + settings* setting; + + setting = g_new0(settings, 1); + while ((c = getopt(argc, argv, "ha:dlp:u:?")) != -1) { + switch (c) { + case 'h': + case '?': + fprintf(stdout, "%s", usage[0]); + return 0; + case 'a': + setting->url = g_strdup(optarg); + break; + case 'd': + DEBUG = TRUE; + break; + case 'l': + DEBUG_LIB = TRUE; + break; + case 'p': + setting->pwd = g_strdup(optarg); + break; + case 'u': + setting->uid = g_strdup(optarg); + break; + } + } + if (argv[optind]) { + fprintf(stderr, "No arguments after options expected\n"); + fprintf(stderr, "%s", usage[0]); + settings_free(&setting); + return NULL; + } + + return setting; +} + +void read_file(const gchar* file) { + GKeyFile* keyfile; + + if (! SETTING) { + SETTING = g_new0(settings, 1); + keyfile = g_key_file_new(); + if (g_key_file_load_from_file(keyfile, + file, + G_KEY_FILE_KEEP_COMMENTS, + NULL)) { + SETTING->pwd = g_key_file_get_string(keyfile, + "server", + "password", + NULL); + SETTING->uid = g_key_file_get_string(keyfile, + "server", + "username", + NULL); + SETTING->url = g_key_file_get_string(keyfile, + "server", + "url", + NULL); + } + g_key_file_free(keyfile); + } +} + +const gchar* get_setting_from_file(CONFIG config) { + gchar* cwd; + gchar* path; + gchar* pos; + gchar* setting = NULL; + int step; + + gchar* filename = g_get_prgname(); + if (filename[0] == '/') { + /* absolute path */ + cwd = g_path_get_dirname(filename); + } + else if ((pos = strchr(filename, '/')) != NULL) { + /* relative path */ + if (filename[0] == '.') { + char* tmp = pos; + while (tmp) { + if (strncmp(tmp, "..", 2) == 0) + step = 2; + else + step = 1; + tmp = strchr(pos + step, '/'); + if (tmp) + pos = tmp; + } + if (pos == NULL) { + pos = strchr(filename, '/'); + } + } + path = g_get_current_dir(); + cwd = g_build_filename(path, pos + 1, NULL); + g_free(path); + if (g_file_test(cwd, G_FILE_TEST_IS_REGULAR)) { + pos = strrchr(cwd, '/'); + if (pos) { + path = g_strndup(cwd, pos - cwd); + g_free(cwd); + cwd = g_strdup(path); + g_free(path); + } + } + } + else { + /* find cwd in PATH */ + cwd = g_find_program_in_path(filename); + } + path = g_build_filename(cwd, CONFFILE, NULL); + g_free(cwd); + if (g_file_test(path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) { + read_file(path); + switch (config) { + case UID: setting = SETTING->uid; break; + case PWD: setting = SETTING->pwd; break; + case URL: setting = SETTING->url; break; + } + } + g_free(path); + return setting; +} + +gboolean find_missing(settings** setting) { + settings* s = *setting; + const char* env; + gboolean error = FALSE; + + if (! s) + return TRUE; + + if (! s->uid) { + if ((env = getenv("LIBCALDAV_UID")) == NULL) { + env = get_setting_from_file(UID); + if (env == NULL) + error = TRUE; + } + s->uid = g_strdup(env); + } + if (! s->pwd) { + if ((env = getenv("LIBCALDAV_PWD")) == NULL) { + env = get_setting_from_file(PWD); + if (env == NULL) + error = TRUE; + } + s->pwd = g_strdup(env); + } + if (! s->url) { + if ((env = getenv("LIBCALDAV_URL")) == NULL) { + env = get_setting_from_file(URL); + if (env == NULL) + error = TRUE; + } + s->url = g_strdup(env); + } + settings_free(&SETTING); + return error; +} + +time_t make_time_t(const char* time_elem) { + struct tm datetime = {0,0,0,0,0,0,0,0,0,0,NULL}; + struct tm* tmp; + gchar** elem; + time_t t; + + t = time(NULL); + tmp = localtime(&t); + elem = g_strsplit(time_elem, "/", 3); + datetime.tm_year = atoi(elem[0]) - 1900; + datetime.tm_mon = atoi(elem[1]) - 1; + datetime.tm_mday = atoi(elem[2]); + g_strfreev(elem); + t = mktime(&datetime); + return t; +} + +gboolean compare_freebusy(const gchar* s1, const gchar* s2) { + const char* TOKEN = "FREEBUSY:"; + gchar* pos1; + gchar* pos2; + gchar* id1; + + if (! s1 && ! s2) + return TRUE; + if (! s1 || ! s2) + return FALSE; + pos1 = strstr(s2, TOKEN); + if (! pos1) + return FALSE; + pos1 += strlen(TOKEN); + pos2 = strchr(pos1, '\n'); + if (! pos2) + return FALSE; + if (*(pos2 - 1) == '\r') + pos2--; + id1 = g_strndup(pos1, pos2 - pos1); + int res = strcmp(s1, id1); + g_free(id1); + return (res == 0); +} + +gboolean compare_object(const gchar* TOKEN, const gchar* s1, const gchar* s2) { + gchar* pos1; + gchar* pos2; + gchar* id1; + gchar* id2; + + if (! s1 && ! s2) + return TRUE; + if (! s1 || ! s2) + return FALSE; + pos1 = strstr(s1, TOKEN); + if (! pos1) + return FALSE; + pos1 += strlen(TOKEN) + 1; + pos2 = strchr(pos1, '\n'); + if (! pos2) + return FALSE; + if (*(pos2 - 1) == '\r') + pos2--; + id1 = g_strndup(pos1, pos2 - pos1); + pos2 = strstr(s2, TOKEN); + if (! pos2) { + g_free(id1); + return FALSE; + } + pos2 += strlen(TOKEN) + 1; + pos1 = strchr(pos2, '\n'); + if (! pos1) { + g_free(id1); + return FALSE; + } + if (*(pos1 - 1) == '\r') + pos1--; + id2 = g_strndup(pos2, pos1 - pos2); + int res = strcmp(id1, id2); + g_free(id1); + g_free(id2); + return (res == 0); +} + +void run_tests(settings* s) { + runtime_info* info = caldav_get_runtime_info(); + response* resp = caldav_get_response(); + gchar** parts; + gchar* url; + gchar* object; + + if (DEBUG_LIB) { + info->options->debug = 1; + info->options->trace_ascii = 1; + } + parts = g_strsplit(s->url, "//", 2); + url = g_strconcat( + parts[0], "//", s->uid, ":", s->pwd, "@", parts[1], NULL); + g_strfreev(parts); + fprintf(stdout, "Test caldav_enabled_resource:\t\t\t"); + if (caldav_enabled_resource(url, info)) { + fprintf(stdout, "OK\n"); + if (DEBUG) fprintf(stdout, "caldav enabled server\n"); + } + else { + fprintf(stdout, "FAIL\n"); + if (DEBUG) fprintf(stdout, "%ld: %s\n", info->error->code, info->error->str); + } + fprintf(stdout, "Test caldav_get_displayname:\t\t\t"); + if (caldav_get_displayname(resp, url, info) == OK) { + fprintf(stdout, "OK\n"); + if (DEBUG) fprintf(stdout, "Display Name: %s\n", resp->msg); + } + else { + fprintf(stdout, "FAIL\n"); + if (DEBUG) fprintf(stdout, "%ld: %s\n", info->error->code, info->error->str); + } + g_free(resp->msg); + resp->msg = NULL; + fprintf(stdout, "Test caldav_get_server_options:\t\t\t"); + if ((parts = caldav_get_server_options(url, info)) != NULL) { + fprintf(stdout, "OK\n"); + if (DEBUG) { + char** tmp = parts; + while (*tmp) { + fprintf(stdout, "--> %s\n", *tmp++); + } + } + g_strfreev(parts); + } + else { + fprintf(stdout, "FAIL\n"); + if (DEBUG) fprintf(stdout, "%ld: %s\n", info->error->code, info->error->str); + } + g_file_get_contents("../ics/add.ics", &object, NULL, NULL); + fprintf(stdout, "Test caldav_add_object:\t\t\t\t"); + if (caldav_add_object(object, url, info) == OK) { + fprintf(stdout, "OK\n"); + if (DEBUG) fprintf(stdout, "Added successfully\n"); + } + else { + fprintf(stdout, "FAIL\n"); + if (DEBUG) fprintf(stdout, "%ld: %s\n", info->error->code, info->error->str); + } + fprintf(stdout, "Test if object was added:\t\t\t"); + if (caldav_get_object(resp, make_time_t("2008/04/15"), + make_time_t("2008/04/16"), url, info) == OK) { + if (compare_object("UID", object, resp->msg)) + fprintf(stdout, "OK\n"); + else + fprintf(stdout, "FAIL\n"); + if (DEBUG) fprintf(stdout, "%s\n", resp->msg); + } + else { + fprintf(stdout, "FAIL\n"); + if (DEBUG) fprintf(stdout, "%ld: %s\n", info->error->code, info->error->str); + } + g_free(resp->msg); + resp->msg = NULL; + g_free(object); + fprintf(stdout, "Test FREEBUSY search the same day:\t\t"); + if (caldav_get_freebusy(resp, make_time_t("2008/04/15"), + make_time_t("2008/04/16"), url, info) == OK) { + if (compare_freebusy("20080415T151500Z/20080415T162500", resp->msg)) + fprintf(stdout, "OK\n"); + else + fprintf(stdout, "FAIL\n"); + if (DEBUG) fprintf(stdout, "%s\n", resp->msg); + } + else { + fprintf(stdout, "FAIL\n"); + if (DEBUG) fprintf(stdout, "%ld: %s\n", info->error->code, info->error->str); + } + g_free(resp->msg); + resp->msg = NULL; + g_file_get_contents("../ics/modify.ics", &object, NULL, NULL); + fprintf(stdout, "Test caldav_modify_object:\t\t\t"); + if (caldav_modify_object(object, url, info) == OK) { + fprintf(stdout, "OK\n"); + if (DEBUG) fprintf(stdout, "Modified successfully\n"); + } + else { + fprintf(stdout, "FAIL\n"); + if (DEBUG) fprintf(stdout, "%ld: %s\n", info->error->code, info->error->str); + } + fprintf(stdout, "Test if object was modified:\t\t\t"); + if (caldav_get_object(resp, make_time_t("2008/04/16"), + make_time_t("2008/04/17"), url, info) == OK) { + if (compare_object("DTEND", object, resp->msg)) + fprintf(stdout, "OK\n"); + else + fprintf(stdout, "FAIL\n"); + if (DEBUG) fprintf(stdout, "%s\n", resp->msg); + } + else { + fprintf(stdout, "FAIL\n"); + if (DEBUG) fprintf(stdout, "%ld: %s\n", info->error->code, info->error->str); + } + g_free(resp->msg); + resp->msg = NULL; + fprintf(stdout, "Test caldav_getall_object:\t\t\t"); + if (caldav_getall_object(resp, url, info) == OK) { + fprintf(stdout, "OK\n"); + if (DEBUG) fprintf(stdout, "%s\n", resp->msg); + } + else { + fprintf(stdout, "FAIL\n"); + if (DEBUG) fprintf(stdout, "%ld: %s\n", info->error->code, info->error->str); + } + fprintf(stdout, "Test if object exists:\t\t\t\t"); + if (compare_object("UID", object, resp->msg)) + fprintf(stdout, "FAIL\n"); + else + fprintf(stdout, "OK\n"); + g_free(resp->msg); + resp->msg = NULL; + g_free(object); + g_file_get_contents("../ics/delete.ics", &object, NULL, NULL); + fprintf(stdout, "Test caldav_delete_object:\t\t\t"); + if (caldav_delete_object(object, url, info) == OK) { + fprintf(stdout, "OK\n"); + if (DEBUG) fprintf(stdout, "Deleted successfully\n"); + } + else { + fprintf(stdout, "FAIL\n"); + if (DEBUG) fprintf(stdout, "%ld: %s\n", info->error->code, info->error->str); + } + fprintf(stdout, "Test if object was deleted:\t\t\t"); + if (caldav_get_object(resp, make_time_t("2008/04/16"), + make_time_t("2008/04/17"), url, info) == OK) { + if (compare_object("UID", object, resp->msg)) + fprintf(stdout, "FAIL\n"); + else + fprintf(stdout, "OK\n"); + if (DEBUG) fprintf(stdout, "%s\n", (resp->msg) ? resp->msg : "No object found"); + g_free(resp->msg); + resp->msg = NULL; + } + else { + fprintf(stdout, "FAIL\n"); + if (DEBUG) fprintf(stdout, "%ld: %s\n", info->error->code, info->error->str); + } + g_free(object); + fprintf(stdout, "\nTesting without using locks\n"); + info->options->use_locking = 0; + g_file_get_contents("../ics/add.ics", &object, NULL, NULL); + fprintf(stdout, "Test caldav_add_object:\t\t\t\t"); + if (caldav_add_object(object, url, info) == OK) { + fprintf(stdout, "OK\n"); + if (DEBUG) fprintf(stdout, "Added successfully\n"); + } + else { + fprintf(stdout, "FAIL\n"); + if (DEBUG) fprintf(stdout, "%ld: %s\n", info->error->code, info->error->str); + } + fprintf(stdout, "Test if object was added:\t\t\t"); + if (caldav_get_object(resp, make_time_t("2008/04/15"), + make_time_t("2008/04/16"), url, info) == OK) { + if (compare_object("UID", object, resp->msg)) + fprintf(stdout, "OK\n"); + else + fprintf(stdout, "FAIL\n"); + if (DEBUG) fprintf(stdout, "%s\n", resp->msg); + } + else { + fprintf(stdout, "FAIL\n"); + if (DEBUG) fprintf(stdout, "%ld: %s\n", info->error->code, info->error->str); + } + g_free(resp->msg); + resp->msg = NULL; + g_free(object); +/* fprintf(stdout, "Test FREEBUSY search the same day:\t\t"); + if (caldav_get_freebusy(resp, make_time_t("2008/04/15"), + make_time_t("2008/04/16"), url, info) == OK) { + if (compare_freebusy("20080415T151500Z/20080415T162500", resp->msg)) + fprintf(stdout, "OK\n"); + else + fprintf(stdout, "FAIL\n"); + if (DEBUG) fprintf(stdout, "%s\n", resp->msg); + } + else { + fprintf(stdout, "FAIL\n"); + if (DEBUG) fprintf(stdout, "%ld: %s\n", info->error->code, info->error->str); + } + g_free(resp->msg); + resp->msg = NULL;*/ + g_file_get_contents("../ics/modify.ics", &object, NULL, NULL); + fprintf(stdout, "Test caldav_modify_object:\t\t\t"); + if (caldav_modify_object(object, url, info) == OK) { + fprintf(stdout, "OK\n"); + if (DEBUG) fprintf(stdout, "Modified successfully\n"); + } + else { + fprintf(stdout, "FAIL\n"); + if (DEBUG) fprintf(stdout, "%ld: %s\n", info->error->code, info->error->str); + } + fprintf(stdout, "Test if object was modified:\t\t\t"); + if (caldav_get_object(resp, make_time_t("2008/04/16"), + make_time_t("2008/04/17"), url, info) == OK) { + if (compare_object("DTEND", object, resp->msg)) + fprintf(stdout, "OK\n"); + else + fprintf(stdout, "FAIL\n"); + if (DEBUG) fprintf(stdout, "%s\n", resp->msg); + } + else { + fprintf(stdout, "FAIL\n"); + if (DEBUG) fprintf(stdout, "%ld: %s\n", info->error->code, info->error->str); + } + g_free(resp->msg); + resp->msg = NULL; + g_free(object); + g_file_get_contents("../ics/delete.ics", &object, NULL, NULL); + fprintf(stdout, "Test caldav_delete_object:\t\t\t"); + if (caldav_delete_object(object, url, info) == OK) { + fprintf(stdout, "OK\n"); + if (DEBUG) fprintf(stdout, "Deleted successfully\n"); + } + else { + fprintf(stdout, "FAIL\n"); + if (DEBUG) fprintf(stdout, "%ld: %s\n", info->error->code, info->error->str); + } + fprintf(stdout, "Test if object was deleted:\t\t\t"); + if (caldav_get_object(resp, make_time_t("2008/04/16"), + make_time_t("2008/04/17"), url, info) == OK) { + if (compare_object("UID", object, resp->msg)) + fprintf(stdout, "FAIL\n"); + else + fprintf(stdout, "OK\n"); + if (DEBUG) fprintf(stdout, "%s\n", (resp->msg) ? resp->msg : "No object found"); + g_free(resp->msg); + resp->msg = NULL; + } + else { + fprintf(stdout, "FAIL\n"); + if (DEBUG) fprintf(stdout, "%ld: %s\n", info->error->code, info->error->str); + } + g_free(url); + caldav_free_response(&resp); + caldav_free_runtime_info(&info); +} + +int main(int argc, char** argv) { + settings* setting; + + g_set_prgname(argv[0]); + setting = parse_cmdline(argc, argv); + if (find_missing(&setting)) { + fprintf(stderr, "missing required information\n"); + fprintf(stdout, "%s", usage[0]); + settings_free(&setting); + return 1; + } + run_tests(setting); + settings_free(&setting); + return 0; +} |