1
0
mirror of https://github.com/fwbuilder/fwbuilder synced 2025-02-14 09:37:36 +01:00

test: Remove CppUnit, use QtTest only

This commit is contained in:
Sirius Bakke 2020-03-19 01:03:28 +01:00
parent a27b4d339b
commit 79cae6201f
130 changed files with 1619 additions and 1713 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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();

View File

@ -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})

View File

@ -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());
}

View File

@ -1,6 +1,5 @@
include( CTest )
find_package(CppUnit REQUIRED)
find_package(Qt5Test REQUIRED)
enable_testing(TRUE)

View File

@ -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)

View File

@ -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;
}

View File

@ -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)

View File

@ -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])));
}

View File

@ -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

View File

@ -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());
}

View File

@ -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)

View File

@ -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);
}

View File

@ -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();
};

View File

@ -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());
}

View File

@ -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)

View File

@ -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);
}

View File

@ -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

View File

@ -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());
}

View File

@ -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)

View File

@ -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;
}

View File

@ -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)

View File

@ -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;
}

View File

@ -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)

View File

@ -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;
}

View File

@ -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)

View File

@ -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;
}

View File

@ -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)

View File

@ -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;
}

View File

@ -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)

View File

@ -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: