Line data Source code
1 : /* 2 : * Copyright (C) 2004-2024 Savoir-faire Linux Inc. 3 : * 4 : * This program is free software: you can redistribute it and/or modify 5 : * it under the terms of the GNU General Public License as published by 6 : * the Free Software Foundation, either version 3 of the License, or 7 : * (at your option) any later version. 8 : * 9 : * This program is distributed in the hope that it will be useful, 10 : * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 : * GNU General Public License for more details. 13 : * 14 : * You should have received a copy of the GNU General Public License 15 : * along with this program. If not, see <https://www.gnu.org/licenses/>. 16 : */ 17 : 18 : #include <cppunit/ui/text/TestRunner.h> 19 : #include <cppunit/extensions/TestFactoryRegistry.h> 20 : #include <cppunit/CompilerOutputter.h> 21 : 22 : #include "jami.h" 23 : 24 : #include <stdexcept> 25 : 26 1 : void init_daemon() 27 : { 28 1 : libjami::init(libjami::InitFlag(libjami::LIBJAMI_FLAG_DEBUG | libjami::LIBJAMI_FLAG_CONSOLE_LOG)); 29 1 : libjami::start("test/unitTest/jami-sample.yml"); 30 1 : } 31 : 32 1 : int main() 33 : { 34 1 : init_daemon(); 35 : 36 1 : CppUnit::TextUi::TestRunner runner; 37 : 38 : // Register all tests 39 1 : auto& registry = CppUnit::TestFactoryRegistry::getRegistry(); 40 1 : runner.addTest(registry.makeTest()); 41 : 42 : // Use a compiler error format outputter for results and output into stderr 43 1 : runner.setOutputter(new CppUnit::CompilerOutputter(&runner.result(), std::cerr )); 44 : 45 : bool ret; 46 : 47 : try { 48 : // Run tests 49 1 : ret = !runner.run("", false); 50 0 : } catch (const std::exception& e) { 51 0 : std::cerr << "Exception catched during tests: " << e.what() << '\n'; 52 0 : ret = 1; 53 0 : } 54 : 55 1 : libjami::fini(); 56 : 57 1 : return ret; 58 1 : }