timeout_test.cpp 842 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #if defined(_WIN32)
  2. #include <windows.h>
  3. #else
  4. #include <unistd.h>
  5. #endif
  6. #include <iostream>
  7. #include <string>
  8. void sleepFor(unsigned seconds)
  9. {
  10. #if defined(_WIN32)
  11. Sleep(seconds * 1000);
  12. #else
  13. sleep(seconds);
  14. #endif
  15. }
  16. int main(int argc, char** argv)
  17. {
  18. // Note: GoogleTest.cmake doesn't actually depend on Google Test as such;
  19. // it only requires that we produce output in the expected format when
  20. // invoked with --gtest_list_tests. Thus, we fake that here. This allows us
  21. // to test the module without actually needing Google Test.
  22. if (argc > 1 && std::string(argv[1]) == "--gtest_list_tests") {
  23. std::cout << "timeout." << std::endl;
  24. std::cout << " case" << std::endl;
  25. #ifdef discoverySleepSec
  26. sleepFor(discoverySleepSec);
  27. #endif
  28. return 0;
  29. }
  30. #ifdef sleepSec
  31. sleepFor(sleepSec);
  32. #endif
  33. return 0;
  34. }