mirror of https://github.com/Icinga/icinga2.git
Fix: Unit tests randomly crash after the tests have completed
fixes #12610
This commit is contained in:
parent
7d13b12919
commit
1dc4ab367e
|
@ -15,6 +15,8 @@
|
|||
# along with this program; if not, write to the Free Software Foundation
|
||||
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
set(Boost_USE_STATIC_LIBS OFF)
|
||||
|
||||
include(BoostTestTargets)
|
||||
|
||||
set(base_test_SOURCES
|
||||
|
@ -31,7 +33,7 @@ if(ICINGA2_UNITY_BUILD)
|
|||
endif()
|
||||
|
||||
add_boost_test(base
|
||||
SOURCES base-test.cpp ${base_test_SOURCES}
|
||||
SOURCES test-runner.cpp ${base_test_SOURCES}
|
||||
LIBRARIES base config icinga
|
||||
TESTS base_array/construct
|
||||
base_array/getset
|
||||
|
@ -123,7 +125,7 @@ if(ICINGA2_WITH_LIVESTATUS)
|
|||
endif()
|
||||
|
||||
add_boost_test(livestatus
|
||||
SOURCES livestatus-test.cpp ${livestatus_test_SOURCES}
|
||||
SOURCES test-runner.cpp livestatus-fixture.cpp ${livestatus_test_SOURCES}
|
||||
LIBRARIES base config icinga livestatus
|
||||
DEPENDENCIES methods
|
||||
TESTS livestatus/hosts livestatus/services
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#include "base/array.hpp"
|
||||
#include "base/objectlock.hpp"
|
||||
#include "base/json.hpp"
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <BoostTestTargetConfig.h>
|
||||
|
||||
using namespace icinga;
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
#include "base/convert.hpp"
|
||||
#include "base/object.hpp"
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <BoostTestTargetConfig.h>
|
||||
#include <iostream>
|
||||
|
||||
using namespace icinga;
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#include "base/dictionary.hpp"
|
||||
#include "base/objectlock.hpp"
|
||||
#include "base/json.hpp"
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <BoostTestTargetConfig.h>
|
||||
#include <boost/tuple/tuple.hpp>
|
||||
|
||||
using namespace icinga;
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
#include "base/fifo.hpp"
|
||||
#include "base/objectlock.hpp"
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <BoostTestTargetConfig.h>
|
||||
|
||||
using namespace icinga;
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include "base/dictionary.hpp"
|
||||
#include "base/objectlock.hpp"
|
||||
#include "base/json.hpp"
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <BoostTestTargetConfig.h>
|
||||
#include <boost/tuple/tuple.hpp>
|
||||
|
||||
using namespace icinga;
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
******************************************************************************/
|
||||
|
||||
#include "base/utility.hpp"
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <BoostTestTargetConfig.h>
|
||||
|
||||
using namespace icinga;
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
#include "base/netstring.hpp"
|
||||
#include "base/fifo.hpp"
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <BoostTestTargetConfig.h>
|
||||
|
||||
using namespace icinga;
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
#include "base/object.hpp"
|
||||
#include "base/value.hpp"
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <BoostTestTargetConfig.h>
|
||||
|
||||
using namespace icinga;
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#include "base/serializer.hpp"
|
||||
#include "base/array.hpp"
|
||||
#include "base/dictionary.hpp"
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <BoostTestTargetConfig.h>
|
||||
#include <boost/tuple/tuple.hpp>
|
||||
|
||||
using namespace icinga;
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
******************************************************************************/
|
||||
|
||||
#include "base/utility.hpp"
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <BoostTestTargetConfig.h>
|
||||
#include <iostream>
|
||||
|
||||
using namespace icinga;
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
******************************************************************************/
|
||||
|
||||
#include "base/stacktrace.hpp"
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <BoostTestTargetConfig.h>
|
||||
|
||||
using namespace icinga;
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
#include "base/stdiostream.hpp"
|
||||
#include "base/string.hpp"
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <BoostTestTargetConfig.h>
|
||||
#include <sstream>
|
||||
|
||||
using namespace icinga;
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
******************************************************************************/
|
||||
|
||||
#include "base/string.hpp"
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <BoostTestTargetConfig.h>
|
||||
|
||||
using namespace icinga;
|
||||
|
||||
|
|
|
@ -1,48 +0,0 @@
|
|||
/******************************************************************************
|
||||
* Icinga 2 *
|
||||
* Copyright (C) 2012-2016 Icinga Development Team (https://www.icinga.org/) *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public 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. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the Free Software Foundation *
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||
******************************************************************************/
|
||||
|
||||
#define BOOST_TEST_MAIN
|
||||
#define BOOST_TEST_MODULE icinga2_test
|
||||
|
||||
#include "icinga/icingaapplication.hpp"
|
||||
#include "base/application.hpp"
|
||||
#include "base/timer.hpp"
|
||||
#include <BoostTestTargetConfig.h>
|
||||
|
||||
using namespace icinga;
|
||||
|
||||
struct InitLibBase
|
||||
{
|
||||
IcingaApplication::Ptr appInst;
|
||||
|
||||
InitLibBase(void)
|
||||
{
|
||||
Application::InitializeBase();
|
||||
|
||||
appInst = new IcingaApplication();
|
||||
static_pointer_cast<ConfigObject>(appInst)->OnConfigLoaded();
|
||||
}
|
||||
|
||||
~InitLibBase(void)
|
||||
{
|
||||
Application::UninitializeBase();
|
||||
}
|
||||
};
|
||||
|
||||
BOOST_GLOBAL_FIXTURE(InitLibBase);
|
|
@ -20,7 +20,7 @@
|
|||
#include "base/timer.hpp"
|
||||
#include "base/utility.hpp"
|
||||
#include "base/application.hpp"
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <BoostTestTargetConfig.h>
|
||||
|
||||
using namespace icinga;
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include "base/objectlock.hpp"
|
||||
#include "base/application.hpp"
|
||||
#include "base/type.hpp"
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <BoostTestTargetConfig.h>
|
||||
#include <boost/tuple/tuple.hpp>
|
||||
|
||||
using namespace icinga;
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
******************************************************************************/
|
||||
|
||||
#include "base/value.hpp"
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <BoostTestTargetConfig.h>
|
||||
|
||||
using namespace icinga;
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
#include "config/configcompiler.hpp"
|
||||
#include "base/exception.hpp"
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <BoostTestTargetConfig.h>
|
||||
|
||||
using namespace icinga;
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
******************************************************************************/
|
||||
|
||||
#include "icinga/host.hpp"
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <BoostTestTargetConfig.h>
|
||||
|
||||
using namespace icinga;
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
******************************************************************************/
|
||||
|
||||
#include "icinga/macroprocessor.hpp"
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <BoostTestTargetConfig.h>
|
||||
|
||||
using namespace icinga;
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
#include "icinga/perfdatavalue.hpp"
|
||||
#include "icinga/pluginutility.hpp"
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <BoostTestTargetConfig.h>
|
||||
|
||||
using namespace icinga;
|
||||
|
||||
|
|
|
@ -17,14 +17,10 @@
|
|||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||
******************************************************************************/
|
||||
|
||||
#define BOOST_TEST_MAIN
|
||||
#define BOOST_TEST_MODULE icinga2_test
|
||||
|
||||
#include "config/configcompiler.hpp"
|
||||
#include "config/configitem.hpp"
|
||||
#include "base/application.hpp"
|
||||
#include "base/loader.hpp"
|
||||
#include <fstream>
|
||||
#include <BoostTestTargetConfig.h>
|
||||
|
||||
using namespace icinga;
|
||||
|
@ -33,22 +29,11 @@ struct LivestatusFixture
|
|||
{
|
||||
LivestatusFixture(void)
|
||||
{
|
||||
BOOST_TEST_MESSAGE("setup global config fixture");
|
||||
|
||||
Application::InitializeBase();
|
||||
|
||||
BOOST_TEST_MESSAGE( "Preparing config objects...");
|
||||
BOOST_TEST_MESSAGE("Preparing config objects...");
|
||||
|
||||
ConfigItem::RunWithActivationContext(new Function("CreateTestObjects", WrapFunction(CreateTestObjects)));
|
||||
}
|
||||
|
||||
~LivestatusFixture(void)
|
||||
{
|
||||
BOOST_TEST_MESSAGE("cleanup global config fixture");
|
||||
|
||||
Application::UninitializeBase();
|
||||
}
|
||||
|
||||
static void CreateTestObjects(void)
|
||||
{
|
||||
String config = R"CONFIG(
|
||||
|
@ -78,5 +63,4 @@ apply Service "livestatus" {
|
|||
}
|
||||
};
|
||||
|
||||
BOOST_GLOBAL_FIXTURE(LivestatusFixture);
|
||||
|
||||
BOOST_GLOBAL_FIXTURE(LivestatusFixture);
|
|
@ -21,7 +21,7 @@
|
|||
#include "base/application.hpp"
|
||||
#include "base/stdiostream.hpp"
|
||||
#include "base/json.hpp"
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <BoostTestTargetConfig.h>
|
||||
|
||||
using namespace icinga;
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
******************************************************************************/
|
||||
|
||||
#include "remote/base64.hpp"
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <BoostTestTargetConfig.h>
|
||||
|
||||
using namespace icinga;
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
#include "base/array.hpp"
|
||||
#include "remote/url.hpp"
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <BoostTestTargetConfig.h>
|
||||
#include <boost/assign/list_of.hpp>
|
||||
|
||||
using namespace icinga;
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
/******************************************************************************
|
||||
* Icinga 2 *
|
||||
* Copyright (C) 2012-2016 Icinga Development Team (https://www.icinga.org/) *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public 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. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the Free Software Foundation *
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||
******************************************************************************/
|
||||
|
||||
#include "icinga/icingaapplication.hpp"
|
||||
#include "base/application.hpp"
|
||||
#include <BoostTestTargetConfig.h>
|
||||
|
||||
using namespace icinga;
|
||||
|
||||
static bool init_unit_test(void)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
Application::InitializeBase();
|
||||
|
||||
IcingaApplication::Ptr appInst;
|
||||
|
||||
appInst = new IcingaApplication();
|
||||
static_pointer_cast<ConfigObject>(appInst)->OnConfigLoaded();
|
||||
|
||||
int rc = boost::unit_test::unit_test_main(&init_unit_test, argc, argv);
|
||||
|
||||
appInst.reset();
|
||||
|
||||
Application::Exit(rc);
|
||||
}
|
|
@ -78,9 +78,7 @@ if(Boost_FOUND AND NOT "${Boost_VERSION}0" LESS "1034000")
|
|||
if(Boost_USE_STATIC_LIBS)
|
||||
set(_boostConfig "BoostTestTargetsStatic.h")
|
||||
else()
|
||||
if(NOT APPLE)
|
||||
set(_boostConfig "BoostTestTargetsDynamic.h")
|
||||
endif()
|
||||
set(_boostConfig "BoostTestTargetsDynamic.h")
|
||||
endif()
|
||||
endif()
|
||||
get_filename_component(_moddir ${CMAKE_CURRENT_LIST_FILE} PATH)
|
||||
|
|
Loading…
Reference in New Issue