// Custom includes
#include "NetdeviceController.hh"
#include "Protocols/Raw/MACAddress.hh"
+#include <net/if.h>
#include "../Utils/auto_unit_test.hh"
#include <boost/test/test_tools.hpp>
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 );
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");
///////////////////////////////cc.e////////////////////////////////////////
#undef prefix_
-
+\f
// Local Variables:
// mode: c++
// fill-column: 100
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;
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////////////////////////////////////////