mirror of
https://github.com/google/benchmark.git
synced 2024-11-29 18:34:47 +00:00
4f47ed2c9a
* [RFC] Adding API for setting/getting benchmark_filter flag? This PR is more of a Request-for-comment - open to other ideas/suggestions as well. Details: This flag has different implementations(absl vs benchmark) and since the proposal to add absl as a dependency was rejected, it would be nice to have a reliable (and less hacky) way to access this flag internally. (Actually, reading it isn't much a problem but setting it is). Internally, we have a sizeable number users to use absl::SetFlags to set this flag. This will not work with benchmark-flags. Another motivation is that not all users use the command line flag. Some prefer to programmatically set this value. * fixed build errors * fix lints again * per discussion: add additional RunSpecifiedBenchmarks instead. * add tests * fix up tests * clarify comment * fix stray : in test * more assertion in test * add test file to test/CMakeLists.txt * more test * make test ISO C++ compliant * fix up BUILD file to pass the flag
76 lines
1.9 KiB
Python
76 lines
1.9 KiB
Python
TEST_COPTS = [
|
|
"-pedantic",
|
|
"-pedantic-errors",
|
|
"-std=c++11",
|
|
"-Wall",
|
|
"-Wextra",
|
|
"-Wshadow",
|
|
# "-Wshorten-64-to-32",
|
|
"-Wfloat-equal",
|
|
"-fstrict-aliasing",
|
|
]
|
|
|
|
PER_SRC_COPTS = ({
|
|
"cxx03_test.cc": ["-std=c++03"],
|
|
# Some of the issues with DoNotOptimize only occur when optimization is enabled
|
|
"donotoptimize_test.cc": ["-O3"],
|
|
})
|
|
|
|
TEST_ARGS = ["--benchmark_min_time=0.01"]
|
|
|
|
PER_SRC_TEST_ARGS = ({
|
|
"user_counters_tabular_test.cc": ["--benchmark_counters_tabular=true"],
|
|
"repetitions_test.cc": [" --benchmark_repetitions=3"],
|
|
"spec_arg_test.cc" : ["--benchmark_filter=BM_NotChosen"],
|
|
})
|
|
|
|
load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test")
|
|
|
|
cc_library(
|
|
name = "output_test_helper",
|
|
testonly = 1,
|
|
srcs = ["output_test_helper.cc"],
|
|
hdrs = ["output_test.h"],
|
|
copts = TEST_COPTS,
|
|
deps = [
|
|
"//:benchmark",
|
|
"//:benchmark_internal_headers",
|
|
],
|
|
)
|
|
|
|
[
|
|
cc_test(
|
|
name = test_src[:-len(".cc")],
|
|
size = "small",
|
|
srcs = [test_src],
|
|
args = TEST_ARGS + PER_SRC_TEST_ARGS.get(test_src, []),
|
|
copts = TEST_COPTS + PER_SRC_COPTS.get(test_src, []),
|
|
deps = [
|
|
":output_test_helper",
|
|
"//:benchmark",
|
|
"//:benchmark_internal_headers",
|
|
"@com_google_googletest//:gtest",
|
|
] + (
|
|
["@com_google_googletest//:gtest_main"] if (test_src[-len("gtest.cc"):] == "gtest.cc") else []
|
|
),
|
|
# FIXME: Add support for assembly tests to bazel.
|
|
# See Issue #556
|
|
# https://github.com/google/benchmark/issues/556
|
|
)
|
|
for test_src in glob(
|
|
["*test.cc"],
|
|
exclude = [
|
|
"*_assembly_test.cc",
|
|
"link_main_test.cc",
|
|
],
|
|
)
|
|
]
|
|
|
|
cc_test(
|
|
name = "link_main_test",
|
|
size = "small",
|
|
srcs = ["link_main_test.cc"],
|
|
copts = TEST_COPTS,
|
|
deps = ["//:benchmark_main"],
|
|
)
|