diff options
author | Adin Scannell <ascannell@google.com> | 2020-02-19 18:20:52 -0800 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2020-02-19 18:21:54 -0800 |
commit | 30794512d3977ebb2b185e5e9cfb969d558a07a4 (patch) | |
tree | 2c0a32af1b57018d589511983c784de81d76f0b8 /test/util/test_util_impl.cc | |
parent | 2daa21e4d73f2297a8bca32c76100333e9ac4af4 (diff) |
Add basic microbenchmarks.
PiperOrigin-RevId: 296104390
Diffstat (limited to 'test/util/test_util_impl.cc')
-rw-r--r-- | test/util/test_util_impl.cc | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/util/test_util_impl.cc b/test/util/test_util_impl.cc index ba7c0a85b..7e1ad9e66 100644 --- a/test/util/test_util_impl.cc +++ b/test/util/test_util_impl.cc @@ -17,8 +17,12 @@ #include "gtest/gtest.h" #include "absl/flags/flag.h" #include "absl/flags/parse.h" +#include "benchmark/benchmark.h" #include "test/util/logging.h" +extern bool FLAGS_benchmark_list_tests; +extern std::string FLAGS_benchmark_filter; + namespace gvisor { namespace testing { @@ -26,6 +30,7 @@ void SetupGvisorDeathTest() {} void TestInit(int* argc, char*** argv) { ::testing::InitGoogleTest(argc, *argv); + benchmark::Initialize(argc, *argv); ::absl::ParseCommandLine(*argc, *argv); // Always mask SIGPIPE as it's common and tests aren't expected to handle it. @@ -34,5 +39,14 @@ void TestInit(int* argc, char*** argv) { TEST_CHECK(sigaction(SIGPIPE, &sa, nullptr) == 0); } +int RunAllTests() { + if (FLAGS_benchmark_list_tests || FLAGS_benchmark_filter != ".") { + benchmark::RunSpecifiedBenchmarks(); + return 0; + } else { + return RUN_ALL_TESTS(); + } +} + } // namespace testing } // namespace gvisor |