1
0
mirror of https://github.com/fwbuilder/fwbuilder synced 2026-03-20 10:17:16 +01:00

Unit test for isEligibleForCluster

This commit is contained in:
Roman Bovsunivskiy 2009-12-06 01:10:10 +00:00
parent 03b5dbff3d
commit 628209f02f
3 changed files with 85 additions and 10 deletions

View File

@ -25,6 +25,8 @@
#include "interfaceProperties.h"
#include <QDebug>
using namespace std;
using namespace libfwbuilder;
using namespace CppUnit;
@ -33,11 +35,11 @@ void interfacePropertiesTest::validateInterface()
{
vector<vector<string> > testData;
vector<string> row;
row.push_back("linux24");
row.push_back("ethernet");
row.push_back("ethernet");
row.push_back("false");
row.push_back("true");
row.push_back("linux24"); // host_OS
row.push_back("ethernet"); // type
row.push_back("ethernet"); // parent_type
row.push_back("false"); // is unnumbered
row.push_back("true"); // right answer
testData.push_back(row);
row.clear();
@ -103,6 +105,76 @@ void interfacePropertiesTest::validateInterface()
}
}
void interfacePropertiesTest::isEligibleForCluster()
{
vector<vector<string> > testData;
vector<string> row;
row.push_back("ethernet"); // type
row.push_back("ethernet"); // parent_type
row.push_back("true"); // right answer
testData.push_back(row);
row.clear();
row.push_back("ethernet");
row.push_back("bridge");
row.push_back("false");
testData.push_back(row);
row.clear();
row.push_back("bonding");
row.push_back("ethernet");
row.push_back("true");
testData.push_back(row);
row.clear();
row.push_back("bridge");
row.push_back("ethernet");
row.push_back("true");
testData.push_back(row);
row.clear();
row.push_back("8021q");
row.push_back("ethernet");
row.push_back("true");
testData.push_back(row);
row.clear();
row.push_back("ethernet");
row.push_back("bridge");
row.push_back("false");
testData.push_back(row);
for (unsigned int i = 0; i<testData.size(); i++)
{
string type = testData[i][0];
string parent_type = testData[i][1];
bool answer = testData[i][2] == "true";
Interface parent;
Interface iface;
db->add(&parent);
parent.add(&iface, true);
parent.getOptionsObject()->setStr("type", parent_type);
iface.getOptionsObject()->setStr("type", type);
iface.getParent()->setStr("type", parent_type);
Resources* os_res = Resources::os_res["linux24"];
string os_family = "linux24";
if (os_res!=NULL)
os_family = os_res->getResourceStr("/FWBuilderResources/Target/family");
interfaceProperties * int_prop = interfacePropertiesObjectFactory::getInterfacePropertiesObject(os_family);
CPPUNIT_ASSERT(int_prop != NULL);
bool result = int_prop->isEligibleForCluster(&iface);
CPPUNIT_ASSERT(result == answer);
}
}
void interfacePropertiesTest::setUp()
{
db = new FWObjectDatabase();

View File

@ -51,6 +51,7 @@ public:
//interfaceProperties( std::string name ) : CppUnit::TestCase( name ) {}
void validateInterface();
void isEligibleForCluster();
void setUp();
static CppUnit::Test *suite()
@ -59,6 +60,9 @@ public:
suiteOfTests->addTest( new CppUnit::TestCaller<interfacePropertiesTest>(
"validateInterface",
&interfacePropertiesTest::validateInterface ) );
suiteOfTests->addTest( new CppUnit::TestCaller<interfacePropertiesTest>(
"validateInterface",
&interfacePropertiesTest::isEligibleForCluster ) );
return suiteOfTests;
}

View File

@ -2,16 +2,15 @@
# Automatically generated by qmake (2.01a) Sat Dec 5 20:04:56 2009
# #####################################################################
include(../../../../qmake.inc)
#exists(../../qmake.inc):include( ../../qmake.inc)
# exists(../../qmake.inc):include( ../../qmake.inc)
TEMPLATE = app
TARGET =
DEPENDPATH += .
INCLUDEPATH += ../../../iptlib \
../../../pflib \
../../../cisco_lib/ \
../../../compiler_lib/
DEPENDPATH = ../../../iptlib \
../../../pflib \
../../../cisco_lib/ \
@ -32,8 +31,8 @@ win32:PRE_TARGETDEPS = ../../../iptlib/release/iptlib.lib \
../../../pflib/libfwbpf.a \
../../../cisco_lib/libfwbcisco.a \
../../../compiler_lib/libcompilerdriver.a
QMAKE_LFLAGS += -lcppunit -lfwbuilder
QMAKE_LFLAGS += -lcppunit \
-lfwbuilder
# Input
HEADERS += interfaceProperties.h