Add time print mode to test application

This commit is contained in:
momo5502
2024-11-24 10:49:13 +01:00
parent 5f49b30fe0
commit a687dc13f7

View File

@@ -4,10 +4,14 @@
#include <fstream>
#include <thread>
#include <atomic>
#include <optional>
#include <vector>
#include <optional>
#include <string_view>
#include <Windows.h>
using namespace std::literals;
// Externally visible and potentially modifiable state
// to trick compiler optimizations
__declspec(dllexport) bool do_the_task = true;
@@ -178,6 +182,12 @@ bool test_native_exceptions()
}
}
void print_time()
{
const auto epoch_time = std::chrono::system_clock::now().time_since_epoch();
printf("Time: %lld\n", epoch_time.count());
}
#define RUN_TEST(func, name) \
{ \
printf("Running test '" name "': "); \
@@ -186,8 +196,14 @@ bool test_native_exceptions()
puts(res ? "Success" : "Fail"); \
}
int main(int /*argc*/, const char* /*argv*/[])
int main(int argc, const char* argv[])
{
if(argc == 2 && argv[1] == "-time"sv)
{
print_time();
return 0;
}
bool valid = true;
RUN_TEST(test_io, "I/O")