ixfr.cc ixfr.hh \
logger.cc logger.hh \
misc.cc misc.hh \
+ mtasker_fcontext.cc \
negcache.hh negcache.cc \
namespaces.hh \
nsecrecords.cc \
test-iputils_hh.cc \
test-ixfr_cc.cc \
test-misc_hh.cc \
+ test-mtasker.cc \
test-nmtree.cc \
test-negcache_cc.cc \
test-rcpgenerator_cc.cc \
testrunner_LDFLAGS = \
$(AM_LDFLAGS) \
+ $(BOOST_CONTEXT_LDFLAGS) \
$(BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS) \
$(LIBCRYPTO_LDFLAGS)
testrunner_LDADD = \
+ $(BOOST_CONTEXT_LIBS) \
$(BOOST_UNIT_TEST_FRAMEWORK_LIBS) \
$(LIBCRYPTO_LIBS) \
$(RT_LIBS)
--- /dev/null
+#define BOOST_TEST_DYN_LINK
+#define BOOST_TEST_NO_MAIN
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+#include <boost/test/unit_test.hpp>
+#include <boost/test/floating_point_comparison.hpp>
+#include "mtasker.hh"
+
+BOOST_AUTO_TEST_SUITE(mtasker_cc)
+
+static int g_result;
+
+static void doSomething(void* p)
+{
+ MTasker<>* mt = reinterpret_cast<MTasker<>*>(p);
+ int i=12, o;
+ mt->waitEvent(i, &o);
+ g_result = o;
+
+}
+
+BOOST_AUTO_TEST_CASE(test_Simple) {
+ MTasker<> mt;
+ mt.makeThread(doSomething, &mt);
+ struct timeval now;
+ gettimeofday(&now, 0);
+ bool first=true;
+ int o=24;
+ for(;;) {
+ while(mt.schedule(&now));
+ if(first) {
+ mt.sendEvent(12, &o);
+ first=false;
+ }
+ if(mt.noProcesses())
+ break;
+ }
+ BOOST_CHECK_EQUAL(g_result, o);
+}
+
+static void willThrow(void* p)
+{
+ throw std::runtime_error("Help!");
+}
+
+
+BOOST_AUTO_TEST_CASE(test_MtaskerException) {
+ BOOST_CHECK_EXCEPTION( {
+ MTasker<> mt;
+ mt.makeThread(willThrow, 0);
+ struct timeval now;
+
+ for(;;) {
+ mt.schedule(&now);
+ }
+ }, std::exception, [](const std::exception& e) { return true; });
+}
+BOOST_AUTO_TEST_SUITE_END()