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)
|
||||
|
||||
ADD_LIBRARY(TelldusCommonTests SHARED ${SRCS} )
|
||||
ADD_LIBRARY(TelldusCommonTests STATIC ${SRCS} )
|
||||
|
||||
TARGET_LINK_LIBRARIES( TelldusCommonTests TelldusCommon ${CPPUNIT} )
|
||||
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 "Strings.h"
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION (StringsTest);
|
||||
|
||||
void StringsTest :: setUp (void)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -8,32 +8,39 @@
|
|||
|
||||
#include <fstream>
|
||||
|
||||
#include "common/CommonTests.h"
|
||||
#include "service/ServiceTests.h"
|
||||
|
||||
int main (int argc, char* argv[])
|
||||
{
|
||||
// informs test-listener about testresults
|
||||
CPPUNIT_NS :: TestResult testresult;
|
||||
// Setup our tests
|
||||
CommonTests::setup();
|
||||
ServiceTests::setup();
|
||||
|
||||
// register listener for collecting the test-results
|
||||
CPPUNIT_NS :: TestResultCollector collectedresults;
|
||||
testresult.addListener (&collectedresults);
|
||||
// informs test-listener about testresults
|
||||
CPPUNIT_NS :: TestResult testresult;
|
||||
|
||||
// register listener for per-test progress output
|
||||
CPPUNIT_NS :: BriefTestProgressListener progress;
|
||||
testresult.addListener (&progress);
|
||||
// register listener for collecting the test-results
|
||||
CPPUNIT_NS :: TestResultCollector collectedresults;
|
||||
testresult.addListener (&collectedresults);
|
||||
|
||||
// insert test-suite at test-runner by registry
|
||||
CPPUNIT_NS :: TestRunner testrunner;
|
||||
testrunner.addTest (CPPUNIT_NS :: TestFactoryRegistry :: getRegistry ().makeTest ());
|
||||
testrunner.run (testresult);
|
||||
// register listener for per-test progress output
|
||||
CPPUNIT_NS :: BriefTestProgressListener progress;
|
||||
testresult.addListener (&progress);
|
||||
|
||||
// output results in compiler-format
|
||||
CPPUNIT_NS :: CompilerOutputter compileroutputter (&collectedresults, std::cerr);
|
||||
compileroutputter.write ();
|
||||
// insert test-suite at test-runner by registry
|
||||
CPPUNIT_NS :: TestRunner testrunner;
|
||||
testrunner.addTest (CPPUNIT_NS :: TestFactoryRegistry :: getRegistry ().makeTest ());
|
||||
testrunner.run (testresult);
|
||||
|
||||
std::ofstream xmlFileOut("cpptestresults.xml");
|
||||
CPPUNIT_NS :: XmlOutputter xmlOut(&collectedresults, xmlFileOut);
|
||||
xmlOut.write();
|
||||
// output results in compiler-format
|
||||
CPPUNIT_NS :: CompilerOutputter compileroutputter (&collectedresults, std::cerr);
|
||||
compileroutputter.write ();
|
||||
|
||||
// return 0 if tests were successful
|
||||
return collectedresults.wasSuccessful () ? 0 : 1;
|
||||
std::ofstream xmlFileOut("cpptestresults.xml");
|
||||
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})
|
||||
|
||||
ADD_LIBRARY(TelldusServiceTests SHARED ${SRCS} )
|
||||
ADD_LIBRARY(TelldusServiceTests STATIC ${SRCS} )
|
||||
|
||||
TARGET_LINK_LIBRARIES( TelldusServiceTests TelldusServiceStatic ${CPPUNIT} )
|
||||
ADD_DEPENDENCIES( TelldusServiceTests ${telldus-service_TARGET} )
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
#include "ProtocolEverflourishTest.h"
|
||||
#include "service/ProtocolEverflourish.h"
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION (ProtocolEverflourishTest);
|
||||
|
||||
class ProtocolEverflourishTest::PrivateData {
|
||||
public:
|
||||
ProtocolEverflourish *protocol;
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
#include "ProtocolNexaTest.h"
|
||||
#include "service/ProtocolNexa.h"
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION (ProtocolNexaTest);
|
||||
|
||||
class ProtocolNexaTest::PrivateData {
|
||||
public:
|
||||
ProtocolNexa *protocol;
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
#include "ProtocolOregonTest.h"
|
||||
#include "service/ProtocolOregon.h"
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION (ProtocolOregonTest);
|
||||
|
||||
class ProtocolOregonTest::PrivateData {
|
||||
public:
|
||||
};
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
#include "ProtocolSartanoTest.h"
|
||||
#include "service/ProtocolSartano.h"
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION (ProtocolSartanoTest);
|
||||
|
||||
class ProtocolSartanoTest::PrivateData {
|
||||
public:
|
||||
ProtocolSartano *protocol;
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
#include "ProtocolX10Test.h"
|
||||
#include "service/ProtocolX10.h"
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION (ProtocolX10Test);
|
||||
|
||||
class ProtocolX10Test::PrivateData {
|
||||
public:
|
||||
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