mirror of
https://github.com/google/benchmark.git
synced 2024-11-25 22:47:20 +00:00
6cf7725ea1
* Allow specifying number of iterations via --benchmark_min_time. Make the flag accept two new suffixes: + <integer>x: number of iterations + <floag>s: minimum number of seconds. This matches the internal benchmark API. * forgot to change flag type to string * used tagged union instead of std::variant, which is not available pre C++14 * update decl in benchmark_runner.h too * fixed errors * refactor * backward compat * typo * use IterationCount type * fixed test * const_cast * ret type * remove extra _ * debug * fixed bug from reporting that caused the new configs not to be included in the final report * addressed review comments * restore unnecessary changes in test/BUILD * fix float comparisons warnings from Release builds * clang format * fix visibility warning * remove misc file * removed backup files * addressed review comments * fix shorten in warning * use suffix for existing min_time specs to silent warnings in tests * fix leaks * use default min-time value in flag decl for consistency * removed double kMinTimeDecl from benchmark.h * dont need to preserve errno * add death tests * Add BENCHMARK_EXPORT to hopefully fix missing def errors * only enable death tests in debug mode because bm_check is no-op in release mode * guard death tests with additional support-check macros * Add additional guard to prevent running in Release mode --------- Co-authored-by: dominic <510002+dmah42@users.noreply.github.com>
111 lines
2.7 KiB
Python
111 lines
2.7 KiB
Python
load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test")
|
|
|
|
platform(
|
|
name = "windows",
|
|
constraint_values = [
|
|
"@platforms//os:windows",
|
|
],
|
|
)
|
|
|
|
TEST_COPTS = [
|
|
"-pedantic",
|
|
"-pedantic-errors",
|
|
"-std=c++11",
|
|
"-Wall",
|
|
"-Wconversion",
|
|
"-Wextra",
|
|
"-Wshadow",
|
|
# "-Wshorten-64-to-32",
|
|
"-Wfloat-equal",
|
|
"-fstrict-aliasing",
|
|
]
|
|
|
|
# Some of the issues with DoNotOptimize only occur when optimization is enabled
|
|
PER_SRC_COPTS = {
|
|
"donotoptimize_test.cc": ["-O3"],
|
|
}
|
|
|
|
TEST_ARGS = ["--benchmark_min_time=0.01s"]
|
|
|
|
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"],
|
|
"spec_arg_verbosity_test.cc": ["--v=42"],
|
|
}
|
|
|
|
cc_library(
|
|
name = "output_test_helper",
|
|
testonly = 1,
|
|
srcs = ["output_test_helper.cc"],
|
|
hdrs = ["output_test.h"],
|
|
copts = select({
|
|
"//:windows": [],
|
|
"//conditions:default": 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 = select({
|
|
"//:windows": [],
|
|
"//conditions:default": 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",
|
|
],
|
|
# 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",
|
|
"cxx03_test.cc",
|
|
"link_main_test.cc",
|
|
],
|
|
)
|
|
]
|
|
|
|
cc_test(
|
|
name = "cxx03_test",
|
|
size = "small",
|
|
srcs = ["cxx03_test.cc"],
|
|
copts = TEST_COPTS + ["-std=c++03"],
|
|
target_compatible_with = select({
|
|
"//:windows": ["@platforms//:incompatible"],
|
|
"//conditions:default": [],
|
|
}),
|
|
deps = [
|
|
":output_test_helper",
|
|
"//:benchmark",
|
|
"//:benchmark_internal_headers",
|
|
"@com_google_googletest//:gtest",
|
|
"@com_google_googletest//:gtest_main",
|
|
],
|
|
)
|
|
|
|
cc_test(
|
|
name = "link_main_test",
|
|
size = "small",
|
|
srcs = ["link_main_test.cc"],
|
|
copts = select({
|
|
"//:windows": [],
|
|
"//conditions:default": TEST_COPTS,
|
|
}),
|
|
deps = ["//:benchmark_main"],
|
|
)
|