summaryrefslogtreecommitdiffhomepage
path: root/test/util/test_util_impl.cc
diff options
context:
space:
mode:
authorAdin Scannell <ascannell@google.com>2020-02-19 18:20:52 -0800
committerCopybara-Service <copybara-worker@google.com>2020-02-19 18:21:54 -0800
commit30794512d3977ebb2b185e5e9cfb969d558a07a4 (patch)
tree2c0a32af1b57018d589511983c784de81d76f0b8 /test/util/test_util_impl.cc
parent2daa21e4d73f2297a8bca32c76100333e9ac4af4 (diff)
Add basic microbenchmarks.
PiperOrigin-RevId: 296104390
Diffstat (limited to 'test/util/test_util_impl.cc')
-rw-r--r--test/util/test_util_impl.cc14
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