gtest_runner.cc 787 B

123456789101112131415161718192021222324252627
  1. #include <gtest/gtest.h>
  2. #include <apt-pkg/configuration.h>
  3. #include <apt-pkg/pkgsystem.h>
  4. #include <apt-pkg/error.h>
  5. #include <apt-pkg/init.h>
  6. int main(int argc, char **argv) {
  7. ::testing::InitGoogleTest(&argc, argv);
  8. if (pkgInitSystem(*_config, _system) == false)
  9. return 42;
  10. int const result = RUN_ALL_TESTS();
  11. if (_error->empty() == false)
  12. {
  13. std::cerr << "The test generated the following global messages:" << std::endl;
  14. _error->DumpErrors(std::cerr);
  15. // messages on the stack can't be right, error out
  16. // even if we have no idea where this message came from
  17. if (result == 0)
  18. {
  19. std::cerr << "All tests successful, but messages were generated, so still a failure!" << std::endl;
  20. return 29;
  21. }
  22. }
  23. return result;
  24. }