From 01cde2195de25b9afc2acaf39f16f14a9b28731f Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Fri, 8 Feb 2013 06:49:23 +0100 Subject: [PATCH] Build unit tests on Windows. Refs #3645 --- icinga2.sln | 10 +++++ test/Makefile.am | 11 ++--- test/base-dictionary.cpp | 26 ++++++++++- test/test.cpp | 26 +++++++++++ test/test.vcxproj | 95 +++++++++++++++++++++++++++++++++++++++ test/test.vcxproj.filters | 25 +++++++++++ 6 files changed, 186 insertions(+), 7 deletions(-) create mode 100644 test/test.cpp create mode 100644 test/test.vcxproj create mode 100644 test/test.vcxproj.filters diff --git a/icinga2.sln b/icinga2.sln index 475e9a14f..c1d951195 100644 --- a/icinga2.sln +++ b/icinga2.sln @@ -81,6 +81,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "remoting", "lib\remoting\re {B26AFFA6-2BDF-42E6-A224-2591FFD9BFB7} = {B26AFFA6-2BDF-42E6-A224-2591FFD9BFB7} EndProjectSection EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test", "test\test.vcxproj", "{5163C576-6AA1-4769-8396-9639C45BE124}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -259,6 +261,14 @@ Global {8DD52FAC-ECEE-48C2-B266-E7C47ED485F8}.Release|Win64.Build.0 = Release|x64 {8DD52FAC-ECEE-48C2-B266-E7C47ED485F8}.Release|x64.ActiveCfg = Release|x64 {8DD52FAC-ECEE-48C2-B266-E7C47ED485F8}.Release|x64.Build.0 = Release|x64 + {5163C576-6AA1-4769-8396-9639C45BE124}.Debug|Win32.ActiveCfg = Debug|Win32 + {5163C576-6AA1-4769-8396-9639C45BE124}.Debug|Win32.Build.0 = Debug|Win32 + {5163C576-6AA1-4769-8396-9639C45BE124}.Debug|Win64.ActiveCfg = Debug|Win32 + {5163C576-6AA1-4769-8396-9639C45BE124}.Debug|x64.ActiveCfg = Debug|Win32 + {5163C576-6AA1-4769-8396-9639C45BE124}.Release|Win32.ActiveCfg = Release|Win32 + {5163C576-6AA1-4769-8396-9639C45BE124}.Release|Win32.Build.0 = Release|Win32 + {5163C576-6AA1-4769-8396-9639C45BE124}.Release|Win64.ActiveCfg = Release|Win32 + {5163C576-6AA1-4769-8396-9639C45BE124}.Release|x64.ActiveCfg = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/test/Makefile.am b/test/Makefile.am index 11c288a9d..259c5ba87 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -1,21 +1,22 @@ ## Process this file with automake to produce Makefile.in TESTS = \ - base-dictionary + icinga2_test check_PROGRAMS = \ - base-dictionary + icinga2_test -base_dictionary_SOURCES = \ +icinga2_test_SOURCES = \ + test.cpp \ base-dictionary.cpp -base_dictionary_CPPFLAGS = \ +icinga2_test_CPPFLAGS = \ $(BOOST_CPPFLAGS) \ -I${top_srcdir}/lib/base \ -I${top_srcdir}/lib/icinga \ -I${top_srcdir} -base_dictionary_LDADD = \ +icinga2_test_LDADD = \ $(BOOST_LDFLAGS) \ $(BOOST_UNIT_TEST_FRAMEWORK_LIB) \ ${top_builddir}/lib/base/libbase.la \ diff --git a/test/base-dictionary.cpp b/test/base-dictionary.cpp index 9dc507095..cbb87f47b 100644 --- a/test/base-dictionary.cpp +++ b/test/base-dictionary.cpp @@ -1,10 +1,30 @@ -#define BOOST_TEST_DYN_LINK -#define BOOST_TEST_MODULE base_dictionary +/****************************************************************************** + * Icinga 2 * + * Copyright (C) 2012 Icinga Development Team (http://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 #include + using namespace icinga; +BOOST_AUTO_TEST_SUITE(base_dictionary) + BOOST_AUTO_TEST_CASE(construct) { Dictionary::Ptr dictionary = boost::make_shared(); @@ -70,3 +90,5 @@ BOOST_AUTO_TEST_CASE(unnamed_order) i++; } } + +BOOST_AUTO_TEST_SUITE_END() diff --git a/test/test.cpp b/test/test.cpp new file mode 100644 index 000000000..35984e033 --- /dev/null +++ b/test/test.cpp @@ -0,0 +1,26 @@ +/****************************************************************************** + * Icinga 2 * + * Copyright (C) 2012 Icinga Development Team (http://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 +#ifndef _WIN32 +# define BOOST_TEST_DYN_LINK +#endif /* _WIN32 */ + +#include diff --git a/test/test.vcxproj b/test/test.vcxproj new file mode 100644 index 000000000..7c142f812 --- /dev/null +++ b/test/test.vcxproj @@ -0,0 +1,95 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {5163C576-6AA1-4769-8396-9639C45BE124} + Win32Proj + test + + + + Application + true + MultiByte + + + Application + false + true + MultiByte + + + + + + + + + + + + + true + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + $(SolutionDir)\lib\base;$(SolutionDir)\lib\remoting;$(SolutionDir)\lib\icinga;$(SolutionDir)\lib\config;$(IncludePath) + $(SolutionDir)$(Platform)\$(Configuration)\;$(LibraryPath) + + + false + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + + + + + + Level3 + Disabled + WIN32;I2_TEST_BUILD;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + false + + + Console + true + base.lib;config.lib;icinga.lib;%(AdditionalDependencies) + + + + + Level3 + + + MaxSpeed + true + true + WIN32;I2_TEST_BUILD;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + false + + + Console + true + true + true + base.lib;config.lib;icinga.lib;%(AdditionalDependencies) + + + + + + + + + + \ No newline at end of file diff --git a/test/test.vcxproj.filters b/test/test.vcxproj.filters new file mode 100644 index 000000000..75fd96994 --- /dev/null +++ b/test/test.vcxproj.filters @@ -0,0 +1,25 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Quelldateien + + + Quelldateien + + + \ No newline at end of file