AllTest.cc 1.3 KB

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