AllTest.cc 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #include "common.h"
  2. #include <iostream>
  3. #include <cppunit/CompilerOutputter.h>
  4. #include <cppunit/extensions/TestFactoryRegistry.h>
  5. #include <cppunit/ui/text/TestRunner.h>
  6. #include "Platform.h"
  7. #include "SocketCore.h"
  8. int main(int argc, char* argv[]) {
  9. aria2::Platform platform;
  10. #ifdef ENABLE_NLS
  11. // Set locale to C to prevent the messages to be localized.
  12. setlocale (LC_CTYPE, "C");
  13. setlocale (LC_MESSAGES, "C");
  14. #endif // ENABLE_NLS
  15. // By default, SocketCore uses AF_UNSPEC for getaddrinfo hints to
  16. // resolve address. Sometime SocketCore::bind() and
  17. // SocketCore::establishConnection() use difference protocl family
  18. // and latter cannot connect to former. To avoid this situation, we
  19. // limit protocol family to AF_INET for unit tests.
  20. aria2::SocketCore::setProtocolFamily(AF_INET);
  21. // If AI_ADDRCONFIG is set, tests fail if IPv4 address is not
  22. // configured.
  23. aria2::setDefaultAIFlags(0);
  24. CppUnit::Test* suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
  25. CppUnit::TextUi::TestRunner runner;
  26. runner.addTest(suite);
  27. runner.setOutputter(new CppUnit::CompilerOutputter(&runner.result(), std::cerr));
  28. // Run the tests.
  29. bool successfull = runner.run();
  30. return successfull ? 0 : 1;
  31. }