X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Scheduler%2FDaemon.test.cc;h=aceed1c34d4b19ca3fbda2c23a4885c4b54d9082;hb=44c966bc9d744d0926cffd5184fdb77a62564c16;hp=3e44b3e93aeaa2847128523b178e34efe7871ba8;hpb=8e973da50bdd625d2cbdd218143a4fcd920f9109;p=senf.git diff --git a/Scheduler/Daemon.test.cc b/Scheduler/Daemon.test.cc index 3e44b3e..aceed1c 100644 --- a/Scheduler/Daemon.test.cc +++ b/Scheduler/Daemon.test.cc @@ -31,6 +31,7 @@ #include #include #include +#include #include #include "Daemon.hh" #include "../Utils/Exception.hh" @@ -55,7 +56,9 @@ namespace { { void configure() { std::cout << "Running configure()" << std::endl; - pidFile("testDaemon.pid"); + pidFile("invalid.pid"); + consoleLog("invalid.log"); + senf::Daemon::configure(); } void init() { @@ -83,19 +86,30 @@ namespace { } int status; if (::waitpid(pid, &status, 0) < 0) senf::throwErrno("::waitpid()"); - return WIFEXITED(status) ? WEXITSTATUS(status) : -1; + return WIFEXITED(status) ? WEXITSTATUS(status) : -1; } } BOOST_AUTO_UNIT_TEST(testDaemon) { - char const * args[] = { "run", 0 }; - BOOST_CHECK_EQUAL( run(1,args), 0 ); + char const * args[] = { "run", + "--console-log=testDaemon.log,none", + "--pid-file=testDaemon.pid" }; + BOOST_CHECK_EQUAL( run(sizeof(args)/sizeof(*args),args), 0 ); + BOOST_CHECK( ! boost::filesystem::exists("invalid.log") ); + BOOST_CHECK( ! boost::filesystem::exists("invalid.pid") ); BOOST_CHECK( boost::filesystem::exists("testDaemon.pid") ); delay(1000); BOOST_CHECK( ! boost::filesystem::exists("testDaemon.pid") ); + BOOST_REQUIRE( boost::filesystem::exists("testDaemon.log") ); + + std::ifstream log ("testDaemon.log"); + std::stringstream data; + data << log.rdbuf(); + BOOST_CHECK_EQUAL( data.str(), "Running init()\nRunning run()\n" ); + BOOST_CHECK_NO_THROW( boost::filesystem::remove("testDaemon.log") ); } ///////////////////////////////cc.e////////////////////////////////////////