Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 34 additions & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
- name: Tests
run: >
bazel test ...
--build_tag_filters=-fuzztest
--copt=-DGTEST_REMOVE_LEGACY_TEST_CASEAPI_=1
--copt=-Werror
--cxxopt=-Wall
Expand All @@ -43,7 +44,7 @@ jobs:
--show_timestamps
--test_env="TZDIR=${GITHUB_WORKSPACE}/testdata/zoneinfo"
--test_output=errors
--test_tag_filters=-benchmark
--test_tag_filters=-benchmark,-fuzztest

Linux-Clang:
runs-on: ubuntu-latest
Expand All @@ -57,6 +58,7 @@ jobs:
run: >
bazel test ...
--action_env=CC=clang
--build_tag_filters=-fuzztest
--copt=-DGTEST_REMOVE_LEGACY_TEST_CASEAPI_=1
--copt=-Werror
--cxxopt=-Wall
Expand Down Expand Up @@ -97,7 +99,33 @@ jobs:
--show_timestamps
--test_env="TZDIR=${GITHUB_WORKSPACE}/testdata/zoneinfo"
--test_output=errors
--test_tag_filters=-benchmark
--test_tag_filters=-benchmark,-fuzztest

Linux-FuzzTest:
runs-on: ubuntu-latest
steps:

- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Configure Fuzztest
run: bazel run @fuzztest//bazel:setup_configs > fuzztest.bazelrc
- name: Fuzz
run: >
bazel --bazelrc=fuzztest.bazelrc test ...
--action_env=CC=clang
--build_tag_filters=fuzztest
--config=fuzztest
--copt=-DGTEST_REMOVE_LEGACY_TEST_CASEAPI_=1
--define=absl=1
--features=external_include_paths
--keep_going
--show_timestamps
--test_arg=--fuzz_for=30s
--test_env="TZDIR=${GITHUB_WORKSPACE}/testdata/zoneinfo"
--test_output=errors
--test_tag_filters=fuzztest

macOS:
runs-on: macos-latest
Expand All @@ -110,13 +138,14 @@ jobs:
- name: Tests
run: >
bazel test ...
--build_tag_filters=-fuzztest
--cxxopt="-std=c++17"
--features=external_include_paths
--keep_going
--show_timestamps
--test_env="TZDIR=${GITHUB_WORKSPACE}/testdata/zoneinfo"
--test_output=errors
--test_tag_filters=-benchmark
--test_tag_filters=-benchmark,-fuzztest

Windows:
runs-on: windows-latest
Expand All @@ -129,8 +158,9 @@ jobs:
- name: Tests
run: >
bazel test ...
--build_tag_filters="-fuzztest"
--keep_going
--show_timestamps
--test_env="TZDIR=$env:GITHUB_WORKSPACE\testdata\zoneinfo"
--test_output=errors
--test_tag_filters=-benchmark
--test_tag_filters="-benchmark,-fuzztest"
33 changes: 30 additions & 3 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,12 @@ cc_library(

### tests

test_suite(
name = "all_tests",
visibility = ["//visibility:public"],
cc_library(
name = "test_time_zone_names",
testonly = True,
srcs = ["src/test_time_zone_names.cc"],
hdrs = ["src/test_time_zone_names.h"],
visibility = ["//visibility:private"],
)

cc_test(
Expand Down Expand Up @@ -109,12 +112,35 @@ cc_test(
srcs = ["src/time_zone_lookup_test.cc"],
deps = [
":civil_time",
":test_time_zone_names",
":time_zone",
"@googletest//:gtest",
"@googletest//:gtest_main",
],
)

cc_test(
name = "time_zone_fuzz_test",
srcs = [
"src/time_zone_fuzz_test.cc",
"src/time_zone_if.h",
"src/time_zone_impl.h",
"src/time_zone_info.h",
"src/tzfile.h",
],
tags = [
"fuzztest",
],
deps = [
":civil_time",
":test_time_zone_names",
":time_zone",
"@fuzztest//fuzztest",
"@fuzztest//fuzztest:fuzztest_gtest_main",
"@googletest//:gtest",
],
)

### benchmarks

cc_test(
Expand All @@ -130,6 +156,7 @@ cc_test(
tags = ["benchmark"],
deps = [
":civil_time",
":test_time_zone_names",
":time_zone",
"@google_benchmark//:benchmark_main",
],
Expand Down
12 changes: 11 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@ if (BUILD_EXAMPLES)
endif()

if (BUILD_TESTING)
add_library(test_time_zone_names
"src/test_time_zone_names.cc"
"src/test_time_zone_names.h"
)

add_executable(civil_time_test src/civil_time_test.cc)
cctz_target_set_cxx_standard(civil_time_test)
target_include_directories(civil_time_test PRIVATE ${GTEST_INCLUDE_DIRS})
Expand All @@ -126,6 +131,7 @@ if (BUILD_TESTING)
target_include_directories(time_zone_lookup_test PRIVATE ${GTEST_INCLUDE_DIRS})
target_link_libraries(time_zone_lookup_test
cctz::cctz
test_time_zone_names
${GTEST_BOTH_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
)
Expand Down Expand Up @@ -153,7 +159,11 @@ if (BUILD_TESTING)
if (BUILD_BENCHMARK)
add_executable(cctz_benchmark src/cctz_benchmark.cc)
cctz_target_set_cxx_standard(cctz_benchmark)
target_link_libraries(cctz_benchmark cctz::cctz benchmark::benchmark_main)
target_link_libraries(cctz_benchmark
cctz::cctz
test_time_zone_names
benchmark::benchmark_main
)
endif()
endif()

Expand Down
4 changes: 4 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ module(

# Only direct dependencies need to be listed below.

bazel_dep(name = "fuzztest",
version = "20250728.0",
dev_dependency = True)

bazel_dep(name = "google_benchmark",
version = "1.9.4",
dev_dependency = True)
Expand Down
Loading
Loading