2009-05-06 07:42:59 +00:00
|
|
|
#include "common.h"
|
|
|
|
|
2008-03-03 11:30:12 +00:00
|
|
|
#include <iostream>
|
2009-05-06 07:42:59 +00:00
|
|
|
|
2006-02-17 13:35:04 +00:00
|
|
|
#include <cppunit/CompilerOutputter.h>
|
|
|
|
#include <cppunit/extensions/TestFactoryRegistry.h>
|
|
|
|
#include <cppunit/ui/text/TestRunner.h>
|
|
|
|
|
2009-05-06 07:42:59 +00:00
|
|
|
#include "Platform.h"
|
|
|
|
#include "SocketCore.h"
|
2010-12-02 13:38:36 +00:00
|
|
|
#include "util.h"
|
2013-05-02 02:30:42 +00:00
|
|
|
#include "console.h"
|
2013-07-05 12:08:03 +00:00
|
|
|
#include "LogFactory.h"
|
|
|
|
#include "prefs.h"
|
2009-05-06 07:42:59 +00:00
|
|
|
|
2006-02-17 13:35:04 +00:00
|
|
|
int main(int argc, char* argv[]) {
|
2013-05-02 02:30:42 +00:00
|
|
|
aria2::global::initConsole(false);
|
2008-06-16 11:59:34 +00:00
|
|
|
aria2::Platform platform;
|
|
|
|
|
|
|
|
#ifdef ENABLE_NLS
|
|
|
|
// Set locale to C to prevent the messages to be localized.
|
|
|
|
setlocale (LC_CTYPE, "C");
|
|
|
|
setlocale (LC_MESSAGES, "C");
|
|
|
|
#endif // ENABLE_NLS
|
|
|
|
|
2009-05-06 07:42:59 +00:00
|
|
|
// By default, SocketCore uses AF_UNSPEC for getaddrinfo hints to
|
|
|
|
// resolve address. Sometime SocketCore::bind() and
|
|
|
|
// SocketCore::establishConnection() use difference protocl family
|
|
|
|
// and latter cannot connect to former. To avoid this situation, we
|
|
|
|
// limit protocol family to AF_INET for unit tests.
|
|
|
|
aria2::SocketCore::setProtocolFamily(AF_INET);
|
2009-12-24 14:59:47 +00:00
|
|
|
// If AI_ADDRCONFIG is set, tests fail if IPv4 address is not
|
|
|
|
// configured.
|
|
|
|
aria2::setDefaultAIFlags(0);
|
2010-12-02 13:38:36 +00:00
|
|
|
// Create output directory
|
|
|
|
aria2::util::mkdirs(A2_TEST_OUT_DIR);
|
2009-05-06 07:42:59 +00:00
|
|
|
|
2013-07-05 12:08:03 +00:00
|
|
|
aria2::LogFactory::setConsoleLogLevel(aria2::V_DEBUG);
|
|
|
|
aria2::LogFactory::reconfigure();
|
|
|
|
|
2006-02-17 13:35:04 +00:00
|
|
|
CppUnit::Test* suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
|
|
|
|
CppUnit::TextUi::TestRunner runner;
|
|
|
|
runner.addTest(suite);
|
|
|
|
|
|
|
|
runner.setOutputter(new CppUnit::CompilerOutputter(&runner.result(), std::cerr));
|
2007-06-10 07:55:43 +00:00
|
|
|
|
2006-02-17 13:35:04 +00:00
|
|
|
// Run the tests.
|
|
|
|
bool successfull = runner.run();
|
|
|
|
|
|
|
|
return successfull ? 0 : 1;
|
|
|
|
}
|