From: tho Date: Tue, 14 Apr 2009 09:28:26 +0000 (+0000) Subject: added some tests X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=a0d25046d1eb01188789c55ba896589fed42fb88;p=senf.git added some tests git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1189 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/Socket/NetdeviceController.test.cc b/Socket/NetdeviceController.test.cc index 24258ee..ed401f8 100644 --- a/Socket/NetdeviceController.test.cc +++ b/Socket/NetdeviceController.test.cc @@ -29,6 +29,7 @@ // Custom includes #include "NetdeviceController.hh" #include "Protocols/Raw/MACAddress.hh" +#include #include "../Utils/auto_unit_test.hh" #include @@ -38,11 +39,13 @@ BOOST_AUTO_UNIT_TEST(NetdeviceController) { - senf::NetdeviceController ctrl ("lo"); - BOOST_CHECK_EQUAL( ctrl.interfaceName(), "lo"); + std::string ifname ("lo"); + senf::NetdeviceController ctrl (ifname); + BOOST_CHECK_EQUAL( ctrl.interfaceName(), ifname); int index = ctrl.interfaceIndex(); BOOST_CHECK_EQUAL( index, senf::NetdeviceController(index).interfaceIndex() ); + BOOST_CHECK_EQUAL( index, if_nametoindex( ifname.c_str()) ); BOOST_CHECK_THROW( senf::NetdeviceController("invalid_interfacename"), senf::SystemException ); @@ -51,6 +54,8 @@ BOOST_AUTO_UNIT_TEST(NetdeviceController) { bool promisc; SENF_CHECK_NO_THROW( promisc = ctrl.promisc()); + + BOOST_CHECK( ctrl.isUp()); if (getuid() != 0) { BOOST_WARN_MESSAGE(false, "Cannot run some tests of senf::NetdeviceController as non-root user"); @@ -71,7 +76,7 @@ BOOST_AUTO_UNIT_TEST(NetdeviceController) { ///////////////////////////////cc.e//////////////////////////////////////// #undef prefix_ - + // Local Variables: // mode: c++ // fill-column: 100 diff --git a/Utils/Console/Config.test.cc b/Utils/Console/Config.test.cc index 6dd7ab2..daefcca 100644 --- a/Utils/Console/Config.test.cc +++ b/Utils/Console/Config.test.cc @@ -69,10 +69,15 @@ namespace { BOOST_AUTO_UNIT_TEST(configBundle) { senf::console::ScopedDirectory<> root; - senf::console::root().add("root",root); + senf::console::root().add("root", root); - root.mkdir("dir1").add("fun1",&fun1); - root.add("fun2",&fun2); + senf::console::ScopedDirectory<> chroot; + senf::console::root().add("chroot", chroot); + + root.mkdir("dir1").add("fun1", &fun1); + root.add("fun2", &fun2); + chroot.mkdir("dir1").add("fun1", &fun1); + chroot.add("fun2", &fun2); TempFile cfg ("test.cfg"); cfg << "dir1/fun1 foo; fun2;" << TempFile::close; @@ -86,6 +91,11 @@ BOOST_AUTO_UNIT_TEST(configBundle) SENF_CHECK_NO_THROW( bundle.parse() ); BOOST_CHECK_EQUAL( val1, "bar" ); BOOST_CHECK_EQUAL( val2, true ); + + bundle.chroot( chroot); + SENF_CHECK_NO_THROW( bundle.parse() ); + BOOST_CHECK_EQUAL( val1, "bar" ); + BOOST_CHECK_EQUAL( val2, true ); } ///////////////////////////////cc.e////////////////////////////////////////