cmake/Tests/RunCMake/GoogleTest/timeout_test.cpp

41 lines
818 B
C++
Raw Normal View History

2018-01-26 17:06:56 +01:00
#if defined(_WIN32)
2018-08-09 18:06:22 +02:00
# include <windows.h>
2018-01-26 17:06:56 +01:00
#else
2018-08-09 18:06:22 +02:00
# include <unistd.h>
2018-01-26 17:06:56 +01:00
#endif
2018-04-23 21:13:27 +02:00
#include <string>
2020-08-30 11:54:41 +02:00
#include <stdio.h>
2018-04-23 21:13:27 +02:00
void sleepFor(unsigned seconds)
2018-01-26 17:06:56 +01:00
{
#if defined(_WIN32)
2018-04-23 21:13:27 +02:00
Sleep(seconds * 1000);
2018-01-26 17:06:56 +01:00
#else
2018-04-23 21:13:27 +02:00
sleep(seconds);
#endif
}
int main(int argc, char** argv)
{
// Note: GoogleTest.cmake doesn't actually depend on Google Test as such;
// it only requires that we produce output in the expected format when
// invoked with --gtest_list_tests. Thus, we fake that here. This allows us
// to test the module without actually needing Google Test.
if (argc > 1 && std::string(argv[1]) == "--gtest_list_tests") {
2020-08-30 11:54:41 +02:00
printf("timeout.\n case\n");
fflush(stdout);
2018-04-23 21:13:27 +02:00
#ifdef discoverySleepSec
sleepFor(discoverySleepSec);
#endif
return 0;
}
#ifdef sleepSec
sleepFor(sleepSec);
2018-01-26 17:06:56 +01:00
#endif
2018-04-23 21:13:27 +02:00
2018-01-26 17:06:56 +01:00
return 0;
}