Some compilers seems to optimize away our tests. Compiling them
statically and force initiating them seems to do the trick.
This commit is contained in:
parent
a78773a8ed
commit
b56823a6e7
11 changed files with 59 additions and 34 deletions
|
@ -2,7 +2,7 @@ FILE(GLOB SRCS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*Test.cpp" )
|
||||||
|
|
||||||
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/common)
|
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/common)
|
||||||
|
|
||||||
ADD_LIBRARY(TelldusCommonTests SHARED ${SRCS} )
|
ADD_LIBRARY(TelldusCommonTests STATIC ${SRCS} )
|
||||||
|
|
||||||
TARGET_LINK_LIBRARIES( TelldusCommonTests TelldusCommon ${CPPUNIT} )
|
TARGET_LINK_LIBRARIES( TelldusCommonTests TelldusCommon ${CPPUNIT} )
|
||||||
ADD_DEPENDENCIES( TelldusCommonTests TelldusCommon )
|
ADD_DEPENDENCIES( TelldusCommonTests TelldusCommon )
|
||||||
|
|
11
telldus-core/tests/common/CommonTests.h
Normal file
11
telldus-core/tests/common/CommonTests.h
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
#ifndef COMMONTESTS_H
|
||||||
|
#define COMMONTESTS_H
|
||||||
|
|
||||||
|
#include "StringsTest.h"
|
||||||
|
|
||||||
|
namespace CommonTests {
|
||||||
|
inline void setup() {
|
||||||
|
CPPUNIT_TEST_SUITE_REGISTRATION (StringsTest);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif // COMMONTESTS_H
|
|
@ -1,8 +1,6 @@
|
||||||
#include "StringsTest.h"
|
#include "StringsTest.h"
|
||||||
#include "Strings.h"
|
#include "Strings.h"
|
||||||
|
|
||||||
CPPUNIT_TEST_SUITE_REGISTRATION (StringsTest);
|
|
||||||
|
|
||||||
void StringsTest :: setUp (void)
|
void StringsTest :: setUp (void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,32 +8,39 @@
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
|
#include "common/CommonTests.h"
|
||||||
|
#include "service/ServiceTests.h"
|
||||||
|
|
||||||
int main (int argc, char* argv[])
|
int main (int argc, char* argv[])
|
||||||
{
|
{
|
||||||
// informs test-listener about testresults
|
// Setup our tests
|
||||||
CPPUNIT_NS :: TestResult testresult;
|
CommonTests::setup();
|
||||||
|
ServiceTests::setup();
|
||||||
|
|
||||||
// register listener for collecting the test-results
|
// informs test-listener about testresults
|
||||||
CPPUNIT_NS :: TestResultCollector collectedresults;
|
CPPUNIT_NS :: TestResult testresult;
|
||||||
testresult.addListener (&collectedresults);
|
|
||||||
|
|
||||||
// register listener for per-test progress output
|
// register listener for collecting the test-results
|
||||||
CPPUNIT_NS :: BriefTestProgressListener progress;
|
CPPUNIT_NS :: TestResultCollector collectedresults;
|
||||||
testresult.addListener (&progress);
|
testresult.addListener (&collectedresults);
|
||||||
|
|
||||||
// insert test-suite at test-runner by registry
|
// register listener for per-test progress output
|
||||||
CPPUNIT_NS :: TestRunner testrunner;
|
CPPUNIT_NS :: BriefTestProgressListener progress;
|
||||||
testrunner.addTest (CPPUNIT_NS :: TestFactoryRegistry :: getRegistry ().makeTest ());
|
testresult.addListener (&progress);
|
||||||
testrunner.run (testresult);
|
|
||||||
|
|
||||||
// output results in compiler-format
|
// insert test-suite at test-runner by registry
|
||||||
CPPUNIT_NS :: CompilerOutputter compileroutputter (&collectedresults, std::cerr);
|
CPPUNIT_NS :: TestRunner testrunner;
|
||||||
compileroutputter.write ();
|
testrunner.addTest (CPPUNIT_NS :: TestFactoryRegistry :: getRegistry ().makeTest ());
|
||||||
|
testrunner.run (testresult);
|
||||||
|
|
||||||
std::ofstream xmlFileOut("cpptestresults.xml");
|
// output results in compiler-format
|
||||||
CPPUNIT_NS :: XmlOutputter xmlOut(&collectedresults, xmlFileOut);
|
CPPUNIT_NS :: CompilerOutputter compileroutputter (&collectedresults, std::cerr);
|
||||||
xmlOut.write();
|
compileroutputter.write ();
|
||||||
|
|
||||||
// return 0 if tests were successful
|
std::ofstream xmlFileOut("cpptestresults.xml");
|
||||||
return collectedresults.wasSuccessful () ? 0 : 1;
|
CPPUNIT_NS :: XmlOutputter xmlOut(&collectedresults, xmlFileOut);
|
||||||
|
xmlOut.write();
|
||||||
|
|
||||||
|
// return 0 if tests were successful
|
||||||
|
return collectedresults.wasSuccessful () ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ FILE(GLOB SRCS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*Test.cpp" )
|
||||||
|
|
||||||
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR})
|
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR})
|
||||||
|
|
||||||
ADD_LIBRARY(TelldusServiceTests SHARED ${SRCS} )
|
ADD_LIBRARY(TelldusServiceTests STATIC ${SRCS} )
|
||||||
|
|
||||||
TARGET_LINK_LIBRARIES( TelldusServiceTests TelldusServiceStatic ${CPPUNIT} )
|
TARGET_LINK_LIBRARIES( TelldusServiceTests TelldusServiceStatic ${CPPUNIT} )
|
||||||
ADD_DEPENDENCIES( TelldusServiceTests ${telldus-service_TARGET} )
|
ADD_DEPENDENCIES( TelldusServiceTests ${telldus-service_TARGET} )
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
#include "ProtocolEverflourishTest.h"
|
#include "ProtocolEverflourishTest.h"
|
||||||
#include "service/ProtocolEverflourish.h"
|
#include "service/ProtocolEverflourish.h"
|
||||||
|
|
||||||
CPPUNIT_TEST_SUITE_REGISTRATION (ProtocolEverflourishTest);
|
|
||||||
|
|
||||||
class ProtocolEverflourishTest::PrivateData {
|
class ProtocolEverflourishTest::PrivateData {
|
||||||
public:
|
public:
|
||||||
ProtocolEverflourish *protocol;
|
ProtocolEverflourish *protocol;
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
#include "ProtocolNexaTest.h"
|
#include "ProtocolNexaTest.h"
|
||||||
#include "service/ProtocolNexa.h"
|
#include "service/ProtocolNexa.h"
|
||||||
|
|
||||||
CPPUNIT_TEST_SUITE_REGISTRATION (ProtocolNexaTest);
|
|
||||||
|
|
||||||
class ProtocolNexaTest::PrivateData {
|
class ProtocolNexaTest::PrivateData {
|
||||||
public:
|
public:
|
||||||
ProtocolNexa *protocol;
|
ProtocolNexa *protocol;
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
#include "ProtocolOregonTest.h"
|
#include "ProtocolOregonTest.h"
|
||||||
#include "service/ProtocolOregon.h"
|
#include "service/ProtocolOregon.h"
|
||||||
|
|
||||||
CPPUNIT_TEST_SUITE_REGISTRATION (ProtocolOregonTest);
|
|
||||||
|
|
||||||
class ProtocolOregonTest::PrivateData {
|
class ProtocolOregonTest::PrivateData {
|
||||||
public:
|
public:
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
#include "ProtocolSartanoTest.h"
|
#include "ProtocolSartanoTest.h"
|
||||||
#include "service/ProtocolSartano.h"
|
#include "service/ProtocolSartano.h"
|
||||||
|
|
||||||
CPPUNIT_TEST_SUITE_REGISTRATION (ProtocolSartanoTest);
|
|
||||||
|
|
||||||
class ProtocolSartanoTest::PrivateData {
|
class ProtocolSartanoTest::PrivateData {
|
||||||
public:
|
public:
|
||||||
ProtocolSartano *protocol;
|
ProtocolSartano *protocol;
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
#include "ProtocolX10Test.h"
|
#include "ProtocolX10Test.h"
|
||||||
#include "service/ProtocolX10.h"
|
#include "service/ProtocolX10.h"
|
||||||
|
|
||||||
CPPUNIT_TEST_SUITE_REGISTRATION (ProtocolX10Test);
|
|
||||||
|
|
||||||
class ProtocolX10Test::PrivateData {
|
class ProtocolX10Test::PrivateData {
|
||||||
public:
|
public:
|
||||||
ProtocolX10 *protocol;
|
ProtocolX10 *protocol;
|
||||||
|
|
19
telldus-core/tests/service/ServiceTests.h
Normal file
19
telldus-core/tests/service/ServiceTests.h
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
#ifndef SERVICETESTS_H
|
||||||
|
#define SERVICETESTS_H
|
||||||
|
|
||||||
|
#include "ProtocolEverflourishTest.h"
|
||||||
|
#include "ProtocolNexaTest.h"
|
||||||
|
#include "ProtocolOregonTest.h"
|
||||||
|
#include "ProtocolSartanoTest.h"
|
||||||
|
#include "ProtocolX10Test.h"
|
||||||
|
|
||||||
|
namespace ServiceTests {
|
||||||
|
inline void setup() {
|
||||||
|
CPPUNIT_TEST_SUITE_REGISTRATION (ProtocolEverflourishTest);
|
||||||
|
CPPUNIT_TEST_SUITE_REGISTRATION (ProtocolNexaTest);
|
||||||
|
CPPUNIT_TEST_SUITE_REGISTRATION (ProtocolOregonTest);
|
||||||
|
CPPUNIT_TEST_SUITE_REGISTRATION (ProtocolSartanoTest);
|
||||||
|
CPPUNIT_TEST_SUITE_REGISTRATION (ProtocolX10Test);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif // SERVICETESTS_H
|
Loading…
Add table
Add a link
Reference in a new issue