diff --git a/Makefile.in b/Makefile.in
index 99f0c6dad5b3b9b8b541cf24e8958ae4a12f306e..5cb5b6a214265c5d6c8bb66c29c24d6017c6ae68 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -226,6 +226,9 @@ CFLAGS = @CFLAGS@
 CHECK_INCLUDE = @CHECK_INCLUDE@
 CHECK_LIBS = @CHECK_LIBS@
 CHECK_ROOT = @CHECK_ROOT@
+CMOCKA_INCLUDE = @CMOCKA_INCLUDE@
+CMOCKA_LIBS = @CMOCKA_LIBS@
+CMOCKA_ROOT = @CMOCKA_ROOT@
 CPP = @CPP@
 CPPFLAGS = @CPPFLAGS@
 CYGPATH_W = @CYGPATH_W@
diff --git a/check/Makefile.am b/check/Makefile.am
index d58e48ad1b99a32bb34693784ff12867f021bbf3..94107d3002fcc95a181e3f7516b3b0ce5d561a90 100644
--- a/check/Makefile.am
+++ b/check/Makefile.am
@@ -1,5 +1,6 @@
-noinst_LTLIBRARIES = 
+noinst_LTLIBRARIES =
 noinst_PROGRAMS =
+CHECKS =
 
 if ENABLE_CHECK
 noinst_LTLIBRARIES += libmtime_check.la
@@ -25,15 +26,22 @@ test_runner_SOURCES = test_runner.c
 test_runner_CPPFLAGS = -I$(top_srcdir)/include $(CHECK_INCLUDE)
 test_runner_LDADD    = libmtime_check.la $(top_builddir)/src/libmtime.la $(CHECK_LIBS)
 
+CHECKS += test_runner
+endif
+
+if ENABLE_CMOCKA
 noinst_PROGRAMS   += test_timedelta
 test_timedelta_SOURCES = test_timedelta.c
-test_timedelta_CPPFLAGS = -I$(top_srcdir)/include
+test_timedelta_CPPFLAGS = -I$(top_srcdir)/include $(CMOCKA_INCLUDE)
 test_timedelta_LDADD = ../src/libmtime.la
-test_timedelta_LDFLAGS= -L/usr/lib -lcmocka
+test_timedelta_LDFLAGS= $(CMOCKA_LIBS) -lcmocka
+
+CHECKS += test_timedelta
 endif
 
 ac-local: check
 .PHONY :check
-check: test_runner test_timedelta
-	./test_timedelta
-	./test_runner
+check: $(CHECKS)
+	for test in $(CHECKS); do \
+	  ./$$test; \
+	done
diff --git a/check/Makefile.in b/check/Makefile.in
index ec7b8a3da3ccb51e94bfd19350ddf0b5c5d3462c..8e2749cf027cd964707401984bfc80e729548b65 100644
--- a/check/Makefile.in
+++ b/check/Makefile.in
@@ -89,9 +89,12 @@ PRE_UNINSTALL = :
 POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
-noinst_PROGRAMS = $(am__EXEEXT_1)
+noinst_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2)
 @ENABLE_CHECK_TRUE@am__append_1 = libmtime_check.la
-@ENABLE_CHECK_TRUE@am__append_2 = test_runner test_timedelta
+@ENABLE_CHECK_TRUE@am__append_2 = test_runner
+@ENABLE_CHECK_TRUE@am__append_3 = test_runner
+@ENABLE_CMOCKA_TRUE@am__append_4 = test_timedelta
+@ENABLE_CMOCKA_TRUE@am__append_5 = test_timedelta
 subdir = check
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_prog_doxygen.m4 \
@@ -127,8 +130,8 @@ am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
 am__v_lt_0 = --silent
 am__v_lt_1 = 
 @ENABLE_CHECK_TRUE@am_libmtime_check_la_rpath =
-@ENABLE_CHECK_TRUE@am__EXEEXT_1 = test_runner$(EXEEXT) \
-@ENABLE_CHECK_TRUE@	test_timedelta$(EXEEXT)
+@ENABLE_CHECK_TRUE@am__EXEEXT_1 = test_runner$(EXEEXT)
+@ENABLE_CMOCKA_TRUE@am__EXEEXT_2 = test_timedelta$(EXEEXT)
 PROGRAMS = $(noinst_PROGRAMS)
 am__test_runner_SOURCES_DIST = test_runner.c
 @ENABLE_CHECK_TRUE@am_test_runner_OBJECTS =  \
@@ -139,10 +142,10 @@ am__DEPENDENCIES_1 =
 @ENABLE_CHECK_TRUE@	$(top_builddir)/src/libmtime.la \
 @ENABLE_CHECK_TRUE@	$(am__DEPENDENCIES_1)
 am__test_timedelta_SOURCES_DIST = test_timedelta.c
-@ENABLE_CHECK_TRUE@am_test_timedelta_OBJECTS =  \
-@ENABLE_CHECK_TRUE@	test_timedelta-test_timedelta.$(OBJEXT)
+@ENABLE_CMOCKA_TRUE@am_test_timedelta_OBJECTS =  \
+@ENABLE_CMOCKA_TRUE@	test_timedelta-test_timedelta.$(OBJEXT)
 test_timedelta_OBJECTS = $(am_test_timedelta_OBJECTS)
-@ENABLE_CHECK_TRUE@test_timedelta_DEPENDENCIES = ../src/libmtime.la
+@ENABLE_CMOCKA_TRUE@test_timedelta_DEPENDENCIES = ../src/libmtime.la
 test_timedelta_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \
 	$(AM_CFLAGS) $(CFLAGS) $(test_timedelta_LDFLAGS) $(LDFLAGS) -o \
@@ -226,6 +229,9 @@ CFLAGS = @CFLAGS@
 CHECK_INCLUDE = @CHECK_INCLUDE@
 CHECK_LIBS = @CHECK_LIBS@
 CHECK_ROOT = @CHECK_ROOT@
+CMOCKA_INCLUDE = @CMOCKA_INCLUDE@
+CMOCKA_LIBS = @CMOCKA_LIBS@
+CMOCKA_ROOT = @CMOCKA_ROOT@
 CPP = @CPP@
 CPPFLAGS = @CPPFLAGS@
 CYGPATH_W = @CYGPATH_W@
@@ -366,6 +372,7 @@ top_build_prefix = @top_build_prefix@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 noinst_LTLIBRARIES = $(am__append_1)
+CHECKS = $(am__append_3) $(am__append_5)
 @ENABLE_CHECK_TRUE@libmtime_check_la_SOURCES = mtime_calendar_test.c  \
 @ENABLE_CHECK_TRUE@			 mtime_calendar_test.h  \
 @ENABLE_CHECK_TRUE@			 mtime_date_test.c  \
@@ -383,10 +390,10 @@ noinst_LTLIBRARIES = $(am__append_1)
 @ENABLE_CHECK_TRUE@test_runner_SOURCES = test_runner.c
 @ENABLE_CHECK_TRUE@test_runner_CPPFLAGS = -I$(top_srcdir)/include $(CHECK_INCLUDE)
 @ENABLE_CHECK_TRUE@test_runner_LDADD = libmtime_check.la $(top_builddir)/src/libmtime.la $(CHECK_LIBS)
-@ENABLE_CHECK_TRUE@test_timedelta_SOURCES = test_timedelta.c
-@ENABLE_CHECK_TRUE@test_timedelta_CPPFLAGS = -I$(top_srcdir)/include
-@ENABLE_CHECK_TRUE@test_timedelta_LDADD = ../src/libmtime.la
-@ENABLE_CHECK_TRUE@test_timedelta_LDFLAGS = -L/usr/lib -lcmocka
+@ENABLE_CMOCKA_TRUE@test_timedelta_SOURCES = test_timedelta.c
+@ENABLE_CMOCKA_TRUE@test_timedelta_CPPFLAGS = -I$(top_srcdir)/include $(CMOCKA_INCLUDE)
+@ENABLE_CMOCKA_TRUE@test_timedelta_LDADD = ../src/libmtime.la
+@ENABLE_CMOCKA_TRUE@test_timedelta_LDFLAGS = $(CMOCKA_LIBS) -lcmocka
 all: all-am
 
 .SUFFIXES:
@@ -772,9 +779,10 @@ uninstall-am:
 
 ac-local: check
 .PHONY :check
-check: test_runner test_timedelta
-	./test_timedelta
-	./test_runner
+check: $(CHECKS)
+	for test in $(CHECKS); do \
+	  ./$$test; \
+	done
 
 # 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.
diff --git a/config/config.h.in b/config/config.h.in
index 5a7733a6af808af3e6c949d14b8298ca3dd8a2fc..965f913d58418907264313a2f87de5f6cbe86c95 100644
--- a/config/config.h.in
+++ b/config/config.h.in
@@ -3,6 +3,9 @@
 /* Define to 1 if you have the <check.h> header file. */
 #undef HAVE_CHECK_H
 
+/* Define to 1 if you have the <cmocka.h> header file. */
+#undef HAVE_CMOCKA_H
+
 /* Define to 1 if you have the <dlfcn.h> header file. */
 #undef HAVE_DLFCN_H
 
diff --git a/configure b/configure
index 17a482cae1489bdb05ebb2379fb16a5c92f007e8..25318caf5e859a618bdc5cbf2c8ae26c182a0d49 100755
--- a/configure
+++ b/configure
@@ -681,6 +681,11 @@ DX_ENV
 DX_DOCDIR
 DX_CONFIG
 DX_PROJECT
+CMOCKA_LIBS
+CMOCKA_INCLUDE
+CMOCKA_ROOT
+ENABLE_CMOCKA_FALSE
+ENABLE_CMOCKA_TRUE
 CHECK_LIBS
 CHECK_INCLUDE
 CHECK_ROOT
@@ -830,6 +835,7 @@ enable_libtool_lock
 enable_dependency_tracking
 enable_silent_rules
 with_check
+with_cmocka
 enable_doxygen_doc
 enable_doxygen_dot
 enable_doxygen_man
@@ -1513,6 +1519,8 @@ Optional Packages:
                           compiler's sysroot if not specified).
   --with-check=<yes|no|directory> (default=no)
                           location of CHECK library
+  --with-cmocka=<yes|no|directory> (default=no)
+                          location of CMOCKA library
 
 Some influential environment variables:
   CC          C compiler command
@@ -16525,6 +16533,199 @@ fi
 
 
 
+# search for libcmocka
+CMOCKA_ROOT=''
+CMOCKA_INCLUDE=''
+CMOCKA_LIBS=''
+
+# Check whether --with-cmocka was given.
+if test "${with_cmocka+set}" = set; then :
+  withval=$with_cmocka; case "$with_cmocka" in #(
+  no) :
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for cmocka library" >&5
+$as_echo_n "checking for cmocka library... " >&6; }
+                           { $as_echo "$as_me:${as_lineno-$LINENO}: result: suppressed" >&5
+$as_echo "suppressed" >&6; } ;; #(
+  yes) :
+    for ac_header in cmocka.h
+do :
+  ac_fn_c_check_header_compile "$LINENO" "cmocka.h" "ac_cv_header_cmocka_h" "#include <stdarg.h>
+ #include <stddef.h>
+ #include <setjmp.h>
+
+"
+if test "x$ac_cv_header_cmocka_h" = xyes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_CMOCKA_H 1
+_ACEOF
+
+fi
+
+done
+
+                            { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing assert_true" >&5
+$as_echo_n "checking for library containing assert_true... " >&6; }
+if ${ac_cv_search_assert_true+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_func_search_save_LIBS=$LIBS
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char assert_true ();
+int
+main ()
+{
+return assert_true ();
+  ;
+  return 0;
+}
+_ACEOF
+for ac_lib in '' cmocka; do
+  if test -z "$ac_lib"; then
+    ac_res="none required"
+  else
+    ac_res=-l$ac_lib
+    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
+  fi
+  if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_search_assert_true=$ac_res
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext
+  if ${ac_cv_search_assert_true+:} false; then :
+  break
+fi
+done
+if ${ac_cv_search_assert_true+:} false; then :
+
+else
+  ac_cv_search_assert_true=no
+fi
+rm conftest.$ac_ext
+LIBS=$ac_func_search_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_assert_true" >&5
+$as_echo "$ac_cv_search_assert_true" >&6; }
+ac_res=$ac_cv_search_assert_true
+if test "$ac_res" != no; then :
+  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
+
+else
+  as_fn_error $? "Cannot link to cmocka library!" "$LINENO" 5
+fi
+
+                            CMOCKA_LIBS=" -lcmocka" ;; #(
+  *) :
+    if test -d "$with_cmocka"; then :
+  CMOCKA_ROOT="$with_cmocka"
+                                 LDFLAGS="-L$CMOCKA_ROOT/lib $LDFLAGS"
+                                 CPPFLAGS="-I$CMOCKA_ROOT/include $CPPFLAGS"
+                                 for ac_header in cmocka.h
+do :
+  ac_fn_c_check_header_compile "$LINENO" "cmocka.h" "ac_cv_header_cmocka_h" "#include <stdarg.h>
+#include <stddef.h>
+#include <setjmp.h>
+
+"
+if test "x$ac_cv_header_cmocka_h" = xyes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_CMOCKA_H 1
+_ACEOF
+
+fi
+
+done
+
+                                 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing assert_true" >&5
+$as_echo_n "checking for library containing assert_true... " >&6; }
+if ${ac_cv_search_assert_true+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_func_search_save_LIBS=$LIBS
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char assert_true ();
+int
+main ()
+{
+return assert_true ();
+  ;
+  return 0;
+}
+_ACEOF
+for ac_lib in '' cmocka; do
+  if test -z "$ac_lib"; then
+    ac_res="none required"
+  else
+    ac_res=-l$ac_lib
+    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
+  fi
+  if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_search_assert_true=$ac_res
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext
+  if ${ac_cv_search_assert_true+:} false; then :
+  break
+fi
+done
+if ${ac_cv_search_assert_true+:} false; then :
+
+else
+  ac_cv_search_assert_true=no
+fi
+rm conftest.$ac_ext
+LIBS=$ac_func_search_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_assert_true" >&5
+$as_echo "$ac_cv_search_assert_true" >&6; }
+ac_res=$ac_cv_search_assert_true
+if test "$ac_res" != no; then :
+  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
+
+fi
+
+                                 CMOCKA_LIBS=" -L$CMOCKA_ROOT/lib -lcmocka"
+                                 CMOCKA_INCLUDE=" -I$CMOCKA_ROOT/include"
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: $with_cmocka is not a directory! CMOCKA suppressed" >&5
+$as_echo "$as_me: $with_cmocka is not a directory! CMOCKA suppressed" >&6;}
+fi ;; #(
+  *) :
+     ;;
+esac
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for cmocka library" >&5
+$as_echo_n "checking for cmocka library... " >&6; }
+             { $as_echo "$as_me:${as_lineno-$LINENO}: result: suppressed" >&5
+$as_echo "suppressed" >&6; }
+fi
+
+ if test -n "$CMOCKA_LIBS"; then
+  ENABLE_CMOCKA_TRUE=
+  ENABLE_CMOCKA_FALSE='#'
+else
+  ENABLE_CMOCKA_TRUE='#'
+  ENABLE_CMOCKA_FALSE=
+fi
+
+
+
+
 
 # Doxygen documentation support
 
@@ -18513,6 +18714,10 @@ if test -z "${ENABLE_CHECK_TRUE}" && test -z "${ENABLE_CHECK_FALSE}"; then
   as_fn_error $? "conditional \"ENABLE_CHECK\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
 fi
+if test -z "${ENABLE_CMOCKA_TRUE}" && test -z "${ENABLE_CMOCKA_FALSE}"; then
+  as_fn_error $? "conditional \"ENABLE_CMOCKA\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
 if test -z "${DX_COND_doc_TRUE}" && test -z "${DX_COND_doc_FALSE}"; then
   as_fn_error $? "conditional \"DX_COND_doc\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
diff --git a/configure.ac b/configure.ac
index c64e97545242c12bf429f3e6bed093d27456ad43..381119b7bcf80a0ac04397ce3a567dc9028c00db 100644
--- a/configure.ac
+++ b/configure.ac
@@ -76,6 +76,46 @@ AM_CONDITIONAL([ENABLE_CHECK],[test -n "$CHECK_LIBS"])
 AC_SUBST([CHECK_ROOT])
 AC_SUBST([CHECK_INCLUDE])
 AC_SUBST([CHECK_LIBS])
+# search for libcmocka
+CMOCKA_ROOT=''
+CMOCKA_INCLUDE=''
+CMOCKA_LIBS=''
+AC_ARG_WITH([cmocka],
+            [AS_HELP_STRING([--with-cmocka=<yes|no|directory> (default=no)],[location of CMOCKA library])],
+            [AS_CASE(["$with_cmocka"],
+                     [no],[AC_MSG_CHECKING([for cmocka library])
+                           AC_MSG_RESULT([suppressed])],
+                     [yes],[AC_CHECK_HEADERS([cmocka.h],[],[],
+[[#include <stdarg.h>
+ #include <stddef.h>
+ #include <setjmp.h>
+]])
+                            AC_SEARCH_LIBS([assert_true],
+                                           [cmocka],
+                                           [],
+                                           [AC_MSG_ERROR([Cannot link to cmocka library!])])
+                            CMOCKA_LIBS=" -lcmocka"],
+                     [*],[AS_IF([test -d "$with_cmocka"],
+                                [CMOCKA_ROOT="$with_cmocka"
+                                 LDFLAGS="-L$CMOCKA_ROOT/lib $LDFLAGS"
+                                 CPPFLAGS="-I$CMOCKA_ROOT/include $CPPFLAGS"
+                                 AC_CHECK_HEADERS([cmocka.h],[],[],
+[[#include <stdarg.h>
+#include <stddef.h>
+#include <setjmp.h>
+]])
+                                 AC_SEARCH_LIBS([assert_true],
+                                                [cmocka],
+                                                [])
+                                 CMOCKA_LIBS=" -L$CMOCKA_ROOT/lib -lcmocka"
+                                 CMOCKA_INCLUDE=" -I$CMOCKA_ROOT/include"],
+                                [AC_MSG_NOTICE([$with_cmocka is not a directory! CMOCKA suppressed])])])],
+            [AC_MSG_CHECKING([for cmocka library])
+             AC_MSG_RESULT([suppressed])])
+AM_CONDITIONAL([ENABLE_CMOCKA],[test -n "$CMOCKA_LIBS"])
+AC_SUBST([CMOCKA_ROOT])
+AC_SUBST([CMOCKA_INCLUDE])
+AC_SUBST([CMOCKA_LIBS])
 
 # Doxygen documentation support
 
diff --git a/doc/Makefile.in b/doc/Makefile.in
index ca724bbbf38743117d4f621f9f677a47855e4205..8969603f28fcf8d9c425399e5f5b55a83a1e4395 100644
--- a/doc/Makefile.in
+++ b/doc/Makefile.in
@@ -137,6 +137,9 @@ CFLAGS = @CFLAGS@
 CHECK_INCLUDE = @CHECK_INCLUDE@
 CHECK_LIBS = @CHECK_LIBS@
 CHECK_ROOT = @CHECK_ROOT@
+CMOCKA_INCLUDE = @CMOCKA_INCLUDE@
+CMOCKA_LIBS = @CMOCKA_LIBS@
+CMOCKA_ROOT = @CMOCKA_ROOT@
 CPP = @CPP@
 CPPFLAGS = @CPPFLAGS@
 CYGPATH_W = @CYGPATH_W@
diff --git a/src/Makefile.in b/src/Makefile.in
index 281c92ab1c15f145c6cec880673ed34b9637cdc2..fa8be5e69aa1a80ba2508606c570fbb1b335433d 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -234,6 +234,9 @@ CFLAGS = @CFLAGS@
 CHECK_INCLUDE = @CHECK_INCLUDE@
 CHECK_LIBS = @CHECK_LIBS@
 CHECK_ROOT = @CHECK_ROOT@
+CMOCKA_INCLUDE = @CMOCKA_INCLUDE@
+CMOCKA_LIBS = @CMOCKA_LIBS@
+CMOCKA_ROOT = @CMOCKA_ROOT@
 CPP = @CPP@
 CPPFLAGS = @CPPFLAGS@
 CYGPATH_W = @CYGPATH_W@
diff --git a/test/Makefile.in b/test/Makefile.in
index 5949922c5de93589111c30f5e37a7b6e36b0d375..76160419731caaa6ce12e916cd04f0c6036ed299 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -295,6 +295,9 @@ CFLAGS = @CFLAGS@
 CHECK_INCLUDE = @CHECK_INCLUDE@
 CHECK_LIBS = @CHECK_LIBS@
 CHECK_ROOT = @CHECK_ROOT@
+CMOCKA_INCLUDE = @CMOCKA_INCLUDE@
+CMOCKA_LIBS = @CMOCKA_LIBS@
+CMOCKA_ROOT = @CMOCKA_ROOT@
 CPP = @CPP@
 CPPFLAGS = @CPPFLAGS@
 CYGPATH_W = @CYGPATH_W@