X-Git-Url: https://git.sesse.net/?p=movit;a=blobdiff_plain;f=gtest_sdl_main.cpp;h=70fed134b2ad4b134787c8d26c8875b2ea95ac89;hp=cd68777721e19cc92b300920fd094473ef5d5a7d;hb=0ed2c7fe3876a49d1565e3425e5a491206ffe32d;hpb=dc03e3b0a5b0bbe8c6cdf5da9bc72376f79857b4 diff --git a/gtest_sdl_main.cpp b/gtest_sdl_main.cpp index cd68777..70fed13 100644 --- a/gtest_sdl_main.cpp +++ b/gtest_sdl_main.cpp @@ -9,6 +9,9 @@ #include #include #endif +#ifdef HAVE_BENCHMARK +#include +#endif #include #include @@ -34,6 +37,10 @@ int main(int argc, char **argv) { // SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE); // SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3); // SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2); + + // See also init.cpp for how to enable debugging. +// SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_DEBUG_FLAG); + SDL_Window *window = SDL_CreateWindow("OpenGL window for unit test", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, @@ -46,8 +53,22 @@ int main(int argc, char **argv) { SDL_WM_SetCaption("OpenGL window for unit test", NULL); #endif - testing::InitGoogleTest(&argc, argv); - int err = RUN_ALL_TESTS(); + int err; + if (argc >= 2 && strcmp(argv[1], "--benchmark") == 0) { +#ifdef HAVE_BENCHMARK + --argc; + ::benchmark::Initialize(&argc, argv + 1); + if (::benchmark::ReportUnrecognizedArguments(argc, argv)) return 1; + ::benchmark::RunSpecifiedBenchmarks(); + err = 0; +#else + fprintf(stderr, "No support for microbenchmarks compiled in.\n"); + err = 1; +#endif + } else { + testing::InitGoogleTest(&argc, argv); + err = RUN_ALL_TESTS(); + } SDL_Quit(); - exit(err); + return err; }