~ubuntu-branches/ubuntu/natty/sflphone/natty

« back to all changes in this revision

Viewing changes to sflphone-common/test/main.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Francois Marier
  • Date: 2010-12-24 16:33:55 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20101224163355-tkvvikqxbrbav6up
Tags: 0.9.11-1
* New upstream release
* Add new build dependencies on libwebkit-dev and libyaml-dev

* Bump Standards-Version up to 3.9.1
* Bump debhelper compatibility to 8
* Patch another typo in the upstream code (lintian notice)

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
 *  as that of the covered work.
29
29
 */
30
30
 
31
 
#include "logger.h"
32
 
#include "global.h"
33
 
#include "manager.h"
34
 
#include "constants.h"
 
31
#include <logger.h>
 
32
#include <manager.h>
 
33
#include <constants.h>
35
34
 
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>
39
39
 
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"
51
 
 
52
 
 
53
 
int main(int argc, char* argv[]) {
54
 
 
55
 
        printf("\nSFLphone Daemon Test Suite, by Savoir-Faire Linux 2004-2010\n\n");
56
 
 
57
 
        Logger::setConsoleLog(true);
58
 
 
59
 
        Logger::setDebugMode(true);
60
 
        /*
61
 
        Logger::setDebugMode(false);
62
 
 
63
 
        int argvIndex = 1;
64
 
 
65
 
        if (argc > 1) {
66
 
                if (strcmp("--help", argv[1]) == 0) {
67
 
                        argvIndex++;
68
 
 
69
 
                        CPPUNIT_NS::Test
70
 
                                        *suite = CPPUNIT_NS::TestFactoryRegistry::getRegistry(
71
 
                                                        "All Tests").makeTest();
72
 
                        int testSuiteCount = suite->getChildTestCount();
73
 
 
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());
81
 
                        }
82
 
                        exit(0);
83
 
                }
84
 
                else if (strcmp("--debug", argv[1]) == 0) {
85
 
                        argvIndex++;
86
 
 
87
 
                        Logger::setDebugMode(true);
88
 
                        _info("Debug mode activated");
89
 
                }
90
 
        }
91
 
 
92
 
        std::string testSuiteName = "All Tests";
93
 
        if(argvIndex < argc)
94
 
        {
95
 
                testSuiteName = argv[argvIndex];
96
 
                argvIndex++;
97
 
        }
98
 
 
99
 
        printf("\n\n=== SFLphone initialization ===\n\n");
100
 
        Manager::instance().initConfigFile(true, CONFIG_SAMPLE);
101
 
        Manager::instance().init();
102
 
 
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();
106
 
        */
107
 
        CPPUNIT_NS::Test *suite = CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest();
108
 
 
109
 
        /*
110
 
        if(suite->getChildTestCount() == 0)
111
 
        {
112
 
                _error("Invalid test suite name: %s", testSuiteName.c_str());
113
 
                exit(-1);
114
 
        }
115
 
        */
116
 
        Manager::instance().initConfigFile(true, CONFIG_SAMPLE);
117
 
                Manager::instance().init();
118
 
 
119
 
        // Adds the test to the list of test to run
120
 
        CppUnit::TextTestRunner runner;
121
 
        runner.addTest(suite);
122
 
 
123
 
        // Change the default outputter to a compiler error format outputter
124
 
        runner.setOutputter(new CppUnit::CompilerOutputter(&runner.result(),
125
 
                        std::cerr));
126
 
        // Run the tests.
127
 
        bool wasSucessful = runner.run();
128
 
 
129
 
        // Return error code 1 if the one of test failed.
130
 
        return wasSucessful ? 0 : 1;
131
 
 
132
 
        Manager::instance().terminate();
 
40
int main (int argc, char* argv[])
 
41
{
 
42
 
 
43
    printf ("\nSFLphone Daemon Test Suite, by Savoir-Faire Linux 2004-2010\n\n");
 
44
    Logger::setConsoleLog (true);
 
45
    Logger::setDebugMode (true);
 
46
 
 
47
    int argvIndex = 1;
 
48
        bool xmlOutput = false;
 
49
 
 
50
    if (argc > 1) {
 
51
        if (strcmp ("--help", argv[1]) == 0) {
 
52
            argvIndex++;
 
53
 
 
54
            CPPUNIT_NS::Test* suite = CPPUNIT_NS::TestFactoryRegistry::getRegistry ("All Tests").makeTest();
 
55
 
 
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");
 
63
 
 
64
            for (int i = 0; i < testSuiteCount; i++) {
 
65
                printf (" - %s\n", suite->getChildTestAt (i)->getName().c_str());
 
66
            }
 
67
 
 
68
            exit (0);
 
69
        } else if (strcmp ("--debug", argv[1]) == 0) {
 
70
            argvIndex++;
 
71
 
 
72
            Logger::setDebugMode (true);
 
73
            _info ("Debug mode activated");
 
74
 
 
75
        } else if (strcmp("--xml", argv[1]) == 0) {
 
76
            argvIndex++;
 
77
 
 
78
                        xmlOutput = true;
 
79
            _info ("Using XML output");
 
80
                }
 
81
    }
 
82
 
 
83
    // Default test suite : all tests
 
84
    std::string testSuiteName = "All Tests";
 
85
 
 
86
    if (argvIndex < argc) {
 
87
        testSuiteName = argv[argvIndex];
 
88
        argvIndex++;
 
89
    }
 
90
 
 
91
    printf ("\n\n=== SFLphone initialization ===\n\n");
 
92
    Manager::instance().initConfigFile (true, CONFIG_SAMPLE);
 
93
    Manager::instance().init();
 
94
 
 
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();
 
98
 
 
99
    if (suite->getChildTestCount() == 0) {
 
100
        _error ("Invalid test suite name: %s", testSuiteName.c_str());
 
101
        exit (-1);
 
102
    }
 
103
 
 
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");
 
109
 
 
110
        if (xmlOutput) {
 
111
                CppUnit::XmlOutputter* outputter = new CppUnit::XmlOutputter(&runner.result(), outfile);
 
112
                runner.setOutputter(outputter);
 
113
        } else {
 
114
                // Change the default outputter to a compiler error format outputter
 
115
                runner.setOutputter (new CppUnit::CompilerOutputter (&runner.result(), std::cerr));
 
116
        }
 
117
 
 
118
    // Run the tests.
 
119
    bool wasSucessful = runner.run();
 
120
 
 
121
    Manager::instance().terminate();
 
122
 
 
123
    // Return error code 1 if the one of test failed.
 
124
    return wasSucessful ? 0 : 1;
133
125
}