28
28
* as that of the covered work.
34
#include "constants.h"
33
#include <constants.h>
36
35
#include <cppunit/CompilerOutputter.h>
36
#include <cppunit/XmlOutputter.h>
37
37
#include <cppunit/extensions/TestFactoryRegistry.h>
38
38
#include <cppunit/ui/text/TextTestRunner.h>
40
// TODO: Why some header cannot be included ?
41
#include "accounttest.h"
42
#include "audiolayertest.h"
43
#include "configurationtest.h"
44
//#include "historytest.h"
45
//#include "hookmanagertest.h"
46
#include "mainbuffertest.h"
47
#include "numbercleanertest.h"
48
//#include "pluginmanagertest.h"
49
//#include "rtptest.h"
50
#include "sdesnegotiatortest.h"
53
int main(int argc, char* argv[]) {
55
printf("\nSFLphone Daemon Test Suite, by Savoir-Faire Linux 2004-2010\n\n");
57
Logger::setConsoleLog(true);
59
Logger::setDebugMode(true);
61
Logger::setDebugMode(false);
66
if (strcmp("--help", argv[1]) == 0) {
70
*suite = CPPUNIT_NS::TestFactoryRegistry::getRegistry(
71
"All Tests").makeTest();
72
int testSuiteCount = suite->getChildTestCount();
74
printf("Usage: test [OPTIONS] [TEST_SUITE]\n");
75
printf("\nOptions:\n");
76
printf(" --debug - Debug mode\n");
77
printf(" --help - Print help\n");
78
printf("\nAvailable test suites:\n");
79
for (int i = 0; i < testSuiteCount; i++) {
80
printf(" - %s\n", suite->getChildTestAt(i)->getName().c_str());
84
else if (strcmp("--debug", argv[1]) == 0) {
87
Logger::setDebugMode(true);
88
_info("Debug mode activated");
92
std::string testSuiteName = "All Tests";
95
testSuiteName = argv[argvIndex];
99
printf("\n\n=== SFLphone initialization ===\n\n");
100
Manager::instance().initConfigFile(true, CONFIG_SAMPLE);
101
Manager::instance().init();
103
printf("\n\n=== Test Suite: %s ===\n\n", testSuiteName.c_str());
104
// Get the top level suite from the registry
105
CPPUNIT_NS::Test *suite = CPPUNIT_NS::TestFactoryRegistry::getRegistry(testSuiteName).makeTest();
107
CPPUNIT_NS::Test *suite = CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest();
110
if(suite->getChildTestCount() == 0)
112
_error("Invalid test suite name: %s", testSuiteName.c_str());
116
Manager::instance().initConfigFile(true, CONFIG_SAMPLE);
117
Manager::instance().init();
119
// Adds the test to the list of test to run
120
CppUnit::TextTestRunner runner;
121
runner.addTest(suite);
123
// Change the default outputter to a compiler error format outputter
124
runner.setOutputter(new CppUnit::CompilerOutputter(&runner.result(),
127
bool wasSucessful = runner.run();
129
// Return error code 1 if the one of test failed.
130
return wasSucessful ? 0 : 1;
132
Manager::instance().terminate();
40
int main (int argc, char* argv[])
43
printf ("\nSFLphone Daemon Test Suite, by Savoir-Faire Linux 2004-2010\n\n");
44
Logger::setConsoleLog (true);
45
Logger::setDebugMode (true);
48
bool xmlOutput = false;
51
if (strcmp ("--help", argv[1]) == 0) {
54
CPPUNIT_NS::Test* suite = CPPUNIT_NS::TestFactoryRegistry::getRegistry ("All Tests").makeTest();
56
int testSuiteCount = suite->getChildTestCount();
57
printf ("Usage: test [OPTIONS] [TEST_SUITE]\n");
58
printf ("\nOptions:\n");
59
printf (" --xml - Output results in an XML file, instead of standard output.\n");
60
printf (" --debug - Debug mode\n");
61
printf (" --help - Print help\n");
62
printf ("\nAvailable test suites:\n");
64
for (int i = 0; i < testSuiteCount; i++) {
65
printf (" - %s\n", suite->getChildTestAt (i)->getName().c_str());
69
} else if (strcmp ("--debug", argv[1]) == 0) {
72
Logger::setDebugMode (true);
73
_info ("Debug mode activated");
75
} else if (strcmp("--xml", argv[1]) == 0) {
79
_info ("Using XML output");
83
// Default test suite : all tests
84
std::string testSuiteName = "All Tests";
86
if (argvIndex < argc) {
87
testSuiteName = argv[argvIndex];
91
printf ("\n\n=== SFLphone initialization ===\n\n");
92
Manager::instance().initConfigFile (true, CONFIG_SAMPLE);
93
Manager::instance().init();
95
// Get the top level suite from the registry
96
printf ("\n\n=== Test Suite: %s ===\n\n", testSuiteName.c_str());
97
CPPUNIT_NS::Test *suite = CPPUNIT_NS::TestFactoryRegistry::getRegistry (testSuiteName).makeTest();
99
if (suite->getChildTestCount() == 0) {
100
_error ("Invalid test suite name: %s", testSuiteName.c_str());
104
// Adds the test to the list of test to run
105
CppUnit::TextTestRunner runner;
106
runner.addTest (suite);
107
/* Specify XML output */
108
std::ofstream outfile("cppunitresults.xml");
111
CppUnit::XmlOutputter* outputter = new CppUnit::XmlOutputter(&runner.result(), outfile);
112
runner.setOutputter(outputter);
114
// Change the default outputter to a compiler error format outputter
115
runner.setOutputter (new CppUnit::CompilerOutputter (&runner.result(), std::cerr));
119
bool wasSucessful = runner.run();
121
Manager::instance().terminate();
123
// Return error code 1 if the one of test failed.
124
return wasSucessful ? 0 : 1;