diff --git a/build_num b/build_num index e056b5e74..919489c84 100644 --- a/build_num +++ b/build_num @@ -1 +1 @@ -#define BUILD_NUM 3252 +#define BUILD_NUM 3253 diff --git a/doc/ChangeLog b/doc/ChangeLog index c30b343b1..b473fc29e 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,19 @@ +2010-09-16 Vadim Kurland + + * generatedScriptTestsIpfilter.cpp (GeneratedScriptTest::runCompiler): + unit tests to test manifest and activation commands in the generated + .fw script for ipfilter. Refs #1702 + + * FirewallInstaller.cpp (FirewallInstaller::getGeneratedFileFullPath): + fixed how we append suffix ".fw" to the name of generated script + when it is preconfigured in the firewall settings dialog and already + includes ".fw" suffix (it was added twice). + + * CompilerDriver_ipf_run.cpp (CompilerDriver_ipf::run): fixed #1702 + "Wrong path in the activation script for ipfilter". Activation command + embedded in the generated .fw script used local path to the generated + .conf file on the machine where fwbuilder compiler was running. + 2010-09-14 Vadim Kurland * FirewallInstaller.cpp (getGeneratedFileFullPath): fixed SF bug diff --git a/src/gui/FirewallInstaller.cpp b/src/gui/FirewallInstaller.cpp index a0596dc64..02d83cf88 100644 --- a/src/gui/FirewallInstaller.cpp +++ b/src/gui/FirewallInstaller.cpp @@ -757,7 +757,7 @@ QString FirewallInstaller::getGeneratedFileFullPath(Firewall *fw) if (!ofname.isEmpty()) { QFileInfo fi(ofname); - if (fi.suffix() != ".fw") generated_file = ofname + ".fw"; + if (fi.suffix() != "fw") generated_file = ofname + ".fw"; else generated_file = ofname; } else generated_file = QString::fromUtf8(fw->getName().c_str()) + ".fw"; diff --git a/src/pflib/CompilerDriver_ipf_run.cpp b/src/pflib/CompilerDriver_ipf_run.cpp index 0ee76c5d0..837d90a65 100644 --- a/src/pflib/CompilerDriver_ipf_run.cpp +++ b/src/pflib/CompilerDriver_ipf_run.cpp @@ -71,7 +71,7 @@ #include #include #include - +#include using namespace std; @@ -104,6 +104,9 @@ QString CompilerDriver_ipf::composeActivationCommand(libfwbuilder::Firewall *fw, QString CompilerDriver_ipf::assembleManifest(Cluster*, Firewall* fw, bool ) { FWOptions* options = fw->getOptionsObject(); + + //qDebug() << "CompilerDriver_ipf::assembleManifest fw_file_name=" << fw_file_name; + QFileInfo fw_file_info(fw_file_name); QString ipf_file_name = fw_file_info.completeBaseName() + "-ipf.conf"; QString nat_file_name = fw_file_info.completeBaseName() + "-nat.conf"; @@ -200,10 +203,14 @@ QString CompilerDriver_ipf::run(const std::string &cluster_id, } QString remote_ipf_name = options->getStr("ipf_conf_file_name_on_firewall").c_str(); - if (remote_ipf_name.isEmpty()) remote_ipf_name = ipf_file_name; + if (remote_ipf_name.isEmpty()) + remote_ipf_name = QFileInfo(ipf_file_name).fileName(); + remote_ipf_name = this->escapeFileName(remote_ipf_name); QString remote_nat_name = options->getStr("nat_conf_file_name_on_firewall").c_str(); - if (remote_nat_name.isEmpty()) remote_nat_name = nat_file_name; + if (remote_nat_name.isEmpty()) + remote_nat_name = QFileInfo(nat_file_name).fileName(); + remote_nat_name = this->escapeFileName(remote_nat_name); string s; diff --git a/src/pflib/unit_tests/generatedScriptTestsIpfilter/generatedScriptTestsIpfilter.cpp b/src/pflib/unit_tests/generatedScriptTestsIpfilter/generatedScriptTestsIpfilter.cpp new file mode 100644 index 000000000..aabc1a42e --- /dev/null +++ b/src/pflib/unit_tests/generatedScriptTestsIpfilter/generatedScriptTestsIpfilter.cpp @@ -0,0 +1,284 @@ +/* + + Firewall Builder + + Copyright (C) 2010 NetCitadel, LLC + + Author: Vadim Kurland vadim@fwbuilder.org + + $Id$ + + This program is free software which we release under the GNU General Public + License. You may redistribute and/or modify this program under the terms + of that license as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + 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 "../../config.h" + +#include "generatedScriptTestsIpfilter.h" + +#include "CompilerDriver_ipf.h" +#include "Configlet.h" + +#include "fwbuilder/FWObjectDatabase.h" +#include "fwbuilder/FWException.h" +#include "fwbuilder/IPService.h" + +#include +#include +#include +#include +#include + + +using namespace std; +using namespace libfwbuilder; +using namespace fwcompiler; + + +extern string librespath; + +class UpgradePredicate: public XMLTools::UpgradePredicate +{ + public: + 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() +{ + Configlet::setDebugging(true); +} + +void GeneratedScriptTest::tearDown() +{ +} + +void GeneratedScriptTest::loadDataFile(const string &file_name) +{ + /* load the data file */ + UpgradePredicate upgrade_predicate; + + objdb->setReadOnly( false ); + objdb->load(file_name, &upgrade_predicate, librespath); + objdb->setFileName(file_name); + objdb->reIndex(); +} + +void GeneratedScriptTest::runCompiler(const std::string &test_file, + const std::string &firewall_object_name, + const std::string &generate_file_name, + const std::string &output_file_option) +{ + loadDataFile(test_file); + + QStringList args; + + if (!output_file_option.empty()) + { + args << "-o" << output_file_option.c_str(); + } + + args << firewall_object_name.c_str(); + + CompilerDriver_ipf driver(objdb); + + driver.setEmbeddedMode(); + CPPUNIT_ASSERT_MESSAGE("CompilerDriver_ipf initialization failed", + driver.prepare(args) == true); + 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); +} + +// I can check only certain parts of the top comment. Can't +// compare against "golden" file because some parts of the comment +// are variable, such as date, version and build number + +void GeneratedScriptTest::ManifestTest_1() +{ + objdb = new FWObjectDatabase(); + 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); + delete objdb; +} + +void GeneratedScriptTest::ManifestTest_2() +{ + /* + * output script name is set to ipf2-1.fw in the fw object. This + * parameter is used by instDialog and passed to the compiler via + * "-o" command line option. Calling compiler without this option + * produces file with standard name. + */ + objdb = new FWObjectDatabase(); + runCompiler("test1.fwb", "ipf2", "ipf2.fw"); + QString res = Configlet::findConfigletInFile("top_comment", "ipf2.fw"); + // find manifest and compare + CPPUNIT_ASSERT(res.indexOf("# files: * ipf2.fw") != -1); + CPPUNIT_ASSERT(res.indexOf("# files: ipf2-ipf.conf") != -1); + CPPUNIT_ASSERT(res.indexOf("# files: ipf2-nat.conf") != -1); + delete objdb; +} + +void GeneratedScriptTest::ManifestTest_3() +{ + /* + * output script name is set to ipf2a in the fw object. This + * parameter is used by instDialog and passed to the compiler via + * "-o" command line option. Calling compiler without this option + * produces file with standard name. + */ + objdb = new FWObjectDatabase(); + runCompiler("test1.fwb", "ipf2a", "ipf2.fw"); + QString res = Configlet::findConfigletInFile("top_comment", "ipf2.fw"); + // find manifest and compare + CPPUNIT_ASSERT(res.indexOf("# files: * ipf2.fw") != -1); + CPPUNIT_ASSERT(res.indexOf("# files: ipf2-ipf.conf") != -1); + CPPUNIT_ASSERT(res.indexOf("# files: ipf2-nat.conf") != -1); + delete objdb; +} + +void GeneratedScriptTest::ManifestTest_4() +{ + /* + * Compile ipf2 and ipf2a adding "-o" option as instDialog does + */ + objdb = new FWObjectDatabase(); + QString option_o = QDir::currentPath() + "/ipf2-1.fw"; + 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: * ipf2-1.fw") != -1); + CPPUNIT_ASSERT(res.indexOf("# files: ipf2-1-ipf.conf") != -1); + CPPUNIT_ASSERT(res.indexOf("# files: ipf2-1-nat.conf") != -1); + delete objdb; +} + +void GeneratedScriptTest::ManifestTest_5() +{ + 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); + delete objdb; +} + +void GeneratedScriptTest::ManifestTest_6() +{ + /* + * remote ipf and nat files are configured as /etc/fw/ipf3-ipf.conf and + * /etc/fw/ipf3-nat.conf in ipf3 + */ + objdb = new FWObjectDatabase(); + 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); + delete objdb; +} + +void GeneratedScriptTest::ManifestTest_7() +{ + /* + * remote ipf and nat files in ipf4 have spaces in the path + */ + objdb = new FWObjectDatabase(); + 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); + delete objdb; +} + +// ************************************************************************ + +void GeneratedScriptTest::FwCommentTest() +{ + objdb = new FWObjectDatabase(); + 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); + delete objdb; +} + +// ************************************************************************ + +void GeneratedScriptTest::ActivationCommandsTest_1() +{ + objdb = new FWObjectDatabase(); + QString res = Configlet::findConfigletInFile("activation", "ipf1.fw"); + CPPUNIT_ASSERT(res.indexOf("$IPF -I -f ${FWDIR}/ipf1-ipf.conf") != -1); + delete objdb; +} + +void GeneratedScriptTest::ActivationCommandsTest_2() +{ + objdb = new FWObjectDatabase(); + QString res = Configlet::findConfigletInFile("activation", "ipf2.fw"); + CPPUNIT_ASSERT(res.indexOf("$IPF -I -f ${FWDIR}/ipf2-ipf.conf") != -1); + delete objdb; +} + +void GeneratedScriptTest::ActivationCommandsTest_3() +{ + objdb = new FWObjectDatabase(); + QString res = Configlet::findConfigletInFile("activation", "ipf2.fw"); + CPPUNIT_ASSERT(res.indexOf("$IPF -I -f ${FWDIR}/ipf2-ipf.conf") != -1); + delete objdb; +} + +void GeneratedScriptTest::ActivationCommandsTest_4() +{ + objdb = new FWObjectDatabase(); + QString res = Configlet::findConfigletInFile("activation", "ipf2-1.fw"); + CPPUNIT_ASSERT(res.indexOf("$IPF -I -f ${FWDIR}/ipf2-1-ipf.conf") != -1); + delete objdb; +} + +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); + delete objdb; +} + +void GeneratedScriptTest::ActivationCommandsTest_7() +{ + objdb = new FWObjectDatabase(); + QString res = Configlet::findConfigletInFile("activation", "ipf4.fw"); + CPPUNIT_ASSERT(res.indexOf("$IPF -I -f /etc/path\\ with\\ space/ipf4-ipf.conf") != -1); + delete objdb; +} + + diff --git a/src/pflib/unit_tests/generatedScriptTestsIpfilter/generatedScriptTestsIpfilter.h b/src/pflib/unit_tests/generatedScriptTestsIpfilter/generatedScriptTestsIpfilter.h new file mode 100644 index 000000000..af3464441 --- /dev/null +++ b/src/pflib/unit_tests/generatedScriptTestsIpfilter/generatedScriptTestsIpfilter.h @@ -0,0 +1,100 @@ +/* + + Firewall Builder + + Copyright (C) 2010 NetCitadel, LLC + + Author: Vadim Kurland vadim@fwbuilder.org + + $Id$ + + This program is free software which we release under the GNU General Public + License. You may redistribute and/or modify this program under the terms + of that license as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + 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 + +*/ + +#ifndef GENERATEDSCRIPTTESTS_IPFILTER_H +#define GENERATEDSCRIPTTESTS_IPFILTER_H + +#include "fwbuilder/Resources.h" +#include "fwbuilder/FWObjectDatabase.h" +#include "fwbuilder/Library.h" +#include "fwbuilder/FWException.h" +#include "fwbuilder/Logger.h" + +#include + +#include + + +class GeneratedScriptTest : public CppUnit::TestFixture +{ + libfwbuilder::FWObjectDatabase *objdb; + + void loadDataFile(const std::string &file_name); + void runCompiler(const std::string &test_file, + const std::string &firewall_object_name, + const std::string &generate_file_name, + const std::string &output_file_option=""); + +public: + void setUp(); + void tearDown(); + void ManifestTest_1(); + void ManifestTest_2(); + void ManifestTest_3(); + void ManifestTest_4(); + void ManifestTest_5(); + void ManifestTest_6(); + void ManifestTest_7(); + void FwCommentTest(); + void ActivationCommandsTest_1(); + 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(); + +}; + +#endif // GENERATEDSCRIPTTESTS_IPFILTER_H diff --git a/src/pflib/unit_tests/generatedScriptTestsIpfilter/generatedScriptTestsIpfilter.pro b/src/pflib/unit_tests/generatedScriptTestsIpfilter/generatedScriptTestsIpfilter.pro new file mode 100644 index 000000000..4d02d2db5 --- /dev/null +++ b/src/pflib/unit_tests/generatedScriptTestsIpfilter/generatedScriptTestsIpfilter.pro @@ -0,0 +1,57 @@ +include(../../../../qmake.inc) +QT += gui network +TEMPLATE = app +LANGUAGE = C++ +CONFIG += console + +INCLUDEPATH += ../../../.. \ + ../.. \ + ../../../compiler_lib/ \ + ../../../common + +DEPENDPATH = ../../../.. \ + ../.. \ + ../../../compiler_lib/ \ + ../../../common + +HEADERS = generatedScriptTestsIpfilter.h + +SOURCES = main_generatedScriptTestsIpfilter.cpp \ + generatedScriptTestsIpfilter.cpp + + +TARGET = generatedScriptTestsIpfilter +CONFIG -= release +CONFIG += debug +win32:CONFIG += console + +QMAKE_CXXFLAGS += $$CPPUNIT_CFLAGS + +LIBS += $$LIBS_FWCOMPILER $$LIBS_FWBUILDER $$CPPUNIT_LIBS + + +win32:LIBS += ../../../common/release/common.lib \ + ../../release/fwbpf.lib \ + ../../../compiler_lib/release/compilerdriver.lib + +!win32:LIBS += ../../../common/libcommon.a \ + ../../libfwbpf.a \ + ../../../compiler_lib/libcompilerdriver.a + +win32:PRE_TARGETDEPS = ../../../common/release/common.lib \ + ../../release/fwbpf.lib \ + ../compiler_lib/release/compilerdriver.lib + +!win32:PRE_TARGETDEPS = ../../../common/libcommon.a \ + ../../libfwbpf.a \ + ../../../compiler_lib/libcompilerdriver.a + +run_tests.commands = echo "Running tests..." && \ + rm -f *.fw *.conf && \ + ./${TARGET} && \ + echo "OK" || { echo "FAILED"; exit 1; } + +run_tests.depends = build_tests +build_tests.depends = all +clean_tests.depends = all +QMAKE_EXTRA_TARGETS += run_tests build_tests clean_tests diff --git a/src/pflib/unit_tests/generatedScriptTestsIpfilter/main_generatedScriptTestsIpfilter.cpp b/src/pflib/unit_tests/generatedScriptTestsIpfilter/main_generatedScriptTestsIpfilter.cpp new file mode 100644 index 000000000..aac536ec3 --- /dev/null +++ b/src/pflib/unit_tests/generatedScriptTestsIpfilter/main_generatedScriptTestsIpfilter.cpp @@ -0,0 +1,63 @@ +/* + + Firewall Builder + + Copyright (C) 2010 NetCitadel, LLC + + Author: Vadim Kurland vadim@fwbuilder.org + + $Id: main_generatedScriptTestsIpfilter.cpp 2775 2010-03-29 02:53:31Z vadim $ + + This program is free software which we release under the GNU General Public + License. You may redistribute and/or modify this program under the terms + of that license as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + 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 "../../config.h" + +#include "generatedScriptTestsIpfilter.h" + +#include +#include + +#include "fwbuilder/Resources.h" + +#include +#include + +#include "../../../common/init.cpp" + +using namespace std; +using namespace libfwbuilder; + + +int main(int argc, char **argv) +{ + QApplication app(argc, argv, false); + + // compilers always write file names into manifest in Utf8 + QTextCodec::setCodecForCStrings(QTextCodec::codecForName("Utf8")); + QTextCodec::setCodecForLocale(QTextCodec::codecForName("Utf8")); + + init(argv); + + Resources res(respath + FS_SEPARATOR + "resources.xml"); + + + CppUnit::TextUi::TestRunner runner; + runner.addTest( GeneratedScriptTest::suite() ); + runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(), + std::cerr ) ); + + runner.run(); +} diff --git a/src/pflib/unit_tests/generatedScriptTestsIpfilter/test1.fwb b/src/pflib/unit_tests/generatedScriptTestsIpfilter/test1.fwb new file mode 100644 index 000000000..3421777f3 --- /dev/null +++ b/src/pflib/unit_tests/generatedScriptTestsIpfilter/test1.fwb @@ -0,0 +1,956 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + established + + established + -m state --state ESTABLISHED,RELATED + established + + + + established + + established + -m state --state ESTABLISHED,RELATED + established + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -m record_rpc + + + + + + + + + + -m irc + + + + + + + + + + -m psd --psd-weight-threshold 5 --psd-delay-threshold 10000 + + + + + + + + + + -m string --string test_pattern + + + + + + + + + + -m talk + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/pflib/unit_tests/unit_tests.pro b/src/pflib/unit_tests/unit_tests.pro new file mode 100644 index 000000000..25feaec01 --- /dev/null +++ b/src/pflib/unit_tests/unit_tests.pro @@ -0,0 +1,12 @@ +DOLLAR = $ + +build_tests.commands = echo "Building tests..."; \ + ./unit_tests.sh make build_tests + +run_tests.commands = echo "Running tests..."; \ + ./unit_tests.sh make run_tests + +clean_tests.commands = echo "Cleaning tests..."; \ + ./unit_tests.sh make clean_tests + +QMAKE_EXTRA_TARGETS += run_tests clean_tests build_tests diff --git a/src/pflib/unit_tests/unit_tests.sh b/src/pflib/unit_tests/unit_tests.sh new file mode 100755 index 000000000..4cd18fbb6 --- /dev/null +++ b/src/pflib/unit_tests/unit_tests.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +commands=$@ + +for directory in `find . -maxdepth 1 -type d -regex '\./[A-Za-z0-9\-\_]*'` +do + cd $directory + [ ! -e Makefile ] && qmake -spec $QMAKESPEC + $commands || exit 1; + cd - +done +