mirror of
https://github.com/fwbuilder/fwbuilder
synced 2025-11-06 18:52:58 +01:00
test: Remove CppUnit, use QtTest only
This commit is contained in:
parent
a27b4d339b
commit
79cae6201f
@ -1,48 +0,0 @@
|
||||
#
|
||||
# Find the CppUnit includes and library
|
||||
#
|
||||
# This module defines
|
||||
# CPPUNIT_INCLUDE_DIR, where to find tiff.h, etc.
|
||||
# CPPUNIT_LIBRARIES, the libraries to link against to use CppUnit.
|
||||
# CPPUNIT_FOUND, If false, do not try to use CppUnit.
|
||||
|
||||
# also defined, but not for general use are
|
||||
# CPPUNIT_LIBRARY, where to find the CppUnit library.
|
||||
# CPPUNIT_DEBUG_LIBRARY, where to find the CppUnit library in debug mode.
|
||||
|
||||
FIND_PATH(CPPUNIT_INCLUDE_DIR cppunit/TestCase.h HINTS
|
||||
/usr/local/include
|
||||
/usr/include
|
||||
ENV CppUnit_ROOT
|
||||
)
|
||||
|
||||
# With Win32, important to have both
|
||||
IF(WIN32)
|
||||
FIND_LIBRARY(CPPUNIT_LIBRARY cppunit
|
||||
${CPPUNIT_INCLUDE_DIR}/../lib
|
||||
/usr/local/lib
|
||||
/usr/lib)
|
||||
FIND_LIBRARY(CPPUNIT_DEBUG_LIBRARY cppunitd
|
||||
${CPPUNIT_INCLUDE_DIR}/../lib
|
||||
/usr/local/lib
|
||||
/usr/lib)
|
||||
ELSE(WIN32)
|
||||
# On unix system, debug and release have the same name
|
||||
FIND_LIBRARY(CPPUNIT_LIBRARY cppunit
|
||||
${CPPUNIT_INCLUDE_DIR}/../lib
|
||||
/usr/local/lib
|
||||
/usr/lib)
|
||||
FIND_LIBRARY(CPPUNIT_DEBUG_LIBRARY cppunit
|
||||
${CPPUNIT_INCLUDE_DIR}/../lib
|
||||
/usr/local/lib
|
||||
/usr/lib)
|
||||
ENDIF(WIN32)
|
||||
|
||||
IF(CPPUNIT_INCLUDE_DIR)
|
||||
IF(CPPUNIT_LIBRARY)
|
||||
SET(CPPUNIT_FOUND "YES")
|
||||
SET(CPPUNIT_LIBRARIES ${CPPUNIT_LIBRARY} ${CMAKE_DL_LIBS})
|
||||
SET(CPPUNIT_DEBUG_LIBRARIES ${CPPUNIT_DEBUG_LIBRARY}
|
||||
${CMAKE_DL_LIBS})
|
||||
ENDIF(CPPUNIT_LIBRARY)
|
||||
ENDIF(CPPUNIT_INCLUDE_DIR)
|
||||
@ -3,4 +3,4 @@ SET(CMAKE_AUTOMOC ON)
|
||||
add_executable(AddressRangeDialogTest AddressRangeDialogTest.cpp main_AddressRangeDialogTest.cpp)
|
||||
add_test(NAME AddressRangeDialogTest COMMAND AddressRangeDialogTest)
|
||||
|
||||
target_link_libraries(AddressRangeDialogTest PRIVATE test_main netsnmp gui import fwbparser antlr common iptlib fwbpf fwbjuniper fwbcisco compilerdriver fwcompiler fwbuilder xml2 xslt z pthread Qt5::Test)
|
||||
target_link_libraries(AddressRangeDialogTest PRIVATE test_main gui import fwbparser antlr common iptlib fwbpf fwbjuniper fwbcisco compilerdriver fwcompiler fwbuilder netsnmp xml2 xslt z pthread Qt5::Test)
|
||||
|
||||
@ -37,10 +37,10 @@ using namespace std;
|
||||
using namespace libfwbuilder;
|
||||
|
||||
int fwbdebug = 0;
|
||||
FWWindow *mw = nullptr;
|
||||
FWBSettings *st = nullptr;
|
||||
FWBApplication *app = nullptr;
|
||||
|
||||
FWWindow *mw = nullptr;
|
||||
FWBSettings *st = nullptr;
|
||||
FWBApplication *app = nullptr;
|
||||
|
||||
|
||||
|
||||
extern void build_app(int argc, char** argv,
|
||||
@ -48,15 +48,17 @@ extern void build_app(int argc, char** argv,
|
||||
FWBSettings** st);
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
app = new FWBApplication(argc, argv);
|
||||
app->setOrganizationName(QLatin1String("NetCitadel"));
|
||||
app->setApplicationName(QLatin1String("Firewall Builder"));
|
||||
{
|
||||
app = new FWBApplication(argc, argv);
|
||||
app->setOrganizationName(QLatin1String("NetCitadel"));
|
||||
app->setApplicationName(QLatin1String("Firewall Builder"));
|
||||
|
||||
build_app(argc, argv, &app, &st);
|
||||
|
||||
QTest::qExec(new AddressRangeDialogTest());
|
||||
int testResult = QTest::qExec(new AddressRangeDialogTest());
|
||||
|
||||
if (QFile::exists("test_work.fwb"))
|
||||
QFile::remove("test_work.fwb");
|
||||
if (QFile::exists("test_work.fwb"))
|
||||
QFile::remove("test_work.fwb");
|
||||
|
||||
return testResult;
|
||||
}
|
||||
|
||||
@ -23,8 +23,9 @@
|
||||
|
||||
*/
|
||||
|
||||
#include "AddressTableTest.h"
|
||||
#include <QTest>
|
||||
|
||||
#include "AddressTableTest.h"
|
||||
|
||||
#include "fwbuilder/Resources.h"
|
||||
|
||||
@ -46,7 +47,7 @@ using namespace libfwbuilder;
|
||||
|
||||
|
||||
|
||||
void AddressTableTest::setUp()
|
||||
void AddressTableTest::init()
|
||||
{
|
||||
objdb = new FWObjectDatabase();
|
||||
|
||||
@ -63,6 +64,11 @@ void AddressTableTest::setUp()
|
||||
o1->add(address_tables_group);
|
||||
}
|
||||
|
||||
void AddressTableTest::cleanup()
|
||||
{
|
||||
delete objdb;
|
||||
}
|
||||
|
||||
void AddressTableTest::positiveTest()
|
||||
{
|
||||
setStrings addrres;
|
||||
@ -82,7 +88,7 @@ void AddressTableTest::positiveTest()
|
||||
addrset.insert("192.168.100.0/255.255.255.0");
|
||||
addrset.insert("192.168.11.0/255.255.255.0");
|
||||
|
||||
CPPUNIT_ASSERT(address_tables_group!=nullptr);
|
||||
QVERIFY(address_tables_group!=nullptr);
|
||||
|
||||
|
||||
AddressTable *nobj = AddressTable::cast(objdb->create(AddressTable::TYPENAME, true));
|
||||
@ -98,13 +104,13 @@ void AddressTableTest::positiveTest()
|
||||
for ( ; t != nobj->end(); ++t )
|
||||
{
|
||||
ref = FWReference::cast(*t);
|
||||
CPPUNIT_ASSERT(ref!=nullptr);
|
||||
QVERIFY(ref!=nullptr);
|
||||
net = Network::cast(ref->getPointer());
|
||||
CPPUNIT_ASSERT(net!=nullptr);
|
||||
QVERIFY(net!=nullptr);
|
||||
addrres.insert(net->getAddressPtr()->toString() + "/" + net->getNetmaskPtr()->toString());
|
||||
}
|
||||
|
||||
CPPUNIT_ASSERT(addrset==addrres);
|
||||
QVERIFY(addrset==addrres);
|
||||
}
|
||||
|
||||
|
||||
@ -112,27 +118,27 @@ void AddressTableTest::negativeTest1()
|
||||
{
|
||||
setStrings addrres;
|
||||
|
||||
CPPUNIT_ASSERT(address_tables_group!=nullptr);
|
||||
QVERIFY(address_tables_group!=nullptr);
|
||||
|
||||
|
||||
AddressTable *nobj = AddressTable::cast(objdb->create(AddressTable::TYPENAME, true));
|
||||
address_tables_group->add(nobj);
|
||||
nobj->setName("TestADT2");
|
||||
nobj->setSourceName("addresstable-2.txt");
|
||||
CPPUNIT_ASSERT_THROW(nobj->loadFromSource(false, nullptr, true), FWException);
|
||||
QVERIFY_EXCEPTION_THROWN(nobj->loadFromSource(false, nullptr, true), FWException);
|
||||
}
|
||||
|
||||
void AddressTableTest::negativeTest2()
|
||||
{
|
||||
setStrings addrres;
|
||||
|
||||
CPPUNIT_ASSERT(address_tables_group!=nullptr);
|
||||
QVERIFY(address_tables_group!=nullptr);
|
||||
|
||||
|
||||
AddressTable *nobj = AddressTable::cast(objdb->create(AddressTable::TYPENAME, true));
|
||||
address_tables_group->add(nobj);
|
||||
nobj->setName("TestADT3");
|
||||
nobj->setSourceName("addresstable-not-found.txt");
|
||||
CPPUNIT_ASSERT_THROW(nobj->loadFromSource(false, nullptr, true), FWException);
|
||||
QVERIFY_EXCEPTION_THROWN(nobj->loadFromSource(false, nullptr, true), FWException);
|
||||
}
|
||||
|
||||
|
||||
@ -27,29 +27,26 @@
|
||||
#ifndef ADDRESSTABLETEST_H
|
||||
#define ADDRESSTABLETEST_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include "fwbuilder/FWObjectDatabase.h"
|
||||
|
||||
#include <set>
|
||||
#include <string>
|
||||
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
typedef std::set <std::string, std::less<std::string> > setStrings;
|
||||
|
||||
class AddressTableTest : public CppUnit::TestFixture
|
||||
class AddressTableTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
libfwbuilder::FWObjectDatabase *objdb;
|
||||
libfwbuilder::FWObject *address_tables_group;
|
||||
|
||||
CPPUNIT_TEST_SUITE(AddressTableTest);
|
||||
CPPUNIT_TEST(positiveTest);
|
||||
CPPUNIT_TEST(negativeTest1);
|
||||
CPPUNIT_TEST(negativeTest2);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
private slots:
|
||||
void init();
|
||||
void cleanup();
|
||||
|
||||
public:
|
||||
void setUp();
|
||||
void positiveTest();
|
||||
void negativeTest1();
|
||||
void negativeTest2();
|
||||
|
||||
@ -3,7 +3,7 @@ SET(CMAKE_AUTOMOC ON)
|
||||
add_executable(AddressTableTest AddressTableTest.cpp main.cpp)
|
||||
add_test(NAME AddressTableTest COMMAND AddressTableTest)
|
||||
|
||||
target_link_libraries(AddressTableTest PRIVATE test_main netsnmp gui import fwbparser antlr common iptlib fwbpf fwbjuniper fwbcisco compilerdriver fwcompiler fwbuilder xml2 xslt z pthread cppunit)
|
||||
target_link_libraries(AddressTableTest PRIVATE test_main netsnmp gui import fwbparser antlr common iptlib fwbpf fwbjuniper fwbcisco compilerdriver fwcompiler fwbuilder xml2 xslt z pthread Qt5::Test)
|
||||
|
||||
file(COPY addresstable-1.txt addresstable-2.txt DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
|
||||
@ -22,9 +22,8 @@
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
#include <QTest>
|
||||
|
||||
#include <cppunit/ui/text/TestRunner.h>
|
||||
#include <cppunit/CompilerOutputter.h>
|
||||
#include "AddressTableTest.h"
|
||||
#include "fwbuilder/FWObjectDatabase.h"
|
||||
|
||||
@ -33,13 +32,7 @@
|
||||
int fwbdebug = 0;
|
||||
std::string platform;
|
||||
|
||||
int main( int, char** argv)
|
||||
int main()
|
||||
{
|
||||
CppUnit::TextUi::TestRunner runner;
|
||||
runner.addTest( AddressTableTest::suite() );
|
||||
runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(),
|
||||
std::cerr ) );
|
||||
|
||||
runner.run();
|
||||
return 0;
|
||||
return QTest::qExec(new AddressTableTest());
|
||||
}
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
include( CTest )
|
||||
|
||||
find_package(CppUnit REQUIRED)
|
||||
find_package(Qt5Test REQUIRED)
|
||||
|
||||
enable_testing(TRUE)
|
||||
|
||||
@ -3,4 +3,4 @@ SET(CMAKE_AUTOMOC ON)
|
||||
add_executable(CustomServiceDialogTest CustomServiceDialogTest.cpp main_CustomServiceDialogTest.cpp)
|
||||
add_test(NAME CustomServiceDialogTest COMMAND CustomServiceDialogTest)
|
||||
|
||||
target_link_libraries(CustomServiceDialogTest PRIVATE test_main netsnmp gui import fwbparser antlr common iptlib fwbpf fwbjuniper fwbcisco compilerdriver fwcompiler fwbuilder xml2 xslt z pthread Qt5::Test)
|
||||
target_link_libraries(CustomServiceDialogTest PRIVATE test_main gui import fwbparser antlr common iptlib fwbpf fwbjuniper fwbcisco compilerdriver fwcompiler fwbuilder netsnmp xml2 xslt z pthread Qt5::Test)
|
||||
|
||||
@ -38,9 +38,9 @@ using namespace std;
|
||||
using namespace libfwbuilder;
|
||||
|
||||
int fwbdebug = 0;
|
||||
FWWindow *mw = nullptr;
|
||||
FWBSettings *st = nullptr;
|
||||
FWBApplication *app = nullptr;
|
||||
FWWindow *mw = nullptr;
|
||||
FWBSettings *st = nullptr;
|
||||
FWBApplication *app = nullptr;
|
||||
|
||||
|
||||
extern void build_app(int argc, char** argv,
|
||||
@ -48,16 +48,18 @@ extern void build_app(int argc, char** argv,
|
||||
FWBSettings** st);
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
app = new FWBApplication(argc, argv);
|
||||
app->setOrganizationName(QLatin1String("NetCitadel"));
|
||||
app->setApplicationName(QLatin1String("Firewall Builder"));
|
||||
{
|
||||
app = new FWBApplication(argc, argv);
|
||||
app->setOrganizationName(QLatin1String("NetCitadel"));
|
||||
app->setApplicationName(QLatin1String("Firewall Builder"));
|
||||
|
||||
build_app(argc, argv, &app, &st);
|
||||
|
||||
|
||||
QTest::qExec(new CustomServiceDialogTest());
|
||||
int testResult = QTest::qExec(new CustomServiceDialogTest());
|
||||
|
||||
if (QFile::exists("test_work.fwb"))
|
||||
QFile::remove("test_work.fwb");
|
||||
if (QFile::exists("test_work.fwb"))
|
||||
QFile::remove("test_work.fwb");
|
||||
|
||||
return testResult;
|
||||
}
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
SET(CMAKE_AUTOMOC ON)
|
||||
|
||||
add_executable(DNSTest DNSTest.cpp main.cpp)
|
||||
add_test(NAME DNSTest COMMAND DNSTest)
|
||||
|
||||
target_link_libraries(DNSTest PRIVATE test_main netsnmp gui import fwbparser antlr common iptlib fwbpf fwbjuniper fwbcisco compilerdriver fwcompiler fwbuilder xml2 xslt z pthread cppunit)
|
||||
target_link_libraries(DNSTest PRIVATE test_main netsnmp gui import fwbparser antlr common iptlib fwbpf fwbjuniper fwbcisco compilerdriver fwcompiler fwbuilder xml2 xslt z pthread Qt5::Test)
|
||||
|
||||
@ -23,6 +23,8 @@
|
||||
|
||||
*/
|
||||
|
||||
#include <QTest>
|
||||
|
||||
#include "DNSTest.h"
|
||||
#include "fwbuilder/FWObjectDatabase.h"
|
||||
#include "fwbuilder/XMLTools.h"
|
||||
@ -84,7 +86,7 @@ bool DNSTest::testDNSNameObject(FWObjectDatabase *objdb, FWObject *root,
|
||||
return true;
|
||||
}
|
||||
|
||||
void DNSTest::runTest()
|
||||
void DNSTest::init()
|
||||
{
|
||||
libfwbuilder::init();
|
||||
|
||||
@ -98,17 +100,30 @@ void DNSTest::runTest()
|
||||
o1->setName("Objects");
|
||||
nlib->add(o1);
|
||||
|
||||
FWObject *root = objdb->create(ObjectGroup::TYPENAME);
|
||||
root = objdb->create(ObjectGroup::TYPENAME);
|
||||
root->setName("DNS Names");
|
||||
o1->add(root);
|
||||
}
|
||||
|
||||
InetAddr addr;
|
||||
void DNSTest::cleanup()
|
||||
{
|
||||
delete objdb;
|
||||
}
|
||||
|
||||
void DNSTest::testLocalhost()
|
||||
{
|
||||
const char* test1[] = {"localhost", "127.0.0.1", nullptr};
|
||||
CPPUNIT_ASSERT(testDNSNameObject(objdb, root, test1[0], &(test1[1])));
|
||||
QVERIFY(testDNSNameObject(objdb, root, test1[0], &(test1[1])));
|
||||
}
|
||||
|
||||
void DNSTest::testSingleIP()
|
||||
{
|
||||
const char* test2[] = {"www.fwbuilder.org","70.85.175.170", nullptr};
|
||||
CPPUNIT_ASSERT(testDNSNameObject(objdb, root, test2[0], &(test2[1])));
|
||||
QVERIFY(testDNSNameObject(objdb, root, test2[0], &(test2[1])));
|
||||
}
|
||||
|
||||
void DNSTest::testMultipleIPs()
|
||||
{
|
||||
const char* test3[] = {"www.microsoft.com",
|
||||
"65.55.21.250",
|
||||
"207.46.232.182",
|
||||
@ -118,5 +133,5 @@ void DNSTest::runTest()
|
||||
"207.46.193.254",
|
||||
nullptr};
|
||||
|
||||
CPPUNIT_ASSERT(testDNSNameObject(objdb, root, test3[0], &(test3[1])));
|
||||
QVERIFY(testDNSNameObject(objdb, root, test3[0], &(test3[1])));
|
||||
}
|
||||
|
||||
@ -26,31 +26,28 @@
|
||||
#ifndef DNSTEST_H
|
||||
#define DNSTEST_H
|
||||
|
||||
#include <cppunit/TestCase.h>
|
||||
#include <cppunit/TestSuite.h>
|
||||
#include <cppunit/TestCaller.h>
|
||||
#include <QObject>
|
||||
|
||||
#include "fwbuilder/FWObjectDatabase.h"
|
||||
#include "fwbuilder/FWObject.h"
|
||||
|
||||
|
||||
class DNSTest : public CppUnit::TestCase
|
||||
class DNSTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
libfwbuilder::FWObjectDatabase *objdb = nullptr;
|
||||
libfwbuilder::FWObject *root = nullptr;
|
||||
|
||||
libfwbuilder::FWObjectDatabase *objdb;
|
||||
bool testDNSNameObject(libfwbuilder::FWObjectDatabase *objdb,
|
||||
libfwbuilder::FWObject *root,
|
||||
const std::string &dnsrec,
|
||||
const char* results[]);
|
||||
public:
|
||||
void runTest();
|
||||
|
||||
static CppUnit::Test *suite()
|
||||
{
|
||||
CppUnit::TestSuite *suiteOfTests = new CppUnit::TestSuite( "ObjectMatcherTest" );
|
||||
suiteOfTests->addTest( new CppUnit::TestCaller<DNSTest>( "runTest", &DNSTest::runTest ) );
|
||||
return suiteOfTests;
|
||||
}
|
||||
private slots:
|
||||
void init();
|
||||
void cleanup();
|
||||
void testLocalhost();
|
||||
void testSingleIP();
|
||||
void testMultipleIPs();
|
||||
};
|
||||
|
||||
#endif // DNSTEST_H
|
||||
|
||||
@ -22,9 +22,8 @@
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
#include <QTest>
|
||||
|
||||
#include <cppunit/ui/text/TestRunner.h>
|
||||
#include <cppunit/CompilerOutputter.h>
|
||||
#include "DNSTest.h"
|
||||
#include "fwbuilder/FWObjectDatabase.h"
|
||||
|
||||
@ -33,13 +32,7 @@
|
||||
int fwbdebug = 0;
|
||||
std::string platform;
|
||||
|
||||
int main( int, char** argv)
|
||||
int main()
|
||||
{
|
||||
CppUnit::TextUi::TestRunner runner;
|
||||
runner.addTest( DNSTest::suite() );
|
||||
runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(),
|
||||
std::cerr ) );
|
||||
|
||||
runner.run();
|
||||
return 0;
|
||||
return QTest::qExec(new DNSTest());
|
||||
}
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
SET(CMAKE_AUTOMOC ON)
|
||||
|
||||
add_executable(FWBTreeTest FWBTreeTest.cpp main_FWBTreeTest.cpp)
|
||||
add_test(NAME FWBTreeTest COMMAND FWBTreeTest)
|
||||
|
||||
target_link_libraries(FWBTreeTest PRIVATE gui fwbuilder xml2 xslt z cppunit)
|
||||
target_link_libraries(FWBTreeTest PRIVATE gui fwbuilder xml2 xslt z Qt5::Test)
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
#include <QTest>
|
||||
#include <QDebug>
|
||||
#include "FWBTreeTest.h"
|
||||
|
||||
@ -57,21 +57,21 @@ void FWBTreeTest::isSystem()
|
||||
FWBTree fwbtree;
|
||||
|
||||
FWObjectDatabase db;
|
||||
CPPUNIT_ASSERT(fwbtree.isSystem(&db) == true);
|
||||
QVERIFY(fwbtree.isSystem(&db) == true);
|
||||
|
||||
Library *lib = db.createLibrary(4);
|
||||
CPPUNIT_ASSERT(fwbtree.isSystem(lib) == true);
|
||||
QVERIFY(fwbtree.isSystem(lib) == true);
|
||||
lib = db.createLibrary(7);
|
||||
CPPUNIT_ASSERT(fwbtree.isSystem(lib) == true);
|
||||
QVERIFY(fwbtree.isSystem(lib) == true);
|
||||
lib = db.createLibrary(1);
|
||||
CPPUNIT_ASSERT(fwbtree.isSystem(lib) == false);
|
||||
QVERIFY(fwbtree.isSystem(lib) == false);
|
||||
|
||||
lib = Library::cast(fwbtree.createNewLibrary(&db));
|
||||
FWObject *slot = fwbtree.getStandardSlotForObject(lib, Firewall::TYPENAME);
|
||||
CPPUNIT_ASSERT(fwbtree.isSystem(slot) == true);
|
||||
QVERIFY(fwbtree.isSystem(slot) == true);
|
||||
|
||||
Firewall fw;
|
||||
CPPUNIT_ASSERT(fwbtree.isSystem(&fw) == false);
|
||||
QVERIFY(fwbtree.isSystem(&fw) == false);
|
||||
}
|
||||
|
||||
QSet<FWObject*> FWBTreeTest::getStandardFolders(FWObject *root)
|
||||
@ -104,26 +104,26 @@ void FWBTreeTest::validateForInsertion()
|
||||
Firewall fw;
|
||||
Network net;
|
||||
|
||||
CPPUNIT_ASSERT(tree.validateForInsertion(&host, &iface, err) == true);
|
||||
CPPUNIT_ASSERT(tree.validateForInsertion(&firewall, &iface, err) == true);
|
||||
CPPUNIT_ASSERT(tree.validateForInsertion(&iface, &ipv4, err) == true);
|
||||
CPPUNIT_ASSERT(tree.validateForInsertion(&iface, &ipv6, err) == true);
|
||||
QVERIFY(tree.validateForInsertion(&host, &iface, err) == true);
|
||||
QVERIFY(tree.validateForInsertion(&firewall, &iface, err) == true);
|
||||
QVERIFY(tree.validateForInsertion(&iface, &ipv4, err) == true);
|
||||
QVERIFY(tree.validateForInsertion(&iface, &ipv6, err) == true);
|
||||
firewall.addInterface(&iface);
|
||||
CPPUNIT_ASSERT(tree.validateForInsertion(&iface, &ipv4, err) == true);
|
||||
CPPUNIT_ASSERT(tree.validateForInsertion(&iface, &ipv6, err) == true);
|
||||
QVERIFY(tree.validateForInsertion(&iface, &ipv4, err) == true);
|
||||
QVERIFY(tree.validateForInsertion(&iface, &ipv6, err) == true);
|
||||
|
||||
ObjectGroup grp, grp2;
|
||||
Cluster cluster;
|
||||
DNSName dnsname;
|
||||
AddressRange addrrange;
|
||||
AddressTable addrtable;
|
||||
CPPUNIT_ASSERT(tree.validateForInsertion(&grp, &host, err) == true);
|
||||
CPPUNIT_ASSERT(tree.validateForInsertion(&grp, &firewall, err) == true);
|
||||
CPPUNIT_ASSERT(tree.validateForInsertion(&grp, &cluster, err) == true);
|
||||
CPPUNIT_ASSERT(tree.validateForInsertion(&grp, &dnsname, err) == true);
|
||||
CPPUNIT_ASSERT(tree.validateForInsertion(&grp, &addrrange, err) == true);
|
||||
CPPUNIT_ASSERT(tree.validateForInsertion(&grp, &addrtable, err) == true);
|
||||
CPPUNIT_ASSERT(tree.validateForInsertion(&grp, &grp2, err) == true);
|
||||
QVERIFY(tree.validateForInsertion(&grp, &host, err) == true);
|
||||
QVERIFY(tree.validateForInsertion(&grp, &firewall, err) == true);
|
||||
QVERIFY(tree.validateForInsertion(&grp, &cluster, err) == true);
|
||||
QVERIFY(tree.validateForInsertion(&grp, &dnsname, err) == true);
|
||||
QVERIFY(tree.validateForInsertion(&grp, &addrrange, err) == true);
|
||||
QVERIFY(tree.validateForInsertion(&grp, &addrtable, err) == true);
|
||||
QVERIFY(tree.validateForInsertion(&grp, &grp2, err) == true);
|
||||
|
||||
ServiceGroup sgrp, sgrp2;
|
||||
IPService ip;
|
||||
@ -131,67 +131,67 @@ void FWBTreeTest::validateForInsertion()
|
||||
TCPService tcp;
|
||||
UDPService udp;
|
||||
CustomService custom;
|
||||
CPPUNIT_ASSERT(tree.validateForInsertion(&sgrp, &ip, err) == true);
|
||||
CPPUNIT_ASSERT(tree.validateForInsertion(&sgrp, &icmp, err) == true);
|
||||
CPPUNIT_ASSERT(tree.validateForInsertion(&sgrp, &tcp, err) == true);
|
||||
CPPUNIT_ASSERT(tree.validateForInsertion(&sgrp, &udp, err) == true);
|
||||
CPPUNIT_ASSERT(tree.validateForInsertion(&sgrp, &custom, err) == true);
|
||||
CPPUNIT_ASSERT(tree.validateForInsertion(&sgrp, &sgrp2, err) == true);
|
||||
QVERIFY(tree.validateForInsertion(&sgrp, &ip, err) == true);
|
||||
QVERIFY(tree.validateForInsertion(&sgrp, &icmp, err) == true);
|
||||
QVERIFY(tree.validateForInsertion(&sgrp, &tcp, err) == true);
|
||||
QVERIFY(tree.validateForInsertion(&sgrp, &udp, err) == true);
|
||||
QVERIFY(tree.validateForInsertion(&sgrp, &custom, err) == true);
|
||||
QVERIFY(tree.validateForInsertion(&sgrp, &sgrp2, err) == true);
|
||||
|
||||
Interval interval;
|
||||
IntervalGroup igrp;
|
||||
CPPUNIT_ASSERT(tree.validateForInsertion(&igrp, &interval, err) == true);
|
||||
QVERIFY(tree.validateForInsertion(&igrp, &interval, err) == true);
|
||||
|
||||
foreach (FWObject* folder, stdFolders)
|
||||
{
|
||||
if (folder->getName() == "Hosts")
|
||||
CPPUNIT_ASSERT(tree.validateForInsertion(folder, &host, err) == true);
|
||||
QVERIFY(tree.validateForInsertion(folder, &host, err) == true);
|
||||
if (folder->getName() == "Firewalls")
|
||||
CPPUNIT_ASSERT(tree.validateForInsertion(folder, &fw, err) == true);
|
||||
QVERIFY(tree.validateForInsertion(folder, &fw, err) == true);
|
||||
if (folder->getName() == "Addresses")
|
||||
CPPUNIT_ASSERT(tree.validateForInsertion(folder, &ipv4, err) == true);
|
||||
QVERIFY(tree.validateForInsertion(folder, &ipv4, err) == true);
|
||||
if (folder->getName() == "Addresses")
|
||||
CPPUNIT_ASSERT(tree.validateForInsertion(folder, &ipv6, err) == true);
|
||||
QVERIFY(tree.validateForInsertion(folder, &ipv6, err) == true);
|
||||
if (folder->getName() == "TCP")
|
||||
CPPUNIT_ASSERT(tree.validateForInsertion(folder, &tcp, err) == true);
|
||||
QVERIFY(tree.validateForInsertion(folder, &tcp, err) == true);
|
||||
if (folder->getName() == "UDP")
|
||||
CPPUNIT_ASSERT(tree.validateForInsertion(folder, &udp, err) == true);
|
||||
QVERIFY(tree.validateForInsertion(folder, &udp, err) == true);
|
||||
if (folder->getName() == "ICMP")
|
||||
CPPUNIT_ASSERT(tree.validateForInsertion(folder, &icmp, err) == true);
|
||||
QVERIFY(tree.validateForInsertion(folder, &icmp, err) == true);
|
||||
if (folder->getName() == "Address ranges")
|
||||
CPPUNIT_ASSERT(tree.validateForInsertion(folder, &addrrange, err) == true);
|
||||
QVERIFY(tree.validateForInsertion(folder, &addrrange, err) == true);
|
||||
if (folder->getName() == "Networks")
|
||||
CPPUNIT_ASSERT(tree.validateForInsertion(folder, &net, err) == true);
|
||||
QVERIFY(tree.validateForInsertion(folder, &net, err) == true);
|
||||
}
|
||||
|
||||
CPPUNIT_ASSERT(tree.validateForInsertion(&host, &ipv4, err) == false);
|
||||
CPPUNIT_ASSERT(tree.validateForInsertion(&firewall, &ipv4, err) == false);
|
||||
CPPUNIT_ASSERT(tree.validateForInsertion(&cluster, &ipv4, err) == false);
|
||||
CPPUNIT_ASSERT(tree.validateForInsertion(&grp, &ip, err) == false);
|
||||
CPPUNIT_ASSERT(tree.validateForInsertion(&sgrp, &ipv4, err) == false);
|
||||
CPPUNIT_ASSERT(tree.validateForInsertion(&grp, &interval, err) == false);
|
||||
CPPUNIT_ASSERT(tree.validateForInsertion(&sgrp, &interval, err) == false);
|
||||
QVERIFY(tree.validateForInsertion(&host, &ipv4, err) == false);
|
||||
QVERIFY(tree.validateForInsertion(&firewall, &ipv4, err) == false);
|
||||
QVERIFY(tree.validateForInsertion(&cluster, &ipv4, err) == false);
|
||||
QVERIFY(tree.validateForInsertion(&grp, &ip, err) == false);
|
||||
QVERIFY(tree.validateForInsertion(&sgrp, &ipv4, err) == false);
|
||||
QVERIFY(tree.validateForInsertion(&grp, &interval, err) == false);
|
||||
QVERIFY(tree.validateForInsertion(&sgrp, &interval, err) == false);
|
||||
|
||||
foreach (FWObject* folder, stdFolders)
|
||||
{
|
||||
if (folder->getName() == "Addresses")
|
||||
CPPUNIT_ASSERT(tree.validateForInsertion(folder, &host, err) == false);
|
||||
QVERIFY(tree.validateForInsertion(folder, &host, err) == false);
|
||||
if (folder->getName() == "Addresses")
|
||||
CPPUNIT_ASSERT(tree.validateForInsertion(folder, &fw, err) == false);
|
||||
QVERIFY(tree.validateForInsertion(folder, &fw, err) == false);
|
||||
if (folder->getName() == "Hosts")
|
||||
CPPUNIT_ASSERT(tree.validateForInsertion(folder, &ipv4, err) == false);
|
||||
QVERIFY(tree.validateForInsertion(folder, &ipv4, err) == false);
|
||||
if (folder->getName() == "Firewalls")
|
||||
CPPUNIT_ASSERT(tree.validateForInsertion(folder, &ipv6, err) == false);
|
||||
QVERIFY(tree.validateForInsertion(folder, &ipv6, err) == false);
|
||||
if (folder->getName() == "Networks")
|
||||
CPPUNIT_ASSERT(tree.validateForInsertion(folder, &tcp, err) == false);
|
||||
QVERIFY(tree.validateForInsertion(folder, &tcp, err) == false);
|
||||
if (folder->getName() == "TCP")
|
||||
CPPUNIT_ASSERT(tree.validateForInsertion(folder, &udp, err) == false);
|
||||
QVERIFY(tree.validateForInsertion(folder, &udp, err) == false);
|
||||
if (folder->getName() == "Address ranges")
|
||||
CPPUNIT_ASSERT(tree.validateForInsertion(folder, &icmp, err) == false);
|
||||
QVERIFY(tree.validateForInsertion(folder, &icmp, err) == false);
|
||||
if (folder->getName() == "ICMP")
|
||||
CPPUNIT_ASSERT(tree.validateForInsertion(folder, &addrrange, err) == false);
|
||||
QVERIFY(tree.validateForInsertion(folder, &addrrange, err) == false);
|
||||
if (folder->getName() == "UDP")
|
||||
CPPUNIT_ASSERT(tree.validateForInsertion(folder, &net, err) == false);
|
||||
QVERIFY(tree.validateForInsertion(folder, &net, err) == false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -26,24 +26,19 @@
|
||||
#ifndef FWBTREETEST_H
|
||||
#define FWBTREETEST_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include "FWBTree.h"
|
||||
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
|
||||
class FWBTreeTest : public CppUnit::TestFixture
|
||||
class FWBTreeTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
QSet<libfwbuilder::FWObject*> getStandardFolders(libfwbuilder::FWObject *root);
|
||||
|
||||
public:
|
||||
private slots:
|
||||
void isSystem();
|
||||
void validateForInsertion();
|
||||
|
||||
CPPUNIT_TEST_SUITE(FWBTreeTest);
|
||||
CPPUNIT_TEST(isSystem);
|
||||
CPPUNIT_TEST(validateForInsertion);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -22,21 +22,14 @@
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
#include <QTest>
|
||||
|
||||
#include <cppunit/ui/text/TestRunner.h>
|
||||
#include <cppunit/CompilerOutputter.h>
|
||||
#include "FWBTreeTest.h"
|
||||
|
||||
int fwbdebug;
|
||||
|
||||
|
||||
int main(int /*UNUSED argc*/, char ** /*UNUSED argv[]*/)
|
||||
int main()
|
||||
{
|
||||
CppUnit::TextUi::TestRunner runner;
|
||||
runner.addTest( FWBTreeTest::suite() );
|
||||
runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(),
|
||||
std::cerr ) );
|
||||
|
||||
runner.run();
|
||||
return 0;
|
||||
return QTest::qExec(new FWBTreeTest());
|
||||
}
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
SET(CMAKE_AUTOMOC ON)
|
||||
|
||||
add_executable(FWObjectTest FWObjectTest.cpp main.cpp)
|
||||
add_test(NAME FWObjectTest COMMAND FWObjectTest)
|
||||
|
||||
target_link_libraries(FWObjectTest PRIVATE fwbuilder xml2 xslt z cppunit)
|
||||
target_link_libraries(FWObjectTest PRIVATE fwbuilder xml2 xslt z Qt5::Test)
|
||||
|
||||
@ -22,6 +22,7 @@
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
#include <QTest>
|
||||
|
||||
#include "FWObjectTest.h"
|
||||
|
||||
@ -49,14 +50,14 @@ void FWObjectTest::cmpTest()
|
||||
FWObject *obj2 = db.create(Firewall::TYPENAME);
|
||||
obj2->duplicate(obj1);
|
||||
obj1->setStr("key", "value1");
|
||||
CPPUNIT_ASSERT(obj1->cmp(obj2) == false);
|
||||
QVERIFY(obj1->cmp(obj2) == false);
|
||||
obj2->setStr("key", "value2");
|
||||
CPPUNIT_ASSERT(obj1->cmp(obj2) == false);
|
||||
QVERIFY(obj1->cmp(obj2) == false);
|
||||
obj2->remStr("key");
|
||||
obj1->setStr("key", "");
|
||||
CPPUNIT_ASSERT(obj1->cmp(obj2) == false);
|
||||
QVERIFY(obj1->cmp(obj2) == false);
|
||||
obj1->remStr("key");
|
||||
CPPUNIT_ASSERT(obj2->cmp(obj1) == true);
|
||||
QVERIFY(obj2->cmp(obj1) == true);
|
||||
|
||||
|
||||
FWObject *ch1 = db.create(Interface::TYPENAME);
|
||||
@ -66,12 +67,12 @@ void FWObjectTest::cmpTest()
|
||||
|
||||
ch1->setStr("key", "value1");
|
||||
ch2->duplicate(ch1);
|
||||
CPPUNIT_ASSERT(ch1->cmp(ch2) == true);
|
||||
QVERIFY(ch1->cmp(ch2) == true);
|
||||
ch3->duplicate(ch1);
|
||||
CPPUNIT_ASSERT(ch1->cmp(ch3) == true);
|
||||
QVERIFY(ch1->cmp(ch3) == true);
|
||||
ch4->duplicate(ch1);
|
||||
ch4->setStr("key", "value2");
|
||||
CPPUNIT_ASSERT(ch1->cmp(ch4) == false);
|
||||
QVERIFY(ch1->cmp(ch4) == false);
|
||||
|
||||
obj1->add(ch1);
|
||||
obj1->add(ch2);
|
||||
@ -79,9 +80,9 @@ void FWObjectTest::cmpTest()
|
||||
obj2->add(ch3);
|
||||
obj2->add(ch4);
|
||||
|
||||
CPPUNIT_ASSERT(obj1->cmp(obj2, true) == false);
|
||||
QVERIFY(obj1->cmp(obj2, true) == false);
|
||||
|
||||
ch4->setStr("key", "value1");
|
||||
|
||||
CPPUNIT_ASSERT(obj1->cmp(obj2, true) == true);
|
||||
QVERIFY(obj1->cmp(obj2, true) == true);
|
||||
}
|
||||
|
||||
@ -26,24 +26,14 @@
|
||||
#ifndef OBJECTMATCHERTEST_H
|
||||
#define OBJECTMATCHERTEST_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include <cppunit/TestCase.h>
|
||||
#include <cppunit/TestSuite.h>
|
||||
#include <cppunit/TestCaller.h>
|
||||
|
||||
class FWObjectTest : public CppUnit::TestCase
|
||||
class FWObjectTest : public QObject
|
||||
{
|
||||
public:
|
||||
void cmpTest();
|
||||
Q_OBJECT
|
||||
|
||||
static CppUnit::Test *suite()
|
||||
{
|
||||
CppUnit::TestSuite *suiteOfTests = new CppUnit::TestSuite( "FWObjectTest" );
|
||||
suiteOfTests->addTest( new CppUnit::TestCaller<FWObjectTest>(
|
||||
"cmpTest",
|
||||
&FWObjectTest::cmpTest ) );
|
||||
return suiteOfTests;
|
||||
}
|
||||
private slots:
|
||||
void cmpTest();
|
||||
};
|
||||
|
||||
#endif // OBJECTMATCHERTEST_H
|
||||
|
||||
@ -22,9 +22,8 @@
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
#include <QTest>
|
||||
|
||||
#include <cppunit/ui/text/TestRunner.h>
|
||||
#include <cppunit/CompilerOutputter.h>
|
||||
#include "FWObjectTest.h"
|
||||
#include "fwbuilder/FWObjectDatabase.h"
|
||||
|
||||
@ -33,19 +32,11 @@
|
||||
using namespace libfwbuilder;
|
||||
|
||||
int fwbdebug = 0;
|
||||
//QString user_name;
|
||||
std::string platform;
|
||||
|
||||
int main( int, char** argv)
|
||||
int main()
|
||||
{
|
||||
//init(argv);
|
||||
init();
|
||||
|
||||
CppUnit::TextUi::TestRunner runner;
|
||||
runner.addTest( FWObjectTest::suite() );
|
||||
runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(),
|
||||
std::cerr ) );
|
||||
|
||||
runner.run();
|
||||
return 0;
|
||||
return QTest::qExec(new FWObjectTest());
|
||||
}
|
||||
|
||||
@ -3,6 +3,6 @@ SET(CMAKE_AUTOMOC ON)
|
||||
add_executable(FWWindowTest FWWindowTest.cpp main_FWWindowTest.cpp)
|
||||
add_test(NAME FWWindowTest COMMAND FWWindowTest)
|
||||
|
||||
target_link_libraries(FWWindowTest PRIVATE test_main netsnmp gui import fwbparser antlr common iptlib fwbpf fwbjuniper fwbcisco compilerdriver fwcompiler fwbuilder xml2 xslt z pthread Qt5::Test)
|
||||
target_link_libraries(FWWindowTest PRIVATE test_main gui import fwbparser antlr common iptlib fwbpf fwbjuniper fwbcisco compilerdriver fwcompiler fwbuilder netsnmp xml2 xslt z pthread Qt5::Test)
|
||||
#target_link_libraries(fwb_ipt common iptlib compilerdriver fwcompiler fwbuilder xml2 pthread m xslt z)
|
||||
#target_link_libraries(fwbuilder-gui gui import fwbparser antlr common iptlib fwbpf fwbjuniper fwbcisco compilerdriver fwcompiler fwbuilder xml2 m xslt z OpenSSL::Crypto pthread)
|
||||
|
||||
@ -38,9 +38,9 @@ using namespace std;
|
||||
using namespace libfwbuilder;
|
||||
|
||||
int fwbdebug = 0;
|
||||
FWWindow *mw = nullptr;
|
||||
FWBSettings *st = nullptr;
|
||||
FWBApplication *app = nullptr;
|
||||
FWWindow *mw = nullptr;
|
||||
FWBSettings *st = nullptr;
|
||||
FWBApplication *app = nullptr;
|
||||
|
||||
|
||||
extern void build_app(int argc, char** argv,
|
||||
@ -48,16 +48,18 @@ extern void build_app(int argc, char** argv,
|
||||
FWBSettings** st);
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
app = new FWBApplication(argc, argv);
|
||||
app->setOrganizationName(QLatin1String("NetCitadel"));
|
||||
app->setApplicationName(QLatin1String("Firewall Builder"));
|
||||
{
|
||||
app = new FWBApplication(argc, argv);
|
||||
app->setOrganizationName(QLatin1String("NetCitadel"));
|
||||
app->setApplicationName(QLatin1String("Firewall Builder"));
|
||||
|
||||
build_app(argc, argv, &app, &st);
|
||||
|
||||
|
||||
QTest::qExec(new FWWindowTest());
|
||||
int testResult = QTest::qExec(new FWWindowTest());
|
||||
|
||||
if (QFile::exists("test_work.fwb"))
|
||||
QFile::remove("test_work.fwb");
|
||||
if (QFile::exists("test_work.fwb"))
|
||||
QFile::remove("test_work.fwb");
|
||||
|
||||
return testResult;
|
||||
}
|
||||
|
||||
@ -3,4 +3,4 @@ SET(CMAKE_AUTOMOC ON)
|
||||
add_executable(FirewallDialogTest FirewallDialogTest.cpp main_FirewallDialogTest.cpp)
|
||||
add_test(NAME FirewallDialogTest COMMAND FirewallDialogTest)
|
||||
|
||||
target_link_libraries(FirewallDialogTest PRIVATE test_main netsnmp gui import fwbparser antlr common iptlib fwbpf fwbjuniper fwbcisco compilerdriver fwcompiler fwbuilder xml2 xslt z pthread Qt5::Test)
|
||||
target_link_libraries(FirewallDialogTest PRIVATE test_main gui import fwbparser antlr common iptlib fwbpf fwbjuniper fwbcisco compilerdriver fwcompiler fwbuilder netsnmp xml2 xslt z pthread Qt5::Test)
|
||||
|
||||
@ -38,9 +38,9 @@ using namespace std;
|
||||
using namespace libfwbuilder;
|
||||
|
||||
int fwbdebug = 0;
|
||||
FWWindow *mw = nullptr;
|
||||
FWBSettings *st = nullptr;
|
||||
FWBApplication *app = nullptr;
|
||||
FWWindow *mw = nullptr;
|
||||
FWBSettings *st = nullptr;
|
||||
FWBApplication *app = nullptr;
|
||||
|
||||
|
||||
extern void build_app(int argc, char** argv,
|
||||
@ -48,16 +48,18 @@ extern void build_app(int argc, char** argv,
|
||||
FWBSettings** st);
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
app = new FWBApplication(argc, argv);
|
||||
app->setOrganizationName(QLatin1String("NetCitadel"));
|
||||
app->setApplicationName(QLatin1String("Firewall Builder"));
|
||||
{
|
||||
app = new FWBApplication(argc, argv);
|
||||
app->setOrganizationName(QLatin1String("NetCitadel"));
|
||||
app->setApplicationName(QLatin1String("Firewall Builder"));
|
||||
|
||||
build_app(argc, argv, &app, &st);
|
||||
|
||||
|
||||
QTest::qExec(new FirewallDialogTest());
|
||||
int testResult = QTest::qExec(new FirewallDialogTest());
|
||||
|
||||
if (QFile::exists("test_work.fwb"))
|
||||
QFile::remove("test_work.fwb");
|
||||
if (QFile::exists("test_work.fwb"))
|
||||
QFile::remove("test_work.fwb");
|
||||
|
||||
return testResult;
|
||||
}
|
||||
|
||||
@ -3,4 +3,4 @@ SET(CMAKE_AUTOMOC ON)
|
||||
add_executable(GroupObjectDialogTest GroupObjectDialogTest.cpp main_GroupObjectDialogTest.cpp)
|
||||
add_test(NAME GroupObjectDialogTest COMMAND GroupObjectDialogTest)
|
||||
|
||||
target_link_libraries(GroupObjectDialogTest PRIVATE test_main netsnmp gui import fwbparser antlr common iptlib fwbpf fwbjuniper fwbcisco compilerdriver fwcompiler fwbuilder xml2 xslt z pthread Qt5::Test)
|
||||
target_link_libraries(GroupObjectDialogTest PRIVATE test_main gui import fwbparser antlr common iptlib fwbpf fwbjuniper fwbcisco compilerdriver fwcompiler fwbuilder netsnmp xml2 xslt z pthread Qt5::Test)
|
||||
|
||||
@ -38,9 +38,9 @@ using namespace std;
|
||||
using namespace libfwbuilder;
|
||||
|
||||
int fwbdebug = 0;
|
||||
FWWindow *mw = nullptr;
|
||||
FWBSettings *st = nullptr;
|
||||
FWBApplication *app = nullptr;
|
||||
FWWindow *mw = nullptr;
|
||||
FWBSettings *st = nullptr;
|
||||
FWBApplication *app = nullptr;
|
||||
|
||||
|
||||
extern void build_app(int argc, char** argv,
|
||||
@ -48,16 +48,18 @@ extern void build_app(int argc, char** argv,
|
||||
FWBSettings** st);
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
app = new FWBApplication(argc, argv);
|
||||
app->setOrganizationName(QLatin1String("NetCitadel"));
|
||||
app->setApplicationName(QLatin1String("Firewall Builder"));
|
||||
{
|
||||
app = new FWBApplication(argc, argv);
|
||||
app->setOrganizationName(QLatin1String("NetCitadel"));
|
||||
app->setApplicationName(QLatin1String("Firewall Builder"));
|
||||
|
||||
build_app(argc, argv, &app, &st);
|
||||
|
||||
|
||||
QTest::qExec(new GroupObjectDialogTest());
|
||||
int testResult = QTest::qExec(new GroupObjectDialogTest());
|
||||
|
||||
if (QFile::exists("test_work.fwb"))
|
||||
QFile::remove("test_work.fwb");
|
||||
if (QFile::exists("test_work.fwb"))
|
||||
QFile::remove("test_work.fwb");
|
||||
|
||||
return testResult;
|
||||
}
|
||||
|
||||
@ -3,4 +3,4 @@ SET(CMAKE_AUTOMOC ON)
|
||||
add_executable(ICMP6ServiceDialogTest ICMP6ServiceDialogTest.cpp main_ICMP6ServiceDialogTest.cpp)
|
||||
add_test(NAME ICMP6ServiceDialogTest COMMAND ICMP6ServiceDialogTest)
|
||||
|
||||
target_link_libraries(ICMP6ServiceDialogTest PRIVATE test_main netsnmp gui import fwbparser antlr common iptlib fwbpf fwbjuniper fwbcisco compilerdriver fwcompiler fwbuilder xml2 xslt z pthread Qt5::Test)
|
||||
target_link_libraries(ICMP6ServiceDialogTest PRIVATE test_main gui import fwbparser antlr common iptlib fwbpf fwbjuniper fwbcisco compilerdriver fwcompiler fwbuilder netsnmp xml2 xslt z pthread Qt5::Test)
|
||||
|
||||
@ -38,9 +38,9 @@ using namespace std;
|
||||
using namespace libfwbuilder;
|
||||
|
||||
int fwbdebug = 0;
|
||||
FWWindow *mw = nullptr;
|
||||
FWBSettings *st = nullptr;
|
||||
FWBApplication *app = nullptr;
|
||||
FWWindow *mw = nullptr;
|
||||
FWBSettings *st = nullptr;
|
||||
FWBApplication *app = nullptr;
|
||||
|
||||
|
||||
extern void build_app(int argc, char** argv,
|
||||
@ -48,16 +48,18 @@ extern void build_app(int argc, char** argv,
|
||||
FWBSettings** st);
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
app = new FWBApplication(argc, argv);
|
||||
app->setOrganizationName(QLatin1String("NetCitadel"));
|
||||
app->setApplicationName(QLatin1String("Firewall Builder"));
|
||||
{
|
||||
app = new FWBApplication(argc, argv);
|
||||
app->setOrganizationName(QLatin1String("NetCitadel"));
|
||||
app->setApplicationName(QLatin1String("Firewall Builder"));
|
||||
|
||||
build_app(argc, argv, &app, &st);
|
||||
|
||||
|
||||
QTest::qExec(new ICMP6ServiceDialogTest());
|
||||
int testResult = QTest::qExec(new ICMP6ServiceDialogTest());
|
||||
|
||||
if (QFile::exists("test_work.fwb"))
|
||||
QFile::remove("test_work.fwb");
|
||||
if (QFile::exists("test_work.fwb"))
|
||||
QFile::remove("test_work.fwb");
|
||||
|
||||
return testResult;
|
||||
}
|
||||
|
||||
@ -3,4 +3,4 @@ SET(CMAKE_AUTOMOC ON)
|
||||
add_executable(ICMPServiceDialogTest ICMPServiceDialogTest.cpp main_ICMPServiceDialogTest.cpp)
|
||||
add_test(NAME ICMPServiceDialogTest COMMAND ICMPServiceDialogTest)
|
||||
|
||||
target_link_libraries(ICMPServiceDialogTest PRIVATE test_main netsnmp gui import fwbparser antlr common iptlib fwbpf fwbjuniper fwbcisco compilerdriver fwcompiler fwbuilder xml2 xslt z pthread Qt5::Test)
|
||||
target_link_libraries(ICMPServiceDialogTest PRIVATE test_main gui import fwbparser antlr common iptlib fwbpf fwbjuniper fwbcisco compilerdriver fwcompiler fwbuilder netsnmp xml2 xslt z pthread Qt5::Test)
|
||||
|
||||
@ -38,9 +38,9 @@ using namespace std;
|
||||
using namespace libfwbuilder;
|
||||
|
||||
int fwbdebug = 0;
|
||||
FWWindow *mw = nullptr;
|
||||
FWBSettings *st = nullptr;
|
||||
FWBApplication *app = nullptr;
|
||||
FWWindow *mw = nullptr;
|
||||
FWBSettings *st = nullptr;
|
||||
FWBApplication *app = nullptr;
|
||||
|
||||
|
||||
extern void build_app(int argc, char** argv,
|
||||
@ -48,16 +48,18 @@ extern void build_app(int argc, char** argv,
|
||||
FWBSettings** st);
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
app = new FWBApplication(argc, argv);
|
||||
app->setOrganizationName(QLatin1String("NetCitadel"));
|
||||
app->setApplicationName(QLatin1String("Firewall Builder"));
|
||||
{
|
||||
app = new FWBApplication(argc, argv);
|
||||
app->setOrganizationName(QLatin1String("NetCitadel"));
|
||||
app->setApplicationName(QLatin1String("Firewall Builder"));
|
||||
|
||||
build_app(argc, argv, &app, &st);
|
||||
|
||||
|
||||
QTest::qExec(new ICMPServiceDialogTest());
|
||||
int testResult = QTest::qExec(new ICMPServiceDialogTest());
|
||||
|
||||
if (QFile::exists("test_work.fwb"))
|
||||
QFile::remove("test_work.fwb");
|
||||
if (QFile::exists("test_work.fwb"))
|
||||
QFile::remove("test_work.fwb");
|
||||
|
||||
return testResult;
|
||||
}
|
||||
|
||||
@ -3,4 +3,4 @@ SET(CMAKE_AUTOMOC ON)
|
||||
add_executable(IPDialogTest IPDialogTest.cpp main_IPDialogTest.cpp)
|
||||
add_test(NAME IPDialogTest COMMAND IPDialogTest)
|
||||
|
||||
target_link_libraries(IPDialogTest PRIVATE test_main netsnmp gui import fwbparser antlr common iptlib fwbpf fwbjuniper fwbcisco compilerdriver fwcompiler fwbuilder xml2 xslt z pthread Qt5::Test)
|
||||
target_link_libraries(IPDialogTest PRIVATE test_main gui import fwbparser antlr common iptlib fwbpf fwbjuniper fwbcisco compilerdriver fwcompiler fwbuilder netsnmp xml2 xslt z pthread Qt5::Test)
|
||||
|
||||
@ -37,9 +37,9 @@ using namespace std;
|
||||
using namespace libfwbuilder;
|
||||
|
||||
int fwbdebug = 0;
|
||||
FWWindow *mw = nullptr;
|
||||
FWBSettings *st = nullptr;
|
||||
FWBApplication *app = nullptr;
|
||||
FWWindow *mw = nullptr;
|
||||
FWBSettings *st = nullptr;
|
||||
FWBApplication *app = nullptr;
|
||||
|
||||
|
||||
extern void build_app(int argc, char** argv,
|
||||
@ -47,16 +47,18 @@ extern void build_app(int argc, char** argv,
|
||||
FWBSettings** st);
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
app = new FWBApplication(argc, argv);
|
||||
app->setOrganizationName(QLatin1String("NetCitadel"));
|
||||
app->setApplicationName(QLatin1String("Firewall Builder"));
|
||||
{
|
||||
app = new FWBApplication(argc, argv);
|
||||
app->setOrganizationName(QLatin1String("NetCitadel"));
|
||||
app->setApplicationName(QLatin1String("Firewall Builder"));
|
||||
|
||||
build_app(argc, argv, &app, &st);
|
||||
|
||||
|
||||
QTest::qExec(new IPDialogTest());
|
||||
int testResult = QTest::qExec(new IPDialogTest());
|
||||
|
||||
if (QFile::exists("test_work.fwb"))
|
||||
QFile::remove("test_work.fwb");
|
||||
if (QFile::exists("test_work.fwb"))
|
||||
QFile::remove("test_work.fwb");
|
||||
|
||||
return testResult;
|
||||
}
|
||||
|
||||
@ -3,4 +3,4 @@ SET(CMAKE_AUTOMOC ON)
|
||||
add_executable(IPServiceDialogTest IPServiceDialogTest.cpp main_IPServiceDialogTest.cpp)
|
||||
add_test(NAME IPServiceDialogTest COMMAND IPServiceDialogTest)
|
||||
|
||||
target_link_libraries(IPServiceDialogTest PRIVATE test_main netsnmp gui import fwbparser antlr common iptlib fwbpf fwbjuniper fwbcisco compilerdriver fwcompiler fwbuilder xml2 xslt z pthread Qt5::Test)
|
||||
target_link_libraries(IPServiceDialogTest PRIVATE test_main gui import fwbparser antlr common iptlib fwbpf fwbjuniper fwbcisco compilerdriver fwcompiler fwbuilder netsnmp xml2 xslt z pthread Qt5::Test)
|
||||
|
||||
@ -37,9 +37,9 @@ using namespace std;
|
||||
using namespace libfwbuilder;
|
||||
|
||||
int fwbdebug = 0;
|
||||
FWWindow *mw = nullptr;
|
||||
FWBSettings *st = nullptr;
|
||||
FWBApplication *app = nullptr;
|
||||
FWWindow *mw = nullptr;
|
||||
FWBSettings *st = nullptr;
|
||||
FWBApplication *app = nullptr;
|
||||
|
||||
|
||||
extern void build_app(int argc, char** argv,
|
||||
@ -47,16 +47,18 @@ extern void build_app(int argc, char** argv,
|
||||
FWBSettings** st);
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
app = new FWBApplication(argc, argv);
|
||||
app->setOrganizationName(QLatin1String("NetCitadel"));
|
||||
app->setApplicationName(QLatin1String("Firewall Builder"));
|
||||
{
|
||||
app = new FWBApplication(argc, argv);
|
||||
app->setOrganizationName(QLatin1String("NetCitadel"));
|
||||
app->setApplicationName(QLatin1String("Firewall Builder"));
|
||||
|
||||
build_app(argc, argv, &app, &st);
|
||||
|
||||
|
||||
QTest::qExec(new IPServiceDialogTest());
|
||||
int testResult = QTest::qExec(new IPServiceDialogTest());
|
||||
|
||||
if (QFile::exists("test_work.fwb"))
|
||||
QFile::remove("test_work.fwb");
|
||||
if (QFile::exists("test_work.fwb"))
|
||||
QFile::remove("test_work.fwb");
|
||||
|
||||
return testResult;
|
||||
}
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
set (CMAKE_AUTOMOC ON)
|
||||
|
||||
add_executable(ImporterTest ImporterTest.cpp main_ImporterTest.cpp)
|
||||
add_test(NAME ImporterTest COMMAND ImporterTest)
|
||||
|
||||
target_link_libraries(ImporterTest PRIVATE test_main netsnmp gui import fwbparser antlr common iptlib fwbpf fwbjuniper fwbcisco compilerdriver fwcompiler fwbuilder xml2 xslt z pthread cppunit)
|
||||
target_link_libraries(ImporterTest PRIVATE test_main netsnmp gui import fwbparser antlr common iptlib fwbpf fwbjuniper fwbcisco compilerdriver fwcompiler fwbuilder xml2 xslt z pthread Qt5::Test)
|
||||
|
||||
file(COPY test_data DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
|
||||
@ -43,6 +43,7 @@
|
||||
#include "fwbuilder/TagService.h"
|
||||
#include "fwbuilder/Constants.h"
|
||||
|
||||
#include <QTest>
|
||||
#include <QDebug>
|
||||
#include <QFile>
|
||||
#include <QStringList>
|
||||
@ -55,7 +56,7 @@ using namespace libfwbuilder;
|
||||
|
||||
extern string platform;
|
||||
|
||||
const char* iptables_sample =
|
||||
const char* iptables_sample =
|
||||
"# Generated by iptables-save %VERSION% on Mon Apr 11 15:50:58 2011\n"
|
||||
"*filter\n"
|
||||
":INPUT ACCEPT [0:0]\n"
|
||||
@ -82,7 +83,7 @@ class UpgradePredicate: public XMLTools::UpgradePredicate
|
||||
}
|
||||
};
|
||||
|
||||
void ImporterTest::setUp()
|
||||
void ImporterTest::init()
|
||||
{
|
||||
//init();
|
||||
|
||||
@ -138,15 +139,15 @@ void ImporterTest::compareResults(QueueLogger* logger,
|
||||
QString result_file = rr.readAll();
|
||||
QStringList expected_result = result_file.split("\n");
|
||||
|
||||
CPPUNIT_ASSERT_MESSAGE(
|
||||
QVERIFY2(
|
||||
expected_result.size() == obtained_result.size(),
|
||||
QString(
|
||||
"Sizes of the generated importer output and test files are different.\n"
|
||||
"Expected: %1 (%2)\n"
|
||||
"Obtained: %3 (%4)\n"
|
||||
"diff -u %1 %3 | less -S")
|
||||
.arg(expected_result_file_name).arg(expected_result.size())
|
||||
.arg(obtained_result_file_name).arg(obtained_result.size()).toStdString(),
|
||||
expected_result.size() == obtained_result.size());
|
||||
.arg(obtained_result_file_name).arg(obtained_result.size()).toStdString().data());
|
||||
|
||||
int max_idx = max(expected_result.size(), obtained_result.size());
|
||||
for (int i=0; i < max_idx; ++i)
|
||||
@ -156,8 +157,7 @@ void ImporterTest::compareResults(QueueLogger* logger,
|
||||
.arg(i)
|
||||
.arg(expected_result[i])
|
||||
.arg(obtained_result[i]);
|
||||
CPPUNIT_ASSERT_MESSAGE(
|
||||
err.toStdString(), obtained_result[i] == expected_result[i]);
|
||||
QVERIFY2(obtained_result[i] == expected_result[i], err.toStdString().data());
|
||||
}
|
||||
}
|
||||
|
||||
@ -172,7 +172,7 @@ void ImporterTest::compareFwbFiles(QString expected_result_file_name,
|
||||
QString result_file = rr.readAll();
|
||||
rr.close();
|
||||
obtained_result = result_file.split("\n");
|
||||
|
||||
|
||||
QFile er(expected_result_file_name);
|
||||
er.open(QFile::ReadOnly);
|
||||
result_file = er.readAll();
|
||||
@ -187,12 +187,12 @@ void ImporterTest::compareFwbFiles(QString expected_result_file_name,
|
||||
"Obtained: %3 (%4)\n"
|
||||
"diff -u %1 %3 | less -S");
|
||||
|
||||
CPPUNIT_ASSERT_MESSAGE(
|
||||
QVERIFY2(
|
||||
expected_result.size() == obtained_result.size(),
|
||||
err
|
||||
.arg(expected_result_file_name).arg(expected_result.size())
|
||||
.arg(obtained_result_file_name).arg(obtained_result.size())
|
||||
.toStdString(),
|
||||
expected_result.size() == obtained_result.size());
|
||||
.toStdString().data());
|
||||
|
||||
QRegExp last_mod_re("lastModified=\"\\d+\"");
|
||||
int max_idx = max(expected_result.size(), obtained_result.size());
|
||||
@ -212,8 +212,7 @@ void ImporterTest::compareFwbFiles(QString expected_result_file_name,
|
||||
.arg(i)
|
||||
.arg(expected_result[i])
|
||||
.arg(obtained_result[i]);
|
||||
CPPUNIT_ASSERT_MESSAGE(
|
||||
err.toStdString(), obtained_result[i] == expected_result[i]);
|
||||
QVERIFY2(obtained_result[i] == expected_result[i], err.toStdString().data());
|
||||
}
|
||||
}
|
||||
|
||||
@ -231,7 +230,12 @@ void ImporterTest::IOSImporterTest()
|
||||
|
||||
Importer* imp = new IOSImporter(lib, instream, logger, "test_fw");
|
||||
imp->setAddStandardCommentsFlag(true);
|
||||
CPPUNIT_ASSERT_NO_THROW( imp->run() );
|
||||
|
||||
try {
|
||||
imp->run();
|
||||
} catch (const std::exception &e) {
|
||||
QFAIL(std::string("Exception thrown: ").append(e.what()).data());
|
||||
}
|
||||
|
||||
imp->finalize();
|
||||
|
||||
@ -256,7 +260,12 @@ void ImporterTest::IPTImporterTest()
|
||||
|
||||
Importer* imp = new IPTImporter(lib, instream, logger, "test_fw");
|
||||
imp->setAddStandardCommentsFlag(true);
|
||||
CPPUNIT_ASSERT_NO_THROW( imp->run() );
|
||||
|
||||
try {
|
||||
imp->run();
|
||||
} catch (const std::exception &e) {
|
||||
QFAIL(std::string("Exception thrown: ").append(e.what()).data());
|
||||
}
|
||||
|
||||
imp->finalize();
|
||||
|
||||
@ -281,7 +290,12 @@ void ImporterTest::IPTImporterNoNatTest()
|
||||
|
||||
Importer* imp = new IPTImporter(lib, instream, logger, "test_fw");
|
||||
imp->setAddStandardCommentsFlag(true);
|
||||
CPPUNIT_ASSERT_NO_THROW( imp->run() );
|
||||
|
||||
try {
|
||||
imp->run();
|
||||
} catch (const std::exception &e) {
|
||||
QFAIL(std::string("Exception thrown: ").append(e.what()).data());
|
||||
}
|
||||
|
||||
imp->finalize();
|
||||
|
||||
@ -317,7 +331,12 @@ void ImporterTest::IPTImporterParseVersionsTest()
|
||||
|
||||
Importer* imp = new IPTImporter(lib, instream, logger, "test_fw");
|
||||
imp->setAddStandardCommentsFlag(true);
|
||||
CPPUNIT_ASSERT_NO_THROW( imp->run() );
|
||||
|
||||
try {
|
||||
imp->run();
|
||||
} catch (const std::exception &e) {
|
||||
QFAIL(std::string("Exception thrown: ").append(e.what()).data());
|
||||
}
|
||||
|
||||
imp->finalize();
|
||||
|
||||
|
||||
@ -30,41 +30,34 @@
|
||||
#include "fwbuilder/FWException.h"
|
||||
#include "fwbuilder/Logger.h"
|
||||
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
#include <map>
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
|
||||
|
||||
class ImporterTest : public CppUnit::TestFixture
|
||||
class ImporterTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
libfwbuilder::FWObjectDatabase *db;
|
||||
libfwbuilder::Library *lib;
|
||||
libfwbuilder::QueueLogger *logger;
|
||||
int predictable_id_tracker;
|
||||
std::map<std::string, std::string> id_mapping;
|
||||
|
||||
|
||||
void compareResults(libfwbuilder::QueueLogger* logger,
|
||||
QString expected_result_file_name,
|
||||
QString obtained_result_file_name);
|
||||
void compareFwbFiles(QString expected_result_file_name,
|
||||
QString obtained_result_file_name);
|
||||
|
||||
public:
|
||||
void setUp();
|
||||
private slots:
|
||||
void init();
|
||||
void IOSImporterTest();
|
||||
void IPTImporterTest();
|
||||
void IPTImporterNoNatTest();
|
||||
void IPTImporterParseVersionsTest();
|
||||
|
||||
CPPUNIT_TEST_SUITE(ImporterTest);
|
||||
CPPUNIT_TEST(IOSImporterTest);
|
||||
CPPUNIT_TEST(IPTImporterTest);
|
||||
CPPUNIT_TEST(IPTImporterNoNatTest);
|
||||
CPPUNIT_TEST(IPTImporterParseVersionsTest);
|
||||
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -23,8 +23,6 @@
|
||||
|
||||
*/
|
||||
|
||||
#include <cppunit/ui/text/TestRunner.h>
|
||||
#include <cppunit/CompilerOutputter.h>
|
||||
#include "ImporterTest.h"
|
||||
#include "fwbuilder/Resources.h"
|
||||
|
||||
@ -32,6 +30,7 @@
|
||||
#include "FWBSettings.h"
|
||||
#include "FWBApplication.h"
|
||||
|
||||
#include <QTest>
|
||||
#include <QApplication>
|
||||
#include <QString>
|
||||
#include <string>
|
||||
@ -39,10 +38,9 @@
|
||||
#include "common/init.cpp"
|
||||
|
||||
int fwbdebug = 0;
|
||||
//QString user_name;
|
||||
FWWindow *mw = nullptr;
|
||||
FWBSettings *st = nullptr;
|
||||
FWBApplication *app = nullptr;
|
||||
FWWindow *mw = nullptr;
|
||||
FWBSettings *st = nullptr;
|
||||
FWBApplication *app = nullptr;
|
||||
std::string platform;
|
||||
|
||||
int main(int argc, char** argv)
|
||||
@ -51,11 +49,6 @@ int main(int argc, char** argv)
|
||||
|
||||
init(argv);
|
||||
Resources res(Constants::getResourcesFilePath());
|
||||
CppUnit::TextUi::TestRunner runner;
|
||||
runner.addTest( ImporterTest::suite() );
|
||||
runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(),
|
||||
std::cerr ) );
|
||||
|
||||
runner.run();
|
||||
return 0;
|
||||
return QTest::qExec(new ImporterTest());
|
||||
}
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
set (CMAKE_AUTOMOC ON)
|
||||
|
||||
add_executable(Inet6AddrMaskTest Inet6AddrMaskTest.cpp main.cpp)
|
||||
add_test(NAME Inet6AddrMaskTest COMMAND Inet6AddrMaskTest)
|
||||
|
||||
target_link_libraries(Inet6AddrMaskTest PRIVATE fwbuilder xml2 xslt z cppunit)
|
||||
target_link_libraries(Inet6AddrMaskTest PRIVATE fwbuilder xml2 xslt z Qt5::Test)
|
||||
|
||||
@ -27,6 +27,8 @@
|
||||
#include <fwbuilder/Inet6AddrMask.h>
|
||||
#include <fwbuilder/uint128.h>
|
||||
|
||||
#include <QTest>
|
||||
|
||||
using namespace libfwbuilder;
|
||||
using namespace std;
|
||||
|
||||
@ -36,110 +38,119 @@ void Inet6AddrMaskTest::testUInt128ToInetAddr6()
|
||||
uint128 x = x1.to_uint128();
|
||||
InetAddr x2(AF_INET6, 0);
|
||||
x2.init_from_uint128(x);
|
||||
CPPUNIT_ASSERT(x2.toString() == "::1");
|
||||
QVERIFY(x2.toString() == "::1");
|
||||
|
||||
InetAddr x3(AF_INET6, "::8000");
|
||||
x = x3.to_uint128();
|
||||
InetAddr x4(AF_INET6, 0);
|
||||
x4.init_from_uint128(x);
|
||||
CPPUNIT_ASSERT(x4.toString() == "::8000");
|
||||
QVERIFY(x4.toString() == "::8000");
|
||||
|
||||
InetAddr x5(AF_INET6, "::ff00");
|
||||
x = x5.to_uint128();
|
||||
InetAddr x6(AF_INET6, 0);
|
||||
x6.init_from_uint128(x);
|
||||
CPPUNIT_ASSERT(x6.toString() == "::ff00");
|
||||
QVERIFY(x6.toString() == "::ff00");
|
||||
|
||||
InetAddr x90(AF_INET6, "fe80::20c:29ff:fed2:cca1");
|
||||
x = x90.to_uint128();
|
||||
InetAddr x91(AF_INET6, 0);
|
||||
x91.init_from_uint128(x);
|
||||
CPPUNIT_ASSERT(x91.toString() == "fe80::20c:29ff:fed2:cca1");
|
||||
QVERIFY(x91.toString() == "fe80::20c:29ff:fed2:cca1");
|
||||
}
|
||||
|
||||
void Inet6AddrMaskTest::testInetAddr6ToUInt128()
|
||||
{
|
||||
InetAddr x1(AF_INET6, 0);
|
||||
uint128 x = x1.to_uint128();
|
||||
CPPUNIT_ASSERT(x.to_string() == "0");
|
||||
QVERIFY(x.to_string() == "0");
|
||||
|
||||
InetAddr x2(AF_INET6, 1);
|
||||
x = x2.to_uint128();
|
||||
CPPUNIT_ASSERT(x.to_string() == "800000000000000000000000");
|
||||
QVERIFY(x.to_string() == "800000000000000000000000");
|
||||
|
||||
InetAddr x3(AF_INET6, 8);
|
||||
x = x3.to_uint128();
|
||||
CPPUNIT_ASSERT(x.to_string() == "FF0000000000000000000000");
|
||||
QVERIFY(x.to_string() == "FF0000000000000000000000");
|
||||
|
||||
InetAddr x4(AF_INET6, 16);
|
||||
x = x4.to_uint128();
|
||||
CPPUNIT_ASSERT(x.to_string() == "FFFF00000000000000000000");
|
||||
QVERIFY(x.to_string() == "FFFF00000000000000000000");
|
||||
|
||||
InetAddr x5(AF_INET6, 64);
|
||||
x = x5.to_uint128();
|
||||
CPPUNIT_ASSERT(x.to_string() == "FFFFFFFFFFFFFFFF00000000");
|
||||
QVERIFY(x.to_string() == "FFFFFFFFFFFFFFFF00000000");
|
||||
|
||||
InetAddr x6(AF_INET6, 128);
|
||||
x = x6.to_uint128();
|
||||
CPPUNIT_ASSERT(x.to_string() == "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF");
|
||||
QVERIFY(x.to_string() == "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF");
|
||||
|
||||
InetAddr x7(AF_INET6, "fe80::20c:29ff:fed2:cca1");
|
||||
x = x7.to_uint128();
|
||||
CPPUNIT_ASSERT(x.to_string() == "FE8000000000000020C29FFFED2CCA1");
|
||||
QVERIFY(x.to_string() == "FE8000000000000020C29FFFED2CCA1");
|
||||
}
|
||||
|
||||
void Inet6AddrMaskTest::testIntToInetAddr6()
|
||||
{
|
||||
InetAddr x1(AF_INET6, 0);
|
||||
CPPUNIT_ASSERT(x1.toString()=="::" && x1.getLength()==128);
|
||||
QVERIFY(x1.toString()=="::" && x1.getLength()==128);
|
||||
|
||||
InetAddr x2(AF_INET6, 1);
|
||||
CPPUNIT_ASSERT(x2.toString()=="8000::" && x2.getLength()==1);
|
||||
QVERIFY(x2.toString()=="8000::" && x2.getLength()==1);
|
||||
|
||||
InetAddr x3(AF_INET6, 8);
|
||||
CPPUNIT_ASSERT(x3.toString()=="ff00::" && x3.getLength()==8);
|
||||
QVERIFY(x3.toString()=="ff00::" && x3.getLength()==8);
|
||||
|
||||
InetAddr x4(AF_INET6, 16);
|
||||
CPPUNIT_ASSERT(x4.toString()=="ffff::" && x4.getLength()==16);
|
||||
QVERIFY(x4.toString()=="ffff::" && x4.getLength()==16);
|
||||
|
||||
InetAddr x5(AF_INET6, 64);
|
||||
CPPUNIT_ASSERT(x5.toString()=="ffff:ffff:ffff:ffff::" && x5.getLength()==64);
|
||||
QVERIFY(x5.toString()=="ffff:ffff:ffff:ffff::" && x5.getLength()==64);
|
||||
|
||||
InetAddr x6(AF_INET6, 128);
|
||||
CPPUNIT_ASSERT(x6.toString()=="ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff" && x6.getLength()==128);
|
||||
QVERIFY(x6.toString()=="ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff" && x6.getLength()==128);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Inet6AddrMaskTest::testStringToInetAddr6()
|
||||
{
|
||||
InetAddr *sa1 = new InetAddr(AF_INET6, "::");
|
||||
CPPUNIT_ASSERT_MESSAGE(sa1->toString(), sa1->toString() == "::");
|
||||
QVERIFY2(sa1->toString() == "::", sa1->toString().data());
|
||||
|
||||
sa1 = new InetAddr(AF_INET6, "::1");
|
||||
CPPUNIT_ASSERT_MESSAGE(sa1->toString(), sa1->toString() == "::1");
|
||||
|
||||
QVERIFY2(sa1->toString() == "::1", sa1->toString().data());
|
||||
|
||||
sa1 = new InetAddr(AF_INET6, "fe80::20c:29ff:fed2:cca1");
|
||||
CPPUNIT_ASSERT_MESSAGE(sa1->toString(),
|
||||
sa1->toString() == "fe80::20c:29ff:fed2:cca1");
|
||||
QVERIFY2(sa1->toString() == "fe80::20c:29ff:fed2:cca1", sa1->toString().data());
|
||||
|
||||
InetAddr x6(AF_INET6, "64");
|
||||
CPPUNIT_ASSERT_MESSAGE(x6.toString(),
|
||||
x6.toString()=="ffff:ffff:ffff:ffff::");
|
||||
CPPUNIT_ASSERT(x6.getLength()==64);
|
||||
QVERIFY2(x6.toString()=="ffff:ffff:ffff:ffff::", x6.toString().data());
|
||||
QVERIFY(x6.getLength()==64);
|
||||
}
|
||||
|
||||
void Inet6AddrMaskTest::testStringToInetAddrExceptions()
|
||||
{
|
||||
CPPUNIT_ASSERT_THROW(new InetAddr(AF_INET, "fe80::20c:29ff:fed2:cca1"), FWException);
|
||||
CPPUNIT_ASSERT_THROW(new InetAddr("fe80::20c:29ff:fed2:cca1"), FWException);
|
||||
CPPUNIT_ASSERT_NO_THROW(new InetAddr(AF_INET6, "fe80::20c:29ff:fed2:cca1/64"));
|
||||
CPPUNIT_ASSERT_THROW(new InetAddr(AF_INET6, "fe80::20c:29ff:fed2:cca1/200"), FWException);
|
||||
CPPUNIT_ASSERT_THROW(new InetAddr(AF_INET6, "fe80::foo:bar:fed2:cca1"), FWException);
|
||||
CPPUNIT_ASSERT_THROW(new InetAddr(AF_INET6, "1.2.3.4"), FWException);
|
||||
QVERIFY_EXCEPTION_THROWN(new InetAddr(AF_INET, "fe80::20c:29ff:fed2:cca1"), FWException);
|
||||
QVERIFY_EXCEPTION_THROWN(new InetAddr("fe80::20c:29ff:fed2:cca1"), FWException);
|
||||
|
||||
CPPUNIT_ASSERT_NO_THROW(new InetAddr(AF_INET6, 64));
|
||||
CPPUNIT_ASSERT_THROW(new InetAddr(AF_INET6, 256), FWException);
|
||||
try {
|
||||
new InetAddr(AF_INET6, "fe80::20c:29ff:fed2:cca1/64");
|
||||
} catch (const std::exception &e) {
|
||||
QFAIL(std::string("Exception thrown: ").append(e.what()).data());
|
||||
}
|
||||
|
||||
QVERIFY_EXCEPTION_THROWN(new InetAddr(AF_INET6, "fe80::20c:29ff:fed2:cca1/200"), FWException);
|
||||
QVERIFY_EXCEPTION_THROWN(new InetAddr(AF_INET6, "fe80::foo:bar:fed2:cca1"), FWException);
|
||||
QVERIFY_EXCEPTION_THROWN(new InetAddr(AF_INET6, "1.2.3.4"), FWException);
|
||||
|
||||
try {
|
||||
new InetAddr(AF_INET6, 64);
|
||||
} catch (const std::exception &e) {
|
||||
QFAIL(std::string("Exception thrown: ").append(e.what()).data());
|
||||
}
|
||||
|
||||
QVERIFY_EXCEPTION_THROWN(new InetAddr(AF_INET6, 256), FWException);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -152,45 +163,45 @@ void Inet6AddrMaskTest::testInet6AddressOps()
|
||||
InetAddr y6(AF_INET6, 64);
|
||||
InetAddr z1 = x7 & y6;
|
||||
|
||||
CPPUNIT_ASSERT(z1.toString()=="fe80::");
|
||||
QVERIFY(z1.toString()=="fe80::");
|
||||
|
||||
CPPUNIT_ASSERT((~y6).toString()=="::ffff:ffff:ffff:ffff");
|
||||
QVERIFY((~y6).toString()=="::ffff:ffff:ffff:ffff");
|
||||
|
||||
InetAddr z2 = z1 | ~y6;
|
||||
CPPUNIT_ASSERT_MESSAGE(z2.toString(), z2.toString()=="fe80::ffff:ffff:ffff:ffff");
|
||||
QVERIFY2(z2.toString()=="fe80::ffff:ffff:ffff:ffff", z2.toString().data());
|
||||
|
||||
InetAddr z3 = x7 + 1;
|
||||
CPPUNIT_ASSERT_MESSAGE(z3.toString(), z3.toString() == "fe80::21d:9ff:fe8b:8e95");
|
||||
QVERIFY2(z3.toString() == "fe80::21d:9ff:fe8b:8e95", z3.toString().data());
|
||||
|
||||
InetAddr z4 = z3 - 1;
|
||||
CPPUNIT_ASSERT_MESSAGE(z4.toString(), z4.toString() == "fe80::21d:9ff:fe8b:8e94");
|
||||
QVERIFY2(z4.toString() == "fe80::21d:9ff:fe8b:8e94", z4.toString().data());
|
||||
|
||||
|
||||
InetAddr z5 = x7 + 65536;
|
||||
CPPUNIT_ASSERT_MESSAGE(z5.toString(), z5.toString() == "fe80::21d:9ff:fe8c:8e94");
|
||||
QVERIFY2(z5.toString() == "fe80::21d:9ff:fe8c:8e94", z5.toString().data());
|
||||
|
||||
InetAddr z6 = z5 - 65536;
|
||||
CPPUNIT_ASSERT_MESSAGE(z6.toString(), z6.toString() == "fe80::21d:9ff:fe8b:8e94");
|
||||
QVERIFY2(z6.toString() == "fe80::21d:9ff:fe8b:8e94", z6.toString().data());
|
||||
|
||||
InetAddr z7 = x7 + 2147483647; // 2^31-1
|
||||
CPPUNIT_ASSERT_MESSAGE(z7.toString(), z7.toString() == "fe80::21d:a00:7e8b:8e93");
|
||||
QVERIFY2(z7.toString() == "fe80::21d:a00:7e8b:8e93", z7.toString().data());
|
||||
|
||||
InetAddr z8 = z7 - 2147483647;
|
||||
CPPUNIT_ASSERT_MESSAGE(z8.toString(), z8.toString() == "fe80::21d:9ff:fe8b:8e94");
|
||||
QVERIFY2(z8.toString() == "fe80::21d:9ff:fe8b:8e94", z8.toString().data());
|
||||
|
||||
InetAddr x8(AF_INET6, "fe80::21d:9ff:fe8b:1111");
|
||||
CPPUNIT_ASSERT(x7 > x8);
|
||||
CPPUNIT_ASSERT(x8 < x7);
|
||||
QVERIFY(x7 > x8);
|
||||
QVERIFY(x8 < x7);
|
||||
|
||||
unsigned int dist = x8.distance(x7);
|
||||
CPPUNIT_ASSERT(dist == 32132);
|
||||
QVERIFY(dist == 32132);
|
||||
|
||||
InetAddr x9(AF_INET6, "fe80::21d:9ff:fe8b:8e94");
|
||||
CPPUNIT_ASSERT(x7 == x9);
|
||||
QVERIFY(x7 == x9);
|
||||
|
||||
InetAddr x10(AF_INET6, "fe80::21d:a00:7e8b:8e93");
|
||||
CPPUNIT_ASSERT(x10 > x9);
|
||||
CPPUNIT_ASSERT(x9 < x10);
|
||||
QVERIFY(x10 > x9);
|
||||
QVERIFY(x9 < x10);
|
||||
}
|
||||
|
||||
void Inet6AddrMaskTest::testStringToInetAddrMask()
|
||||
@ -199,19 +210,19 @@ void Inet6AddrMaskTest::testStringToInetAddrMask()
|
||||
|
||||
Inet6AddrMask *a1 = new Inet6AddrMask();
|
||||
sa = a1->getAddressPtr()->toString();
|
||||
CPPUNIT_ASSERT(sa=="::");
|
||||
QVERIFY(sa=="::");
|
||||
|
||||
Inet6AddrMask *a2 = new Inet6AddrMask(
|
||||
InetAddr(AF_INET6, "fe80::21d:9ff:fe8b:8e94"),
|
||||
InetAddr(AF_INET6, 128));
|
||||
|
||||
sa = a2->getAddressPtr()->toString();
|
||||
CPPUNIT_ASSERT(sa=="fe80::21d:9ff:fe8b:8e94");
|
||||
QVERIFY(sa=="fe80::21d:9ff:fe8b:8e94");
|
||||
sa = a2->getNetmaskPtr()->toString();
|
||||
CPPUNIT_ASSERT(sa=="ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff");
|
||||
CPPUNIT_ASSERT(a2->getNetmaskPtr()->getLength()==128);
|
||||
QVERIFY(sa=="ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff");
|
||||
QVERIFY(a2->getNetmaskPtr()->getLength()==128);
|
||||
|
||||
CPPUNIT_ASSERT(a2->toString()=="fe80::21d:9ff:fe8b:8e94");
|
||||
QVERIFY(a2->toString()=="fe80::21d:9ff:fe8b:8e94");
|
||||
|
||||
Inet6AddrMask *a3 = new Inet6AddrMask(
|
||||
InetAddr(AF_INET6, "fe80::21d:9ff:fe8b:8e94"),
|
||||
@ -219,33 +230,33 @@ void Inet6AddrMaskTest::testStringToInetAddrMask()
|
||||
|
||||
a3->setNetmask(InetAddr(AF_INET6, 64));
|
||||
sa = a3->getAddressPtr()->toString();
|
||||
CPPUNIT_ASSERT(sa=="fe80::21d:9ff:fe8b:8e94");
|
||||
QVERIFY(sa=="fe80::21d:9ff:fe8b:8e94");
|
||||
sa = a3->getNetmaskPtr()->toString();
|
||||
CPPUNIT_ASSERT(sa=="ffff:ffff:ffff:ffff::");
|
||||
CPPUNIT_ASSERT(a3->getNetmaskPtr()->getLength()==64);
|
||||
CPPUNIT_ASSERT(a3->toString()=="fe80::21d:9ff:fe8b:8e94/64");
|
||||
QVERIFY(sa=="ffff:ffff:ffff:ffff::");
|
||||
QVERIFY(a3->getNetmaskPtr()->getLength()==64);
|
||||
QVERIFY(a3->toString()=="fe80::21d:9ff:fe8b:8e94/64");
|
||||
|
||||
|
||||
Inet6AddrMask *a4 = new Inet6AddrMask(
|
||||
string("fe80::21d:9ff:fe8b:8e94/64"));
|
||||
sa = a4->getAddressPtr()->toString();
|
||||
CPPUNIT_ASSERT(sa=="fe80::21d:9ff:fe8b:8e94");
|
||||
QVERIFY(sa=="fe80::21d:9ff:fe8b:8e94");
|
||||
sa = a4->getNetmaskPtr()->toString();
|
||||
CPPUNIT_ASSERT(sa=="ffff:ffff:ffff:ffff::");
|
||||
QVERIFY(sa=="ffff:ffff:ffff:ffff::");
|
||||
|
||||
CPPUNIT_ASSERT(a4->belongs( *(a2->getAddressPtr()) ));
|
||||
QVERIFY(a4->belongs( *(a2->getAddressPtr()) ));
|
||||
|
||||
|
||||
Inet6AddrMask *a5 = new Inet6AddrMask(*a3);
|
||||
sa = a5->getAddressPtr()->toString();
|
||||
CPPUNIT_ASSERT(sa=="fe80::21d:9ff:fe8b:8e94");
|
||||
QVERIFY(sa=="fe80::21d:9ff:fe8b:8e94");
|
||||
sa = a5->getNetmaskPtr()->toString();
|
||||
CPPUNIT_ASSERT(sa=="ffff:ffff:ffff:ffff::");
|
||||
QVERIFY(sa=="ffff:ffff:ffff:ffff::");
|
||||
|
||||
a5->setAddress(InetAddr(AF_INET6, "3ffe:1200:2001:1:8000::1"));
|
||||
sa = a5->getAddressPtr()->toString();
|
||||
CPPUNIT_ASSERT(sa=="3ffe:1200:2001:1:8000::1");
|
||||
QVERIFY(sa=="3ffe:1200:2001:1:8000::1");
|
||||
sa = a5->getNetmaskPtr()->toString();
|
||||
CPPUNIT_ASSERT(sa=="ffff:ffff:ffff:ffff::");
|
||||
QVERIFY(sa=="ffff:ffff:ffff:ffff::");
|
||||
|
||||
}
|
||||
|
||||
@ -26,11 +26,13 @@
|
||||
#ifndef INET6ADDRMASKTEST_H
|
||||
#define INET6ADDRMASKTEST_H
|
||||
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
#include <QObject>
|
||||
|
||||
class Inet6AddrMaskTest : public CppUnit::TestFixture
|
||||
class Inet6AddrMaskTest : public QObject
|
||||
{
|
||||
public:
|
||||
Q_OBJECT
|
||||
|
||||
private slots:
|
||||
void testStringToInetAddrExceptions();
|
||||
void testIntToInetAddr6();
|
||||
void testStringToInetAddr6();
|
||||
@ -39,18 +41,6 @@ public:
|
||||
void testUInt128ToInetAddr6();
|
||||
void testInetAddr6ToUInt128();
|
||||
|
||||
CPPUNIT_TEST_SUITE(Inet6AddrMaskTest);
|
||||
|
||||
CPPUNIT_TEST(testStringToInetAddrExceptions);
|
||||
CPPUNIT_TEST(testIntToInetAddr6);
|
||||
CPPUNIT_TEST(testUInt128ToInetAddr6);
|
||||
CPPUNIT_TEST(testInetAddr6ToUInt128);
|
||||
CPPUNIT_TEST(testStringToInetAddr6);
|
||||
CPPUNIT_TEST(testStringToInetAddrMask);
|
||||
CPPUNIT_TEST(testInet6AddressOps);
|
||||
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
};
|
||||
|
||||
#endif // INET6ADDRMASKTEST_H
|
||||
|
||||
@ -23,28 +23,19 @@
|
||||
|
||||
*/
|
||||
|
||||
#include <cppunit/ui/text/TestRunner.h>
|
||||
#include <cppunit/CompilerOutputter.h>
|
||||
#include "Inet6AddrMaskTest.h"
|
||||
#include "fwbuilder/FWObjectDatabase.h"
|
||||
#include <string>
|
||||
#include <QTest>
|
||||
|
||||
using namespace libfwbuilder;
|
||||
|
||||
int fwbdebug = 0;
|
||||
//QString user_name;
|
||||
std::string platform;
|
||||
|
||||
int main( int, char** argv)
|
||||
{
|
||||
//init(argv);
|
||||
init();
|
||||
|
||||
CppUnit::TextUi::TestRunner runner;
|
||||
runner.addTest( Inet6AddrMaskTest::suite() );
|
||||
runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(),
|
||||
std::cerr ) );
|
||||
|
||||
runner.run();
|
||||
return 0;
|
||||
return QTest::qExec(new Inet6AddrMaskTest());
|
||||
}
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
set (CMAKE_AUTOMOC ON)
|
||||
|
||||
add_executable(InetAddrMaskTest InetAddrMaskTest.cpp main.cpp)
|
||||
add_test(NAME InetAddrMaskTest COMMAND InetAddrMaskTest)
|
||||
|
||||
target_link_libraries(InetAddrMaskTest PRIVATE fwbuilder xml2 xslt z cppunit)
|
||||
target_link_libraries(InetAddrMaskTest PRIVATE fwbuilder xml2 xslt z Qt5::Test)
|
||||
|
||||
@ -25,6 +25,7 @@
|
||||
|
||||
#include "InetAddrMaskTest.h"
|
||||
#include <fwbuilder/InetAddrMask.h>
|
||||
#include <QTest>
|
||||
|
||||
using namespace libfwbuilder;
|
||||
using namespace std;
|
||||
@ -33,90 +34,111 @@ using namespace std;
|
||||
void InetAddrMaskTest::testIntToInetAddr()
|
||||
{
|
||||
InetAddr *sa1 = new InetAddr(0);
|
||||
CPPUNIT_ASSERT_MESSAGE(sa1->toString(), sa1->toString() == "0.0.0.0");
|
||||
|
||||
QVERIFY2(sa1->toString() == "0.0.0.0", sa1->toString().data());
|
||||
|
||||
sa1 = new InetAddr(AF_INET, 0);
|
||||
CPPUNIT_ASSERT_MESSAGE(sa1->toString(), sa1->toString() == "0.0.0.0");
|
||||
|
||||
QVERIFY2(sa1->toString() == "0.0.0.0", sa1->toString().data());
|
||||
|
||||
sa1 = new InetAddr(1);
|
||||
CPPUNIT_ASSERT_MESSAGE(sa1->toString(), sa1->toString() == "128.0.0.0");
|
||||
QVERIFY2(sa1->toString() == "128.0.0.0", sa1->toString().data());
|
||||
|
||||
sa1 = new InetAddr(24);
|
||||
CPPUNIT_ASSERT_MESSAGE(sa1->toString(), sa1->toString() == "255.255.255.0");
|
||||
QVERIFY2(sa1->toString() == "255.255.255.0", sa1->toString().data());
|
||||
}
|
||||
|
||||
void InetAddrMaskTest::testStringToInetAddr()
|
||||
{
|
||||
InetAddr *sa1 = new InetAddr("0.0.0.1");
|
||||
CPPUNIT_ASSERT_MESSAGE("0.0.0.1 -> " + sa1->toString(), sa1->toString() == "0.0.0.1");
|
||||
|
||||
QVERIFY2(sa1->toString() == "0.0.0.1", std::string("0.0.0.1 -> " + sa1->toString()).data());
|
||||
|
||||
sa1 = new InetAddr("0.0.0.0");
|
||||
CPPUNIT_ASSERT_MESSAGE("0.0.0.0 -> " + sa1->toString(), sa1->toString() == "0.0.0.0");
|
||||
|
||||
QVERIFY2(sa1->toString() == "0.0.0.0", std::string("0.0.0.0 -> " + sa1->toString()).data());
|
||||
|
||||
sa1 = new InetAddr("1.2.3.4");
|
||||
CPPUNIT_ASSERT_MESSAGE("1.2.3.4 -> " + sa1->toString(), sa1->toString() == "1.2.3.4");
|
||||
QVERIFY2(sa1->toString() == "1.2.3.4", std::string("1.2.3.4 -> " + sa1->toString()).data());
|
||||
|
||||
sa1 = new InetAddr("0.0.1");
|
||||
CPPUNIT_ASSERT_MESSAGE("0.0.1 -> " + sa1->toString(), sa1->toString() == "0.0.1.0");
|
||||
QVERIFY2(sa1->toString() == "0.0.1.0", std::string("0.0.1 -> " + sa1->toString()).data());
|
||||
|
||||
sa1 = new InetAddr("0.1");
|
||||
CPPUNIT_ASSERT_MESSAGE("0.1 -> " + sa1->toString(), sa1->toString() == "0.1.0.0");
|
||||
|
||||
QVERIFY2(sa1->toString() == "0.1.0.0", std::string("0.1 -> " + sa1->toString()).data());
|
||||
|
||||
// "1" ---> "128.0.0.0" I am not sure this is correct
|
||||
sa1 = new InetAddr("1");
|
||||
CPPUNIT_ASSERT_MESSAGE("1 -> " + sa1->toString(), sa1->toString() == "128.0.0.0");
|
||||
QVERIFY2(sa1->toString() == "128.0.0.0", std::string("1 -> " + sa1->toString()).data());
|
||||
|
||||
sa1 = new InetAddr("1.0");
|
||||
CPPUNIT_ASSERT_MESSAGE("1.0 -> " + sa1->toString(), sa1->toString() == "1.0.0.0");
|
||||
|
||||
QVERIFY2(sa1->toString() == "1.0.0.0", std::string("1.0 -> " + sa1->toString()).data());
|
||||
|
||||
sa1 = new InetAddr("1.0.0");
|
||||
CPPUNIT_ASSERT_MESSAGE("1.0.0 -> " + sa1->toString(), sa1->toString() == "1.0.0.0");
|
||||
QVERIFY2(sa1->toString() == "1.0.0.0", std::string("1.0.0 -> " + sa1->toString()).data());
|
||||
|
||||
sa1 = new InetAddr("255.255.255.255");
|
||||
CPPUNIT_ASSERT_MESSAGE("255.255.255.255 -> " + sa1->toString(), sa1->toString() == "255.255.255.255");
|
||||
CPPUNIT_ASSERT(sa1->isValidV4Netmask() == true);
|
||||
QVERIFY2(sa1->toString() == "255.255.255.255", std::string("255.255.255.255 -> " + sa1->toString()).data());
|
||||
QVERIFY(sa1->isValidV4Netmask() == true);
|
||||
|
||||
sa1 = new InetAddr("255.255.255.128");
|
||||
CPPUNIT_ASSERT_MESSAGE("255.255.255.128 -> " + sa1->toString(), sa1->toString() == "255.255.255.128");
|
||||
CPPUNIT_ASSERT(sa1->isValidV4Netmask() == true);
|
||||
QVERIFY2(sa1->toString() == "255.255.255.128", std::string("255.255.255.128 -> " + sa1->toString()).data());
|
||||
QVERIFY(sa1->isValidV4Netmask() == true);
|
||||
|
||||
sa1 = new InetAddr("255.255.255.0");
|
||||
CPPUNIT_ASSERT_MESSAGE("255.255.255.0 -> " + sa1->toString(), sa1->toString() == "255.255.255.0");
|
||||
CPPUNIT_ASSERT(sa1->isValidV4Netmask() == true);
|
||||
QVERIFY2(sa1->toString() == "255.255.255.0", std::string("255.255.255.0 -> " + sa1->toString()).data());
|
||||
QVERIFY(sa1->isValidV4Netmask() == true);
|
||||
|
||||
sa1 = new InetAddr("255.255.0.0");
|
||||
CPPUNIT_ASSERT_MESSAGE("255.255.0.0 -> " + sa1->toString(), sa1->toString() == "255.255.0.0");
|
||||
CPPUNIT_ASSERT(sa1->isValidV4Netmask() == true);
|
||||
QVERIFY2(sa1->toString() == "255.255.0.0", std::string("255.255.0.0 -> " + sa1->toString()).data());
|
||||
QVERIFY(sa1->isValidV4Netmask() == true);
|
||||
|
||||
sa1 = new InetAddr("255.0.0.0");
|
||||
CPPUNIT_ASSERT_MESSAGE("255.0.0.0 -> " + sa1->toString(), sa1->toString() == "255.0.0.0");
|
||||
CPPUNIT_ASSERT(sa1->isValidV4Netmask() == true);
|
||||
QVERIFY2(sa1->toString() == "255.0.0.0", std::string("255.0.0.0 -> " + sa1->toString()).data());
|
||||
QVERIFY(sa1->isValidV4Netmask() == true);
|
||||
|
||||
sa1 = new InetAddr("0.0.0.0");
|
||||
CPPUNIT_ASSERT_MESSAGE("0.0.0.0 -> " + sa1->toString(), sa1->toString() == "0.0.0.0");
|
||||
CPPUNIT_ASSERT(sa1->isValidV4Netmask() == true);
|
||||
QVERIFY2(sa1->toString() == "0.0.0.0", std::string("0.0.0.0 -> " + sa1->toString()).data());
|
||||
QVERIFY(sa1->isValidV4Netmask() == true);
|
||||
|
||||
sa1 = new InetAddr("255.0.255.0");
|
||||
CPPUNIT_ASSERT_MESSAGE("255.0.255.0 -> " + sa1->toString(), sa1->toString() == "255.0.255.0");
|
||||
CPPUNIT_ASSERT(sa1->isValidV4Netmask() == false);
|
||||
QVERIFY2(sa1->toString() == "255.0.255.0", std::string("255.0.255.0 -> " + sa1->toString()).data());
|
||||
QVERIFY(sa1->isValidV4Netmask() == false);
|
||||
|
||||
}
|
||||
|
||||
void InetAddrMaskTest::testStringToInetAddrExceptions()
|
||||
{
|
||||
CPPUNIT_ASSERT_NO_THROW(new InetAddr("1.2.3.4"));
|
||||
CPPUNIT_ASSERT_NO_THROW(new InetAddr("1.2.3.4/24"));
|
||||
CPPUNIT_ASSERT_THROW(new InetAddr("1.2.3.4/40"), FWException);
|
||||
try {
|
||||
new InetAddr("1.2.3.4");
|
||||
} catch (const std::exception &e) {
|
||||
QFAIL(std::string("Exception thrown: ").append(e.what()).data());
|
||||
}
|
||||
|
||||
CPPUNIT_ASSERT_THROW(new InetAddr("300.300.300.300"), FWException);
|
||||
CPPUNIT_ASSERT_THROW(new InetAddr("1.2.3.4.5"), FWException);
|
||||
CPPUNIT_ASSERT_THROW(new InetAddr("foo.bar"), FWException);
|
||||
CPPUNIT_ASSERT_THROW(new InetAddr("1.2.foo.bar"), FWException);
|
||||
try {
|
||||
new InetAddr("1.2.3.4/24");
|
||||
} catch (const std::exception &e) {
|
||||
QFAIL(std::string("Exception thrown: ").append(e.what()).data());
|
||||
}
|
||||
|
||||
QVERIFY_EXCEPTION_THROWN(new InetAddr("1.2.3.4/40"), FWException);
|
||||
|
||||
QVERIFY_EXCEPTION_THROWN(new InetAddr("300.300.300.300"), FWException);
|
||||
QVERIFY_EXCEPTION_THROWN(new InetAddr("1.2.3.4.5"), FWException);
|
||||
QVERIFY_EXCEPTION_THROWN(new InetAddr("foo.bar"), FWException);
|
||||
QVERIFY_EXCEPTION_THROWN(new InetAddr("1.2.foo.bar"), FWException);
|
||||
|
||||
QVERIFY_EXCEPTION_THROWN(new InetAddr(40), FWException);
|
||||
try {
|
||||
new InetAddr(24);
|
||||
} catch (const std::exception &e) {
|
||||
QFAIL(std::string("Exception thrown: ").append(e.what()).data());
|
||||
}
|
||||
|
||||
QVERIFY_EXCEPTION_THROWN(new InetAddr((char*)(nullptr)), FWException);
|
||||
|
||||
try {
|
||||
new InetAddr(0);
|
||||
} catch (const std::exception &e) {
|
||||
QFAIL(std::string("Exception thrown: ").append(e.what()).data());
|
||||
}
|
||||
|
||||
CPPUNIT_ASSERT_THROW(new InetAddr(40), FWException);
|
||||
CPPUNIT_ASSERT_NO_THROW(new InetAddr(24));
|
||||
CPPUNIT_ASSERT_THROW(new InetAddr((char*)(nullptr)), FWException);
|
||||
CPPUNIT_ASSERT_NO_THROW(new InetAddr(0));
|
||||
}
|
||||
|
||||
void InetAddrMaskTest::testInetAddressOps()
|
||||
@ -125,30 +147,30 @@ void InetAddrMaskTest::testInetAddressOps()
|
||||
InetAddr y1(24);
|
||||
InetAddr z1 = x1 & y1;
|
||||
|
||||
CPPUNIT_ASSERT(z1.toString() == "1.2.3.0");
|
||||
CPPUNIT_ASSERT( (~y1).toString() == "0.0.0.255");
|
||||
QVERIFY(z1.toString() == "1.2.3.0");
|
||||
QVERIFY( (~y1).toString() == "0.0.0.255");
|
||||
|
||||
InetAddr z2 = z1 | ~y1;
|
||||
CPPUNIT_ASSERT(z2.toString() == "1.2.3.255");
|
||||
QVERIFY(z2.toString() == "1.2.3.255");
|
||||
|
||||
InetAddr z3 = z1 | ~y1;
|
||||
CPPUNIT_ASSERT(z3.toString() == "1.2.3.255");
|
||||
QVERIFY(z3.toString() == "1.2.3.255");
|
||||
|
||||
InetAddr z4 = x1 + 1;
|
||||
CPPUNIT_ASSERT(z4.toString() == "1.2.3.5");
|
||||
QVERIFY(z4.toString() == "1.2.3.5");
|
||||
|
||||
InetAddr z5 = z4 - 1;
|
||||
CPPUNIT_ASSERT(z5.toString() == "1.2.3.4");
|
||||
QVERIFY(z5.toString() == "1.2.3.4");
|
||||
|
||||
CPPUNIT_ASSERT(z5 == x1);
|
||||
QVERIFY(z5 == x1);
|
||||
|
||||
InetAddr x2("255.255.255.255");
|
||||
InetAddr z6 = x2 + 1;
|
||||
CPPUNIT_ASSERT(z6.toString() == "0.0.0.0");
|
||||
QVERIFY(z6.toString() == "0.0.0.0");
|
||||
|
||||
InetAddr x3("1.2.2.4");
|
||||
CPPUNIT_ASSERT(x3 < x1);
|
||||
CPPUNIT_ASSERT(x1 > x3);
|
||||
QVERIFY(x3 < x1);
|
||||
QVERIFY(x1 > x3);
|
||||
|
||||
}
|
||||
|
||||
@ -157,73 +179,73 @@ void InetAddrMaskTest::testStringToInetAddrMask()
|
||||
string sa;
|
||||
|
||||
InetAddrMask *a1 = new InetAddrMask();
|
||||
CPPUNIT_ASSERT(a1->toString() == "0.0.0.0/0.0.0.0");
|
||||
QVERIFY(a1->toString() == "0.0.0.0/0.0.0.0");
|
||||
sa = a1->getAddressPtr()->toString();
|
||||
CPPUNIT_ASSERT(sa=="0.0.0.0");
|
||||
QVERIFY(sa=="0.0.0.0");
|
||||
// 0.0.0.0/0.0.0.0 has maximum dimension (represents all possible addresses)
|
||||
CPPUNIT_ASSERT(a1->dimension() == (((unsigned int)1)<<31)-1);
|
||||
QVERIFY(a1->dimension() == (((unsigned int)1)<<31)-1);
|
||||
|
||||
InetAddrMask *a2 = new InetAddrMask(InetAddr("1.1.1.1"), InetAddr("255.255.255.0"));
|
||||
sa = a2->getAddressPtr()->toString();
|
||||
CPPUNIT_ASSERT(sa=="1.1.1.0");
|
||||
QVERIFY(sa=="1.1.1.0");
|
||||
sa = a2->getNetmaskPtr()->toString();
|
||||
CPPUNIT_ASSERT(sa=="255.255.255.0");
|
||||
CPPUNIT_ASSERT(a2->dimension()==256);
|
||||
CPPUNIT_ASSERT(a2->toString()=="1.1.1.0/255.255.255.0");
|
||||
QVERIFY(sa=="255.255.255.0");
|
||||
QVERIFY(a2->dimension()==256);
|
||||
QVERIFY(a2->toString()=="1.1.1.0/255.255.255.0");
|
||||
|
||||
|
||||
InetAddrMask *a3 = new InetAddrMask(string("1.1.1.1"));
|
||||
sa = a3->getAddressPtr()->toString();
|
||||
CPPUNIT_ASSERT(sa=="1.1.1.1");
|
||||
QVERIFY(sa=="1.1.1.1");
|
||||
sa = a3->getNetmaskPtr()->toString();
|
||||
CPPUNIT_ASSERT(sa=="255.255.255.255");
|
||||
CPPUNIT_ASSERT(a3->dimension()==1);
|
||||
QVERIFY(sa=="255.255.255.255");
|
||||
QVERIFY(a3->dimension()==1);
|
||||
|
||||
CPPUNIT_ASSERT(a2->belongs( *(a3->getAddressPtr()) ));
|
||||
QVERIFY(a2->belongs( *(a3->getAddressPtr()) ));
|
||||
|
||||
InetAddrMask *a4 = new InetAddrMask(*a3);
|
||||
sa = a4->getAddressPtr()->toString();
|
||||
CPPUNIT_ASSERT(sa=="1.1.1.1");
|
||||
QVERIFY(sa=="1.1.1.1");
|
||||
sa = a4->getNetmaskPtr()->toString();
|
||||
CPPUNIT_ASSERT(sa=="255.255.255.255");
|
||||
CPPUNIT_ASSERT(a4->dimension()==1);
|
||||
QVERIFY(sa=="255.255.255.255");
|
||||
QVERIFY(a4->dimension()==1);
|
||||
|
||||
a4->setAddress(InetAddr("2.2.2.2"));
|
||||
sa = a4->getAddressPtr()->toString();
|
||||
CPPUNIT_ASSERT(sa=="2.2.2.2");
|
||||
QVERIFY(sa=="2.2.2.2");
|
||||
sa = a4->getNetmaskPtr()->toString();
|
||||
CPPUNIT_ASSERT(sa=="255.255.255.255");
|
||||
CPPUNIT_ASSERT(a4->dimension()==1);
|
||||
QVERIFY(sa=="255.255.255.255");
|
||||
QVERIFY(a4->dimension()==1);
|
||||
|
||||
a4->setNetmask(InetAddr("255.255.0.0"));
|
||||
sa = a4->getAddressPtr()->toString();
|
||||
CPPUNIT_ASSERT(sa=="2.2.2.2");
|
||||
QVERIFY(sa=="2.2.2.2");
|
||||
sa = a4->getNetmaskPtr()->toString();
|
||||
CPPUNIT_ASSERT(sa=="255.255.0.0");
|
||||
CPPUNIT_ASSERT(a4->dimension()==256*256);
|
||||
QVERIFY(sa=="255.255.0.0");
|
||||
QVERIFY(a4->dimension()==256*256);
|
||||
|
||||
a4->setNetmask(InetAddr("8"));
|
||||
sa = a4->getAddressPtr()->toString();
|
||||
CPPUNIT_ASSERT(sa=="2.2.2.2");
|
||||
QVERIFY(sa=="2.2.2.2");
|
||||
sa = a4->getNetmaskPtr()->toString();
|
||||
CPPUNIT_ASSERT(sa=="255.0.0.0");
|
||||
CPPUNIT_ASSERT(a4->dimension()==256*256*256);
|
||||
QVERIFY(sa=="255.0.0.0");
|
||||
QVERIFY(a4->dimension()==256*256*256);
|
||||
|
||||
CPPUNIT_ASSERT_THROW(a4->setNetmask(InetAddr("40")), FWException);
|
||||
QVERIFY_EXCEPTION_THROWN(a4->setNetmask(InetAddr("40")), FWException);
|
||||
|
||||
// a4 should not have changed
|
||||
sa = a4->getAddressPtr()->toString();
|
||||
CPPUNIT_ASSERT(sa=="2.2.2.2");
|
||||
QVERIFY(sa=="2.2.2.2");
|
||||
sa = a4->getNetmaskPtr()->toString();
|
||||
CPPUNIT_ASSERT(sa=="255.0.0.0");
|
||||
CPPUNIT_ASSERT(a4->dimension()==256*256*256);
|
||||
QVERIFY(sa=="255.0.0.0");
|
||||
QVERIFY(a4->dimension()==256*256*256);
|
||||
|
||||
InetAddrMask *a5 = new InetAddrMask(string("1.1.1.1/24"));
|
||||
sa = a5->getAddressPtr()->toString();
|
||||
CPPUNIT_ASSERT(sa=="1.1.1.1");
|
||||
QVERIFY(sa=="1.1.1.1");
|
||||
sa = a5->getNetmaskPtr()->toString();
|
||||
CPPUNIT_ASSERT(sa=="255.255.255.0");
|
||||
CPPUNIT_ASSERT(a5->dimension()==256);
|
||||
QVERIFY(sa=="255.255.255.0");
|
||||
QVERIFY(a5->dimension()==256);
|
||||
|
||||
}
|
||||
|
||||
@ -248,7 +270,7 @@ void InetAddrMaskTest::testIPv4Overlap()
|
||||
InetAddrMask(InetAddr("10.0.0.0"), InetAddr("255.255.255.0"))
|
||||
)
|
||||
);
|
||||
CPPUNIT_ASSERT(res=="10.0.0.0/255.255.255.0 ");
|
||||
QVERIFY(res=="10.0.0.0/255.255.255.0 ");
|
||||
|
||||
res = vectorInetAddrMaskToString(
|
||||
libfwbuilder::getOverlap(
|
||||
@ -256,7 +278,7 @@ void InetAddrMaskTest::testIPv4Overlap()
|
||||
InetAddrMask(InetAddr("10.0.0.255"), InetAddr("255.255.255.255"))
|
||||
)
|
||||
);
|
||||
CPPUNIT_ASSERT(res=="10.0.0.255/255.255.255.255 ");
|
||||
QVERIFY(res=="10.0.0.255/255.255.255.255 ");
|
||||
|
||||
res = vectorInetAddrMaskToString(
|
||||
libfwbuilder::getOverlap(
|
||||
@ -264,7 +286,7 @@ void InetAddrMaskTest::testIPv4Overlap()
|
||||
InetAddrMask(InetAddr("10.0.0.0"), InetAddr("255.255.255.0"))
|
||||
)
|
||||
);
|
||||
CPPUNIT_ASSERT(res=="10.0.0.255/255.255.255.255 ");
|
||||
QVERIFY(res=="10.0.0.255/255.255.255.255 ");
|
||||
|
||||
res = vectorInetAddrMaskToString(
|
||||
libfwbuilder::getOverlap(
|
||||
@ -272,7 +294,7 @@ void InetAddrMaskTest::testIPv4Overlap()
|
||||
InetAddrMask(InetAddr("10.0.0.0"), InetAddr("255.255.255.0"))
|
||||
)
|
||||
);
|
||||
CPPUNIT_ASSERT(res=="10.0.0.0/255.255.255.254 ");
|
||||
QVERIFY(res=="10.0.0.0/255.255.255.254 ");
|
||||
|
||||
res = vectorInetAddrMaskToString(
|
||||
libfwbuilder::getOverlap(
|
||||
@ -280,7 +302,7 @@ void InetAddrMaskTest::testIPv4Overlap()
|
||||
InetAddrMask(InetAddr("10.0.0.0"), InetAddr("255.255.255.254"))
|
||||
)
|
||||
);
|
||||
CPPUNIT_ASSERT(res=="10.0.0.0/255.255.255.254 ");
|
||||
QVERIFY(res=="10.0.0.0/255.255.255.254 ");
|
||||
|
||||
res = vectorInetAddrMaskToString(
|
||||
libfwbuilder::getOverlap(
|
||||
@ -288,7 +310,7 @@ void InetAddrMaskTest::testIPv4Overlap()
|
||||
InetAddrMask(InetAddr("10.0.0.0"), InetAddr("255.255.255.0"))
|
||||
)
|
||||
);
|
||||
CPPUNIT_ASSERT(res=="10.0.0.252/255.255.255.252 ");
|
||||
QVERIFY(res=="10.0.0.252/255.255.255.252 ");
|
||||
|
||||
res = vectorInetAddrMaskToString(
|
||||
libfwbuilder::getOverlap(
|
||||
@ -296,7 +318,7 @@ void InetAddrMaskTest::testIPv4Overlap()
|
||||
InetAddrMask(InetAddr("10.0.0.252"), InetAddr("255.255.255.252"))
|
||||
)
|
||||
);
|
||||
CPPUNIT_ASSERT(res=="10.0.0.252/255.255.255.252 ");
|
||||
QVERIFY(res=="10.0.0.252/255.255.255.252 ");
|
||||
|
||||
res = vectorInetAddrMaskToString(
|
||||
libfwbuilder::getOverlap(
|
||||
@ -304,7 +326,7 @@ void InetAddrMaskTest::testIPv4Overlap()
|
||||
InetAddrMask(InetAddr("10.0.0.0"), InetAddr("255.255.255.0"))
|
||||
)
|
||||
);
|
||||
CPPUNIT_ASSERT(res=="10.0.0.128/255.255.255.252 ");
|
||||
QVERIFY(res=="10.0.0.128/255.255.255.252 ");
|
||||
|
||||
res = vectorInetAddrMaskToString(
|
||||
libfwbuilder::getOverlap(
|
||||
@ -312,7 +334,7 @@ void InetAddrMaskTest::testIPv4Overlap()
|
||||
InetAddrMask(InetAddr("10.0.0.128"), InetAddr("255.255.255.252"))
|
||||
)
|
||||
);
|
||||
CPPUNIT_ASSERT(res=="10.0.0.128/255.255.255.252 ");
|
||||
QVERIFY(res=="10.0.0.128/255.255.255.252 ");
|
||||
|
||||
// test specifically for #1934
|
||||
res = vectorInetAddrMaskToString(
|
||||
@ -320,13 +342,13 @@ void InetAddrMaskTest::testIPv4Overlap()
|
||||
InetAddrMask(InetAddr("10.0.0.2"), InetAddr("255.255.255.254")),
|
||||
InetAddrMask(InetAddr("10.0.0.0"), InetAddr("255.255.255.0")))
|
||||
);
|
||||
CPPUNIT_ASSERT(res=="10.0.0.2/255.255.255.254 ");
|
||||
QVERIFY(res=="10.0.0.2/255.255.255.254 ");
|
||||
|
||||
res = vectorInetAddrMaskToString(
|
||||
libfwbuilder::getOverlap(
|
||||
InetAddrMask(InetAddr("10.0.0.2"), InetAddr("255.255.255.254")),
|
||||
InetAddrMask(InetAddr("0.0.0.0"), InetAddr("0.0.0.0")))
|
||||
);
|
||||
CPPUNIT_ASSERT(res=="10.0.0.2/255.255.255.254 ");
|
||||
QVERIFY(res=="10.0.0.2/255.255.255.254 ");
|
||||
|
||||
}
|
||||
|
||||
@ -26,20 +26,20 @@
|
||||
#ifndef INETADDRMASKTEST_H
|
||||
#define INETADDRMASKTEST_H
|
||||
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
#include "fwbuilder/InetAddrMask.h"
|
||||
|
||||
#include <vector>
|
||||
#include <QObject>
|
||||
|
||||
|
||||
|
||||
class InetAddrMaskTest : public CppUnit::TestFixture
|
||||
class InetAddrMaskTest : public QObject
|
||||
{
|
||||
public:
|
||||
Q_OBJECT
|
||||
|
||||
std::string vectorInetAddrMaskToString(
|
||||
std::vector<libfwbuilder::InetAddrMask> vect);
|
||||
|
||||
|
||||
private slots:
|
||||
void testIntToInetAddr();
|
||||
void testStringToInetAddr();
|
||||
void testStringToInetAddrExceptions();
|
||||
@ -47,17 +47,6 @@ public:
|
||||
void testInetAddressOps();
|
||||
void testIPv4Overlap();
|
||||
|
||||
CPPUNIT_TEST_SUITE(InetAddrMaskTest);
|
||||
|
||||
CPPUNIT_TEST(testStringToInetAddrExceptions);
|
||||
CPPUNIT_TEST(testIntToInetAddr);
|
||||
CPPUNIT_TEST(testStringToInetAddr);
|
||||
CPPUNIT_TEST(testStringToInetAddrMask);
|
||||
CPPUNIT_TEST(testInetAddressOps);
|
||||
CPPUNIT_TEST(testIPv4Overlap);
|
||||
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
};
|
||||
|
||||
#endif // INETADDRMASKTEST_H
|
||||
|
||||
@ -23,27 +23,18 @@
|
||||
|
||||
*/
|
||||
|
||||
#include <cppunit/ui/text/TestRunner.h>
|
||||
#include <cppunit/CompilerOutputter.h>
|
||||
#include "InetAddrMaskTest.h"
|
||||
#include "fwbuilder/FWObjectDatabase.h"
|
||||
#include <string>
|
||||
#include <QTest>
|
||||
|
||||
using namespace libfwbuilder;
|
||||
int fwbdebug = 0;
|
||||
//QString user_name;
|
||||
std::string platform;
|
||||
|
||||
int main( int, char** argv)
|
||||
{
|
||||
//init(argv);
|
||||
init();
|
||||
|
||||
CppUnit::TextUi::TestRunner runner;
|
||||
runner.addTest( InetAddrMaskTest::suite() );
|
||||
runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(),
|
||||
std::cerr ) );
|
||||
|
||||
runner.run();
|
||||
return 0;
|
||||
return QTest::qExec(new InetAddrMaskTest());
|
||||
}
|
||||
|
||||
@ -3,4 +3,4 @@ SET(CMAKE_AUTOMOC ON)
|
||||
add_executable(InterfaceDialogTest InterfaceDialogTest.cpp main_InterfaceDialogTest.cpp)
|
||||
add_test(NAME InterfaceDialogTest COMMAND InterfaceDialogTest)
|
||||
|
||||
target_link_libraries(InterfaceDialogTest PRIVATE test_main netsnmp gui import fwbparser antlr common iptlib fwbpf fwbjuniper fwbcisco compilerdriver fwcompiler fwbuilder xml2 xslt z pthread Qt5::Test)
|
||||
target_link_libraries(InterfaceDialogTest PRIVATE test_main gui import fwbparser antlr common iptlib fwbpf fwbjuniper fwbcisco compilerdriver fwcompiler fwbuilder netsnmp xml2 xslt z pthread Qt5::Test)
|
||||
|
||||
@ -37,9 +37,9 @@ using namespace std;
|
||||
using namespace libfwbuilder;
|
||||
|
||||
int fwbdebug = 0;
|
||||
FWWindow *mw = nullptr;
|
||||
FWBSettings *st = nullptr;
|
||||
FWBApplication *app = nullptr;
|
||||
FWWindow *mw = nullptr;
|
||||
FWBSettings *st = nullptr;
|
||||
FWBApplication *app = nullptr;
|
||||
|
||||
|
||||
extern void build_app(int argc, char** argv,
|
||||
@ -47,16 +47,18 @@ extern void build_app(int argc, char** argv,
|
||||
FWBSettings** st);
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
app = new FWBApplication(argc, argv);
|
||||
app->setOrganizationName(QLatin1String("NetCitadel"));
|
||||
app->setApplicationName(QLatin1String("Firewall Builder"));
|
||||
{
|
||||
app = new FWBApplication(argc, argv);
|
||||
app->setOrganizationName(QLatin1String("NetCitadel"));
|
||||
app->setApplicationName(QLatin1String("Firewall Builder"));
|
||||
|
||||
build_app(argc, argv, &app, &st);
|
||||
|
||||
|
||||
QTest::qExec(new InterfaceDialogTest());
|
||||
int testResult = QTest::qExec(new InterfaceDialogTest());
|
||||
|
||||
if (QFile::exists("test_work.fwb"))
|
||||
QFile::remove("test_work.fwb");
|
||||
if (QFile::exists("test_work.fwb"))
|
||||
QFile::remove("test_work.fwb");
|
||||
|
||||
return testResult;
|
||||
}
|
||||
|
||||
@ -3,4 +3,4 @@ SET(CMAKE_AUTOMOC ON)
|
||||
add_executable(NetworkDialogTest NetworkDialogTest.cpp main_NetworkDialogTest.cpp)
|
||||
add_test(NAME NetworkDialogTest COMMAND NetworkDialogTest)
|
||||
|
||||
target_link_libraries(NetworkDialogTest PRIVATE test_main netsnmp gui import fwbparser antlr common iptlib fwbpf fwbjuniper fwbcisco compilerdriver fwcompiler fwbuilder xml2 xslt z pthread Qt5::Test)
|
||||
target_link_libraries(NetworkDialogTest PRIVATE test_main gui import fwbparser antlr common iptlib fwbpf fwbjuniper fwbcisco compilerdriver fwcompiler fwbuilder netsnmp xml2 xslt z pthread Qt5::Test)
|
||||
|
||||
@ -37,9 +37,9 @@ using namespace std;
|
||||
using namespace libfwbuilder;
|
||||
|
||||
int fwbdebug = 0;
|
||||
FWWindow *mw = nullptr;
|
||||
FWBSettings *st = nullptr;
|
||||
FWBApplication *app = nullptr;
|
||||
FWWindow *mw = nullptr;
|
||||
FWBSettings *st = nullptr;
|
||||
FWBApplication *app = nullptr;
|
||||
|
||||
|
||||
extern void build_app(int argc, char** argv,
|
||||
@ -47,16 +47,18 @@ extern void build_app(int argc, char** argv,
|
||||
FWBSettings** st);
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
app = new FWBApplication(argc, argv);
|
||||
app->setOrganizationName(QLatin1String("NetCitadel"));
|
||||
app->setApplicationName(QLatin1String("Firewall Builder"));
|
||||
{
|
||||
app = new FWBApplication(argc, argv);
|
||||
app->setOrganizationName(QLatin1String("NetCitadel"));
|
||||
app->setApplicationName(QLatin1String("Firewall Builder"));
|
||||
|
||||
build_app(argc, argv, &app, &st);
|
||||
|
||||
|
||||
QTest::qExec(new NetworkDialogTest());
|
||||
int testResult = QTest::qExec(new NetworkDialogTest());
|
||||
|
||||
if (QFile::exists("test_work.fwb"))
|
||||
QFile::remove("test_work.fwb");
|
||||
if (QFile::exists("test_work.fwb"))
|
||||
QFile::remove("test_work.fwb");
|
||||
|
||||
return testResult;
|
||||
}
|
||||
|
||||
@ -3,6 +3,6 @@ SET(CMAKE_AUTOMOC ON)
|
||||
add_executable(ObjectManipulatorTest ObjectManipulatorTest.cpp main_ObjectManipulatorTest.cpp)
|
||||
add_test(NAME ObjectManipulatorTest COMMAND ObjectManipulatorTest)
|
||||
|
||||
target_link_libraries(ObjectManipulatorTest PRIVATE test_main netsnmp gui import fwbparser antlr common iptlib fwbpf fwbjuniper fwbcisco compilerdriver fwcompiler fwbuilder xml2 xslt z pthread Qt5::Test)
|
||||
target_link_libraries(ObjectManipulatorTest PRIVATE test_main gui import fwbparser antlr common iptlib fwbpf fwbjuniper fwbcisco compilerdriver fwcompiler fwbuilder netsnmp xml2 xslt z pthread Qt5::Test)
|
||||
|
||||
file(COPY test.fwb DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
@ -38,9 +38,9 @@ using namespace std;
|
||||
using namespace libfwbuilder;
|
||||
|
||||
int fwbdebug = 0;
|
||||
FWWindow *mw = nullptr;
|
||||
FWBSettings *st = nullptr;
|
||||
FWBApplication *app = nullptr;
|
||||
FWWindow *mw = nullptr;
|
||||
FWBSettings *st = nullptr;
|
||||
FWBApplication *app = nullptr;
|
||||
|
||||
|
||||
extern void build_app(int argc, char** argv,
|
||||
@ -48,17 +48,19 @@ extern void build_app(int argc, char** argv,
|
||||
FWBSettings** st);
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
app = new FWBApplication(argc, argv);
|
||||
app->setOrganizationName(QLatin1String("NetCitadel"));
|
||||
app->setApplicationName(QLatin1String("Firewall Builder"));
|
||||
{
|
||||
app = new FWBApplication(argc, argv);
|
||||
app->setOrganizationName(QLatin1String("NetCitadel"));
|
||||
app->setApplicationName(QLatin1String("Firewall Builder"));
|
||||
|
||||
build_app(argc, argv, &app, &st);
|
||||
|
||||
QFile::copy("test.fwb", "test_work.fwb");
|
||||
|
||||
QTest::qExec(new ObjectManipulatorTest());
|
||||
int testResult = QTest::qExec(new ObjectManipulatorTest());
|
||||
|
||||
if (QFile::exists("test_work.fwb"))
|
||||
QFile::remove("test_work.fwb");
|
||||
if (QFile::exists("test_work.fwb"))
|
||||
QFile::remove("test_work.fwb");
|
||||
|
||||
return testResult;
|
||||
}
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
set (CMAKE_AUTOMOC ON)
|
||||
|
||||
add_executable(ObjectMatcherTest ObjectMatcherTest.cpp main.cpp)
|
||||
add_test(NAME ObjectMatcherTest COMMAND ObjectMatcherTest)
|
||||
|
||||
target_link_libraries(ObjectMatcherTest PRIVATE test_main netsnmp gui import fwbparser antlr common iptlib fwbpf fwbjuniper fwbcisco compilerdriver fwcompiler fwbuilder xml2 xslt z pthread cppunit)
|
||||
target_link_libraries(ObjectMatcherTest PRIVATE test_main netsnmp gui import fwbparser antlr common iptlib fwbpf fwbjuniper fwbcisco compilerdriver fwcompiler fwbuilder xml2 xslt z pthread Qt5::Test)
|
||||
|
||||
file(COPY test_data.fwb DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
@ -42,6 +42,8 @@
|
||||
#include "fwbuilder/Firewall.h"
|
||||
#include "fwbuilder/Constants.h"
|
||||
|
||||
#include <QTest>
|
||||
|
||||
using namespace libfwbuilder;
|
||||
using namespace std;
|
||||
|
||||
@ -73,101 +75,101 @@ void ObjectMatcherTest::matchTest()
|
||||
om.setAddressRangeMatchMode(ObjectMatcher::EXACT);
|
||||
|
||||
Firewall *fw1 = Firewall::cast(dbsearch(db, "fw1"));
|
||||
CPPUNIT_ASSERT(fw1 != nullptr);
|
||||
QVERIFY(fw1 != nullptr);
|
||||
|
||||
Interface *fw1_eth0 = Interface::cast(dbsearch(fw1, "eth0"));
|
||||
CPPUNIT_ASSERT(fw1_eth0 != nullptr);
|
||||
QVERIFY(fw1_eth0 != nullptr);
|
||||
|
||||
Interface *fw1_eth1 = Interface::cast(dbsearch(fw1, "eth1"));
|
||||
CPPUNIT_ASSERT(fw1_eth1 != nullptr);
|
||||
QVERIFY(fw1_eth1 != nullptr);
|
||||
|
||||
Interface *fw1_eth2 = Interface::cast(dbsearch(fw1, "eth2"));
|
||||
CPPUNIT_ASSERT(fw1_eth2 != nullptr);
|
||||
QVERIFY(fw1_eth2 != nullptr);
|
||||
|
||||
IPv6 *fw1_eth2_ipv6 = IPv6::cast(dbsearch(fw1_eth2, "fw1:eth2:ipv6"));
|
||||
CPPUNIT_ASSERT(fw1_eth2_ipv6 != nullptr);
|
||||
QVERIFY(fw1_eth2_ipv6 != nullptr);
|
||||
|
||||
physAddress *fw1_eth2_mac = physAddress::cast(dbsearch(fw1_eth2, "fw1:eth2:mac"));
|
||||
CPPUNIT_ASSERT(fw1_eth2_mac != nullptr);
|
||||
QVERIFY(fw1_eth2_mac != nullptr);
|
||||
|
||||
Host *host1 = Host::cast(dbsearch(db, "host1"));
|
||||
CPPUNIT_ASSERT(host1 != nullptr);
|
||||
QVERIFY(host1 != nullptr);
|
||||
|
||||
Host *host2 = Host::cast(dbsearch(db, "host2"));
|
||||
CPPUNIT_ASSERT(host2 != nullptr);
|
||||
QVERIFY(host2 != nullptr);
|
||||
|
||||
Host *host3 = Host::cast(dbsearch(db, "host3"));
|
||||
CPPUNIT_ASSERT(host3 != nullptr);
|
||||
QVERIFY(host3 != nullptr);
|
||||
|
||||
Interface *host1_eth0 = Interface::cast(dbsearch(host1, "eth0"));
|
||||
CPPUNIT_ASSERT(host1_eth0 != nullptr);
|
||||
QVERIFY(host1_eth0 != nullptr);
|
||||
|
||||
Interface *host2_eth0 = Interface::cast(dbsearch(host2, "eth0"));
|
||||
CPPUNIT_ASSERT(host2_eth0 != nullptr);
|
||||
QVERIFY(host2_eth0 != nullptr);
|
||||
|
||||
IPv4 *host2_eth0_ip = IPv4::cast(dbsearch(host2_eth0, "ip"));
|
||||
CPPUNIT_ASSERT(host2_eth0_ip != nullptr);
|
||||
QVERIFY(host2_eth0_ip != nullptr);
|
||||
|
||||
Interface *host3_eth0 = Interface::cast(dbsearch(host3, "eth0"));
|
||||
CPPUNIT_ASSERT(host3_eth0 != nullptr);
|
||||
QVERIFY(host3_eth0 != nullptr);
|
||||
|
||||
Interface *host3_eth1 = Interface::cast(dbsearch(host3, "eth1"));
|
||||
CPPUNIT_ASSERT(host3_eth1 != nullptr);
|
||||
QVERIFY(host3_eth1 != nullptr);
|
||||
|
||||
|
||||
CPPUNIT_ASSERT(om.dispatch(fw1, fw1));
|
||||
CPPUNIT_ASSERT(om.dispatch(fw1_eth0, fw1));
|
||||
CPPUNIT_ASSERT(om.dispatch(fw1_eth1, fw1));
|
||||
CPPUNIT_ASSERT(om.dispatch(fw1_eth0, fw1_eth0));
|
||||
QVERIFY(om.dispatch(fw1, fw1));
|
||||
QVERIFY(om.dispatch(fw1_eth0, fw1));
|
||||
QVERIFY(om.dispatch(fw1_eth1, fw1));
|
||||
QVERIFY(om.dispatch(fw1_eth0, fw1_eth0));
|
||||
|
||||
CPPUNIT_ASSERT( ! om.dispatch(fw1_eth2_ipv6, fw1));
|
||||
QVERIFY( ! om.dispatch(fw1_eth2_ipv6, fw1));
|
||||
om.setIPV6(true);
|
||||
CPPUNIT_ASSERT( om.dispatch(fw1_eth2_ipv6, fw1));
|
||||
QVERIFY( om.dispatch(fw1_eth2_ipv6, fw1));
|
||||
om.setIPV6(false);
|
||||
|
||||
CPPUNIT_ASSERT(om.dispatch(fw1_eth2_mac, fw1));
|
||||
QVERIFY(om.dispatch(fw1_eth2_mac, fw1));
|
||||
|
||||
CPPUNIT_ASSERT(om.dispatch(host1_eth0, fw1));
|
||||
CPPUNIT_ASSERT(om.dispatch(host1, fw1));
|
||||
QVERIFY(om.dispatch(host1_eth0, fw1));
|
||||
QVERIFY(om.dispatch(host1, fw1));
|
||||
|
||||
CPPUNIT_ASSERT(static_cast<bool>(om.dispatch(host2_eth0_ip, fw1)) == false);
|
||||
CPPUNIT_ASSERT(static_cast<bool>(om.dispatch(host2_eth0, fw1)) == false);
|
||||
CPPUNIT_ASSERT(static_cast<bool>(om.dispatch(host2, fw1)) == false);
|
||||
QVERIFY(static_cast<bool>(om.dispatch(host2_eth0_ip, fw1)) == false);
|
||||
QVERIFY(static_cast<bool>(om.dispatch(host2_eth0, fw1)) == false);
|
||||
QVERIFY(static_cast<bool>(om.dispatch(host2, fw1)) == false);
|
||||
|
||||
om.setMatchSubnets(true);
|
||||
CPPUNIT_ASSERT(om.dispatch(host2_eth0_ip, fw1));
|
||||
QVERIFY(om.dispatch(host2_eth0_ip, fw1));
|
||||
|
||||
om.setMatchSubnets(false);
|
||||
|
||||
CPPUNIT_ASSERT(static_cast<bool>(om.dispatch(host3_eth0, fw1)) == false);
|
||||
CPPUNIT_ASSERT(static_cast<bool>(om.dispatch(host3_eth1, fw1)) == false);
|
||||
QVERIFY(static_cast<bool>(om.dispatch(host3_eth0, fw1)) == false);
|
||||
QVERIFY(static_cast<bool>(om.dispatch(host3_eth1, fw1)) == false);
|
||||
|
||||
CPPUNIT_ASSERT(om.dispatch(IPv4::cast(o("addr-192.168.1.1")), fw1));
|
||||
CPPUNIT_ASSERT(om.dispatch(IPv4::cast(o("addr-192.168.1.1")), fw1_eth1));
|
||||
CPPUNIT_ASSERT(static_cast<bool>(om.dispatch(IPv4::cast(o("addr-192.168.1.1")), fw1_eth0)) == false);
|
||||
QVERIFY(om.dispatch(IPv4::cast(o("addr-192.168.1.1")), fw1));
|
||||
QVERIFY(om.dispatch(IPv4::cast(o("addr-192.168.1.1")), fw1_eth1));
|
||||
QVERIFY(static_cast<bool>(om.dispatch(IPv4::cast(o("addr-192.168.1.1")), fw1_eth0)) == false);
|
||||
|
||||
om.setIPV6(true);
|
||||
CPPUNIT_ASSERT(om.dispatch(IPv6::cast(o("addr-ipv6-1")), fw1));
|
||||
CPPUNIT_ASSERT(static_cast<bool>(om.dispatch(IPv6::cast(o("addr-ipv6-2")), fw1)) == false);
|
||||
CPPUNIT_ASSERT(static_cast<bool>(om.dispatch(IPv4::cast(o("addr-192.168.1.1")), fw1)) == false);
|
||||
QVERIFY(om.dispatch(IPv6::cast(o("addr-ipv6-1")), fw1));
|
||||
QVERIFY(static_cast<bool>(om.dispatch(IPv6::cast(o("addr-ipv6-2")), fw1)) == false);
|
||||
QVERIFY(static_cast<bool>(om.dispatch(IPv4::cast(o("addr-192.168.1.1")), fw1)) == false);
|
||||
|
||||
om.setIPV6(false);
|
||||
CPPUNIT_ASSERT(static_cast<bool>(om.dispatch(IPv6::cast(o("addr-ipv6-1")), fw1)) == false);
|
||||
CPPUNIT_ASSERT(static_cast<bool>(om.dispatch(IPv6::cast(o("addr-ipv6-2")), fw1)) == false);
|
||||
QVERIFY(static_cast<bool>(om.dispatch(IPv6::cast(o("addr-ipv6-1")), fw1)) == false);
|
||||
QVERIFY(static_cast<bool>(om.dispatch(IPv6::cast(o("addr-ipv6-2")), fw1)) == false);
|
||||
|
||||
|
||||
CPPUNIT_ASSERT(static_cast<bool>(om.dispatch(Network::cast(o("net-192.168.1.0")), fw1)) == false);
|
||||
CPPUNIT_ASSERT(static_cast<bool>(om.dispatch(Network::cast(o("net-192.168.1.0")), fw1_eth1)) == false);
|
||||
CPPUNIT_ASSERT(static_cast<bool>(om.dispatch(Network::cast(o("net-192.168.1.0")), fw1_eth0)) == false);
|
||||
CPPUNIT_ASSERT(om.dispatch(Network::cast(o("net-192.168.1.1")), fw1));
|
||||
QVERIFY(static_cast<bool>(om.dispatch(Network::cast(o("net-192.168.1.0")), fw1)) == false);
|
||||
QVERIFY(static_cast<bool>(om.dispatch(Network::cast(o("net-192.168.1.0")), fw1_eth1)) == false);
|
||||
QVERIFY(static_cast<bool>(om.dispatch(Network::cast(o("net-192.168.1.0")), fw1_eth0)) == false);
|
||||
QVERIFY(om.dispatch(Network::cast(o("net-192.168.1.1")), fw1));
|
||||
|
||||
CPPUNIT_ASSERT(om.dispatch(IPv4::cast(o("addr-192.168.1.255")), fw1));
|
||||
CPPUNIT_ASSERT(om.dispatch(IPv4::cast(o("addr-192.168.1.0")), fw1));
|
||||
CPPUNIT_ASSERT(om.dispatch(Network::cast(o("all multicasts")), fw1));
|
||||
QVERIFY(om.dispatch(IPv4::cast(o("addr-192.168.1.255")), fw1));
|
||||
QVERIFY(om.dispatch(IPv4::cast(o("addr-192.168.1.0")), fw1));
|
||||
QVERIFY(om.dispatch(Network::cast(o("all multicasts")), fw1));
|
||||
|
||||
om.setRecognizeBroadcasts(false);
|
||||
CPPUNIT_ASSERT(static_cast<bool>(om.dispatch(IPv4::cast(o("addr-192.168.1.255")), fw1)) == false);
|
||||
CPPUNIT_ASSERT(static_cast<bool>(om.dispatch(IPv4::cast(o("addr-192.168.1.0")), fw1)) == false);
|
||||
QVERIFY(static_cast<bool>(om.dispatch(IPv4::cast(o("addr-192.168.1.255")), fw1)) == false);
|
||||
QVERIFY(static_cast<bool>(om.dispatch(IPv4::cast(o("addr-192.168.1.0")), fw1)) == false);
|
||||
|
||||
// ================================================================
|
||||
// AddressRange tests
|
||||
@ -175,16 +177,16 @@ void ObjectMatcherTest::matchTest()
|
||||
|
||||
// range1 192.168.1.10 - 192.168.1.20
|
||||
// does not match fw1 exactly, but matches when match_subnets == true
|
||||
CPPUNIT_ASSERT(static_cast<bool>(om.dispatch(AddressRange::cast(o("range1")), fw1)) == false);
|
||||
QVERIFY(static_cast<bool>(om.dispatch(AddressRange::cast(o("range1")), fw1)) == false);
|
||||
|
||||
// range2 192.168.2.1-192.168.2.3 does not match fw1:eth2 at all
|
||||
CPPUNIT_ASSERT(static_cast<bool>(om.dispatch(AddressRange::cast(o("range2")), fw1)) == false);
|
||||
QVERIFY(static_cast<bool>(om.dispatch(AddressRange::cast(o("range2")), fw1)) == false);
|
||||
|
||||
// range3 192.168.2.27-192.168.2.50 partially overlaps with fw1:eth2 subnet
|
||||
CPPUNIT_ASSERT(static_cast<bool>(om.dispatch(AddressRange::cast(o("range3")), fw1)) == false);
|
||||
QVERIFY(static_cast<bool>(om.dispatch(AddressRange::cast(o("range3")), fw1)) == false);
|
||||
|
||||
// range4 192.168.2.27-192.168.2.30 is completely inside fw1:eth2 subnet
|
||||
CPPUNIT_ASSERT(static_cast<bool>(om.dispatch(AddressRange::cast(o("range4")), fw1)) == false);
|
||||
QVERIFY(static_cast<bool>(om.dispatch(AddressRange::cast(o("range4")), fw1)) == false);
|
||||
|
||||
// ================================================================
|
||||
om.setAddressRangeMatchMode(ObjectMatcher::PARTIAL);
|
||||
@ -195,31 +197,31 @@ void ObjectMatcherTest::matchTest()
|
||||
|
||||
// range3 192.168.2.27-192.168.2.50 partially overlaps with fw1:eth2 subnet
|
||||
// but address of interface 192.168.2.24 is outside the range
|
||||
CPPUNIT_ASSERT(static_cast<bool>(om.dispatch(AddressRange::cast(o("range3")), fw1)) == false);
|
||||
QVERIFY(static_cast<bool>(om.dispatch(AddressRange::cast(o("range3")), fw1)) == false);
|
||||
|
||||
// range4 192.168.2.27-192.168.2.30 is completely inside fw1:eth2 subnet
|
||||
CPPUNIT_ASSERT(static_cast<bool>(om.dispatch(AddressRange::cast(o("range4")), fw1)) == false);
|
||||
QVERIFY(static_cast<bool>(om.dispatch(AddressRange::cast(o("range4")), fw1)) == false);
|
||||
|
||||
// fw1:eth2:ip 192.168.2.24 falls inside range5
|
||||
CPPUNIT_ASSERT(om.dispatch(AddressRange::cast(o("range5")), fw1));
|
||||
QVERIFY(om.dispatch(AddressRange::cast(o("range5")), fw1));
|
||||
|
||||
// ================================================================
|
||||
om.setMatchSubnets(true); // ranges will be compared to subnets defined by interface addr/mask
|
||||
// here match_subnets == true address_range_match_mode = PARTIAL
|
||||
|
||||
CPPUNIT_ASSERT(om.dispatch(host2_eth0_ip, fw1));
|
||||
CPPUNIT_ASSERT(om.dispatch(AddressRange::cast(o("range1")), fw1));
|
||||
QVERIFY(om.dispatch(host2_eth0_ip, fw1));
|
||||
QVERIFY(om.dispatch(AddressRange::cast(o("range1")), fw1));
|
||||
|
||||
// range2 192.168.2.1-192.168.2.3 does not match fw1:eth2 at all
|
||||
CPPUNIT_ASSERT(static_cast<bool>(om.dispatch(AddressRange::cast(o("range2")), fw1)) == false);
|
||||
QVERIFY(static_cast<bool>(om.dispatch(AddressRange::cast(o("range2")), fw1)) == false);
|
||||
|
||||
// range3 192.168.2.27-192.168.2.50 partially overlaps with fw1:eth2 subnet
|
||||
CPPUNIT_ASSERT(om.dispatch(AddressRange::cast(o("range3")), fw1));
|
||||
QVERIFY(om.dispatch(AddressRange::cast(o("range3")), fw1));
|
||||
|
||||
// range4 192.168.2.27-192.168.2.30 is completely inside fw1:eth2 subnet
|
||||
CPPUNIT_ASSERT(om.dispatch(AddressRange::cast(o("range4")), fw1));
|
||||
QVERIFY(om.dispatch(AddressRange::cast(o("range4")), fw1));
|
||||
|
||||
// range5 192.168.2.21-192.168.2.27 partially overlaps with fw1:eth2 subnet
|
||||
CPPUNIT_ASSERT(om.dispatch(AddressRange::cast(o("range5")), fw1));
|
||||
QVERIFY(om.dispatch(AddressRange::cast(o("range5")), fw1));
|
||||
|
||||
}
|
||||
|
||||
@ -26,24 +26,15 @@
|
||||
#ifndef OBJECTMATCHERTEST_H
|
||||
#define OBJECTMATCHERTEST_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include <cppunit/TestCase.h>
|
||||
#include <cppunit/TestSuite.h>
|
||||
#include <cppunit/TestCaller.h>
|
||||
|
||||
class ObjectMatcherTest : public CppUnit::TestCase
|
||||
class ObjectMatcherTest : public QObject
|
||||
{
|
||||
public:
|
||||
Q_OBJECT
|
||||
|
||||
private slots:
|
||||
void matchTest();
|
||||
|
||||
static CppUnit::Test *suite()
|
||||
{
|
||||
CppUnit::TestSuite *suiteOfTests = new CppUnit::TestSuite( "ObjectMatcherTest" );
|
||||
suiteOfTests->addTest( new CppUnit::TestCaller<ObjectMatcherTest>(
|
||||
"matchTest",
|
||||
&ObjectMatcherTest::matchTest ) );
|
||||
return suiteOfTests;
|
||||
}
|
||||
};
|
||||
|
||||
#endif // OBJECTMATCHERTEST_H
|
||||
|
||||
@ -23,27 +23,18 @@
|
||||
|
||||
*/
|
||||
|
||||
#include <cppunit/ui/text/TestRunner.h>
|
||||
#include <cppunit/CompilerOutputter.h>
|
||||
#include "ObjectMatcherTest.h"
|
||||
#include "fwbuilder/FWObjectDatabase.h"
|
||||
#include <string>
|
||||
#include <QTest>
|
||||
|
||||
using namespace libfwbuilder;
|
||||
int fwbdebug = 0;
|
||||
//QString user_name;
|
||||
std::string platform;
|
||||
|
||||
int main( int, char** argv)
|
||||
{
|
||||
//init(argv);
|
||||
init();
|
||||
|
||||
CppUnit::TextUi::TestRunner runner;
|
||||
runner.addTest( ObjectMatcherTest::suite() );
|
||||
runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(),
|
||||
std::cerr ) );
|
||||
|
||||
runner.run();
|
||||
return 0;
|
||||
return QTest::qExec(new ObjectMatcherTest());
|
||||
}
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
set (CMAKE_AUTOMOC ON)
|
||||
|
||||
add_executable(PFImporterTest PFImporterTest.cpp main_PFImporterTest.cpp)
|
||||
add_test(NAME PFImporterTest COMMAND PFImporterTest)
|
||||
|
||||
target_link_libraries(PFImporterTest PRIVATE test_main netsnmp gui import fwbparser antlr common iptlib fwbpf fwbjuniper fwbcisco compilerdriver fwcompiler fwbuilder xml2 xslt z pthread cppunit)
|
||||
target_link_libraries(PFImporterTest PRIVATE test_main netsnmp gui import fwbparser antlr common iptlib fwbpf fwbjuniper fwbcisco compilerdriver fwcompiler fwbuilder xml2 xslt z pthread Qt5::Test)
|
||||
|
||||
file(COPY test_data DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
|
||||
@ -42,6 +42,7 @@
|
||||
#include "fwbuilder/TagService.h"
|
||||
#include "fwbuilder/Constants.h"
|
||||
|
||||
#include <QTest>
|
||||
#include <QDebug>
|
||||
#include <QFile>
|
||||
#include <QStringList>
|
||||
@ -67,7 +68,7 @@ class UpgradePredicate: public XMLTools::UpgradePredicate
|
||||
}
|
||||
};
|
||||
|
||||
void PFImporterTest::setUp()
|
||||
void PFImporterTest::init()
|
||||
{
|
||||
FWBTree *tree = new FWBTree();
|
||||
|
||||
@ -122,22 +123,22 @@ void PFImporterTest::compareResults(QueueLogger* logger,
|
||||
QString result_file = rr.readAll();
|
||||
QStringList expected_result = result_file.split("\n");
|
||||
|
||||
CPPUNIT_ASSERT_MESSAGE(
|
||||
QVERIFY2(
|
||||
expected_result.size() == obtained_result.size(),
|
||||
QString(
|
||||
"Sizes of the generated importer output and test files are different.\n"
|
||||
"Expected: %1 (%2)\n"
|
||||
"Obtained: %3 (%4)\n"
|
||||
"diff -u %1 %3 | less -S")
|
||||
.arg(expected_result_file_name).arg(expected_result.size())
|
||||
.arg(obtained_result_file_name).arg(obtained_result.size()).toStdString(),
|
||||
expected_result.size() == obtained_result.size());
|
||||
.arg(obtained_result_file_name).arg(obtained_result.size()).toStdString().data());
|
||||
|
||||
int max_idx = max(expected_result.size(), obtained_result.size());
|
||||
for (int i=0; i < max_idx; ++i)
|
||||
{
|
||||
QString err = QString("Line %1:\nExpected: '%2'\nResult: '%3'\n")
|
||||
.arg(i).arg(expected_result[i]).arg(obtained_result[i]);
|
||||
CPPUNIT_ASSERT_MESSAGE(err.toStdString(), obtained_result[i] == expected_result[i]);
|
||||
QVERIFY2(obtained_result[i] == expected_result[i], err.toStdString().data());
|
||||
}
|
||||
}
|
||||
|
||||
@ -152,7 +153,7 @@ void PFImporterTest::compareFwbFiles(QString expected_result_file_name,
|
||||
QString result_file = rr.readAll();
|
||||
rr.close();
|
||||
obtained_result = result_file.split("\n");
|
||||
|
||||
|
||||
QFile er(expected_result_file_name);
|
||||
er.open(QFile::ReadOnly);
|
||||
result_file = er.readAll();
|
||||
@ -167,12 +168,12 @@ void PFImporterTest::compareFwbFiles(QString expected_result_file_name,
|
||||
"Obtained: %3 (%4)\n"
|
||||
"diff -u %1 %3 | less -S");
|
||||
|
||||
CPPUNIT_ASSERT_MESSAGE(
|
||||
QVERIFY2(
|
||||
expected_result.size() == obtained_result.size(),
|
||||
err
|
||||
.arg(expected_result_file_name).arg(expected_result.size())
|
||||
.arg(obtained_result_file_name).arg(obtained_result.size())
|
||||
.toStdString(),
|
||||
expected_result.size() == obtained_result.size());
|
||||
.toStdString().data());
|
||||
|
||||
QRegExp last_mod_re("lastModified=\"\\d+\"");
|
||||
int max_idx = max(expected_result.size(), obtained_result.size());
|
||||
@ -189,7 +190,7 @@ void PFImporterTest::compareFwbFiles(QString expected_result_file_name,
|
||||
{
|
||||
QString err = QString("Line %1:\nExpected: '%2'\nResult: '%3'\n")
|
||||
.arg(i).arg(expected_result[i]).arg(obtained_result[i]);
|
||||
CPPUNIT_ASSERT_MESSAGE(err.toStdString(), obtained_result[i] == expected_result[i]);
|
||||
QVERIFY2(obtained_result[i] == expected_result[i], err.toStdString().data());
|
||||
}
|
||||
}
|
||||
|
||||
@ -212,7 +213,13 @@ void PFImporterTest::macrosTest()
|
||||
|
||||
Importer* imp = new PFImporter(lib, instream, logger, "test_fw");
|
||||
imp->setAddStandardCommentsFlag(true);
|
||||
CPPUNIT_ASSERT_NO_THROW( imp->run() );
|
||||
|
||||
try {
|
||||
imp->run() ;
|
||||
} catch (const std::exception &e) {
|
||||
QFAIL(std::string("Exception thrown: ").append(e.what()).data());
|
||||
}
|
||||
|
||||
imp->finalize();
|
||||
|
||||
db->setPredictableIds();
|
||||
@ -231,7 +238,13 @@ void PFImporterTest::hostsMatchTest()
|
||||
|
||||
Importer* imp = new PFImporter(lib, instream, logger, "test_fw");
|
||||
imp->setAddStandardCommentsFlag(true);
|
||||
CPPUNIT_ASSERT_NO_THROW( imp->run() );
|
||||
|
||||
try {
|
||||
imp->run() ;
|
||||
} catch (const std::exception &e) {
|
||||
QFAIL(std::string("Exception thrown: ").append(e.what()).data());
|
||||
}
|
||||
|
||||
imp->finalize();
|
||||
|
||||
db->setPredictableIds();
|
||||
@ -253,7 +266,13 @@ void PFImporterTest::blockReturnTest()
|
||||
|
||||
Importer* imp = new PFImporter(lib, instream, logger, "test_fw");
|
||||
imp->setAddStandardCommentsFlag(true);
|
||||
CPPUNIT_ASSERT_NO_THROW( imp->run() );
|
||||
|
||||
try {
|
||||
imp->run() ;
|
||||
} catch (const std::exception &e) {
|
||||
QFAIL(std::string("Exception thrown: ").append(e.what()).data());
|
||||
}
|
||||
|
||||
imp->finalize();
|
||||
|
||||
db->setPredictableIds();
|
||||
@ -275,7 +294,13 @@ void PFImporterTest::icmpMatchTest()
|
||||
|
||||
Importer* imp = new PFImporter(lib, instream, logger, "test_fw");
|
||||
imp->setAddStandardCommentsFlag(true);
|
||||
CPPUNIT_ASSERT_NO_THROW( imp->run() );
|
||||
|
||||
try {
|
||||
imp->run() ;
|
||||
} catch (const std::exception &e) {
|
||||
QFAIL(std::string("Exception thrown: ").append(e.what()).data());
|
||||
}
|
||||
|
||||
imp->finalize();
|
||||
|
||||
db->setPredictableIds();
|
||||
@ -297,7 +322,13 @@ void PFImporterTest::interfaceMatchTest()
|
||||
|
||||
Importer* imp = new PFImporter(lib, instream, logger, "test_fw");
|
||||
imp->setAddStandardCommentsFlag(true);
|
||||
CPPUNIT_ASSERT_NO_THROW( imp->run() );
|
||||
|
||||
try {
|
||||
imp->run() ;
|
||||
} catch (const std::exception &e) {
|
||||
QFAIL(std::string("Exception thrown: ").append(e.what()).data());
|
||||
}
|
||||
|
||||
imp->finalize();
|
||||
|
||||
db->setPredictableIds();
|
||||
@ -319,7 +350,13 @@ void PFImporterTest::portMatchTest()
|
||||
|
||||
Importer* imp = new PFImporter(lib, instream, logger, "test_fw");
|
||||
imp->setAddStandardCommentsFlag(true);
|
||||
CPPUNIT_ASSERT_NO_THROW( imp->run() );
|
||||
|
||||
try {
|
||||
imp->run() ;
|
||||
} catch (const std::exception &e) {
|
||||
QFAIL(std::string("Exception thrown: ").append(e.what()).data());
|
||||
}
|
||||
|
||||
imp->finalize();
|
||||
|
||||
db->setPredictableIds();
|
||||
@ -341,7 +378,13 @@ void PFImporterTest::setCommandsTest()
|
||||
|
||||
Importer* imp = new PFImporter(lib, instream, logger, "test_fw");
|
||||
imp->setAddStandardCommentsFlag(true);
|
||||
CPPUNIT_ASSERT_NO_THROW( imp->run() );
|
||||
|
||||
try {
|
||||
imp->run() ;
|
||||
} catch (const std::exception &e) {
|
||||
QFAIL(std::string("Exception thrown: ").append(e.what()).data());
|
||||
}
|
||||
|
||||
imp->finalize();
|
||||
|
||||
//db->setPredictableIds();
|
||||
@ -363,7 +406,13 @@ void PFImporterTest::stateMatchTest()
|
||||
|
||||
Importer* imp = new PFImporter(lib, instream, logger, "test_fw");
|
||||
imp->setAddStandardCommentsFlag(true);
|
||||
CPPUNIT_ASSERT_NO_THROW( imp->run() );
|
||||
|
||||
try {
|
||||
imp->run() ;
|
||||
} catch (const std::exception &e) {
|
||||
QFAIL(std::string("Exception thrown: ").append(e.what()).data());
|
||||
}
|
||||
|
||||
imp->finalize();
|
||||
|
||||
db->setPredictableIds();
|
||||
@ -385,7 +434,13 @@ void PFImporterTest::tcpFlagsMatchTest()
|
||||
|
||||
Importer* imp = new PFImporter(lib, instream, logger, "test_fw");
|
||||
imp->setAddStandardCommentsFlag(true);
|
||||
CPPUNIT_ASSERT_NO_THROW( imp->run() );
|
||||
|
||||
try {
|
||||
imp->run() ;
|
||||
} catch (const std::exception &e) {
|
||||
QFAIL(std::string("Exception thrown: ").append(e.what()).data());
|
||||
}
|
||||
|
||||
imp->finalize();
|
||||
|
||||
db->setPredictableIds();
|
||||
@ -407,7 +462,13 @@ void PFImporterTest::natCommands()
|
||||
|
||||
Importer* imp = new PFImporter(lib, instream, logger, "test_fw");
|
||||
imp->setAddStandardCommentsFlag(true);
|
||||
CPPUNIT_ASSERT_NO_THROW( imp->run() );
|
||||
|
||||
try {
|
||||
imp->run() ;
|
||||
} catch (const std::exception &e) {
|
||||
QFAIL(std::string("Exception thrown: ").append(e.what()).data());
|
||||
}
|
||||
|
||||
imp->finalize();
|
||||
|
||||
db->setPredictableIds();
|
||||
@ -429,7 +490,13 @@ void PFImporterTest::rdrCommands()
|
||||
|
||||
Importer* imp = new PFImporter(lib, instream, logger, "test_fw");
|
||||
imp->setAddStandardCommentsFlag(true);
|
||||
CPPUNIT_ASSERT_NO_THROW( imp->run() );
|
||||
|
||||
try {
|
||||
imp->run() ;
|
||||
} catch (const std::exception &e) {
|
||||
QFAIL(std::string("Exception thrown: ").append(e.what()).data());
|
||||
}
|
||||
|
||||
imp->finalize();
|
||||
|
||||
db->setPredictableIds();
|
||||
@ -451,7 +518,13 @@ void PFImporterTest::setTimeoutCommands()
|
||||
|
||||
Importer* imp = new PFImporter(lib, instream, logger, "test_fw");
|
||||
imp->setAddStandardCommentsFlag(true);
|
||||
CPPUNIT_ASSERT_NO_THROW( imp->run() );
|
||||
|
||||
try {
|
||||
imp->run() ;
|
||||
} catch (const std::exception &e) {
|
||||
QFAIL(std::string("Exception thrown: ").append(e.what()).data());
|
||||
}
|
||||
|
||||
imp->finalize();
|
||||
|
||||
// db->setPredictableIds();
|
||||
@ -471,7 +544,13 @@ void PFImporterTest::scrubCommandsOld()
|
||||
|
||||
Importer* imp = new PFImporter(lib, instream, logger, "test_fw");
|
||||
imp->setAddStandardCommentsFlag(true);
|
||||
CPPUNIT_ASSERT_NO_THROW( imp->run() );
|
||||
|
||||
try {
|
||||
imp->run() ;
|
||||
} catch (const std::exception &e) {
|
||||
QFAIL(std::string("Exception thrown: ").append(e.what()).data());
|
||||
}
|
||||
|
||||
imp->finalize();
|
||||
|
||||
compareResults(logger,
|
||||
@ -488,7 +567,13 @@ void PFImporterTest::scrubCommandsNew()
|
||||
|
||||
Importer* imp = new PFImporter(lib, instream, logger, "test_fw");
|
||||
imp->setAddStandardCommentsFlag(true);
|
||||
CPPUNIT_ASSERT_NO_THROW( imp->run() );
|
||||
|
||||
try {
|
||||
imp->run() ;
|
||||
} catch (const std::exception &e) {
|
||||
QFAIL(std::string("Exception thrown: ").append(e.what()).data());
|
||||
}
|
||||
|
||||
imp->finalize();
|
||||
|
||||
compareResults(logger,
|
||||
@ -505,7 +590,13 @@ void PFImporterTest::tableDefinitions()
|
||||
|
||||
Importer* imp = new PFImporter(lib, instream, logger, "test_fw");
|
||||
imp->setAddStandardCommentsFlag(true);
|
||||
CPPUNIT_ASSERT_NO_THROW( imp->run() );
|
||||
|
||||
try {
|
||||
imp->run() ;
|
||||
} catch (const std::exception &e) {
|
||||
QFAIL(std::string("Exception thrown: ").append(e.what()).data());
|
||||
}
|
||||
|
||||
imp->finalize();
|
||||
|
||||
db->setPredictableIds();
|
||||
@ -525,7 +616,13 @@ void PFImporterTest::userGroupMatches()
|
||||
|
||||
Importer* imp = new PFImporter(lib, instream, logger, "test_fw");
|
||||
imp->setAddStandardCommentsFlag(true);
|
||||
CPPUNIT_ASSERT_NO_THROW( imp->run() );
|
||||
|
||||
try {
|
||||
imp->run() ;
|
||||
} catch (const std::exception &e) {
|
||||
QFAIL(std::string("Exception thrown: ").append(e.what()).data());
|
||||
}
|
||||
|
||||
imp->finalize();
|
||||
|
||||
db->setPredictableIds();
|
||||
@ -547,7 +644,13 @@ void PFImporterTest::routeToTest()
|
||||
|
||||
Importer* imp = new PFImporter(lib, instream, logger, "test_fw");
|
||||
imp->setAddStandardCommentsFlag(true);
|
||||
CPPUNIT_ASSERT_NO_THROW( imp->run() );
|
||||
|
||||
try {
|
||||
imp->run() ;
|
||||
} catch (const std::exception &e) {
|
||||
QFAIL(std::string("Exception thrown: ").append(e.what()).data());
|
||||
}
|
||||
|
||||
imp->finalize();
|
||||
|
||||
db->setPredictableIds();
|
||||
@ -566,7 +669,13 @@ void PFImporterTest::routeTo47Test()
|
||||
|
||||
Importer* imp = new PFImporter(lib, instream, logger, "test_fw");
|
||||
imp->setAddStandardCommentsFlag(true);
|
||||
CPPUNIT_ASSERT_NO_THROW( imp->run() );
|
||||
|
||||
try {
|
||||
imp->run() ;
|
||||
} catch (const std::exception &e) {
|
||||
QFAIL(std::string("Exception thrown: ").append(e.what()).data());
|
||||
}
|
||||
|
||||
imp->finalize();
|
||||
|
||||
db->setPredictableIds();
|
||||
|
||||
@ -30,23 +30,24 @@
|
||||
#include "fwbuilder/FWException.h"
|
||||
#include "fwbuilder/Logger.h"
|
||||
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
#include <map>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
|
||||
|
||||
class PFImporterTest : public CppUnit::TestFixture
|
||||
class PFImporterTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
libfwbuilder::FWObjectDatabase *db;
|
||||
libfwbuilder::Library *lib;
|
||||
libfwbuilder::QueueLogger *logger;
|
||||
int predictable_id_tracker;
|
||||
std::map<std::string, std::string> id_mapping;
|
||||
|
||||
|
||||
void compareResults(libfwbuilder::QueueLogger* logger,
|
||||
QString expected_result_file_name,
|
||||
QString obtained_result_file_name);
|
||||
@ -54,9 +55,9 @@ class PFImporterTest : public CppUnit::TestFixture
|
||||
QString obtained_result_file_name);
|
||||
|
||||
std::string openTestFile(const QString &file_name);
|
||||
|
||||
public:
|
||||
void setUp();
|
||||
|
||||
private slots:
|
||||
void init();
|
||||
|
||||
void macrosTest();
|
||||
void hostsMatchTest();
|
||||
@ -76,29 +77,6 @@ public:
|
||||
void userGroupMatches();
|
||||
void routeToTest();
|
||||
void routeTo47Test();
|
||||
|
||||
CPPUNIT_TEST_SUITE(PFImporterTest);
|
||||
|
||||
CPPUNIT_TEST(macrosTest);
|
||||
CPPUNIT_TEST(hostsMatchTest);
|
||||
CPPUNIT_TEST(blockReturnTest);
|
||||
CPPUNIT_TEST(icmpMatchTest);
|
||||
CPPUNIT_TEST(interfaceMatchTest);
|
||||
CPPUNIT_TEST(portMatchTest);
|
||||
CPPUNIT_TEST(setCommandsTest);
|
||||
CPPUNIT_TEST(stateMatchTest);
|
||||
CPPUNIT_TEST(tcpFlagsMatchTest);
|
||||
CPPUNIT_TEST(natCommands);
|
||||
CPPUNIT_TEST(rdrCommands);
|
||||
CPPUNIT_TEST(setTimeoutCommands);
|
||||
CPPUNIT_TEST(scrubCommandsOld);
|
||||
CPPUNIT_TEST(scrubCommandsNew);
|
||||
CPPUNIT_TEST(tableDefinitions);
|
||||
CPPUNIT_TEST(userGroupMatches);
|
||||
CPPUNIT_TEST(routeToTest);
|
||||
CPPUNIT_TEST(routeTo47Test);
|
||||
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -21,8 +21,6 @@
|
||||
|
||||
*/
|
||||
|
||||
#include <cppunit/ui/text/TestRunner.h>
|
||||
#include <cppunit/CompilerOutputter.h>
|
||||
#include "PFImporterTest.h"
|
||||
#include "fwbuilder/Resources.h"
|
||||
|
||||
@ -30,6 +28,7 @@
|
||||
#include "FWBSettings.h"
|
||||
#include "FWBApplication.h"
|
||||
|
||||
#include <QTest>
|
||||
#include <QApplication>
|
||||
#include <QString>
|
||||
#include <string>
|
||||
@ -37,10 +36,9 @@
|
||||
#include "common/init.cpp"
|
||||
|
||||
int fwbdebug = 0;
|
||||
//QString user_name;
|
||||
FWWindow *mw = nullptr;
|
||||
FWBSettings *st = nullptr;
|
||||
FWBApplication *app = nullptr;
|
||||
FWWindow *mw = nullptr;
|
||||
FWBSettings *st = nullptr;
|
||||
FWBApplication *app = nullptr;
|
||||
std::string platform;
|
||||
|
||||
int main(int argc, char** argv)
|
||||
@ -49,11 +47,6 @@ int main(int argc, char** argv)
|
||||
|
||||
init(argv);
|
||||
Resources res(Constants::getResourcesFilePath());
|
||||
CppUnit::TextUi::TestRunner runner;
|
||||
runner.addTest( PFImporterTest::suite() );
|
||||
runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(),
|
||||
std::cerr ) );
|
||||
|
||||
runner.run();
|
||||
return 0;
|
||||
return QTest::qExec(new PFImporterTest());
|
||||
}
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
set (CMAKE_AUTOMOC ON)
|
||||
|
||||
add_executable(PIXImporterTest PIXImporterTest.cpp main_PIXImporterTest.cpp)
|
||||
add_test(NAME PIXImporterTest COMMAND PIXImporterTest)
|
||||
|
||||
target_link_libraries(PIXImporterTest PRIVATE test_main netsnmp gui import fwbparser antlr common iptlib fwbpf fwbjuniper fwbcisco compilerdriver fwcompiler fwbuilder xml2 xslt z pthread cppunit)
|
||||
target_link_libraries(PIXImporterTest PRIVATE test_main netsnmp gui import fwbparser antlr common iptlib fwbpf fwbjuniper fwbcisco compilerdriver fwcompiler fwbuilder xml2 xslt z pthread Qt5::Test)
|
||||
|
||||
file(COPY test_data DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
|
||||
@ -42,6 +42,7 @@
|
||||
#include "fwbuilder/TagService.h"
|
||||
#include "fwbuilder/Constants.h"
|
||||
|
||||
#include <QTest>
|
||||
#include <QDebug>
|
||||
#include <QFile>
|
||||
#include <QStringList>
|
||||
@ -67,7 +68,7 @@ class UpgradePredicate: public XMLTools::UpgradePredicate
|
||||
}
|
||||
};
|
||||
|
||||
void PIXImporterTest::setUp()
|
||||
void PIXImporterTest::init()
|
||||
{
|
||||
FWBTree *tree = new FWBTree();
|
||||
|
||||
@ -122,22 +123,22 @@ void PIXImporterTest::compareResults(QueueLogger* logger,
|
||||
QString result_file = rr.readAll();
|
||||
QStringList expected_result = result_file.split("\n");
|
||||
|
||||
CPPUNIT_ASSERT_MESSAGE(
|
||||
QVERIFY2(
|
||||
expected_result.size() == obtained_result.size(),
|
||||
QString(
|
||||
"Sizes of the generated importer output and test files are different.\n"
|
||||
"Expected: %1 (%2)\n"
|
||||
"Obtained: %3 (%4)\n"
|
||||
"diff -u %1 %3 | less -S")
|
||||
.arg(expected_result_file_name).arg(expected_result.size())
|
||||
.arg(obtained_result_file_name).arg(obtained_result.size()).toStdString(),
|
||||
expected_result.size() == obtained_result.size());
|
||||
.arg(obtained_result_file_name).arg(obtained_result.size()).toStdString().data());
|
||||
|
||||
int max_idx = max(expected_result.size(), obtained_result.size());
|
||||
for (int i=0; i < max_idx; ++i)
|
||||
{
|
||||
QString err = QString("Line %1:\nExpected: '%2'\nResult: '%3'\n")
|
||||
.arg(i).arg(expected_result[i]).arg(obtained_result[i]);
|
||||
CPPUNIT_ASSERT_MESSAGE(err.toStdString(), obtained_result[i] == expected_result[i]);
|
||||
QVERIFY2(obtained_result[i] == expected_result[i], err.toStdString().data());
|
||||
}
|
||||
}
|
||||
|
||||
@ -152,7 +153,7 @@ void PIXImporterTest::compareFwbFiles(QString expected_result_file_name,
|
||||
QString result_file = rr.readAll();
|
||||
rr.close();
|
||||
obtained_result = result_file.split("\n");
|
||||
|
||||
|
||||
QFile er(expected_result_file_name);
|
||||
er.open(QFile::ReadOnly);
|
||||
result_file = er.readAll();
|
||||
@ -167,12 +168,12 @@ void PIXImporterTest::compareFwbFiles(QString expected_result_file_name,
|
||||
"Obtained: %3 (%4)\n"
|
||||
"diff -u %1 %3 | less -S");
|
||||
|
||||
CPPUNIT_ASSERT_MESSAGE(
|
||||
QVERIFY2(
|
||||
expected_result.size() == obtained_result.size(),
|
||||
err
|
||||
.arg(expected_result_file_name).arg(expected_result.size())
|
||||
.arg(obtained_result_file_name).arg(obtained_result.size())
|
||||
.toStdString(),
|
||||
expected_result.size() == obtained_result.size());
|
||||
.toStdString().data());
|
||||
|
||||
QRegExp last_mod_re("lastModified=\"\\d+\"");
|
||||
int max_idx = max(expected_result.size(), obtained_result.size());
|
||||
@ -189,7 +190,7 @@ void PIXImporterTest::compareFwbFiles(QString expected_result_file_name,
|
||||
{
|
||||
QString err = QString("Line %1:\nExpected: '%2'\nResult: '%3'\n")
|
||||
.arg(i).arg(expected_result[i]).arg(obtained_result[i]);
|
||||
CPPUNIT_ASSERT_MESSAGE(err.toStdString(), obtained_result[i] == expected_result[i]);
|
||||
QVERIFY2(obtained_result[i] == expected_result[i], err.toStdString().data());
|
||||
}
|
||||
}
|
||||
|
||||
@ -211,7 +212,13 @@ void PIXImporterTest::PIX_6_Test()
|
||||
|
||||
Importer* imp = new PIXImporter(lib, instream, logger, "test_fw");
|
||||
imp->setAddStandardCommentsFlag(true);
|
||||
CPPUNIT_ASSERT_NO_THROW( imp->run() );
|
||||
|
||||
try {
|
||||
imp->run();
|
||||
} catch (const std::exception &e) {
|
||||
QFAIL(std::string("Exception thrown: ").append(e.what()).data());
|
||||
}
|
||||
|
||||
imp->finalize();
|
||||
|
||||
db->setPredictableIds();
|
||||
@ -229,7 +236,13 @@ void PIXImporterTest::PIX_7_Test()
|
||||
|
||||
Importer* imp = new PIXImporter(lib, instream, logger, "test_fw");
|
||||
imp->setAddStandardCommentsFlag(true);
|
||||
CPPUNIT_ASSERT_NO_THROW( imp->run() );
|
||||
|
||||
try {
|
||||
imp->run();
|
||||
} catch (const std::exception &e) {
|
||||
QFAIL(std::string("Exception thrown: ").append(e.what()).data());
|
||||
}
|
||||
|
||||
imp->finalize();
|
||||
|
||||
db->setPredictableIds();
|
||||
@ -247,7 +260,13 @@ void PIXImporterTest::PIX_7_NAT_Test()
|
||||
|
||||
Importer* imp = new PIXImporter(lib, instream, logger, "test_fw");
|
||||
imp->setAddStandardCommentsFlag(true);
|
||||
CPPUNIT_ASSERT_NO_THROW( imp->run() );
|
||||
|
||||
try {
|
||||
imp->run();
|
||||
} catch (const std::exception &e) {
|
||||
QFAIL(std::string("Exception thrown: ").append(e.what()).data());
|
||||
}
|
||||
|
||||
imp->finalize();
|
||||
|
||||
db->setPredictableIds();
|
||||
@ -265,7 +284,13 @@ void PIXImporterTest::ASA_8_0_Test()
|
||||
|
||||
Importer* imp = new PIXImporter(lib, instream, logger, "test_fw");
|
||||
imp->setAddStandardCommentsFlag(true);
|
||||
CPPUNIT_ASSERT_NO_THROW( imp->run() );
|
||||
|
||||
try {
|
||||
imp->run();
|
||||
} catch (const std::exception &e) {
|
||||
QFAIL(std::string("Exception thrown: ").append(e.what()).data());
|
||||
}
|
||||
|
||||
imp->finalize();
|
||||
|
||||
db->setPredictableIds();
|
||||
@ -283,7 +308,13 @@ void PIXImporterTest::ASA_8_3_Test()
|
||||
|
||||
Importer* imp = new PIXImporter(lib, instream, logger, "test_fw");
|
||||
imp->setAddStandardCommentsFlag(true);
|
||||
CPPUNIT_ASSERT_NO_THROW( imp->run() );
|
||||
|
||||
try {
|
||||
imp->run();
|
||||
} catch (const std::exception &e) {
|
||||
QFAIL(std::string("Exception thrown: ").append(e.what()).data());
|
||||
}
|
||||
|
||||
imp->finalize();
|
||||
|
||||
db->setPredictableIds();
|
||||
@ -301,7 +332,13 @@ void PIXImporterTest::ObjectsAndGroupsTest()
|
||||
|
||||
Importer* imp = new PIXImporter(lib, instream, logger, "test_fw");
|
||||
imp->setAddStandardCommentsFlag(true);
|
||||
CPPUNIT_ASSERT_NO_THROW( imp->run() );
|
||||
|
||||
try {
|
||||
imp->run();
|
||||
} catch (const std::exception &e) {
|
||||
QFAIL(std::string("Exception thrown: ").append(e.what()).data());
|
||||
}
|
||||
|
||||
imp->finalize();
|
||||
|
||||
db->setPredictableIds();
|
||||
@ -322,7 +359,13 @@ void PIXImporterTest::ACLObjectsAndGroupsTest()
|
||||
|
||||
Importer* imp = new PIXImporter(lib, instream, logger, "test_fw");
|
||||
imp->setAddStandardCommentsFlag(true);
|
||||
CPPUNIT_ASSERT_NO_THROW( imp->run() );
|
||||
|
||||
try {
|
||||
imp->run();
|
||||
} catch (const std::exception &e) {
|
||||
QFAIL(std::string("Exception thrown: ").append(e.what()).data());
|
||||
}
|
||||
|
||||
imp->finalize();
|
||||
|
||||
db->setPredictableIds();
|
||||
@ -343,7 +386,13 @@ void PIXImporterTest::ACLTest()
|
||||
|
||||
Importer* imp = new PIXImporter(lib, instream, logger, "test_fw");
|
||||
imp->setAddStandardCommentsFlag(true);
|
||||
CPPUNIT_ASSERT_NO_THROW( imp->run() );
|
||||
|
||||
try {
|
||||
imp->run();
|
||||
} catch (const std::exception &e) {
|
||||
QFAIL(std::string("Exception thrown: ").append(e.what()).data());
|
||||
}
|
||||
|
||||
imp->finalize();
|
||||
|
||||
db->setPredictableIds();
|
||||
@ -361,7 +410,13 @@ void PIXImporterTest::NamesTest()
|
||||
|
||||
Importer* imp = new PIXImporter(lib, instream, logger, "test_fw");
|
||||
imp->setAddStandardCommentsFlag(true);
|
||||
CPPUNIT_ASSERT_NO_THROW( imp->run() );
|
||||
|
||||
try {
|
||||
imp->run();
|
||||
} catch (const std::exception &e) {
|
||||
QFAIL(std::string("Exception thrown: ").append(e.what()).data());
|
||||
}
|
||||
|
||||
imp->finalize();
|
||||
|
||||
db->setPredictableIds();
|
||||
@ -377,7 +432,13 @@ void PIXImporterTest::FWSM_4_1_Test()
|
||||
|
||||
Importer* imp = new PIXImporter(lib, instream, logger, "test_fw");
|
||||
imp->setAddStandardCommentsFlag(true);
|
||||
CPPUNIT_ASSERT_NO_THROW( imp->run() );
|
||||
|
||||
try {
|
||||
imp->run();
|
||||
} catch (const std::exception &e) {
|
||||
QFAIL(std::string("Exception thrown: ").append(e.what()).data());
|
||||
}
|
||||
|
||||
imp->finalize();
|
||||
|
||||
db->setPredictableIds();
|
||||
|
||||
@ -30,24 +30,25 @@
|
||||
#include "fwbuilder/FWException.h"
|
||||
#include "fwbuilder/Logger.h"
|
||||
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
#include <map>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
|
||||
|
||||
|
||||
class PIXImporterTest : public CppUnit::TestFixture
|
||||
class PIXImporterTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
libfwbuilder::FWObjectDatabase *db;
|
||||
libfwbuilder::Library *lib;
|
||||
libfwbuilder::QueueLogger *logger;
|
||||
int predictable_id_tracker;
|
||||
std::map<std::string, std::string> id_mapping;
|
||||
|
||||
|
||||
void compareResults(libfwbuilder::QueueLogger* logger,
|
||||
QString expected_result_file_name,
|
||||
QString obtained_result_file_name);
|
||||
@ -55,9 +56,9 @@ class PIXImporterTest : public CppUnit::TestFixture
|
||||
QString obtained_result_file_name);
|
||||
|
||||
std::string openTestFile(const QString &file_name);
|
||||
|
||||
public:
|
||||
void setUp();
|
||||
|
||||
private slots:
|
||||
void init();
|
||||
|
||||
void PIX_6_Test();
|
||||
void PIX_7_Test();
|
||||
@ -70,20 +71,6 @@ public:
|
||||
void ACLTest();
|
||||
void NamesTest();
|
||||
|
||||
CPPUNIT_TEST_SUITE(PIXImporterTest);
|
||||
CPPUNIT_TEST(PIX_6_Test);
|
||||
CPPUNIT_TEST(PIX_7_Test);
|
||||
CPPUNIT_TEST(PIX_7_NAT_Test);
|
||||
CPPUNIT_TEST(ASA_8_0_Test);
|
||||
CPPUNIT_TEST(ASA_8_3_Test);
|
||||
CPPUNIT_TEST(ObjectsAndGroupsTest);
|
||||
CPPUNIT_TEST(ACLObjectsAndGroupsTest);
|
||||
CPPUNIT_TEST(ACLTest);
|
||||
CPPUNIT_TEST(NamesTest);
|
||||
CPPUNIT_TEST(FWSM_4_1_Test);
|
||||
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
};
|
||||
|
||||
#endif // PIXIMPORTERTEST_H
|
||||
|
||||
@ -21,8 +21,6 @@
|
||||
|
||||
*/
|
||||
|
||||
#include <cppunit/ui/text/TestRunner.h>
|
||||
#include <cppunit/CompilerOutputter.h>
|
||||
#include "PIXImporterTest.h"
|
||||
#include "fwbuilder/Resources.h"
|
||||
|
||||
@ -30,6 +28,7 @@
|
||||
#include "FWBSettings.h"
|
||||
#include "FWBApplication.h"
|
||||
|
||||
#include <QTest>
|
||||
#include <QApplication>
|
||||
#include <QString>
|
||||
#include <string>
|
||||
@ -37,10 +36,9 @@
|
||||
#include "common/init.cpp"
|
||||
|
||||
int fwbdebug = 0;
|
||||
//QString user_name;
|
||||
FWWindow *mw = nullptr;
|
||||
FWBSettings *st = nullptr;
|
||||
FWBApplication *app = nullptr;
|
||||
FWWindow *mw = nullptr;
|
||||
FWBSettings *st = nullptr;
|
||||
FWBApplication *app = nullptr;
|
||||
std::string platform;
|
||||
|
||||
int main(int argc, char** argv)
|
||||
@ -49,11 +47,6 @@ int main(int argc, char** argv)
|
||||
|
||||
init(argv);
|
||||
Resources res(Constants::getResourcesFilePath());
|
||||
CppUnit::TextUi::TestRunner runner;
|
||||
runner.addTest( PIXImporterTest::suite() );
|
||||
runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(),
|
||||
std::cerr ) );
|
||||
|
||||
runner.run();
|
||||
return 0;
|
||||
return QTest::qExec(new PIXImporterTest());
|
||||
}
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
set (CMAKE_AUTOMOC ON)
|
||||
|
||||
add_executable(RCSTest RCSTest.cpp main_RCS.cpp)
|
||||
add_test(NAME RCSTest COMMAND RCSTest)
|
||||
|
||||
target_link_libraries(RCSTest PRIVATE test_main netsnmp gui import fwbparser antlr common iptlib fwbpf fwbjuniper fwbcisco compilerdriver fwcompiler fwbuilder xml2 xslt z pthread cppunit)
|
||||
target_link_libraries(RCSTest PRIVATE test_main netsnmp gui import fwbparser antlr common iptlib fwbpf fwbjuniper fwbcisco compilerdriver fwcompiler fwbuilder xml2 xslt z pthread Qt5::Test)
|
||||
|
||||
file(COPY rlog_unit_test.log "zu.fwb,v" DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
@ -25,9 +25,9 @@
|
||||
|
||||
#include "RCSTest.h"
|
||||
|
||||
//#include "../../global.h"
|
||||
#include "../../libgui/RCS.h"
|
||||
|
||||
#include <QTest>
|
||||
#include <QApplication>
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
@ -106,7 +106,7 @@ void RCSTest::verifyRevisions()
|
||||
realrevsmap[rev.rev] = rev;
|
||||
}
|
||||
|
||||
CPPUNIT_ASSERT(realrevs.size() == rcsrevs.size());
|
||||
QVERIFY(realrevs.size() == rcsrevs.size());
|
||||
|
||||
for (int i = 0; i < realrevs.size(); i++)
|
||||
{
|
||||
@ -122,7 +122,7 @@ void RCSTest::verifyRevisions()
|
||||
qDebug() << "----------";
|
||||
qDebug() << (realr == rcsr);
|
||||
*/
|
||||
CPPUNIT_ASSERT (realr == rcsr);
|
||||
QVERIFY (realr == rcsr);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -26,16 +26,14 @@
|
||||
#ifndef RCSTEST_H
|
||||
#define RCSTEST_H
|
||||
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
#include <QObject>
|
||||
|
||||
class RCSTest : public CppUnit::TestFixture
|
||||
class RCSTest : public QObject
|
||||
{
|
||||
public:
|
||||
void verifyRevisions();
|
||||
Q_OBJECT
|
||||
|
||||
CPPUNIT_TEST_SUITE(RCSTest);
|
||||
CPPUNIT_TEST(verifyRevisions);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
private slots:
|
||||
void verifyRevisions();
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -23,22 +23,10 @@
|
||||
|
||||
*/
|
||||
|
||||
#include <cppunit/ui/text/TestRunner.h>
|
||||
#include <cppunit/CompilerOutputter.h>
|
||||
#include "RCSTest.h"
|
||||
#include <QString>
|
||||
#include <string>
|
||||
|
||||
//int fwbdebug = 0;
|
||||
//QString user_name;
|
||||
#include <QTest>
|
||||
|
||||
int main( int, char** )
|
||||
{
|
||||
CppUnit::TextUi::TestRunner runner;
|
||||
runner.addTest( RCSTest::suite() );
|
||||
runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(),
|
||||
std::cerr ) );
|
||||
|
||||
runner.run();
|
||||
return 0;
|
||||
return QTest::qExec(new RCSTest());
|
||||
}
|
||||
|
||||
@ -3,4 +3,4 @@ SET(CMAKE_AUTOMOC ON)
|
||||
add_executable(RuleSetViewContextMenuTest RuleSetViewContextMenuTest.cpp main_RuleSetViewContextMenuTest.cpp)
|
||||
add_test(NAME RuleSetViewContextMenuTest COMMAND RuleSetViewContextMenuTest)
|
||||
|
||||
target_link_libraries(RuleSetViewContextMenuTest PRIVATE test_main netsnmp gui import fwbparser antlr common iptlib fwbpf fwbjuniper fwbcisco compilerdriver fwcompiler fwbuilder xml2 xslt z pthread Qt5::Test)
|
||||
target_link_libraries(RuleSetViewContextMenuTest PRIVATE test_main gui import fwbparser antlr common iptlib fwbpf fwbjuniper fwbcisco compilerdriver fwcompiler fwbuilder netsnmp xml2 xslt z pthread Qt5::Test)
|
||||
|
||||
@ -38,9 +38,9 @@ using namespace std;
|
||||
using namespace libfwbuilder;
|
||||
|
||||
int fwbdebug = 0;
|
||||
FWWindow *mw = nullptr;
|
||||
FWBSettings *st = nullptr;
|
||||
FWBApplication *app = nullptr;
|
||||
FWWindow *mw = nullptr;
|
||||
FWBSettings *st = nullptr;
|
||||
FWBApplication *app = nullptr;
|
||||
|
||||
|
||||
extern void build_app(int argc, char** argv,
|
||||
@ -48,16 +48,18 @@ extern void build_app(int argc, char** argv,
|
||||
FWBSettings** st);
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
app = new FWBApplication(argc, argv);
|
||||
app->setOrganizationName(QLatin1String("NetCitadel"));
|
||||
app->setApplicationName(QLatin1String("Firewall Builder"));
|
||||
{
|
||||
app = new FWBApplication(argc, argv);
|
||||
app->setOrganizationName(QLatin1String("NetCitadel"));
|
||||
app->setApplicationName(QLatin1String("Firewall Builder"));
|
||||
|
||||
build_app(argc, argv, &app, &st);
|
||||
|
||||
|
||||
QTest::qExec(new RuleSetViewContextMenuTest());
|
||||
int testResult = QTest::qExec(new RuleSetViewContextMenuTest());
|
||||
|
||||
if (QFile::exists("test_work.fwb"))
|
||||
QFile::remove("test_work.fwb");
|
||||
if (QFile::exists("test_work.fwb"))
|
||||
QFile::remove("test_work.fwb");
|
||||
|
||||
return testResult;
|
||||
}
|
||||
|
||||
@ -3,4 +3,4 @@ SET(CMAKE_AUTOMOC ON)
|
||||
add_executable(RuleSetViewTest RuleSetViewTest.cpp main_RuleSetViewTest.cpp)
|
||||
add_test(NAME RuleSetViewTest COMMAND RuleSetViewTest)
|
||||
|
||||
target_link_libraries(RuleSetViewTest PRIVATE test_main netsnmp gui import fwbparser antlr common iptlib fwbpf fwbjuniper fwbcisco compilerdriver fwcompiler fwbuilder xml2 xslt z pthread Qt5::Test)
|
||||
target_link_libraries(RuleSetViewTest PRIVATE test_main gui import fwbparser antlr common iptlib fwbpf fwbjuniper fwbcisco compilerdriver fwcompiler fwbuilder netsnmp xml2 xslt z pthread Qt5::Test)
|
||||
|
||||
@ -38,9 +38,9 @@ using namespace std;
|
||||
using namespace libfwbuilder;
|
||||
|
||||
int fwbdebug = 0;
|
||||
FWWindow *mw = nullptr;
|
||||
FWBSettings *st = nullptr;
|
||||
FWBApplication *app = nullptr;
|
||||
FWWindow *mw = nullptr;
|
||||
FWBSettings *st = nullptr;
|
||||
FWBApplication *app = nullptr;
|
||||
|
||||
|
||||
extern void build_app(int argc, char** argv,
|
||||
@ -48,16 +48,18 @@ extern void build_app(int argc, char** argv,
|
||||
FWBSettings** st);
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
app = new FWBApplication(argc, argv);
|
||||
app->setOrganizationName(QLatin1String("NetCitadel"));
|
||||
app->setApplicationName(QLatin1String("Firewall Builder"));
|
||||
{
|
||||
app = new FWBApplication(argc, argv);
|
||||
app->setOrganizationName(QLatin1String("NetCitadel"));
|
||||
app->setApplicationName(QLatin1String("Firewall Builder"));
|
||||
|
||||
build_app(argc, argv, &app, &st);
|
||||
|
||||
|
||||
QTest::qExec(new RuleSetViewTest());
|
||||
int testResult = QTest::qExec(new RuleSetViewTest());
|
||||
|
||||
if (QFile::exists("test_work.fwb"))
|
||||
QFile::remove("test_work.fwb");
|
||||
if (QFile::exists("test_work.fwb"))
|
||||
QFile::remove("test_work.fwb");
|
||||
|
||||
return testResult;
|
||||
}
|
||||
|
||||
@ -3,4 +3,4 @@ SET(CMAKE_AUTOMOC ON)
|
||||
add_executable(TCPServiceDialogTest TCPServiceDialogTest.cpp main_TCPServiceDialogTest.cpp)
|
||||
add_test(NAME TCPServiceDialogTest COMMAND TCPServiceDialogTest)
|
||||
|
||||
target_link_libraries(TCPServiceDialogTest PRIVATE test_main netsnmp gui import fwbparser antlr common iptlib fwbpf fwbjuniper fwbcisco compilerdriver fwcompiler fwbuilder xml2 xslt z pthread Qt5::Test)
|
||||
target_link_libraries(TCPServiceDialogTest PRIVATE test_main gui import fwbparser antlr common iptlib fwbpf fwbjuniper fwbcisco compilerdriver fwcompiler fwbuilder netsnmp xml2 xslt z pthread Qt5::Test)
|
||||
|
||||
@ -37,9 +37,9 @@ using namespace std;
|
||||
using namespace libfwbuilder;
|
||||
|
||||
int fwbdebug = 0;
|
||||
FWWindow *mw = nullptr;
|
||||
FWBSettings *st = nullptr;
|
||||
FWBApplication *app = nullptr;
|
||||
FWWindow *mw = nullptr;
|
||||
FWBSettings *st = nullptr;
|
||||
FWBApplication *app = nullptr;
|
||||
|
||||
|
||||
extern void build_app(int argc, char** argv,
|
||||
@ -47,16 +47,18 @@ extern void build_app(int argc, char** argv,
|
||||
FWBSettings** st);
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
app = new FWBApplication(argc, argv);
|
||||
app->setOrganizationName(QLatin1String("NetCitadel"));
|
||||
app->setApplicationName(QLatin1String("Firewall Builder"));
|
||||
{
|
||||
app = new FWBApplication(argc, argv);
|
||||
app->setOrganizationName(QLatin1String("NetCitadel"));
|
||||
app->setApplicationName(QLatin1String("Firewall Builder"));
|
||||
|
||||
build_app(argc, argv, &app, &st);
|
||||
|
||||
|
||||
QTest::qExec(new TCPServiceDialogTest());
|
||||
int testResult = QTest::qExec(new TCPServiceDialogTest());
|
||||
|
||||
if (QFile::exists("test_work.fwb"))
|
||||
QFile::remove("test_work.fwb");
|
||||
if (QFile::exists("test_work.fwb"))
|
||||
QFile::remove("test_work.fwb");
|
||||
|
||||
return testResult;
|
||||
}
|
||||
|
||||
@ -3,4 +3,4 @@ SET(CMAKE_AUTOMOC ON)
|
||||
add_executable(TagServiceDialogTest TagServiceDialogTest.cpp main_TagServiceDialogTest.cpp)
|
||||
add_test(NAME TagServiceDialogTest COMMAND TagServiceDialogTest)
|
||||
|
||||
target_link_libraries(TagServiceDialogTest PRIVATE test_main netsnmp gui import fwbparser antlr common iptlib fwbpf fwbjuniper fwbcisco compilerdriver fwcompiler fwbuilder xml2 xslt z pthread Qt5::Test)
|
||||
target_link_libraries(TagServiceDialogTest PRIVATE test_main gui import fwbparser antlr common iptlib fwbpf fwbjuniper fwbcisco compilerdriver fwcompiler fwbuilder netsnmp xml2 xslt z pthread Qt5::Test)
|
||||
|
||||
@ -38,9 +38,9 @@ using namespace std;
|
||||
using namespace libfwbuilder;
|
||||
|
||||
int fwbdebug = 0;
|
||||
FWWindow *mw = nullptr;
|
||||
FWBSettings *st = nullptr;
|
||||
FWBApplication *app = nullptr;
|
||||
FWWindow *mw = nullptr;
|
||||
FWBSettings *st = nullptr;
|
||||
FWBApplication *app = nullptr;
|
||||
|
||||
|
||||
extern void build_app(int argc, char** argv,
|
||||
@ -48,16 +48,17 @@ extern void build_app(int argc, char** argv,
|
||||
FWBSettings** st);
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
app = new FWBApplication(argc, argv);
|
||||
app->setOrganizationName(QLatin1String("NetCitadel"));
|
||||
app->setApplicationName(QLatin1String("Firewall Builder"));
|
||||
{
|
||||
app = new FWBApplication(argc, argv);
|
||||
app->setOrganizationName(QLatin1String("NetCitadel"));
|
||||
app->setApplicationName(QLatin1String("Firewall Builder"));
|
||||
|
||||
build_app(argc, argv, &app, &st);
|
||||
|
||||
QTest::qExec(new TagServiceDialogTest());
|
||||
int testResult = QTest::qExec(new TagServiceDialogTest());
|
||||
|
||||
if (QFile::exists("test_work.fwb"))
|
||||
QFile::remove("test_work.fwb");
|
||||
if (QFile::exists("test_work.fwb"))
|
||||
QFile::remove("test_work.fwb");
|
||||
|
||||
return testResult;
|
||||
}
|
||||
|
||||
|
||||
@ -3,4 +3,4 @@ SET(CMAKE_AUTOMOC ON)
|
||||
add_executable(UDPServiceDialogTest UDPServiceDialogTest.cpp main_UDPServiceDialogTest.cpp)
|
||||
add_test(NAME UDPServiceDialogTest COMMAND UDPServiceDialogTest)
|
||||
|
||||
target_link_libraries(UDPServiceDialogTest PRIVATE test_main netsnmp gui import fwbparser antlr common iptlib fwbpf fwbjuniper fwbcisco compilerdriver fwcompiler fwbuilder xml2 xslt z pthread Qt5::Test)
|
||||
target_link_libraries(UDPServiceDialogTest PRIVATE test_main gui import fwbparser antlr common iptlib fwbpf fwbjuniper fwbcisco compilerdriver fwcompiler fwbuilder netsnmp xml2 xslt z pthread Qt5::Test)
|
||||
|
||||
@ -37,9 +37,9 @@ using namespace std;
|
||||
using namespace libfwbuilder;
|
||||
|
||||
int fwbdebug = 0;
|
||||
FWWindow *mw = nullptr;
|
||||
FWBSettings *st = nullptr;
|
||||
FWBApplication *app = nullptr;
|
||||
FWWindow *mw = nullptr;
|
||||
FWBSettings *st = nullptr;
|
||||
FWBApplication *app = nullptr;
|
||||
|
||||
|
||||
extern void build_app(int argc, char** argv,
|
||||
@ -47,16 +47,18 @@ extern void build_app(int argc, char** argv,
|
||||
FWBSettings** st);
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
app = new FWBApplication(argc, argv);
|
||||
app->setOrganizationName(QLatin1String("NetCitadel"));
|
||||
app->setApplicationName(QLatin1String("Firewall Builder"));
|
||||
{
|
||||
app = new FWBApplication(argc, argv);
|
||||
app->setOrganizationName(QLatin1String("NetCitadel"));
|
||||
app->setApplicationName(QLatin1String("Firewall Builder"));
|
||||
|
||||
build_app(argc, argv, &app, &st);
|
||||
|
||||
|
||||
QTest::qExec(new UDPServiceDialogTest());
|
||||
int testResult = QTest::qExec(new UDPServiceDialogTest());
|
||||
|
||||
if (QFile::exists("test_work.fwb"))
|
||||
QFile::remove("test_work.fwb");
|
||||
if (QFile::exists("test_work.fwb"))
|
||||
QFile::remove("test_work.fwb");
|
||||
|
||||
return testResult;
|
||||
}
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
set (CMAKE_AUTOMOC ON)
|
||||
|
||||
add_executable(UsageResolverTest UsageResolverTest.cpp main_UsageResolverTest.cpp)
|
||||
add_test(NAME UsageResolverTest COMMAND UsageResolverTest)
|
||||
|
||||
target_link_libraries(UsageResolverTest PRIVATE test_main netsnmp gui import fwbparser antlr common iptlib fwbpf fwbjuniper fwbcisco compilerdriver fwcompiler fwbuilder xml2 xslt z pthread cppunit)
|
||||
target_link_libraries(UsageResolverTest PRIVATE test_main gui import fwbparser antlr common iptlib fwbpf fwbjuniper fwbcisco compilerdriver fwcompiler fwbuilder netsnmp xml2 xslt z pthread Qt5::Test)
|
||||
|
||||
@ -26,6 +26,7 @@
|
||||
#include "UsageResolverTest.h"
|
||||
#include "UsageResolver.h"
|
||||
|
||||
#include <QTest>
|
||||
#include <QDebug>
|
||||
#include <set>
|
||||
|
||||
@ -38,7 +39,7 @@ void UsageResolverTest::addToLib(FWObject* obj)
|
||||
FWBTree().getStandardSlotForObject(lib, obj->getTypeName().c_str())->add(obj);
|
||||
}
|
||||
|
||||
void UsageResolverTest::setUp()
|
||||
void UsageResolverTest::init()
|
||||
{
|
||||
db = new FWObjectDatabase();
|
||||
db->setName("Database");
|
||||
@ -159,7 +160,7 @@ void UsageResolverTest::findWhereObjectIsUsed()
|
||||
set<FWObject*> res;
|
||||
|
||||
db->findWhereObjectIsUsed(addr1, db, res);
|
||||
CPPUNIT_ASSERT(res.size() == 3);
|
||||
QVERIFY(res.size() == 3);
|
||||
|
||||
set<FWObject*>::iterator iter = res.begin();
|
||||
while (iter!=res.end())
|
||||
@ -173,24 +174,24 @@ void UsageResolverTest::findWhereObjectIsUsed()
|
||||
// if we get reference, the parent must be rule element or user group
|
||||
obj = obj->getParent();
|
||||
|
||||
CPPUNIT_ASSERT(
|
||||
QVERIFY(
|
||||
obj->getTypeName() == RuleElementSrc::TYPENAME ||
|
||||
obj->getTypeName() == ObjectGroup::TYPENAME);
|
||||
|
||||
if (RuleElementSrc::isA(obj))
|
||||
{
|
||||
CPPUNIT_ASSERT(obj->getParent()->getName() == "PolicyRule 1 of Firewall 1");
|
||||
QVERIFY(obj->getParent()->getName() == "PolicyRule 1 of Firewall 1");
|
||||
}
|
||||
|
||||
if (ObjectGroup::isA(obj))
|
||||
{
|
||||
CPPUNIT_ASSERT(obj->getName() == "Group 1");
|
||||
QVERIFY(obj->getName() == "Group 1");
|
||||
}
|
||||
|
||||
} else
|
||||
{
|
||||
// otherwise we should get system folder "Addresses"
|
||||
CPPUNIT_ASSERT(name == "Addresses" );
|
||||
QVERIFY(name == "Addresses" );
|
||||
}
|
||||
iter++;
|
||||
}
|
||||
@ -204,26 +205,26 @@ void UsageResolverTest::findFirewallsForObject()
|
||||
qDebug() << "Dependencies for addr1:";
|
||||
list<Firewall*> res = UsageResolver().findFirewallsForObject(addr1, db);
|
||||
list<Firewall*>::iterator iter = res.begin();
|
||||
CPPUNIT_ASSERT(res.size() == 3);
|
||||
QVERIFY(res.size() == 3);
|
||||
while (iter!=res.end())
|
||||
{
|
||||
string name = (*iter)->getName();
|
||||
qDebug() << name.c_str()
|
||||
<< "' (" << (*iter)->getTypeName().c_str() << ")";
|
||||
CPPUNIT_ASSERT ( name == "Firewall 1" || name == "Firewall 3" || name == "Firewall 4" );
|
||||
QVERIFY ( name == "Firewall 1" || name == "Firewall 3" || name == "Firewall 4" );
|
||||
iter++;
|
||||
}
|
||||
|
||||
qDebug() << "Dependencies for addr2:";
|
||||
res = UsageResolver().findFirewallsForObject(addr2, db);
|
||||
iter = res.begin();
|
||||
CPPUNIT_ASSERT(res.size() == 4);
|
||||
QVERIFY(res.size() == 4);
|
||||
while (iter!=res.end())
|
||||
{
|
||||
string name = (*iter)->getName();
|
||||
qDebug() << name.c_str()
|
||||
<< "' (" << (*iter)->getTypeName().c_str() << ")";
|
||||
CPPUNIT_ASSERT ( name == "Firewall 1" || name == "Firewall 2" || name == "Firewall 3" || name == "Firewall 4");
|
||||
QVERIFY ( name == "Firewall 1" || name == "Firewall 2" || name == "Firewall 3" || name == "Firewall 4");
|
||||
iter++;
|
||||
}
|
||||
|
||||
@ -231,13 +232,13 @@ void UsageResolverTest::findFirewallsForObject()
|
||||
qDebug() << "Dependencies for addr3:";
|
||||
res = UsageResolver().findFirewallsForObject(addr3, db);
|
||||
iter = res.begin();
|
||||
//CPPUNIT_ASSERT(res.size() == 3);
|
||||
//QVERIFY(res.size() == 3);
|
||||
while (iter!=res.end())
|
||||
{
|
||||
string name = (*iter)->getName();
|
||||
qDebug() << name.c_str()
|
||||
<< "' (" << (*iter)->getTypeName().c_str() << ")";
|
||||
CPPUNIT_ASSERT ( name == "Firewall 2" || name == "Firewall 3" || name == "Firewall 4" );
|
||||
QVERIFY ( name == "Firewall 2" || name == "Firewall 3" || name == "Firewall 4" );
|
||||
iter++;
|
||||
}
|
||||
}
|
||||
@ -255,11 +256,11 @@ void UsageResolverTest::humanizeSearchResults()
|
||||
if (type == "ObjectRef")
|
||||
{
|
||||
FWObjectReference *o = FWObjectReference::cast(*iter);
|
||||
CPPUNIT_ASSERT(o->getPointer()->getName() == "Address 1");
|
||||
QVERIFY(o->getPointer()->getName() == "Address 1");
|
||||
}
|
||||
else
|
||||
{
|
||||
CPPUNIT_ASSERT ( name == "Group 1" || name == "Addresses");
|
||||
QVERIFY ( name == "Group 1" || name == "Addresses");
|
||||
}
|
||||
iter++;
|
||||
}
|
||||
|
||||
@ -35,14 +35,14 @@
|
||||
#include "fwbuilder/Library.h"
|
||||
#include "FWBTree.h"
|
||||
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
#include <QObject>
|
||||
|
||||
|
||||
class UsageResolverTest : public CppUnit::TestFixture
|
||||
class UsageResolverTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
void addToLib(libfwbuilder::FWObject* obj);
|
||||
|
||||
public:
|
||||
libfwbuilder::FWObjectDatabase *db;
|
||||
libfwbuilder::Library *lib;
|
||||
libfwbuilder::IPv4 *addr1;
|
||||
@ -50,19 +50,13 @@ public:
|
||||
libfwbuilder::IPv4 *addr3;
|
||||
libfwbuilder::PolicyRule *r1, *r2, *r3, *r4;
|
||||
|
||||
void setUp();
|
||||
private slots:
|
||||
void init();
|
||||
|
||||
void findWhereObjectIsUsed();
|
||||
void findFirewallsForObject();
|
||||
void humanizeSearchResults();
|
||||
|
||||
|
||||
CPPUNIT_TEST_SUITE(UsageResolverTest);
|
||||
CPPUNIT_TEST(findWhereObjectIsUsed);
|
||||
CPPUNIT_TEST(findFirewallsForObject);
|
||||
CPPUNIT_TEST(humanizeSearchResults);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
};
|
||||
|
||||
#endif // FWOBJECTDATABASETEST_H
|
||||
|
||||
@ -23,21 +23,14 @@
|
||||
|
||||
*/
|
||||
|
||||
#include <cppunit/ui/text/TestRunner.h>
|
||||
#include <cppunit/CompilerOutputter.h>
|
||||
#include "UsageResolverTest.h"
|
||||
#include <string>
|
||||
#include <QTest>
|
||||
|
||||
int fwbdebug = 0;
|
||||
QString user_name;
|
||||
|
||||
int main( int, char** )
|
||||
{
|
||||
CppUnit::TextUi::TestRunner runner;
|
||||
runner.addTest( UsageResolverTest::suite() );
|
||||
runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(),
|
||||
std::cerr ) );
|
||||
|
||||
runner.run();
|
||||
return 0;
|
||||
return QTest::qExec(new UsageResolverTest());
|
||||
}
|
||||
|
||||
@ -3,4 +3,4 @@ SET(CMAKE_AUTOMOC ON)
|
||||
add_executable(UserServiceDialogTest UserServiceDialogTest.cpp main_UserServiceDialogTest.cpp)
|
||||
add_test(NAME UserServiceDialogTest COMMAND UserServiceDialogTest)
|
||||
|
||||
target_link_libraries(UserServiceDialogTest PRIVATE test_main netsnmp gui import fwbparser antlr common iptlib fwbpf fwbjuniper fwbcisco compilerdriver fwcompiler fwbuilder xml2 xslt z pthread Qt5::Test)
|
||||
target_link_libraries(UserServiceDialogTest PRIVATE test_main gui import fwbparser antlr common iptlib fwbpf fwbjuniper fwbcisco compilerdriver fwcompiler fwbuilder netsnmp xml2 xslt z pthread Qt5::Test)
|
||||
|
||||
@ -37,9 +37,9 @@ using namespace std;
|
||||
using namespace libfwbuilder;
|
||||
|
||||
int fwbdebug = 0;
|
||||
FWWindow *mw = nullptr;
|
||||
FWBSettings *st = nullptr;
|
||||
FWBApplication *app = nullptr;
|
||||
FWWindow *mw = nullptr;
|
||||
FWBSettings *st = nullptr;
|
||||
FWBApplication *app = nullptr;
|
||||
|
||||
|
||||
extern void build_app(int argc, char** argv,
|
||||
@ -47,16 +47,18 @@ extern void build_app(int argc, char** argv,
|
||||
FWBSettings** st);
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
app = new FWBApplication(argc, argv);
|
||||
app->setOrganizationName(QLatin1String("NetCitadel"));
|
||||
app->setApplicationName(QLatin1String("Firewall Builder"));
|
||||
{
|
||||
app = new FWBApplication(argc, argv);
|
||||
app->setOrganizationName(QLatin1String("NetCitadel"));
|
||||
app->setApplicationName(QLatin1String("Firewall Builder"));
|
||||
|
||||
build_app(argc, argv, &app, &st);
|
||||
|
||||
|
||||
QTest::qExec(new UserServiceDialogTest());
|
||||
int testResult = QTest::qExec(new UserServiceDialogTest());
|
||||
|
||||
if (QFile::exists("test_work.fwb"))
|
||||
QFile::remove("test_work.fwb");
|
||||
if (QFile::exists("test_work.fwb"))
|
||||
QFile::remove("test_work.fwb");
|
||||
|
||||
return testResult;
|
||||
}
|
||||
|
||||
@ -5,6 +5,6 @@ add_definitions(-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\")
|
||||
add_executable(compilerLibTest interfacePropertiesTest.cpp tests_main.cpp)
|
||||
add_test(NAME compilerLibTest COMMAND compilerLibTest)
|
||||
|
||||
target_link_libraries(compilerLibTest PRIVATE test_main netsnmp gui import fwbparser antlr common iptlib fwbpf fwbjuniper fwbcisco compilerdriver fwcompiler fwbuilder xml2 xslt z pthread cppunit)
|
||||
target_link_libraries(compilerLibTest PRIVATE test_main netsnmp gui import fwbparser antlr common iptlib fwbpf fwbjuniper fwbcisco compilerdriver fwcompiler fwbuilder xml2 xslt z pthread Qt5::Test)
|
||||
|
||||
file(COPY test.fwb DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
@ -23,6 +23,8 @@
|
||||
|
||||
*/
|
||||
|
||||
#include <QTest>
|
||||
|
||||
#include "interfacePropertiesTest.h"
|
||||
|
||||
#include "fwbuilder/Firewall.h"
|
||||
@ -35,7 +37,6 @@
|
||||
|
||||
using namespace std;
|
||||
using namespace libfwbuilder;
|
||||
using namespace CppUnit;
|
||||
|
||||
|
||||
class UpgradePredicate: public XMLTools::UpgradePredicate
|
||||
@ -58,7 +59,7 @@ interfaceProperties* interfacePropertiesTest::getIntProps(const QString &os)
|
||||
return interfacePropertiesObjectFactory::getInterfacePropertiesObject(os_family);
|
||||
}
|
||||
|
||||
void interfacePropertiesTest::setUp()
|
||||
void interfacePropertiesTest::init()
|
||||
{
|
||||
db = new FWObjectDatabase();
|
||||
}
|
||||
@ -79,49 +80,49 @@ void interfacePropertiesTest::validateInterfaceNameCommon()
|
||||
|
||||
interfaceProperties * int_prop = getIntProps("unknown");
|
||||
|
||||
CPPUNIT_ASSERT(int_prop != nullptr);
|
||||
QVERIFY(int_prop != nullptr);
|
||||
|
||||
CPPUNIT_ASSERT(int_prop->basicValidateInterfaceName(
|
||||
QVERIFY(int_prop->basicValidateInterfaceName(
|
||||
iface, "eth0", err) == true);
|
||||
|
||||
CPPUNIT_ASSERT(int_prop->basicValidateInterfaceName(
|
||||
QVERIFY(int_prop->basicValidateInterfaceName(
|
||||
iface, "foo0", err) == true);
|
||||
|
||||
CPPUNIT_ASSERT(int_prop->basicValidateInterfaceName(
|
||||
QVERIFY(int_prop->basicValidateInterfaceName(
|
||||
iface, "bar0", err) == true);
|
||||
|
||||
CPPUNIT_ASSERT(int_prop->basicValidateInterfaceName(
|
||||
QVERIFY(int_prop->basicValidateInterfaceName(
|
||||
iface, "vlan100", err) == true);
|
||||
|
||||
CPPUNIT_ASSERT(int_prop->basicValidateInterfaceName(
|
||||
QVERIFY(int_prop->basicValidateInterfaceName(
|
||||
iface, "Vlan100", err) == true);
|
||||
|
||||
CPPUNIT_ASSERT(int_prop->basicValidateInterfaceName(
|
||||
QVERIFY(int_prop->basicValidateInterfaceName(
|
||||
iface, "VlAn100", err) == true);
|
||||
|
||||
CPPUNIT_ASSERT(int_prop->basicValidateInterfaceName(
|
||||
QVERIFY(int_prop->basicValidateInterfaceName(
|
||||
iface, "foo 0", err) == false);
|
||||
|
||||
CPPUNIT_ASSERT(int_prop->basicValidateInterfaceName(
|
||||
QVERIFY(int_prop->basicValidateInterfaceName(
|
||||
iface, "foo-1", err) == false);
|
||||
|
||||
CPPUNIT_ASSERT(int_prop->basicValidateInterfaceName(
|
||||
QVERIFY(int_prop->basicValidateInterfaceName(
|
||||
iface, "foo 12345", err) == false);
|
||||
|
||||
iface->getOptionsObject()->setStr("type", "bridge");
|
||||
|
||||
CPPUNIT_ASSERT(int_prop->basicValidateInterfaceName(
|
||||
QVERIFY(int_prop->basicValidateInterfaceName(
|
||||
iface, "br0", err) == true);
|
||||
|
||||
CPPUNIT_ASSERT(int_prop->basicValidateInterfaceName(
|
||||
QVERIFY(int_prop->basicValidateInterfaceName(
|
||||
iface, "Br0", err) == true);
|
||||
|
||||
// all OS except Linux and possibly some other do not permit
|
||||
// interface name with "-"
|
||||
CPPUNIT_ASSERT(int_prop->basicValidateInterfaceName(
|
||||
QVERIFY(int_prop->basicValidateInterfaceName(
|
||||
iface, "br-lan", err) == false);
|
||||
|
||||
CPPUNIT_ASSERT(int_prop->basicValidateInterfaceName(
|
||||
QVERIFY(int_prop->basicValidateInterfaceName(
|
||||
iface, "br 200", err) == false);
|
||||
|
||||
}
|
||||
@ -142,51 +143,51 @@ void interfacePropertiesTest::validateInterfaceNameLinux()
|
||||
|
||||
interfaceProperties * int_prop = getIntProps("linux24");
|
||||
|
||||
CPPUNIT_ASSERT(int_prop->basicValidateInterfaceName(
|
||||
QVERIFY(int_prop->basicValidateInterfaceName(
|
||||
iface, "eth0", err) == true);
|
||||
|
||||
CPPUNIT_ASSERT(int_prop->basicValidateInterfaceName(
|
||||
QVERIFY(int_prop->basicValidateInterfaceName(
|
||||
iface, "foo0", err) == true);
|
||||
|
||||
CPPUNIT_ASSERT(int_prop->basicValidateInterfaceName(
|
||||
QVERIFY(int_prop->basicValidateInterfaceName(
|
||||
iface, "bar0", err) == true);
|
||||
|
||||
// we do not have special type for p2p interfaces yet
|
||||
// Linux permits "-" in interface names (see #1856)
|
||||
CPPUNIT_ASSERT(int_prop->basicValidateInterfaceName(
|
||||
QVERIFY(int_prop->basicValidateInterfaceName(
|
||||
iface, "ppp-dsl", err) == true);
|
||||
|
||||
iface->getOptionsObject()->setStr("type", "8021q");
|
||||
|
||||
CPPUNIT_ASSERT(int_prop->basicValidateInterfaceName(
|
||||
QVERIFY(int_prop->basicValidateInterfaceName(
|
||||
iface, "vlan100", err) == true);
|
||||
|
||||
CPPUNIT_ASSERT(int_prop->basicValidateInterfaceName(
|
||||
QVERIFY(int_prop->basicValidateInterfaceName(
|
||||
iface, "Vlan100", err) == true);
|
||||
|
||||
CPPUNIT_ASSERT(int_prop->basicValidateInterfaceName(
|
||||
QVERIFY(int_prop->basicValidateInterfaceName(
|
||||
iface, "VlAn100", err) == true);
|
||||
|
||||
CPPUNIT_ASSERT(int_prop->basicValidateInterfaceName(
|
||||
QVERIFY(int_prop->basicValidateInterfaceName(
|
||||
iface, "foo 0", err) == false);
|
||||
|
||||
CPPUNIT_ASSERT(int_prop->basicValidateInterfaceName(
|
||||
QVERIFY(int_prop->basicValidateInterfaceName(
|
||||
iface, "foo 12345", err) == false);
|
||||
|
||||
iface->getOptionsObject()->setStr("type", "bridge");
|
||||
|
||||
CPPUNIT_ASSERT(int_prop->basicValidateInterfaceName(
|
||||
QVERIFY(int_prop->basicValidateInterfaceName(
|
||||
iface, "br0", err) == true);
|
||||
|
||||
CPPUNIT_ASSERT(int_prop->basicValidateInterfaceName(
|
||||
QVERIFY(int_prop->basicValidateInterfaceName(
|
||||
iface, "Br0", err) == true);
|
||||
|
||||
// Linux permits "-" in interface names (see #1856)
|
||||
CPPUNIT_ASSERT(int_prop->basicValidateInterfaceName(
|
||||
QVERIFY(int_prop->basicValidateInterfaceName(
|
||||
iface, "br-lan", err) == true);
|
||||
|
||||
// spaces are not permitted
|
||||
CPPUNIT_ASSERT(int_prop->basicValidateInterfaceName(
|
||||
QVERIFY(int_prop->basicValidateInterfaceName(
|
||||
iface, "br 200", err) == false);
|
||||
|
||||
}
|
||||
@ -207,37 +208,37 @@ void interfacePropertiesTest::validateInterfaceNameProCurve()
|
||||
|
||||
interfaceProperties * int_prop = getIntProps("procurve");
|
||||
|
||||
CPPUNIT_ASSERT(int_prop->basicValidateInterfaceName(
|
||||
QVERIFY(int_prop->basicValidateInterfaceName(
|
||||
iface, "a1", err) == true);
|
||||
|
||||
CPPUNIT_ASSERT(int_prop->basicValidateInterfaceName(
|
||||
QVERIFY(int_prop->basicValidateInterfaceName(
|
||||
iface, "b1", err) == true);
|
||||
|
||||
CPPUNIT_ASSERT(int_prop->basicValidateInterfaceName(
|
||||
QVERIFY(int_prop->basicValidateInterfaceName(
|
||||
iface, "A1", err) == true);
|
||||
|
||||
// basicValidateInterfaceName() only checks name format,
|
||||
// it does not check if port number makes sense
|
||||
CPPUNIT_ASSERT(int_prop->basicValidateInterfaceName(
|
||||
QVERIFY(int_prop->basicValidateInterfaceName(
|
||||
iface, "A1234567890", err) == true);
|
||||
|
||||
// "-" is not permitted
|
||||
CPPUNIT_ASSERT(int_prop->basicValidateInterfaceName(
|
||||
QVERIFY(int_prop->basicValidateInterfaceName(
|
||||
iface, "vlan-100", err) == false);
|
||||
|
||||
// but space is permitted
|
||||
CPPUNIT_ASSERT(int_prop->basicValidateInterfaceName(
|
||||
QVERIFY(int_prop->basicValidateInterfaceName(
|
||||
iface, "vlan 100", err) == true);
|
||||
|
||||
CPPUNIT_ASSERT(int_prop->basicValidateInterfaceName(
|
||||
QVERIFY(int_prop->basicValidateInterfaceName(
|
||||
iface, "Vlan 100", err) == true);
|
||||
|
||||
CPPUNIT_ASSERT(int_prop->basicValidateInterfaceName(
|
||||
QVERIFY(int_prop->basicValidateInterfaceName(
|
||||
iface, "VlAn 100", err) == true);
|
||||
|
||||
// basicValidateInterfaceName() only checks name format,
|
||||
// it does not check if vlan ID is valid.
|
||||
CPPUNIT_ASSERT(int_prop->basicValidateInterfaceName(
|
||||
QVERIFY(int_prop->basicValidateInterfaceName(
|
||||
iface, "VlAn 1000000000", err) == true);
|
||||
}
|
||||
|
||||
@ -252,7 +253,7 @@ void interfacePropertiesTest::validateInterface()
|
||||
|
||||
interfaceProperties * int_prop = interfacePropertiesObjectFactory::getInterfacePropertiesObject(os_family);
|
||||
|
||||
CPPUNIT_ASSERT(int_prop != nullptr);
|
||||
QVERIFY(int_prop != nullptr);
|
||||
|
||||
QString err;
|
||||
|
||||
@ -269,21 +270,21 @@ void interfacePropertiesTest::validateInterface()
|
||||
iface1->getOptionsObject()->setStr("type", "ethernet");
|
||||
cluster1->setStr("host_OS", host_OS);
|
||||
|
||||
CPPUNIT_ASSERT(int_prop->validateInterface(dynamic_cast<FWObject*>(cluster1),
|
||||
QVERIFY(int_prop->validateInterface(dynamic_cast<FWObject*>(cluster1),
|
||||
dynamic_cast<FWObject*>(iface1), false, err) == true );
|
||||
|
||||
iface1->setUnnumbered(true);
|
||||
CPPUNIT_ASSERT(int_prop->validateInterface(dynamic_cast<FWObject*>(cluster1),
|
||||
QVERIFY(int_prop->validateInterface(dynamic_cast<FWObject*>(cluster1),
|
||||
dynamic_cast<FWObject*>(iface1), false, err) == true );
|
||||
|
||||
parent1->getOptionsObject()->setStr("type", "bonding");
|
||||
iface1->setUnnumbered(false);
|
||||
CPPUNIT_ASSERT(int_prop->validateInterface(dynamic_cast<FWObject*>(cluster1),
|
||||
QVERIFY(int_prop->validateInterface(dynamic_cast<FWObject*>(cluster1),
|
||||
dynamic_cast<FWObject*>(iface1), false, err) == false );
|
||||
|
||||
parent1->getOptionsObject()->setStr("type", "bridge");
|
||||
iface1->setUnnumbered(false);
|
||||
CPPUNIT_ASSERT(int_prop->validateInterface(dynamic_cast<FWObject*>(cluster1),
|
||||
QVERIFY(int_prop->validateInterface(dynamic_cast<FWObject*>(cluster1),
|
||||
dynamic_cast<FWObject*>(iface1), false, err) == false );
|
||||
|
||||
|
||||
@ -297,20 +298,20 @@ void interfacePropertiesTest::validateInterface()
|
||||
|
||||
fw.add(parent);
|
||||
|
||||
CPPUNIT_ASSERT(int_prop->validateInterface(dynamic_cast<FWObject*>(parent),
|
||||
QVERIFY(int_prop->validateInterface(dynamic_cast<FWObject*>(parent),
|
||||
dynamic_cast<FWObject*>(iface), true, err)
|
||||
== false);
|
||||
|
||||
parent->getOptionsObject()->setStr("type", "bridge");
|
||||
iface->getOptionsObject()->setStr("type", "ethernet");
|
||||
|
||||
CPPUNIT_ASSERT(int_prop->validateInterface(dynamic_cast<FWObject*>(parent),
|
||||
QVERIFY(int_prop->validateInterface(dynamic_cast<FWObject*>(parent),
|
||||
FWObject::cast(iface), true, err)
|
||||
== true);
|
||||
|
||||
iface->getOptionsObject()->setStr("type", "ethernet");
|
||||
iface->add(subiface);
|
||||
CPPUNIT_ASSERT(int_prop->validateInterface(dynamic_cast<FWObject*>(parent),
|
||||
QVERIFY(int_prop->validateInterface(dynamic_cast<FWObject*>(parent),
|
||||
dynamic_cast<FWObject*>(iface), false, err)
|
||||
== false);
|
||||
iface->remove(subiface);
|
||||
@ -318,37 +319,37 @@ void interfacePropertiesTest::validateInterface()
|
||||
Cluster *cluster = Cluster::cast(db->create(Cluster::TYPENAME));
|
||||
|
||||
iface->setName("vlan0");
|
||||
CPPUNIT_ASSERT(int_prop->validateInterface(dynamic_cast<FWObject*>(cluster),
|
||||
QVERIFY(int_prop->validateInterface(dynamic_cast<FWObject*>(cluster),
|
||||
dynamic_cast<FWObject*>(iface), false, err)
|
||||
== true);
|
||||
|
||||
iface->setName("vlan34324");
|
||||
CPPUNIT_ASSERT(int_prop->validateInterface(dynamic_cast<FWObject*>(cluster),
|
||||
QVERIFY(int_prop->validateInterface(dynamic_cast<FWObject*>(cluster),
|
||||
dynamic_cast<FWObject*>(iface), false, err)
|
||||
== false);
|
||||
|
||||
parent->setName("vlan");
|
||||
parent->getOptionsObject()->setStr("type", "bridge");
|
||||
iface->setName("vlan1");
|
||||
CPPUNIT_ASSERT(int_prop->validateInterface(dynamic_cast<FWObject*>(parent),
|
||||
QVERIFY(int_prop->validateInterface(dynamic_cast<FWObject*>(parent),
|
||||
dynamic_cast<FWObject*>(iface), false, err)
|
||||
== true);
|
||||
|
||||
IPv4 *adr = IPv4::cast(db->create(IPv4::TYPENAME));
|
||||
CPPUNIT_ASSERT(int_prop->validateInterface(dynamic_cast<FWObject*>(adr),
|
||||
QVERIFY(int_prop->validateInterface(dynamic_cast<FWObject*>(adr),
|
||||
dynamic_cast<FWObject*>(iface), false, err)
|
||||
== false);
|
||||
|
||||
parent->setName("notAVlan");
|
||||
parent->getOptionsObject()->setStr("type", "ethernet");
|
||||
iface->setName("vlan1");
|
||||
CPPUNIT_ASSERT(int_prop->validateInterface(dynamic_cast<FWObject*>(parent),
|
||||
QVERIFY(int_prop->validateInterface(dynamic_cast<FWObject*>(parent),
|
||||
dynamic_cast<FWObject*>(iface), false, err)
|
||||
== true);
|
||||
|
||||
|
||||
iface->setName("eth0");
|
||||
CPPUNIT_ASSERT(int_prop->validateInterface(dynamic_cast<FWObject*>(parent),
|
||||
QVERIFY(int_prop->validateInterface(dynamic_cast<FWObject*>(parent),
|
||||
dynamic_cast<FWObject*>(iface), false, err)
|
||||
== false);
|
||||
|
||||
@ -363,7 +364,7 @@ void interfacePropertiesTest::isEligibleForCluster()
|
||||
|
||||
interfaceProperties * int_prop = interfacePropertiesObjectFactory::getInterfacePropertiesObject(os_family);
|
||||
|
||||
CPPUNIT_ASSERT(int_prop != nullptr);
|
||||
QVERIFY(int_prop != nullptr);
|
||||
|
||||
Firewall *fw1 = Firewall::cast(db->create(Firewall::TYPENAME));
|
||||
fw1->setName("iface");
|
||||
@ -378,27 +379,27 @@ void interfacePropertiesTest::isEligibleForCluster()
|
||||
|
||||
iface1->getOptionsObject()->setStr("type", "ethernet");
|
||||
parent1->getOptionsObject()->setStr("type", "ethernet");
|
||||
CPPUNIT_ASSERT(int_prop->isEligibleForCluster(iface1) == true);
|
||||
QVERIFY(int_prop->isEligibleForCluster(iface1) == true);
|
||||
|
||||
iface1->getOptionsObject()->setStr("type", "ethernet");
|
||||
parent1->getOptionsObject()->setStr("type", "bridge");
|
||||
CPPUNIT_ASSERT(int_prop->isEligibleForCluster(iface1) == false);
|
||||
QVERIFY(int_prop->isEligibleForCluster(iface1) == false);
|
||||
|
||||
iface1->getOptionsObject()->setStr("type", "bonding");
|
||||
parent1->getOptionsObject()->setStr("type", "ethernet");
|
||||
CPPUNIT_ASSERT(int_prop->isEligibleForCluster(iface1) == true);
|
||||
QVERIFY(int_prop->isEligibleForCluster(iface1) == true);
|
||||
|
||||
iface1->getOptionsObject()->setStr("type", "bridge");
|
||||
parent1->getOptionsObject()->setStr("type", "ethernet");
|
||||
CPPUNIT_ASSERT(int_prop->isEligibleForCluster(iface1) == true);
|
||||
QVERIFY(int_prop->isEligibleForCluster(iface1) == true);
|
||||
|
||||
iface1->getOptionsObject()->setStr("type", "8021q");
|
||||
parent1->getOptionsObject()->setStr("type", "ethernet");
|
||||
CPPUNIT_ASSERT(int_prop->isEligibleForCluster(iface1) == true);
|
||||
QVERIFY(int_prop->isEligibleForCluster(iface1) == true);
|
||||
|
||||
iface1->getOptionsObject()->setStr("type", "ethernet");
|
||||
parent1->getOptionsObject()->setStr("type", "bridge");
|
||||
CPPUNIT_ASSERT(int_prop->isEligibleForCluster(iface1) == false);
|
||||
QVERIFY(int_prop->isEligibleForCluster(iface1) == false);
|
||||
|
||||
Firewall *fw = Firewall::cast(db->create(Firewall::TYPENAME));
|
||||
fw->setName("iface");
|
||||
@ -409,10 +410,10 @@ void interfacePropertiesTest::isEligibleForCluster()
|
||||
fw->add(iface);
|
||||
iface->getOptionsObject()->setStr("type", "bonding");
|
||||
iface->add(subface);
|
||||
CPPUNIT_ASSERT ( interfaceProperties().isEligibleForCluster(subface) == false );
|
||||
QVERIFY ( interfaceProperties().isEligibleForCluster(subface) == false );
|
||||
|
||||
iface->getOptionsObject()->setStr("type", "ethernet");
|
||||
CPPUNIT_ASSERT ( interfaceProperties().isEligibleForCluster(iface) == false );
|
||||
QVERIFY ( interfaceProperties().isEligibleForCluster(iface) == false );
|
||||
|
||||
}
|
||||
|
||||
@ -430,18 +431,18 @@ eth0.bar eth0 false
|
||||
eth0.99999 eth0 false
|
||||
eth1.101 eth0 false
|
||||
*/
|
||||
CPPUNIT_ASSERT (int_prop->isValidVlanInterfaceName("vlan101", parent, err) == true);
|
||||
CPPUNIT_ASSERT (int_prop->isValidVlanInterfaceName("eth0.101", parent, err) == true);
|
||||
CPPUNIT_ASSERT (int_prop->isValidVlanInterfaceName("foo", parent, err) == false);
|
||||
CPPUNIT_ASSERT (int_prop->isValidVlanInterfaceName("foo101", parent, err) == false);
|
||||
CPPUNIT_ASSERT (int_prop->isValidVlanInterfaceName("eth0.bar", parent, err) == false);
|
||||
CPPUNIT_ASSERT (int_prop->isValidVlanInterfaceName("eth0.99999", parent, err) == false);
|
||||
CPPUNIT_ASSERT (int_prop->isValidVlanInterfaceName("eth1.101", parent, err) == false);
|
||||
QVERIFY (int_prop->isValidVlanInterfaceName("vlan101", parent, err) == true);
|
||||
QVERIFY (int_prop->isValidVlanInterfaceName("eth0.101", parent, err) == true);
|
||||
QVERIFY (int_prop->isValidVlanInterfaceName("foo", parent, err) == false);
|
||||
QVERIFY (int_prop->isValidVlanInterfaceName("foo101", parent, err) == false);
|
||||
QVERIFY (int_prop->isValidVlanInterfaceName("eth0.bar", parent, err) == false);
|
||||
QVERIFY (int_prop->isValidVlanInterfaceName("eth0.99999", parent, err) == false);
|
||||
QVERIFY (int_prop->isValidVlanInterfaceName("eth1.101", parent, err) == false);
|
||||
|
||||
parent = "bond1";
|
||||
CPPUNIT_ASSERT (int_prop->isValidVlanInterfaceName("bond1.15", parent, err) == true);
|
||||
CPPUNIT_ASSERT (int_prop->isValidVlanInterfaceName("bond1.515", parent, err) == true);
|
||||
CPPUNIT_ASSERT (int_prop->isValidVlanInterfaceName("bond1.1205", parent, err) == true);
|
||||
QVERIFY (int_prop->isValidVlanInterfaceName("bond1.15", parent, err) == true);
|
||||
QVERIFY (int_prop->isValidVlanInterfaceName("bond1.515", parent, err) == true);
|
||||
QVERIFY (int_prop->isValidVlanInterfaceName("bond1.1205", parent, err) == true);
|
||||
}
|
||||
|
||||
|
||||
@ -481,17 +482,17 @@ en0.101 en0 false
|
||||
foo en0 false
|
||||
foo101 en0 false
|
||||
*/
|
||||
CPPUNIT_ASSERT (int_prop->isValidVlanInterfaceName("vlan101", parent, err) == true);
|
||||
CPPUNIT_ASSERT (int_prop->isValidVlanInterfaceName("eth0.101", parent, err) == false);
|
||||
CPPUNIT_ASSERT (int_prop->isValidVlanInterfaceName("foo", parent, err) == false);
|
||||
CPPUNIT_ASSERT (int_prop->isValidVlanInterfaceName("foo101", parent, err) == false);
|
||||
QVERIFY (int_prop->isValidVlanInterfaceName("vlan101", parent, err) == true);
|
||||
QVERIFY (int_prop->isValidVlanInterfaceName("eth0.101", parent, err) == false);
|
||||
QVERIFY (int_prop->isValidVlanInterfaceName("foo", parent, err) == false);
|
||||
QVERIFY (int_prop->isValidVlanInterfaceName("foo101", parent, err) == false);
|
||||
|
||||
|
||||
int_prop = getIntProps("freebsd");
|
||||
CPPUNIT_ASSERT (int_prop->isValidVlanInterfaceName("vlan101", parent, err) == true);
|
||||
CPPUNIT_ASSERT (int_prop->isValidVlanInterfaceName("eth0.101", parent, err) == false);
|
||||
CPPUNIT_ASSERT (int_prop->isValidVlanInterfaceName("foo", parent, err) == false);
|
||||
CPPUNIT_ASSERT (int_prop->isValidVlanInterfaceName("foo101", parent, err) == false);
|
||||
QVERIFY (int_prop->isValidVlanInterfaceName("vlan101", parent, err) == true);
|
||||
QVERIFY (int_prop->isValidVlanInterfaceName("eth0.101", parent, err) == false);
|
||||
QVERIFY (int_prop->isValidVlanInterfaceName("foo", parent, err) == false);
|
||||
QVERIFY (int_prop->isValidVlanInterfaceName("foo101", parent, err) == false);
|
||||
}
|
||||
|
||||
void interfacePropertiesTest::isValidVlanInterfaceNameIOS()
|
||||
@ -506,11 +507,11 @@ Ethernet0/0.99999 Ethernet0/0 false
|
||||
*/
|
||||
interfaceProperties *int_prop = getIntProps("ios");
|
||||
parent = "FastEthernet0/1";
|
||||
CPPUNIT_ASSERT (int_prop->isValidVlanInterfaceName("FastEthernet0/1.101", parent, err) == true);
|
||||
CPPUNIT_ASSERT (int_prop->isValidVlanInterfaceName("vlan101", parent, err) == false);
|
||||
CPPUNIT_ASSERT (int_prop->isValidVlanInterfaceName("Ethernet0/0.101", parent, err) == false);
|
||||
QVERIFY (int_prop->isValidVlanInterfaceName("FastEthernet0/1.101", parent, err) == true);
|
||||
QVERIFY (int_prop->isValidVlanInterfaceName("vlan101", parent, err) == false);
|
||||
QVERIFY (int_prop->isValidVlanInterfaceName("Ethernet0/0.101", parent, err) == false);
|
||||
parent = "Ethernet0/0";
|
||||
CPPUNIT_ASSERT (int_prop->isValidVlanInterfaceName("Ethernet0/0.99999", parent, err) == false);
|
||||
QVERIFY (int_prop->isValidVlanInterfaceName("Ethernet0/0.99999", parent, err) == false);
|
||||
}
|
||||
|
||||
void interfacePropertiesTest::isValidVlanInterfaceNamePIX()
|
||||
@ -518,11 +519,11 @@ void interfacePropertiesTest::isValidVlanInterfaceNamePIX()
|
||||
QString err, parent;
|
||||
interfaceProperties *int_prop = getIntProps("pix_os");
|
||||
parent = "FastEthernet0/1";
|
||||
CPPUNIT_ASSERT (int_prop->isValidVlanInterfaceName("FastEthernet0/1.101", parent, err) == true);
|
||||
CPPUNIT_ASSERT (int_prop->isValidVlanInterfaceName("vlan101", parent, err) == false);
|
||||
CPPUNIT_ASSERT (int_prop->isValidVlanInterfaceName("Ethernet0/0.101", parent, err) == false);
|
||||
QVERIFY (int_prop->isValidVlanInterfaceName("FastEthernet0/1.101", parent, err) == true);
|
||||
QVERIFY (int_prop->isValidVlanInterfaceName("vlan101", parent, err) == false);
|
||||
QVERIFY (int_prop->isValidVlanInterfaceName("Ethernet0/0.101", parent, err) == false);
|
||||
parent = "Ethernet0/0";
|
||||
CPPUNIT_ASSERT (int_prop->isValidVlanInterfaceName("Ethernet0/0.99999", parent, err) == false);
|
||||
QVERIFY (int_prop->isValidVlanInterfaceName("Ethernet0/0.99999", parent, err) == false);
|
||||
}
|
||||
|
||||
void interfacePropertiesTest::isValidVlanInterfaceNameProCurve()
|
||||
@ -540,15 +541,15 @@ void interfacePropertiesTest::isValidVlanInterfaceNameProCurve()
|
||||
*/
|
||||
interfaceProperties *int_prop = getIntProps("procurve");
|
||||
parent = "FastEthernet0/1";
|
||||
CPPUNIT_ASSERT (int_prop->isValidVlanInterfaceName("vlan 2", parent, err) == true);
|
||||
CPPUNIT_ASSERT (int_prop->isValidVlanInterfaceName("VLAN 2", parent, err) == true);
|
||||
CPPUNIT_ASSERT (int_prop->isValidVlanInterfaceName("Vlan 2", parent, err) == true);
|
||||
CPPUNIT_ASSERT (int_prop->isValidVlanInterfaceName("vlan2", parent, err) == false);
|
||||
QVERIFY (int_prop->isValidVlanInterfaceName("vlan 2", parent, err) == true);
|
||||
QVERIFY (int_prop->isValidVlanInterfaceName("VLAN 2", parent, err) == true);
|
||||
QVERIFY (int_prop->isValidVlanInterfaceName("Vlan 2", parent, err) == true);
|
||||
QVERIFY (int_prop->isValidVlanInterfaceName("vlan2", parent, err) == false);
|
||||
|
||||
CPPUNIT_ASSERT (int_prop->isValidVlanInterfaceName("vlan 101", parent, err) == true);
|
||||
CPPUNIT_ASSERT (int_prop->isValidVlanInterfaceName("vlan101", parent, err) == false);
|
||||
QVERIFY (int_prop->isValidVlanInterfaceName("vlan 101", parent, err) == true);
|
||||
QVERIFY (int_prop->isValidVlanInterfaceName("vlan101", parent, err) == false);
|
||||
|
||||
CPPUNIT_ASSERT (int_prop->isValidVlanInterfaceName("Ethernet0/0.101", parent, err) == false);
|
||||
QVERIFY (int_prop->isValidVlanInterfaceName("Ethernet0/0.101", parent, err) == false);
|
||||
}
|
||||
|
||||
void interfacePropertiesTest::validateInterfaceProCurve()
|
||||
@ -562,7 +563,7 @@ void interfacePropertiesTest::validateInterfaceProCurve()
|
||||
|
||||
interfaceProperties * int_prop = interfacePropertiesObjectFactory::getInterfacePropertiesObject(os_family);
|
||||
|
||||
CPPUNIT_ASSERT(int_prop != nullptr);
|
||||
QVERIFY(int_prop != nullptr);
|
||||
|
||||
QString err;
|
||||
|
||||
@ -577,10 +578,10 @@ void interfacePropertiesTest::validateInterfaceProCurve()
|
||||
fw.add(parent);
|
||||
|
||||
iface->setName("vlan 2");
|
||||
CPPUNIT_ASSERT(int_prop->validateInterface(&fw, iface, false, err) == true);
|
||||
QVERIFY(int_prop->validateInterface(&fw, iface, false, err) == true);
|
||||
|
||||
iface->setName("vlan 34324");
|
||||
CPPUNIT_ASSERT(int_prop->validateInterface(&fw, iface, false, err) == false);
|
||||
QVERIFY(int_prop->validateInterface(&fw, iface, false, err) == false);
|
||||
}
|
||||
|
||||
void interfacePropertiesTest::testManageIpAddresses()
|
||||
@ -594,7 +595,7 @@ void interfacePropertiesTest::testManageIpAddresses()
|
||||
db->reIndex();
|
||||
|
||||
FWObject *fw = db->findObjectByName(Firewall::TYPENAME, "fw1");
|
||||
CPPUNIT_ASSERT(fw != nullptr);
|
||||
QVERIFY(fw != nullptr);
|
||||
|
||||
Interface *intf = Interface::cast(
|
||||
fw->findObjectByName(Interface::TYPENAME, "eth0"));
|
||||
@ -604,35 +605,35 @@ void interfacePropertiesTest::testManageIpAddresses()
|
||||
QStringList update_addresses;
|
||||
QStringList ignore_addresses;
|
||||
|
||||
CPPUNIT_ASSERT(
|
||||
QVERIFY(
|
||||
int_prop->manageIpAddresses(
|
||||
intf, update_addresses, ignore_addresses) == true);
|
||||
|
||||
intf = Interface::cast(
|
||||
fw->findObjectByName(Interface::TYPENAME, "lo"));
|
||||
|
||||
CPPUNIT_ASSERT(
|
||||
QVERIFY(
|
||||
int_prop->manageIpAddresses(
|
||||
intf, update_addresses, ignore_addresses) == true);
|
||||
|
||||
intf = Interface::cast(
|
||||
fw->findObjectByName(Interface::TYPENAME, "eth1")); // dyn
|
||||
|
||||
CPPUNIT_ASSERT(
|
||||
QVERIFY(
|
||||
int_prop->manageIpAddresses(
|
||||
intf, update_addresses, ignore_addresses) == false);
|
||||
|
||||
intf = Interface::cast(
|
||||
fw->findObjectByName(Interface::TYPENAME, "eth2")); // bridge port
|
||||
|
||||
CPPUNIT_ASSERT(
|
||||
QVERIFY(
|
||||
int_prop->manageIpAddresses(
|
||||
intf, update_addresses, ignore_addresses) == false);
|
||||
|
||||
intf = Interface::cast(
|
||||
fw->findObjectByName(Interface::TYPENAME, "eth3")); // bonding intf slave
|
||||
|
||||
CPPUNIT_ASSERT(
|
||||
QVERIFY(
|
||||
int_prop->manageIpAddresses(
|
||||
intf, update_addresses, ignore_addresses) == false);
|
||||
|
||||
@ -640,14 +641,14 @@ void interfacePropertiesTest::testManageIpAddresses()
|
||||
intf = Interface::cast(
|
||||
fw->findObjectByName(Interface::TYPENAME, "tun0")); // unnumbered
|
||||
|
||||
CPPUNIT_ASSERT(
|
||||
QVERIFY(
|
||||
int_prop->manageIpAddresses(
|
||||
intf, update_addresses, ignore_addresses) == false);
|
||||
|
||||
intf = Interface::cast(
|
||||
fw->findObjectByName(Interface::TYPENAME, "tun*")); // unnumbered
|
||||
|
||||
CPPUNIT_ASSERT(
|
||||
QVERIFY(
|
||||
int_prop->manageIpAddresses(
|
||||
intf, update_addresses, ignore_addresses) == false);
|
||||
|
||||
@ -664,7 +665,7 @@ void interfacePropertiesTest::testManageIpAddressesCluster()
|
||||
db->reIndex();
|
||||
|
||||
FWObject *fw = db->findObjectByName(Cluster::TYPENAME, "cluster1");
|
||||
CPPUNIT_ASSERT(fw != nullptr);
|
||||
QVERIFY(fw != nullptr);
|
||||
|
||||
Interface *intf = Interface::cast(
|
||||
fw->findObjectByName(Interface::TYPENAME, "lo"));
|
||||
@ -676,14 +677,14 @@ void interfacePropertiesTest::testManageIpAddressesCluster()
|
||||
QStringList update_addresses;
|
||||
QStringList ignore_addresses;
|
||||
|
||||
CPPUNIT_ASSERT(
|
||||
QVERIFY(
|
||||
int_prop->manageIpAddresses(
|
||||
intf, update_addresses, ignore_addresses) == false);
|
||||
|
||||
intf = Interface::cast(
|
||||
fw->findObjectByName(Interface::TYPENAME, "eth0"));
|
||||
|
||||
CPPUNIT_ASSERT(
|
||||
QVERIFY(
|
||||
int_prop->manageIpAddresses(
|
||||
intf, update_addresses, ignore_addresses) == true);
|
||||
|
||||
|
||||
@ -27,6 +27,8 @@
|
||||
#ifndef INTERFACEPROPERTIESTEST
|
||||
#define INTERFACEPROPERTIESTEST
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include "fwbuilder/FWObjectDatabase.h"
|
||||
#include "fwbuilder/FWObject.h"
|
||||
#include "fwbuilder/Cluster.h"
|
||||
@ -36,23 +38,24 @@
|
||||
#include "interfaceProperties.h"
|
||||
#include "interfacePropertiesObjectFactory.h"
|
||||
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
#include <list>
|
||||
#include <string>
|
||||
|
||||
|
||||
|
||||
class interfacePropertiesTest: public CppUnit::TestFixture
|
||||
class interfacePropertiesTest: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
libfwbuilder::FWObjectDatabase *db;
|
||||
|
||||
void isValidVlanInterfaceNameLinuxFamilies(interfaceProperties *int_prop);
|
||||
|
||||
public:
|
||||
//interfaceProperties( std::string name ) : CppUnit::TestCase( name ) {}
|
||||
interfaceProperties* getIntProps(const QString &os);
|
||||
|
||||
|
||||
private slots:
|
||||
void init();
|
||||
|
||||
void validateInterfaceNameCommon();
|
||||
void validateInterfaceNameLinux();
|
||||
void validateInterfaceNameProCurve();
|
||||
@ -70,26 +73,6 @@ public:
|
||||
void validateInterfaceProCurve();
|
||||
void testManageIpAddresses();
|
||||
void testManageIpAddressesCluster();
|
||||
|
||||
void setUp();
|
||||
|
||||
CPPUNIT_TEST_SUITE(interfacePropertiesTest);
|
||||
CPPUNIT_TEST(validateInterfaceNameCommon);
|
||||
CPPUNIT_TEST(validateInterfaceNameLinux);
|
||||
CPPUNIT_TEST(validateInterfaceNameProCurve);
|
||||
CPPUNIT_TEST(validateInterface);
|
||||
CPPUNIT_TEST(isEligibleForCluster);
|
||||
CPPUNIT_TEST(isValidVlanInterfaceNameLinux24);
|
||||
CPPUNIT_TEST(isValidVlanInterfaceNameOpenWRT);
|
||||
CPPUNIT_TEST(isValidVlanInterfaceNameDDWRT1);
|
||||
CPPUNIT_TEST(isValidVlanInterfaceNameDDWRT2);
|
||||
CPPUNIT_TEST(isValidVlanInterfaceNameSecuwall);
|
||||
CPPUNIT_TEST(isValidVlanInterfaceNameBSD);
|
||||
CPPUNIT_TEST(isValidVlanInterfaceNameIOS);
|
||||
CPPUNIT_TEST(isValidVlanInterfaceNamePIX);
|
||||
CPPUNIT_TEST(testManageIpAddresses);
|
||||
CPPUNIT_TEST(testManageIpAddressesCluster);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -22,19 +22,15 @@
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
#include <QTest>
|
||||
|
||||
#include "common/init.cpp"
|
||||
#include "interfacePropertiesTest.h"
|
||||
|
||||
#include "fwbuilder/Constants.h"
|
||||
|
||||
#include <cppunit/ui/text/TestRunner.h>
|
||||
#include <cppunit/CompilerOutputter.h>
|
||||
#include <string>
|
||||
|
||||
//QString user_name;
|
||||
|
||||
int main(int, char **argv)
|
||||
{
|
||||
init(argv);
|
||||
@ -43,11 +39,5 @@ int main(int, char **argv)
|
||||
|
||||
Resources res(Constants::getResourcesFilePath());
|
||||
|
||||
CppUnit::TextUi::TestRunner runner;
|
||||
runner.addTest( interfacePropertiesTest::suite() );
|
||||
runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(),
|
||||
std::cerr ) );
|
||||
|
||||
runner.run();
|
||||
return 0;
|
||||
return QTest::qExec(new interfacePropertiesTest());
|
||||
}
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
SET(CMAKE_AUTOMOC ON)
|
||||
|
||||
add_executable(generatedScriptTestsIpfilter generatedScriptTestsIpfilter.cpp main_generatedScriptTestsIpfilter.cpp)
|
||||
add_test(NAME generatedScriptTestsIpfilter COMMAND generatedScriptTestsIpfilter)
|
||||
|
||||
target_link_libraries(generatedScriptTestsIpfilter PRIVATE test_main netsnmp gui import fwbparser antlr common iptlib fwbpf fwbjuniper fwbcisco compilerdriver fwcompiler fwbuilder xml2 xslt z pthread cppunit)
|
||||
target_link_libraries(generatedScriptTestsIpfilter PRIVATE test_main netsnmp gui import fwbparser antlr common iptlib fwbpf fwbjuniper fwbcisco compilerdriver fwcompiler fwbuilder xml2 xslt z pthread Qt5::Test)
|
||||
|
||||
file(COPY test1.fwb DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
|
||||
Firewall Builder
|
||||
|
||||
@ -17,13 +17,12 @@
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
|
||||
To get a copy of the GNU General Public License, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "generatedScriptTestsIpfilter.h"
|
||||
|
||||
#include "CompilerDriver_ipf.h"
|
||||
@ -34,6 +33,7 @@
|
||||
#include "fwbuilder/IPService.h"
|
||||
#include "fwbuilder/Constants.h"
|
||||
|
||||
#include <QTest>
|
||||
#include <QApplication>
|
||||
#include <QStringList>
|
||||
#include <QFileInfo>
|
||||
@ -49,27 +49,27 @@ using namespace fwcompiler;
|
||||
class UpgradePredicate: public XMLTools::UpgradePredicate
|
||||
{
|
||||
public:
|
||||
virtual bool operator()(const string&) const
|
||||
{
|
||||
virtual bool operator()(const string&) const
|
||||
{
|
||||
cout << "Data file has been created in the old version of Firewall Builder. Use fwbuilder GUI to convert it." << std::endl;
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
void GeneratedScriptTest::setUp()
|
||||
void GeneratedScriptTest::init()
|
||||
{
|
||||
Configlet::setDebugging(true);
|
||||
}
|
||||
|
||||
void GeneratedScriptTest::tearDown()
|
||||
void GeneratedScriptTest::cleanup()
|
||||
{
|
||||
}
|
||||
|
||||
void GeneratedScriptTest::loadDataFile(const string &file_name)
|
||||
{
|
||||
/* load the data file */
|
||||
UpgradePredicate upgrade_predicate;
|
||||
UpgradePredicate upgrade_predicate;
|
||||
|
||||
objdb->setReadOnly( false );
|
||||
objdb->load(file_name, &upgrade_predicate, Constants::getDTDDirectory());
|
||||
@ -96,13 +96,13 @@ void GeneratedScriptTest::runCompiler(const std::string &test_file,
|
||||
CompilerDriver_ipf driver(objdb);
|
||||
|
||||
driver.setEmbeddedMode();
|
||||
CPPUNIT_ASSERT_MESSAGE("CompilerDriver_ipf initialization failed",
|
||||
driver.prepare(args) == true);
|
||||
QVERIFY2(driver.prepare(args) == true,
|
||||
"CompilerDriver_ipf initialization failed");
|
||||
driver.compile();
|
||||
// compiler should have created file generate_file_name
|
||||
QFileInfo fi(generate_file_name.c_str());
|
||||
CPPUNIT_ASSERT_MESSAGE("Generated file " + generate_file_name + " not found",
|
||||
fi.exists() == true);
|
||||
QVERIFY2(fi.exists() == true,
|
||||
std::string("Generated file " + generate_file_name + " not found").data());
|
||||
}
|
||||
|
||||
// I can check only certain parts of the top comment. Can't
|
||||
@ -115,12 +115,12 @@ void GeneratedScriptTest::ManifestTest_1()
|
||||
runCompiler("test1.fwb", "ipf1", "ipf1.fw");
|
||||
QString res = Configlet::findConfigletInFile("top_comment", "ipf1.fw");
|
||||
// find manifest and compare
|
||||
CPPUNIT_ASSERT(res.indexOf("# files: * ipf1.fw") != -1);
|
||||
CPPUNIT_ASSERT(res.indexOf("# files: ipf1-ipf.conf") != -1);
|
||||
CPPUNIT_ASSERT(res.indexOf("# files: ipf1-nat.conf") != -1);
|
||||
QVERIFY(res.indexOf("# files: * ipf1.fw") != -1);
|
||||
QVERIFY(res.indexOf("# files: ipf1-ipf.conf") != -1);
|
||||
QVERIFY(res.indexOf("# files: ipf1-nat.conf") != -1);
|
||||
delete objdb;
|
||||
}
|
||||
|
||||
|
||||
void GeneratedScriptTest::ManifestTest_2()
|
||||
{
|
||||
/*
|
||||
@ -133,9 +133,9 @@ void GeneratedScriptTest::ManifestTest_2()
|
||||
runCompiler("test1.fwb", "ipf2", "ipf2-1.fw");
|
||||
QString res = Configlet::findConfigletInFile("top_comment", "ipf2-1.fw");
|
||||
// find manifest and compare
|
||||
CPPUNIT_ASSERT(res.indexOf("# files: * ipf2-1.fw") != -1);
|
||||
CPPUNIT_ASSERT(res.indexOf("# files: ipf2-1-ipf.conf") != -1);
|
||||
CPPUNIT_ASSERT(res.indexOf("# files: ipf2-1-nat.conf") != -1);
|
||||
QVERIFY(res.indexOf("# files: * ipf2-1.fw") != -1);
|
||||
QVERIFY(res.indexOf("# files: ipf2-1-ipf.conf") != -1);
|
||||
QVERIFY(res.indexOf("# files: ipf2-1-nat.conf") != -1);
|
||||
delete objdb;
|
||||
}
|
||||
|
||||
@ -151,9 +151,9 @@ void GeneratedScriptTest::ManifestTest_3()
|
||||
runCompiler("test1.fwb", "ipf2a", "ipf2-1");
|
||||
QString res = Configlet::findConfigletInFile("top_comment", "ipf2-1");
|
||||
// find manifest and compare
|
||||
CPPUNIT_ASSERT(res.indexOf("# files: * ipf2-1") != -1);
|
||||
CPPUNIT_ASSERT(res.indexOf("# files: ipf2-1-ipf.conf") != -1);
|
||||
CPPUNIT_ASSERT(res.indexOf("# files: ipf2-1-nat.conf") != -1);
|
||||
QVERIFY(res.indexOf("# files: * ipf2-1") != -1);
|
||||
QVERIFY(res.indexOf("# files: ipf2-1-ipf.conf") != -1);
|
||||
QVERIFY(res.indexOf("# files: ipf2-1-nat.conf") != -1);
|
||||
delete objdb;
|
||||
}
|
||||
|
||||
@ -167,24 +167,26 @@ void GeneratedScriptTest::ManifestTest_4()
|
||||
runCompiler("test1.fwb", "ipf2", "ipf2-1.fw", option_o.toStdString());
|
||||
QString res = Configlet::findConfigletInFile("top_comment", "ipf2-1.fw");
|
||||
// find manifest and compare
|
||||
CPPUNIT_ASSERT(res.indexOf("# files: * " + option_o) != -1);
|
||||
QVERIFY(res.indexOf("# files: * " + option_o) != -1);
|
||||
QString ipf_file = QDir::currentPath() + "/ipf2-1-ipf.conf";
|
||||
QString nat_file = QDir::currentPath() + "/ipf2-1-nat.conf";
|
||||
CPPUNIT_ASSERT(res.indexOf("# files: " + ipf_file) != -1);
|
||||
CPPUNIT_ASSERT(res.indexOf("# files: " + nat_file) != -1);
|
||||
QVERIFY(res.indexOf("# files: " + ipf_file) != -1);
|
||||
QVERIFY(res.indexOf("# files: " + nat_file) != -1);
|
||||
delete objdb;
|
||||
}
|
||||
|
||||
void GeneratedScriptTest::ManifestTest_5()
|
||||
{
|
||||
QSKIP("This test was disabled in the original code");
|
||||
|
||||
objdb = new FWObjectDatabase();
|
||||
QString option_o = QDir::currentPath() + "/ipf2-1";
|
||||
runCompiler("test1.fwb", "ipf2a", "ipf2-1.fw", option_o.toStdString());
|
||||
QString res = Configlet::findConfigletInFile("top_comment", "ipf2-1.fw");
|
||||
// find manifest and compare
|
||||
CPPUNIT_ASSERT(res.indexOf("# files: * ipf2-1.fw") != -1);
|
||||
CPPUNIT_ASSERT(res.indexOf("# files: ipf2-1-ipf.conf") != -1);
|
||||
CPPUNIT_ASSERT(res.indexOf("# files: ipf2-1-nat.conf") != -1);
|
||||
QVERIFY(res.indexOf("# files: * ipf2-1.fw") != -1);
|
||||
QVERIFY(res.indexOf("# files: ipf2-1-ipf.conf") != -1);
|
||||
QVERIFY(res.indexOf("# files: ipf2-1-nat.conf") != -1);
|
||||
delete objdb;
|
||||
}
|
||||
|
||||
@ -198,9 +200,9 @@ void GeneratedScriptTest::ManifestTest_6()
|
||||
runCompiler("test1.fwb", "ipf3", "ipf3.fw");
|
||||
QString res = Configlet::findConfigletInFile("top_comment", "ipf3.fw");
|
||||
// find manifest and compare
|
||||
CPPUNIT_ASSERT(res.indexOf("# files: * ipf3.fw") != -1);
|
||||
CPPUNIT_ASSERT(res.indexOf("# files: ipf3-ipf.conf /etc/fw/ipf3-ipf.conf") != -1);
|
||||
CPPUNIT_ASSERT(res.indexOf("# files: ipf3-nat.conf /etc/fw/ipf3-nat.conf") != -1);
|
||||
QVERIFY(res.indexOf("# files: * ipf3.fw") != -1);
|
||||
QVERIFY(res.indexOf("# files: ipf3-ipf.conf /etc/fw/ipf3-ipf.conf") != -1);
|
||||
QVERIFY(res.indexOf("# files: ipf3-nat.conf /etc/fw/ipf3-nat.conf") != -1);
|
||||
delete objdb;
|
||||
}
|
||||
|
||||
@ -213,9 +215,9 @@ void GeneratedScriptTest::ManifestTest_7()
|
||||
runCompiler("test1.fwb", "ipf4", "ipf4.fw");
|
||||
QString res = Configlet::findConfigletInFile("top_comment", "ipf4.fw");
|
||||
// find manifest and compare
|
||||
CPPUNIT_ASSERT(res.indexOf("# files: * ipf4.fw /etc/path\\ with\\ space/ipf4.fw") != -1);
|
||||
CPPUNIT_ASSERT(res.indexOf("# files: ipf4-ipf.conf /etc/path\\ with\\ space/ipf4-ipf.conf") != -1);
|
||||
CPPUNIT_ASSERT(res.indexOf("# files: ipf4-nat.conf /etc/path\\ with\\ space/ipf4-nat.conf") != -1);
|
||||
QVERIFY(res.indexOf("# files: * ipf4.fw /etc/path\\ with\\ space/ipf4.fw") != -1);
|
||||
QVERIFY(res.indexOf("# files: ipf4-ipf.conf /etc/path\\ with\\ space/ipf4-ipf.conf") != -1);
|
||||
QVERIFY(res.indexOf("# files: ipf4-nat.conf /etc/path\\ with\\ space/ipf4-nat.conf") != -1);
|
||||
delete objdb;
|
||||
}
|
||||
|
||||
@ -227,7 +229,7 @@ void GeneratedScriptTest::FwCommentTest()
|
||||
runCompiler("test1.fwb", "ipf1", "ipf1.fw");
|
||||
QString res = Configlet::findConfigletInFile("top_comment", "ipf1.fw");
|
||||
// find string from the firewall object comment and compare
|
||||
CPPUNIT_ASSERT(res.indexOf("# Firewall object test1 comment") != -1);
|
||||
QVERIFY(res.indexOf("# Firewall object test1 comment") != -1);
|
||||
delete objdb;
|
||||
}
|
||||
|
||||
@ -237,7 +239,7 @@ void GeneratedScriptTest::ActivationCommandsTest_1()
|
||||
{
|
||||
objdb = new FWObjectDatabase();
|
||||
QString res = Configlet::findConfigletInFile("activation", "ipf1.fw");
|
||||
CPPUNIT_ASSERT(res.indexOf("$IPF -I -f /etc/ipf1-ipf.conf") != -1);
|
||||
QVERIFY(res.indexOf("$IPF -I -f /etc/ipf1-ipf.conf") != -1);
|
||||
delete objdb;
|
||||
}
|
||||
|
||||
@ -245,7 +247,7 @@ void GeneratedScriptTest::ActivationCommandsTest_2()
|
||||
{
|
||||
objdb = new FWObjectDatabase();
|
||||
QString res = Configlet::findConfigletInFile("activation", "ipf2-1.fw");
|
||||
CPPUNIT_ASSERT(res.indexOf("$IPF -I -f /etc/ipf2-1-ipf.conf") != -1);
|
||||
QVERIFY(res.indexOf("$IPF -I -f /etc/ipf2-1-ipf.conf") != -1);
|
||||
delete objdb;
|
||||
}
|
||||
|
||||
@ -253,7 +255,7 @@ void GeneratedScriptTest::ActivationCommandsTest_3()
|
||||
{
|
||||
objdb = new FWObjectDatabase();
|
||||
QString res = Configlet::findConfigletInFile("activation", "ipf2-1");
|
||||
CPPUNIT_ASSERT(res.indexOf("$IPF -I -f /etc/ipf2-1-ipf.conf") != -1);
|
||||
QVERIFY(res.indexOf("$IPF -I -f /etc/ipf2-1-ipf.conf") != -1);
|
||||
delete objdb;
|
||||
}
|
||||
|
||||
@ -261,7 +263,7 @@ void GeneratedScriptTest::ActivationCommandsTest_4()
|
||||
{
|
||||
objdb = new FWObjectDatabase();
|
||||
QString res = Configlet::findConfigletInFile("activation", "ipf2-1.fw");
|
||||
CPPUNIT_ASSERT(res.indexOf("$IPF -I -f /etc/ipf2-1-ipf.conf") != -1);
|
||||
QVERIFY(res.indexOf("$IPF -I -f /etc/ipf2-1-ipf.conf") != -1);
|
||||
delete objdb;
|
||||
}
|
||||
|
||||
@ -269,7 +271,7 @@ void GeneratedScriptTest::ActivationCommandsTest_6()
|
||||
{
|
||||
objdb = new FWObjectDatabase();
|
||||
QString res = Configlet::findConfigletInFile("activation", "ipf3.fw");
|
||||
CPPUNIT_ASSERT(res.indexOf("$IPF -I -f /etc/fw/ipf3-ipf.conf") != -1);
|
||||
QVERIFY(res.indexOf("$IPF -I -f /etc/fw/ipf3-ipf.conf") != -1);
|
||||
delete objdb;
|
||||
}
|
||||
|
||||
@ -277,10 +279,10 @@ void GeneratedScriptTest::ActivationCommandsTest_7()
|
||||
{
|
||||
objdb = new FWObjectDatabase();
|
||||
QString res = Configlet::findConfigletInFile("activation", "ipf4.fw", 1);
|
||||
CPPUNIT_ASSERT(res.indexOf("$IPF -I -f /etc/path\\ with\\ space/ipf4-ipf.conf") != -1);
|
||||
QVERIFY(res.indexOf("$IPF -I -f /etc/path\\ with\\ space/ipf4-ipf.conf") != -1);
|
||||
|
||||
res = Configlet::findConfigletInFile("activation", "ipf4.fw", 2);
|
||||
CPPUNIT_ASSERT(res.indexOf("$IPNAT -f /etc/path\\ with\\ space/ipf4-nat.conf") != -1);
|
||||
QVERIFY(res.indexOf("$IPNAT -f /etc/path\\ with\\ space/ipf4-nat.conf") != -1);
|
||||
|
||||
delete objdb;
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
|
||||
Firewall Builder
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
|
||||
To get a copy of the GNU General Public License, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
@ -26,19 +26,21 @@
|
||||
#ifndef GENERATEDSCRIPTTESTS_IPFILTER_H
|
||||
#define GENERATEDSCRIPTTESTS_IPFILTER_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include "fwbuilder/Resources.h"
|
||||
#include "fwbuilder/FWObjectDatabase.h"
|
||||
#include "fwbuilder/Library.h"
|
||||
#include "fwbuilder/FWException.h"
|
||||
#include "fwbuilder/Logger.h"
|
||||
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
#include <QStringList>
|
||||
|
||||
|
||||
class GeneratedScriptTest : public CppUnit::TestFixture
|
||||
class GeneratedScriptTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
libfwbuilder::FWObjectDatabase *objdb;
|
||||
|
||||
void loadDataFile(const std::string &file_name);
|
||||
@ -47,9 +49,13 @@ class GeneratedScriptTest : public CppUnit::TestFixture
|
||||
const std::string &generate_file_name,
|
||||
const std::string &output_file_option="");
|
||||
|
||||
public:
|
||||
void setUp();
|
||||
void tearDown();
|
||||
private slots:
|
||||
void init();
|
||||
void cleanup();
|
||||
|
||||
// The order of tests matters because activation commands tests use
|
||||
// files produced in manifest tests
|
||||
|
||||
void ManifestTest_1();
|
||||
void ManifestTest_2();
|
||||
void ManifestTest_3();
|
||||
@ -62,38 +68,9 @@ public:
|
||||
void ActivationCommandsTest_2();
|
||||
void ActivationCommandsTest_3();
|
||||
void ActivationCommandsTest_4();
|
||||
// void ActivationCommandsTest_5();
|
||||
|
||||
void ActivationCommandsTest_6();
|
||||
void ActivationCommandsTest_7();
|
||||
|
||||
CPPUNIT_TEST_SUITE(GeneratedScriptTest);
|
||||
|
||||
// The order of tests matters because activation commands tests use
|
||||
// files produced in manifest tests
|
||||
CPPUNIT_TEST(ManifestTest_1);
|
||||
CPPUNIT_TEST(ActivationCommandsTest_1);
|
||||
|
||||
CPPUNIT_TEST(ManifestTest_2);
|
||||
CPPUNIT_TEST(ActivationCommandsTest_2);
|
||||
|
||||
CPPUNIT_TEST(ManifestTest_3);
|
||||
CPPUNIT_TEST(ActivationCommandsTest_3);
|
||||
|
||||
CPPUNIT_TEST(ManifestTest_4);
|
||||
CPPUNIT_TEST(ActivationCommandsTest_4);
|
||||
|
||||
// CPPUNIT_TEST(ManifestTest_5);
|
||||
// CPPUNIT_TEST(ActivationCommandsTest_5);
|
||||
|
||||
CPPUNIT_TEST(ManifestTest_6);
|
||||
CPPUNIT_TEST(ActivationCommandsTest_6);
|
||||
|
||||
CPPUNIT_TEST(ManifestTest_7);
|
||||
CPPUNIT_TEST(ActivationCommandsTest_7);
|
||||
|
||||
CPPUNIT_TEST(FwCommentTest);
|
||||
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
|
||||
Firewall Builder
|
||||
|
||||
@ -17,18 +17,15 @@
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
|
||||
To get a copy of the GNU General Public License, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
#include <QTest>
|
||||
|
||||
#include "generatedScriptTestsIpfilter.h"
|
||||
|
||||
#include <cppunit/ui/text/TestRunner.h>
|
||||
#include <cppunit/CompilerOutputter.h>
|
||||
|
||||
#include "fwbuilder/Resources.h"
|
||||
#include "fwbuilder/Constants.h"
|
||||
|
||||
@ -42,7 +39,7 @@ using namespace libfwbuilder;
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
{
|
||||
QApplication app(argc, argv, false);
|
||||
|
||||
// compilers always write file names into manifest in Utf8
|
||||
@ -52,10 +49,5 @@ int main(int argc, char **argv)
|
||||
|
||||
Resources res(Constants::getResourcesFilePath());
|
||||
|
||||
CppUnit::TextUi::TestRunner runner;
|
||||
runner.addTest( GeneratedScriptTest::suite() );
|
||||
runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(),
|
||||
std::cerr ) );
|
||||
|
||||
runner.run();
|
||||
return QTest::qExec(new GeneratedScriptTest());
|
||||
}
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
SET(CMAKE_AUTOMOC ON)
|
||||
|
||||
add_executable(generatedScriptTestsIpfw generatedScriptTestsIpfw.cpp main_generatedScriptTestsIpfw.cpp)
|
||||
add_test(NAME generatedScriptTestsIpfw COMMAND generatedScriptTestsIpfw)
|
||||
|
||||
target_link_libraries(generatedScriptTestsIpfw PRIVATE test_main netsnmp gui import fwbparser antlr common iptlib fwbpf fwbjuniper fwbcisco compilerdriver fwcompiler fwbuilder xml2 xslt z pthread cppunit)
|
||||
target_link_libraries(generatedScriptTestsIpfw PRIVATE test_main netsnmp gui import fwbparser antlr common iptlib fwbpf fwbjuniper fwbcisco compilerdriver fwcompiler fwbuilder xml2 xslt z pthread Qt5::Test)
|
||||
|
||||
file(COPY test1.fwb DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
|
||||
@ -23,7 +23,6 @@
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "generatedScriptTestsIpfw.h"
|
||||
|
||||
#include "CompilerDriver_ipfw.h"
|
||||
@ -34,6 +33,7 @@
|
||||
#include "fwbuilder/IPService.h"
|
||||
#include "fwbuilder/Constants.h"
|
||||
|
||||
#include <QTest>
|
||||
#include <QApplication>
|
||||
#include <QStringList>
|
||||
#include <QFileInfo>
|
||||
@ -58,12 +58,12 @@ class UpgradePredicate: public XMLTools::UpgradePredicate
|
||||
};
|
||||
|
||||
|
||||
void GeneratedScriptTest::setUp()
|
||||
void GeneratedScriptTest::init()
|
||||
{
|
||||
Configlet::setDebugging(true);
|
||||
}
|
||||
|
||||
void GeneratedScriptTest::tearDown()
|
||||
void GeneratedScriptTest::cleanup()
|
||||
{
|
||||
}
|
||||
|
||||
@ -97,13 +97,13 @@ void GeneratedScriptTest::runCompiler(const std::string &test_file,
|
||||
CompilerDriver_ipfw driver(objdb);
|
||||
|
||||
driver.setEmbeddedMode();
|
||||
CPPUNIT_ASSERT_MESSAGE("CompilerDriver_ipfw initialization failed",
|
||||
driver.prepare(args) == true);
|
||||
QVERIFY2(driver.prepare(args) == true,
|
||||
"CompilerDriver_ipfw initialization failed");
|
||||
driver.compile();
|
||||
// compiler should have created file generate_file_name
|
||||
QFileInfo fi(generate_file_name.c_str());
|
||||
CPPUNIT_ASSERT_MESSAGE("Generated file " + generate_file_name + " not found",
|
||||
fi.exists() == true);
|
||||
QVERIFY2(fi.exists() == true,
|
||||
std::string("Generated file " + generate_file_name + " not found").data());
|
||||
}
|
||||
|
||||
// I can check only certain parts of the top comment. Can't
|
||||
@ -117,7 +117,7 @@ void GeneratedScriptTest::ManifestTest_1()
|
||||
runCompiler("test1.fwb", "ipfw1", "ipfw1.fw");
|
||||
QString res = Configlet::findConfigletInFile("top_comment", "ipfw1.fw");
|
||||
// find manifest and compare
|
||||
CPPUNIT_ASSERT(res.indexOf("# files: * ipfw1.fw") != -1);
|
||||
QVERIFY(res.indexOf("# files: * ipfw1.fw") != -1);
|
||||
delete objdb;
|
||||
}
|
||||
|
||||
@ -131,7 +131,7 @@ void GeneratedScriptTest::ManifestTest_2()
|
||||
runCompiler("test1.fwb", "ipfw2", "ipfw2-1.fw");
|
||||
QString res = Configlet::findConfigletInFile("top_comment", "ipfw2-1.fw");
|
||||
// find manifest and compare
|
||||
CPPUNIT_ASSERT(res.indexOf("# files: * ipfw2-1.fw") != -1);
|
||||
QVERIFY(res.indexOf("# files: * ipfw2-1.fw") != -1);
|
||||
delete objdb;
|
||||
}
|
||||
|
||||
@ -145,7 +145,7 @@ void GeneratedScriptTest::ManifestTest_3()
|
||||
runCompiler("test1.fwb", "ipfw2a", "ipfw2-1");
|
||||
QString res = Configlet::findConfigletInFile("top_comment", "ipfw2-1");
|
||||
// find manifest and compare
|
||||
CPPUNIT_ASSERT(res.indexOf("# files: * ipfw2-1") != -1);
|
||||
QVERIFY(res.indexOf("# files: * ipfw2-1") != -1);
|
||||
delete objdb;
|
||||
}
|
||||
|
||||
@ -160,19 +160,21 @@ void GeneratedScriptTest::ManifestTest_4()
|
||||
runCompiler("test1.fwb", "ipfw2", "ipfw2-1.fw", option_o.toStdString());
|
||||
QString res = Configlet::findConfigletInFile("top_comment", "ipfw2-1.fw");
|
||||
// find manifest and compare
|
||||
CPPUNIT_ASSERT(res.indexOf("# files: * " + option_o) != -1);
|
||||
QVERIFY(res.indexOf("# files: * " + option_o) != -1);
|
||||
delete objdb;
|
||||
}
|
||||
|
||||
void GeneratedScriptTest::ManifestTest_5()
|
||||
{
|
||||
QSKIP("This test was disabled in the original code");
|
||||
|
||||
objdb = new FWObjectDatabase();
|
||||
QString option_o = QDir::currentPath() + "/ipfw2-1";
|
||||
QFile::remove(option_o);
|
||||
runCompiler("test1.fwb", "ipfw2a", "ipfw2-1.fw", option_o.toStdString());
|
||||
QString res = Configlet::findConfigletInFile("top_comment", "ipfw2-1");
|
||||
// find manifest and compare
|
||||
CPPUNIT_ASSERT(res.indexOf("# files: * ipfw2-1") != -1);
|
||||
QVERIFY(res.indexOf("# files: * ipfw2-1") != -1);
|
||||
delete objdb;
|
||||
}
|
||||
|
||||
@ -186,7 +188,7 @@ void GeneratedScriptTest::ManifestTest_6()
|
||||
runCompiler("test1.fwb", "ipfw3", "ipfw3.fw");
|
||||
QString res = Configlet::findConfigletInFile("top_comment", "ipfw3.fw");
|
||||
// find manifest and compare
|
||||
CPPUNIT_ASSERT(res.indexOf("# files: * ipfw3.fw") != -1);
|
||||
QVERIFY(res.indexOf("# files: * ipfw3.fw") != -1);
|
||||
delete objdb;
|
||||
}
|
||||
|
||||
@ -199,7 +201,7 @@ void GeneratedScriptTest::ManifestTest_7()
|
||||
runCompiler("test1.fwb", "ipfw4", "ipfw4.fw");
|
||||
QString res = Configlet::findConfigletInFile("top_comment", "ipfw4.fw");
|
||||
// find manifest and compare
|
||||
CPPUNIT_ASSERT(res.indexOf("# files: * ipfw4.fw /etc/path\\ with\\ space/ipfw4.fw") != -1);
|
||||
QVERIFY(res.indexOf("# files: * ipfw4.fw /etc/path\\ with\\ space/ipfw4.fw") != -1);
|
||||
delete objdb;
|
||||
}
|
||||
|
||||
@ -211,7 +213,7 @@ void GeneratedScriptTest::FwCommentTest()
|
||||
runCompiler("test1.fwb", "ipfw1", "ipfw1.fw");
|
||||
QString res = Configlet::findConfigletInFile("top_comment", "ipfw1.fw");
|
||||
// find string from the firewall object comment and compare
|
||||
CPPUNIT_ASSERT(res.indexOf("# Firewall object test1 comment") != -1);
|
||||
QVERIFY(res.indexOf("# Firewall object test1 comment") != -1);
|
||||
delete objdb;
|
||||
}
|
||||
|
||||
|
||||
@ -26,19 +26,21 @@
|
||||
#ifndef GENERATEDSCRIPTTESTS_IPFILTER_H
|
||||
#define GENERATEDSCRIPTTESTS_IPFILTER_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include "fwbuilder/Resources.h"
|
||||
#include "fwbuilder/FWObjectDatabase.h"
|
||||
#include "fwbuilder/Library.h"
|
||||
#include "fwbuilder/FWException.h"
|
||||
#include "fwbuilder/Logger.h"
|
||||
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
#include <QStringList>
|
||||
|
||||
|
||||
class GeneratedScriptTest : public CppUnit::TestFixture
|
||||
class GeneratedScriptTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
libfwbuilder::FWObjectDatabase *objdb;
|
||||
|
||||
void loadDataFile(const std::string &file_name);
|
||||
@ -48,8 +50,12 @@ class GeneratedScriptTest : public CppUnit::TestFixture
|
||||
const std::string &output_file_option="");
|
||||
|
||||
public:
|
||||
void setUp();
|
||||
void tearDown();
|
||||
void init();
|
||||
void cleanup();
|
||||
|
||||
// The order of tests matters because activation commands tests use
|
||||
// files produced in manifest tests
|
||||
|
||||
void ManifestTest_1();
|
||||
void ManifestTest_2();
|
||||
void ManifestTest_3();
|
||||
@ -59,29 +65,6 @@ public:
|
||||
void ManifestTest_7();
|
||||
void FwCommentTest();
|
||||
|
||||
CPPUNIT_TEST_SUITE(GeneratedScriptTest);
|
||||
|
||||
// The order of tests matters because activation commands tests use
|
||||
// files produced in manifest tests
|
||||
CPPUNIT_TEST(ManifestTest_1);
|
||||
|
||||
CPPUNIT_TEST(ManifestTest_2);
|
||||
|
||||
CPPUNIT_TEST(ManifestTest_3);
|
||||
|
||||
CPPUNIT_TEST(ManifestTest_4);
|
||||
|
||||
// CPPUNIT_TEST(ManifestTest_5);
|
||||
// CPPUNIT_TEST(ActivationCommandsTest_5);
|
||||
|
||||
CPPUNIT_TEST(ManifestTest_6);
|
||||
|
||||
CPPUNIT_TEST(ManifestTest_7);
|
||||
|
||||
CPPUNIT_TEST(FwCommentTest);
|
||||
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
};
|
||||
|
||||
#endif // GENERATEDSCRIPTTESTS_IPFILTER_H
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
|
||||
Firewall Builder
|
||||
|
||||
@ -17,18 +17,15 @@
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
|
||||
To get a copy of the GNU General Public License, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
#include <QTest>
|
||||
|
||||
#include "generatedScriptTestsIpfw.h"
|
||||
|
||||
#include <cppunit/ui/text/TestRunner.h>
|
||||
#include <cppunit/CompilerOutputter.h>
|
||||
|
||||
#include "fwbuilder/Resources.h"
|
||||
#include "fwbuilder/Constants.h"
|
||||
|
||||
@ -42,7 +39,7 @@ using namespace libfwbuilder;
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
{
|
||||
QApplication app(argc, argv, false);
|
||||
|
||||
// compilers always write file names into manifest in Utf8
|
||||
@ -52,11 +49,5 @@ int main(int argc, char **argv)
|
||||
|
||||
Resources res(Constants::getResourcesFilePath());
|
||||
|
||||
|
||||
CppUnit::TextUi::TestRunner runner;
|
||||
runner.addTest( GeneratedScriptTest::suite() );
|
||||
runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(),
|
||||
std::cerr ) );
|
||||
|
||||
runner.run();
|
||||
return QTest::qExec(new GeneratedScriptTest());
|
||||
}
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
SET(CMAKE_AUTOMOC ON)
|
||||
|
||||
add_executable(generatedScriptTestsLinux generatedScriptTestsLinux.cpp main_generatedScriptTestsLinux.cpp)
|
||||
add_test(NAME generatedScriptTestsLinux COMMAND generatedScriptTestsLinux)
|
||||
|
||||
target_link_libraries(generatedScriptTestsLinux PRIVATE test_main netsnmp gui import fwbparser antlr common iptlib fwbpf fwbjuniper fwbcisco compilerdriver fwcompiler fwbuilder xml2 xslt z pthread cppunit)
|
||||
target_link_libraries(generatedScriptTestsLinux PRIVATE test_main netsnmp gui import fwbparser antlr common iptlib fwbpf fwbjuniper fwbcisco compilerdriver fwcompiler fwbuilder xml2 xslt z pthread Qt5::Test)
|
||||
|
||||
file(COPY test1.fwb DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
|
||||
Firewall Builder
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
|
||||
To get a copy of the GNU General Public License, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
@ -34,6 +34,7 @@
|
||||
#include "fwbuilder/IPService.h"
|
||||
#include "fwbuilder/Constants.h"
|
||||
|
||||
#include <QTest>
|
||||
#include <QApplication>
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
@ -49,15 +50,15 @@ using namespace fwcompiler;
|
||||
class UpgradePredicate: public XMLTools::UpgradePredicate
|
||||
{
|
||||
public:
|
||||
virtual bool operator()(const string&) const
|
||||
{
|
||||
virtual bool operator()(const string&) const
|
||||
{
|
||||
cout << "Data file has been created in the old version of Firewall Builder. Use fwbuilder GUI to convert it." << std::endl;
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
void GeneratedScriptTest::setUp()
|
||||
void GeneratedScriptTest::init()
|
||||
{
|
||||
// register protocols we need
|
||||
IPService::addNamedProtocol(51, "ah");
|
||||
@ -66,7 +67,7 @@ void GeneratedScriptTest::setUp()
|
||||
Configlet::setDebugging(true);
|
||||
}
|
||||
|
||||
void GeneratedScriptTest::tearDown()
|
||||
void GeneratedScriptTest::cleanup()
|
||||
{
|
||||
}
|
||||
|
||||
@ -75,7 +76,7 @@ void GeneratedScriptTest::loadDataFile(const string &file_name)
|
||||
try
|
||||
{
|
||||
/* load the data file */
|
||||
UpgradePredicate upgrade_predicate;
|
||||
UpgradePredicate upgrade_predicate;
|
||||
|
||||
objdb->setReadOnly( false );
|
||||
objdb->load(file_name, &upgrade_predicate, Constants::getDTDDirectory());
|
||||
@ -98,13 +99,13 @@ void GeneratedScriptTest::runCompiler(const std::string &test_file,
|
||||
|
||||
CompilerDriver_ipt driver(objdb);
|
||||
driver.setEmbeddedMode();
|
||||
CPPUNIT_ASSERT_MESSAGE("CompilerDriver_ipt initialization failed",
|
||||
driver.prepare(args) == true);
|
||||
QVERIFY2(driver.prepare(args) == true,
|
||||
"CompilerDriver_ipt initialization failed");
|
||||
driver.compile();
|
||||
// compiler should have created file test1.fw
|
||||
QFileInfo fi(generate_file_name.c_str());
|
||||
CPPUNIT_ASSERT_MESSAGE("Generated file " + generate_file_name + " not found",
|
||||
fi.exists() == true);
|
||||
QVERIFY2(fi.exists() == true,
|
||||
std::string("Generated file " + generate_file_name + " not found").data());
|
||||
}
|
||||
|
||||
// I can check only certain parts of the top comment. Can't
|
||||
@ -117,25 +118,25 @@ void GeneratedScriptTest::ManifestTest()
|
||||
runCompiler("test1.fwb", "test1", "test1.fw");
|
||||
QString res = Configlet::findConfigletInFile("top_comment", "test1.fw");
|
||||
// find manifest and compare
|
||||
CPPUNIT_ASSERT(res.indexOf("# files: * test1.fw") != -1);
|
||||
CPPUNIT_ASSERT(res.indexOf("# files: * test2.fw") == -1);
|
||||
QVERIFY(res.indexOf("# files: * test1.fw") != -1);
|
||||
QVERIFY(res.indexOf("# files: * test2.fw") == -1);
|
||||
delete objdb;
|
||||
|
||||
objdb = new FWObjectDatabase();
|
||||
runCompiler("test1.fwb", "test3", "test3.fw");
|
||||
res = Configlet::findConfigletInFile("top_comment", "test3.fw");
|
||||
// find manifest and compare
|
||||
CPPUNIT_ASSERT(res.indexOf("# files: * test3.fw firewall.fw") != -1);
|
||||
CPPUNIT_ASSERT(res.indexOf("# files: * test1.fw") == -1);
|
||||
QVERIFY(res.indexOf("# files: * test3.fw firewall.fw") != -1);
|
||||
QVERIFY(res.indexOf("# files: * test1.fw") == -1);
|
||||
delete objdb;
|
||||
|
||||
objdb = new FWObjectDatabase();
|
||||
runCompiler("test1.fwb", "test4", "test4.fw");
|
||||
res = Configlet::findConfigletInFile("top_comment", "test4.fw");
|
||||
// find manifest and compare
|
||||
CPPUNIT_ASSERT(res.indexOf("# files: * test4.fw /etc/init.d/firewall.fw") != -1);
|
||||
CPPUNIT_ASSERT(res.indexOf("# files: * test4.fw firewall.fw") == -1);
|
||||
CPPUNIT_ASSERT(res.indexOf("# files: * test1.fw") == -1);
|
||||
QVERIFY(res.indexOf("# files: * test4.fw /etc/init.d/firewall.fw") != -1);
|
||||
QVERIFY(res.indexOf("# files: * test4.fw firewall.fw") == -1);
|
||||
QVERIFY(res.indexOf("# files: * test1.fw") == -1);
|
||||
delete objdb;
|
||||
|
||||
}
|
||||
@ -146,7 +147,7 @@ void GeneratedScriptTest::FwCommentTest()
|
||||
runCompiler("test1.fwb", "test1", "test1.fw");
|
||||
QString res = Configlet::findConfigletInFile("top_comment", "test1.fw");
|
||||
// find string from the firewall object comment and compare
|
||||
CPPUNIT_ASSERT(res.indexOf("# Firewall object test1 comment") != -1);
|
||||
QVERIFY(res.indexOf("# Firewall object test1 comment") != -1);
|
||||
delete objdb;
|
||||
}
|
||||
|
||||
@ -178,7 +179,7 @@ void GeneratedScriptTest::CheckUtilitiesTest()
|
||||
utils.push_back(line.trimmed());
|
||||
}
|
||||
}
|
||||
CPPUNIT_ASSERT(utils == test1_utils);
|
||||
QVERIFY(utils == test1_utils);
|
||||
delete objdb;
|
||||
|
||||
utils.clear();
|
||||
@ -193,7 +194,7 @@ void GeneratedScriptTest::CheckUtilitiesTest()
|
||||
utils.push_back(line.trimmed());
|
||||
}
|
||||
}
|
||||
CPPUNIT_ASSERT(utils == test2_utils);
|
||||
QVERIFY(utils == test2_utils);
|
||||
delete objdb;
|
||||
|
||||
}
|
||||
@ -203,13 +204,13 @@ void GeneratedScriptTest::verifyInterfacesTest()
|
||||
objdb = new FWObjectDatabase();
|
||||
runCompiler("test1.fwb", "test1", "test1.fw");
|
||||
QString res = Configlet::findConfigletInFile("verify_interfaces", "test1.fw");
|
||||
CPPUNIT_ASSERT(res.indexOf("for i in eth0 eth1 lo eth2 ; do") != -1);
|
||||
QVERIFY(res.indexOf("for i in eth0 eth1 lo eth2 ; do") != -1);
|
||||
delete objdb;
|
||||
|
||||
objdb = new FWObjectDatabase();
|
||||
runCompiler("test1.fwb", "test4", "test4.fw");
|
||||
res = Configlet::findConfigletInFile("verify_interfaces", "test4.fw");
|
||||
CPPUNIT_ASSERT(res.indexOf("for i in eth0 eth1 lo eth2 eth1.200 vlan110 vlan111 ; do") != -1);
|
||||
QVERIFY(res.indexOf("for i in eth0 eth1 lo eth2 eth1.200 vlan110 vlan111 ; do") != -1);
|
||||
delete objdb;
|
||||
}
|
||||
|
||||
@ -229,7 +230,7 @@ void GeneratedScriptTest::configureInterfacesTest()
|
||||
// own configlet
|
||||
QString res = Configlet::findConfigletInFile("script_skeleton", "test4.fw");
|
||||
int n1 = res.indexOf("configure_interfaces() {");
|
||||
CPPUNIT_ASSERT_MESSAGE("Shell function configure_interfaces is missing", n1 != -1);
|
||||
QVERIFY2( n1 != -1, "Shell function configure_interfaces is missing");
|
||||
int n2 = res.indexOf("}", n1);
|
||||
res = res.mid(n1, n2-n1);
|
||||
|
||||
@ -245,7 +246,7 @@ void GeneratedScriptTest::configureInterfacesTest()
|
||||
sample.sort();
|
||||
intf_list.sort();
|
||||
|
||||
CPPUNIT_ASSERT(sample == intf_list);
|
||||
QVERIFY(sample == intf_list);
|
||||
|
||||
delete objdb;
|
||||
}
|
||||
@ -273,7 +274,7 @@ void GeneratedScriptTest::configureInterfacesClusterTest()
|
||||
// own configlet
|
||||
QString res = Configlet::findConfigletInFile("script_skeleton", "test2.fw");
|
||||
int n1 = res.indexOf("configure_interfaces() {");
|
||||
CPPUNIT_ASSERT_MESSAGE("Shell function configure_interfaces is missing", n1 != -1);
|
||||
QVERIFY2( n1 != -1, "Shell function configure_interfaces is missing");
|
||||
int n2 = res.indexOf("}", n1);
|
||||
res = res.mid(n1, n2-n1);
|
||||
|
||||
@ -287,13 +288,13 @@ void GeneratedScriptTest::configureInterfacesClusterTest()
|
||||
}
|
||||
|
||||
intf_list.sort();
|
||||
CPPUNIT_ASSERT(sample_2 == intf_list);
|
||||
QVERIFY(sample_2 == intf_list);
|
||||
|
||||
intf_list.clear();
|
||||
|
||||
res = Configlet::findConfigletInFile("script_skeleton", "test3.fw");
|
||||
n1 = res.indexOf("configure_interfaces() {");
|
||||
CPPUNIT_ASSERT_MESSAGE("Shell function configure_interfaces is missing", n1 != -1);
|
||||
QVERIFY2( n1 != -1, "Shell function configure_interfaces is missing");
|
||||
n2 = res.indexOf("}", n1);
|
||||
res = res.mid(n1, n2-n1);
|
||||
|
||||
@ -306,7 +307,7 @@ void GeneratedScriptTest::configureInterfacesClusterTest()
|
||||
}
|
||||
|
||||
intf_list.sort();
|
||||
CPPUNIT_ASSERT(sample_3 == intf_list);
|
||||
QVERIFY(sample_3 == intf_list);
|
||||
|
||||
delete objdb;
|
||||
}
|
||||
@ -324,7 +325,7 @@ void GeneratedScriptTest::virtualAddressesForNat1Test()
|
||||
// own configlet
|
||||
QString res = Configlet::findConfigletInFile("script_skeleton", "test5.fw");
|
||||
int n1 = res.indexOf("configure_interfaces() {");
|
||||
CPPUNIT_ASSERT_MESSAGE("Shell function configure_interfaces is missing", n1 != -1);
|
||||
QVERIFY2( n1 != -1, "Shell function configure_interfaces is missing");
|
||||
int n2 = res.indexOf("}", n1);
|
||||
res = res.mid(n1, n2-n1);
|
||||
|
||||
@ -338,7 +339,7 @@ void GeneratedScriptTest::virtualAddressesForNat1Test()
|
||||
}
|
||||
|
||||
intf_list.sort();
|
||||
CPPUNIT_ASSERT(sample_1 == intf_list);
|
||||
QVERIFY(sample_1 == intf_list);
|
||||
|
||||
delete objdb;
|
||||
}
|
||||
@ -355,7 +356,7 @@ void GeneratedScriptTest::virtualAddressesForNat2Test()
|
||||
// own configlet
|
||||
QString res = Configlet::findConfigletInFile("script_skeleton", "test6.fw");
|
||||
int n1 = res.indexOf("configure_interfaces() {");
|
||||
CPPUNIT_ASSERT_MESSAGE("Shell function configure_interfaces is missing", n1 != -1);
|
||||
QVERIFY2( n1 != -1, "Shell function configure_interfaces is missing");
|
||||
int n2 = res.indexOf("}", n1);
|
||||
res = res.mid(n1, n2-n1);
|
||||
|
||||
@ -369,7 +370,7 @@ void GeneratedScriptTest::virtualAddressesForNat2Test()
|
||||
}
|
||||
|
||||
intf_list.sort();
|
||||
CPPUNIT_ASSERT(sample_1 == intf_list);
|
||||
QVERIFY(sample_1 == intf_list);
|
||||
|
||||
delete objdb;
|
||||
}
|
||||
@ -384,11 +385,11 @@ void GeneratedScriptTest::runTimeAddressTablesWithIpSet1Test()
|
||||
runCompiler("test1.fwb", "test6", "test6.fw");
|
||||
|
||||
QString res = Configlet::findConfigletInFile("run_time_address_tables", "test6.fw");
|
||||
CPPUNIT_ASSERT(!res.isEmpty());
|
||||
QVERIFY(!res.isEmpty());
|
||||
int n1 = res.indexOf("load_run_time_address_table_files() {");
|
||||
CPPUNIT_ASSERT(n1 == -1);
|
||||
QVERIFY(n1 == -1);
|
||||
n1 = res.indexOf("check_run_time_address_table_files() {");
|
||||
CPPUNIT_ASSERT(n1 != -1);
|
||||
QVERIFY(n1 != -1);
|
||||
|
||||
delete objdb;
|
||||
}
|
||||
@ -410,7 +411,7 @@ void GeneratedScriptTest::runTimeAddressTablesWithIpSet2Test()
|
||||
|
||||
QString res = Configlet::findConfigletInFile("run_time_address_tables", "test7.fw");
|
||||
int n1 = res.indexOf("load_run_time_address_table_files() {");
|
||||
CPPUNIT_ASSERT_MESSAGE("Shell function load_run_time_address_table_files is missing", n1 != -1);
|
||||
QVERIFY2( n1 != -1, "Shell function load_run_time_address_table_files is missing");
|
||||
int n2 = res.indexOf("}", n1);
|
||||
QString conf = res.mid(n1, n2-n1);
|
||||
|
||||
@ -424,10 +425,10 @@ void GeneratedScriptTest::runTimeAddressTablesWithIpSet2Test()
|
||||
}
|
||||
|
||||
cmd_list.sort();
|
||||
CPPUNIT_ASSERT(sample_1 == cmd_list);
|
||||
QVERIFY(sample_1 == cmd_list);
|
||||
|
||||
n1 = res.indexOf("check_run_time_address_table_files() {");
|
||||
CPPUNIT_ASSERT_MESSAGE("Shell function check_run_time_address_table_files is missing", n1 != -1);
|
||||
QVERIFY2( n1 != -1, "Shell function check_run_time_address_table_files is missing");
|
||||
n2 = res.indexOf("}", n1);
|
||||
conf = res.mid(n1, n2-n1);
|
||||
|
||||
@ -441,7 +442,7 @@ void GeneratedScriptTest::runTimeAddressTablesWithIpSet2Test()
|
||||
}
|
||||
|
||||
cmd_list.sort();
|
||||
CPPUNIT_ASSERT(sample_2 == cmd_list);
|
||||
QVERIFY(sample_2 == cmd_list);
|
||||
|
||||
delete objdb;
|
||||
}
|
||||
@ -464,18 +465,18 @@ void GeneratedScriptTest::minusDTest()
|
||||
|
||||
CompilerDriver_ipt driver(objdb);
|
||||
driver.setEmbeddedMode();
|
||||
CPPUNIT_ASSERT_MESSAGE("CompilerDriver_ipt initialization failed",
|
||||
driver.prepare(args) == true);
|
||||
QVERIFY2(driver.prepare(args) == true,
|
||||
"CompilerDriver_ipt initialization failed");
|
||||
driver.compile();
|
||||
// compiler should have created file /tmp/test1.fw
|
||||
QFileInfo fi("/tmp/test1.fw");
|
||||
CPPUNIT_ASSERT_MESSAGE("Generated file /tmp/test1.fw not found",
|
||||
fi.exists() == true);
|
||||
QVERIFY2(fi.exists() == true,
|
||||
"Generated file /tmp/test1.fw not found");
|
||||
|
||||
QString res = Configlet::findConfigletInFile("top_comment", "/tmp/test1.fw");
|
||||
// find manifest and compare
|
||||
CPPUNIT_ASSERT(res.indexOf("# files: * test1.fw") != -1);
|
||||
CPPUNIT_ASSERT(res.indexOf("# files: * test2.fw") == -1);
|
||||
QVERIFY(res.indexOf("# files: * test1.fw") != -1);
|
||||
QVERIFY(res.indexOf("# files: * test2.fw") == -1);
|
||||
delete objdb;
|
||||
|
||||
QDir::setCurrent(current.path());
|
||||
@ -504,20 +505,19 @@ void GeneratedScriptTest::minusOTest1()
|
||||
|
||||
CompilerDriver_ipt driver(objdb);
|
||||
driver.setEmbeddedMode();
|
||||
CPPUNIT_ASSERT_MESSAGE("CompilerDriver_ipt initialization failed",
|
||||
driver.prepare(args) == true);
|
||||
QVERIFY2(driver.prepare(args) == true,
|
||||
"CompilerDriver_ipt initialization failed");
|
||||
driver.compile();
|
||||
// compiler should have created file full_output_file_name
|
||||
QFileInfo fi(full_output_file_name);
|
||||
CPPUNIT_ASSERT_MESSAGE("Generated file " +
|
||||
full_output_file_name.toStdString() + " not found",
|
||||
fi.exists() == true);
|
||||
QVERIFY2(fi.exists() == true,
|
||||
std::string("Generated file " + full_output_file_name.toStdString() + " not found").data());
|
||||
|
||||
QString res = Configlet::findConfigletInFile(
|
||||
"top_comment", full_output_file_name);
|
||||
// find manifest and compare
|
||||
CPPUNIT_ASSERT(res.indexOf("# files: * " + full_output_file_name) != -1);
|
||||
CPPUNIT_ASSERT(res.indexOf("# files: * test2.fw") == -1);
|
||||
QVERIFY(res.indexOf("# files: * " + full_output_file_name) != -1);
|
||||
QVERIFY(res.indexOf("# files: * test2.fw") == -1);
|
||||
delete objdb;
|
||||
}
|
||||
|
||||
@ -539,21 +539,20 @@ void GeneratedScriptTest::minusOTest2()
|
||||
|
||||
CompilerDriver_ipt driver(objdb);
|
||||
driver.setEmbeddedMode();
|
||||
CPPUNIT_ASSERT_MESSAGE("CompilerDriver_ipt initialization failed",
|
||||
driver.prepare(args) == true);
|
||||
QVERIFY2(driver.prepare(args) == true,
|
||||
"CompilerDriver_ipt initialization failed");
|
||||
driver.compile();
|
||||
// compiler should have created file full_output_file_name
|
||||
QFileInfo fi(full_output_file_name);
|
||||
CPPUNIT_ASSERT_MESSAGE("Generated file " +
|
||||
full_output_file_name.toStdString() + " not found",
|
||||
fi.exists() == true);
|
||||
QVERIFY2(fi.exists() == true,
|
||||
std::string("Generated file " + full_output_file_name.toStdString() + " not found").data());
|
||||
|
||||
QString res = Configlet::findConfigletInFile(
|
||||
"top_comment", full_output_file_name);
|
||||
// find manifest and compare
|
||||
CPPUNIT_ASSERT(res.indexOf("# files: * " + full_output_file_name) != -1);
|
||||
CPPUNIT_ASSERT(res.indexOf("# files: * test1.fw") == -1);
|
||||
CPPUNIT_ASSERT(res.indexOf("# files: * test2.fw") == -1);
|
||||
QVERIFY(res.indexOf("# files: * " + full_output_file_name) != -1);
|
||||
QVERIFY(res.indexOf("# files: * test1.fw") == -1);
|
||||
QVERIFY(res.indexOf("# files: * test2.fw") == -1);
|
||||
delete objdb;
|
||||
}
|
||||
|
||||
@ -575,20 +574,19 @@ void GeneratedScriptTest::minusDminusOTest()
|
||||
|
||||
CompilerDriver_ipt driver(objdb);
|
||||
driver.setEmbeddedMode();
|
||||
CPPUNIT_ASSERT_MESSAGE("CompilerDriver_ipt initialization failed",
|
||||
driver.prepare(args) == true);
|
||||
QVERIFY2(driver.prepare(args) == true,
|
||||
"CompilerDriver_ipt initialization failed");
|
||||
driver.compile();
|
||||
// compiler should have created file full_output_file_name
|
||||
QFileInfo fi(full_output_file_name);
|
||||
CPPUNIT_ASSERT_MESSAGE("Generated file " +
|
||||
full_output_file_name.toStdString() + " not found",
|
||||
fi.exists() == true);
|
||||
QVERIFY2(fi.exists() == true,
|
||||
std::string("Generated file " + full_output_file_name.toStdString() + " not found").data());
|
||||
|
||||
QString res = Configlet::findConfigletInFile(
|
||||
"top_comment", full_output_file_name);
|
||||
// find manifest and compare
|
||||
CPPUNIT_ASSERT(res.indexOf("# files: * " + full_output_file_name) != -1);
|
||||
CPPUNIT_ASSERT(res.indexOf("# files: * test2.fw") == -1);
|
||||
QVERIFY(res.indexOf("# files: * " + full_output_file_name) != -1);
|
||||
QVERIFY(res.indexOf("# files: * test2.fw") == -1);
|
||||
delete objdb;
|
||||
|
||||
QDir::setCurrent(current.path());
|
||||
@ -611,21 +609,20 @@ void GeneratedScriptTest::outputFileNameOptionTest1()
|
||||
|
||||
CompilerDriver_ipt driver(objdb);
|
||||
driver.setEmbeddedMode();
|
||||
CPPUNIT_ASSERT_MESSAGE("CompilerDriver_ipt initialization failed",
|
||||
driver.prepare(args) == true);
|
||||
QVERIFY2(driver.prepare(args) == true,
|
||||
"CompilerDriver_ipt initialization failed");
|
||||
driver.compile();
|
||||
// compiler should have created file full_output_file_name
|
||||
QFileInfo fi(full_output_file_name);
|
||||
CPPUNIT_ASSERT_MESSAGE("Generated file " +
|
||||
full_output_file_name.toStdString() + " not found",
|
||||
fi.exists() == true);
|
||||
QVERIFY2(fi.exists() == true,
|
||||
std::string("Generated file " + full_output_file_name.toStdString() + " not found").data());
|
||||
|
||||
QString res = Configlet::findConfigletInFile(
|
||||
"top_comment", full_output_file_name);
|
||||
// find manifest and compare
|
||||
CPPUNIT_ASSERT(res.indexOf("# files: * " + full_output_file_name) != -1);
|
||||
CPPUNIT_ASSERT(res.indexOf("# files: * test1.fw") == -1);
|
||||
CPPUNIT_ASSERT(res.indexOf("# files: * test2.fw") == -1);
|
||||
QVERIFY(res.indexOf("# files: * " + full_output_file_name) != -1);
|
||||
QVERIFY(res.indexOf("# files: * test1.fw") == -1);
|
||||
QVERIFY(res.indexOf("# files: * test2.fw") == -1);
|
||||
delete objdb;
|
||||
}
|
||||
|
||||
@ -646,21 +643,20 @@ void GeneratedScriptTest::outputFileNameOptionTest2()
|
||||
|
||||
CompilerDriver_ipt driver(objdb);
|
||||
driver.setEmbeddedMode();
|
||||
CPPUNIT_ASSERT_MESSAGE("CompilerDriver_ipt initialization failed",
|
||||
driver.prepare(args) == true);
|
||||
QVERIFY2(driver.prepare(args) == true,
|
||||
"CompilerDriver_ipt initialization failed");
|
||||
driver.compile();
|
||||
// compiler should have created file full_output_file_name
|
||||
QFileInfo fi(full_output_file_name);
|
||||
CPPUNIT_ASSERT_MESSAGE("Generated file " +
|
||||
full_output_file_name.toStdString() + " not found",
|
||||
fi.exists() == true);
|
||||
QVERIFY2(fi.exists() == true,
|
||||
std::string("Generated file " + full_output_file_name.toStdString() + " not found").data());
|
||||
|
||||
QString res = Configlet::findConfigletInFile(
|
||||
"top_comment", full_output_file_name);
|
||||
// find manifest and compare
|
||||
CPPUNIT_ASSERT(res.indexOf("# files: * " + full_output_file_name) != -1);
|
||||
CPPUNIT_ASSERT(res.indexOf("# files: * test1.fw") == -1);
|
||||
CPPUNIT_ASSERT(res.indexOf("# files: * test2.fw") == -1);
|
||||
QVERIFY(res.indexOf("# files: * " + full_output_file_name) != -1);
|
||||
QVERIFY(res.indexOf("# files: * test1.fw") == -1);
|
||||
QVERIFY(res.indexOf("# files: * test2.fw") == -1);
|
||||
delete objdb;
|
||||
}
|
||||
|
||||
@ -685,21 +681,20 @@ void GeneratedScriptTest::outputFileNameOptionTest3()
|
||||
|
||||
CompilerDriver_ipt driver(objdb);
|
||||
driver.setEmbeddedMode();
|
||||
CPPUNIT_ASSERT_MESSAGE("CompilerDriver_ipt initialization failed",
|
||||
driver.prepare(args) == true);
|
||||
QVERIFY2(driver.prepare(args) == true,
|
||||
"CompilerDriver_ipt initialization failed");
|
||||
driver.compile();
|
||||
// compiler should have created file full_output_file_name
|
||||
QFileInfo fi(full_output_file_name);
|
||||
CPPUNIT_ASSERT_MESSAGE("Generated file " +
|
||||
full_output_file_name.toStdString() + " not found",
|
||||
fi.exists() == true);
|
||||
QVERIFY2(fi.exists() == true,
|
||||
std::string("Generated file " + full_output_file_name.toStdString() + " not found").data());
|
||||
|
||||
QString res = Configlet::findConfigletInFile(
|
||||
"top_comment", full_output_file_name);
|
||||
// find manifest and compare
|
||||
CPPUNIT_ASSERT(res.indexOf("# files: * " + full_output_file_name) != -1);
|
||||
CPPUNIT_ASSERT(res.indexOf("# files: * test1.fw") == -1);
|
||||
CPPUNIT_ASSERT(res.indexOf("# files: * test2.fw") == -1);
|
||||
QVERIFY(res.indexOf("# files: * " + full_output_file_name) != -1);
|
||||
QVERIFY(res.indexOf("# files: * test1.fw") == -1);
|
||||
QVERIFY(res.indexOf("# files: * test2.fw") == -1);
|
||||
delete objdb;
|
||||
}
|
||||
|
||||
|
||||
@ -32,13 +32,14 @@
|
||||
#include "fwbuilder/FWException.h"
|
||||
#include "fwbuilder/Logger.h"
|
||||
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
#include <QObject>
|
||||
#include <QStringList>
|
||||
|
||||