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