File
Blob: src/workerd/tests/BUILD.bazel
| 1 | load("//:build/kj_test.bzl", "kj_test") |
| 2 | load("//:build/wd_cc_benchmark.bzl", "wd_cc_benchmark") |
| 3 | load("//:build/wd_cc_library.bzl", "wd_cc_library") |
| 4 | load("//:build/wd_test.bzl", "wd_test") |
| 5 | |
| 6 | wd_cc_library( |
| 7 | name = "bench-tools", |
| 8 | hdrs = ["bench-tools.h"], |
| 9 | defines = select({ |
| 10 | "//src/workerd/server:really_use_tcmalloc": ["WD_USE_TCMALLOC"], |
| 11 | "//conditions:default": [], |
| 12 | }), |
| 13 | # clang-tidy fails on this target when using clang-tidy-21 together with llvm-19 headers due to |
| 14 | # changes in how intrinsics are defined - disable clang-tidy here until we start using LLVM 21 |
| 15 | # everywhere. |
| 16 | tags = [ |
| 17 | "no-clang-tidy", |
| 18 | "workerd-benchmark", |
| 19 | ], |
| 20 | visibility = ["//visibility:public"], |
| 21 | deps = [ |
| 22 | "@capnp-cpp//src/kj:kj-test", |
| 23 | "@google_benchmark//:benchmark", |
| 24 | ] + select({ |
| 25 | # tcmalloc is only available on Linux and when use_tcmalloc is enabled. |
| 26 | # We use the malloc_extension API to configure tcmalloc for deterministic benchmarks. |
| 27 | "//src/workerd/server:really_use_tcmalloc": ["@tcmalloc//tcmalloc:malloc_extension"], |
| 28 | "//conditions:default": [], |
| 29 | }), |
| 30 | ) |
| 31 | |
| 32 | wd_cc_library( |
| 33 | name = "test-fixture", |
| 34 | srcs = ["test-fixture.c++"], |
| 35 | hdrs = ["test-fixture.h"], |
| 36 | visibility = ["//visibility:public"], |
| 37 | deps = [ |
| 38 | "//src/workerd/io", |
| 39 | "//src/workerd/jsg", |
| 40 | "//src/workerd/server:workerd-api", |
| 41 | "//src/workerd/util:autogate", |
| 42 | ], |
| 43 | ) |
| 44 | |
| 45 | kj_test( |
| 46 | src = "test-fixture-test.c++", |
| 47 | deps = [":test-fixture"], |
| 48 | ) |
| 49 | |
| 50 | # Use `bazel run //src/workerd/tests:bench-json` to benchmark |
| 51 | wd_cc_benchmark( |
| 52 | name = "bench-json", |
| 53 | srcs = ["bench-json.c++"], |
| 54 | deps = [ |
| 55 | "//src/workerd/api:r2-api_capnp", |
| 56 | "@capnp-cpp//src/kj", |
| 57 | ], |
| 58 | ) |
| 59 | |
| 60 | wd_cc_benchmark( |
| 61 | name = "bench-mimetype", |
| 62 | srcs = ["bench-mimetype.c++"], |
| 63 | deps = [ |
| 64 | "//src/workerd/util:mimetype", |
| 65 | ], |
| 66 | ) |
| 67 | |
| 68 | wd_cc_benchmark( |
| 69 | name = "bench-kj-headers", |
| 70 | srcs = ["bench-kj-headers.c++"], |
| 71 | deps = [ |
| 72 | "@capnp-cpp//src/kj/compat:kj-http", |
| 73 | ], |
| 74 | ) |
| 75 | |
| 76 | wd_cc_benchmark( |
| 77 | name = "bench-api-headers", |
| 78 | srcs = ["bench-api-headers.c++"], |
| 79 | deps = [ |
| 80 | ":test-fixture", |
| 81 | ], |
| 82 | ) |
| 83 | |
| 84 | wd_cc_benchmark( |
| 85 | name = "bench-global-scope", |
| 86 | srcs = ["bench-global-scope.c++"], |
| 87 | deps = [":test-fixture"], |
| 88 | ) |
| 89 | |
| 90 | wd_cc_benchmark( |
| 91 | name = "bench-regex", |
| 92 | srcs = ["bench-regex.c++"], |
| 93 | deps = [ |
| 94 | ":test-fixture", |
| 95 | "//src/workerd/util", |
| 96 | ], |
| 97 | ) |
| 98 | |
| 99 | wd_cc_benchmark( |
| 100 | name = "bench-util", |
| 101 | srcs = ["bench-util.c++"], |
| 102 | deps = [ |
| 103 | ":test-fixture", |
| 104 | "//src/workerd/jsg", |
| 105 | ], |
| 106 | ) |
| 107 | |
| 108 | wd_cc_benchmark( |
| 109 | name = "bench-text-encoder", |
| 110 | srcs = ["bench-text-encoder.c++"], |
| 111 | deps = [":test-fixture"], |
| 112 | ) |
| 113 | |
| 114 | wd_cc_benchmark( |
| 115 | name = "bench-response", |
| 116 | srcs = ["bench-response.c++"], |
| 117 | deps = [":test-fixture"], |
| 118 | ) |
| 119 | |
| 120 | wd_cc_benchmark( |
| 121 | name = "bench-jsstring", |
| 122 | srcs = ["bench-jsstring.c++"], |
| 123 | deps = [ |
| 124 | ":test-fixture", |
| 125 | "//src/workerd/jsg", |
| 126 | ], |
| 127 | ) |
| 128 | |
| 129 | # Benchmark for comparing stream piping implementations |
| 130 | # Tagged manual because it takes too long for CI - run explicitly with: |
| 131 | # bazel run //src/workerd/tests:bench-stream-piping |
| 132 | wd_cc_benchmark( |
| 133 | name = "bench-stream-piping", |
| 134 | srcs = ["bench-stream-piping.c++"], |
| 135 | tags = ["manual"], |
| 136 | deps = [ |
| 137 | ":test-fixture", |
| 138 | "//src/workerd/io", |
| 139 | "//src/workerd/jsg", |
| 140 | ], |
| 141 | ) |
| 142 | |
| 143 | # Benchmark for PumpToReader (ReadableStream::pumpTo path in standard.c++). |
| 144 | # Run before and after DrainingReader adoption to measure improvement. |
| 145 | # bazel run --config=opt //src/workerd/tests:bench-pumpto |
| 146 | wd_cc_benchmark( |
| 147 | name = "bench-pumpto", |
| 148 | srcs = ["bench-pumpto.c++"], |
| 149 | tags = ["manual"], |
| 150 | deps = [ |
| 151 | ":test-fixture", |
| 152 | "//src/workerd/io", |
| 153 | "//src/workerd/jsg", |
| 154 | ], |
| 155 | ) |
| 156 | |
| 157 | wd_test( |
| 158 | src = "unknown-import-assertions-test.wd-test", |
| 159 | args = ["--experimental"], |
| 160 | data = ["unknown-import-assertions-test.js"], |
| 161 | ) |
| 162 | |
| 163 | wd_test( |
| 164 | src = "module-imports-test.wd-test", |
| 165 | args = ["--experimental"], |
| 166 | data = [ |
| 167 | "module-imports-test.js", |
| 168 | "test.wasm", |
| 169 | ], |
| 170 | lint = False, |
| 171 | ) |
| 172 | |
| 173 | wd_test( |
| 174 | src = "performance-test.wd-test", |
| 175 | data = ["performance-test.js"], |
| 176 | ) |
| 177 | |
| 178 | # REPRL tests using KJ test framework |
| 179 | wd_cc_library( |
| 180 | name = "libreprl", |
| 181 | srcs = ["libreprl/libreprl.c"], |
| 182 | hdrs = ["libreprl/libreprl.h"], |
| 183 | copts = [ |
| 184 | "-std=c23", |
| 185 | ], |
| 186 | ) |
| 187 | |
| 188 | kj_test( |
| 189 | src = "test-reprl.c++", |
| 190 | data = [ |
| 191 | "//fuzzilli:config.capnp", |
| 192 | "//fuzzilli:worker.js", |
| 193 | "//src/workerd/server:workerd", |
| 194 | ], |
| 195 | tags = ["requires-fuzzilli"], |
| 196 | deps = [ |
| 197 | ":libreprl", |
| 198 | "@bazel_tools//tools/cpp/runfiles", |
| 199 | ], |
| 200 | ) |