BUILD 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. # Licensed to the Apache Software Foundation (ASF) under one or more
  2. # contributor license agreements. See the NOTICE file distributed with
  3. # this work for additional information regarding copyright ownership.
  4. # The ASF licenses this file to You under the Apache License, Version 2.0
  5. # (the "License"); you may not use this file except in compliance with
  6. # the License. You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. load("//:bazel/brpc.bzl", "brpc_proto_library")
  16. config_setting(
  17. name = "darwin",
  18. values = {"cpu": "darwin"},
  19. visibility = ["//visibility:public"],
  20. )
  21. COPTS = [
  22. "-D__STDC_FORMAT_MACROS",
  23. "-DBTHREAD_USE_FAST_PTHREAD_MUTEX",
  24. "-D__const__=",
  25. "-D_GNU_SOURCE",
  26. "-DUSE_SYMBOLIZE",
  27. "-DNO_TCMALLOC",
  28. "-D__STDC_LIMIT_MACROS",
  29. "-D__STDC_CONSTANT_MACROS",
  30. "-fPIC",
  31. "-Wno-unused-parameter",
  32. "-fno-omit-frame-pointer",
  33. "-DGFLAGS_NS=google",
  34. "-Dprivate=public",
  35. "-Dprotected=public",
  36. "--include test/sstream_workaround.h",
  37. "-DBAZEL_TEST=1",
  38. "-DBVAR_NOT_LINK_DEFAULT_VARIABLES",
  39. "-DUNIT_TEST",
  40. ] + select({
  41. "//:with_glog": ["-DBRPC_WITH_GLOG=1"],
  42. "//conditions:default": ["-DBRPC_WITH_GLOG=0"],
  43. })
  44. LINKOPTS = [
  45. "-lpthread",
  46. "-lssl",
  47. "-lcrypto",
  48. "-ldl",
  49. "-lz",
  50. ] + select({
  51. ":darwin": [],
  52. "//conditions:default": [
  53. "-lrt",
  54. ],
  55. })
  56. TEST_BUTIL_SOURCES = [
  57. "at_exit_unittest.cc",
  58. "atomicops_unittest.cc",
  59. "base64_unittest.cc",
  60. "big_endian_unittest.cc",
  61. "bits_unittest.cc",
  62. "hash_tables_unittest.cc",
  63. "linked_list_unittest.cc",
  64. "mru_cache_unittest.cc",
  65. "small_map_unittest.cc",
  66. "stack_container_unittest.cc",
  67. "cpu_unittest.cc",
  68. "crash_logging_unittest.cc",
  69. "leak_tracker_unittest.cc",
  70. "stack_trace_unittest.cc",
  71. "environment_unittest.cc",
  72. "file_util_unittest.cc",
  73. "dir_reader_posix_unittest.cc",
  74. "file_path_unittest.cc",
  75. "file_unittest.cc",
  76. "scoped_temp_dir_unittest.cc",
  77. "guid_unittest.cc",
  78. "hash_unittest.cc",
  79. "lazy_instance_unittest.cc",
  80. "aligned_memory_unittest.cc",
  81. "linked_ptr_unittest.cc",
  82. "ref_counted_memory_unittest.cc",
  83. "ref_counted_unittest.cc",
  84. "scoped_ptr_unittest.cc",
  85. "scoped_vector_unittest.cc",
  86. "singleton_unittest.cc",
  87. "weak_ptr_unittest.cc",
  88. "observer_list_unittest.cc",
  89. "file_descriptor_shuffle_unittest.cc",
  90. "rand_util_unittest.cc",
  91. "safe_numerics_unittest.cc",
  92. "scoped_clear_errno_unittest.cc",
  93. "scoped_generic_unittest.cc",
  94. "security_unittest.cc",
  95. "sha1_unittest.cc",
  96. "stl_util_unittest.cc",
  97. "nullable_string16_unittest.cc",
  98. "safe_sprintf_unittest.cc",
  99. "string16_unittest.cc",
  100. "stringprintf_unittest.cc",
  101. "string_number_conversions_unittest.cc",
  102. "string_piece_unittest.cc",
  103. "string_split_unittest.cc",
  104. "string_tokenizer_unittest.cc",
  105. "string_util_unittest.cc",
  106. "stringize_macros_unittest.cc",
  107. "sys_string_conversions_unittest.cc",
  108. "utf_offset_string_conversions_unittest.cc",
  109. "utf_string_conversions_unittest.cc",
  110. "cancellation_flag_unittest.cc",
  111. "condition_variable_unittest.cc",
  112. "lock_unittest.cc",
  113. "waitable_event_unittest.cc",
  114. "type_traits_unittest.cc",
  115. "non_thread_safe_unittest.cc",
  116. "platform_thread_unittest.cc",
  117. "simple_thread_unittest.cc",
  118. "thread_checker_unittest.cc",
  119. "thread_collision_warner_unittest.cc",
  120. "thread_id_name_manager_unittest.cc",
  121. "thread_local_storage_unittest.cc",
  122. "thread_local_unittest.cc",
  123. "watchdog_unittest.cc",
  124. "time_unittest.cc",
  125. "version_unittest.cc",
  126. "logging_unittest.cc",
  127. "cacheline_unittest.cpp",
  128. "class_name_unittest.cpp",
  129. "endpoint_unittest.cpp",
  130. "unique_ptr_unittest.cpp",
  131. "errno_unittest.cpp",
  132. "fd_guard_unittest.cpp",
  133. "file_watcher_unittest.cpp",
  134. "find_cstr_unittest.cpp",
  135. "scoped_lock_unittest.cpp",
  136. "status_unittest.cpp",
  137. "string_printf_unittest.cpp",
  138. "string_splitter_unittest.cpp",
  139. "synchronous_event_unittest.cpp",
  140. "temp_file_unittest.cpp",
  141. "baidu_thread_local_unittest.cpp",
  142. "baidu_time_unittest.cpp",
  143. "flat_map_unittest.cpp",
  144. "crc32c_unittest.cc",
  145. "iobuf_unittest.cpp",
  146. "object_pool_unittest.cpp",
  147. "test_switches.cc",
  148. "scoped_locale.cc",
  149. "recordio_unittest.cpp",
  150. #"popen_unittest.cpp",
  151. "bounded_queue_unittest.cc",
  152. "butil_unittest_main.cpp",
  153. ] + select({
  154. "@bazel_tools//tools/osx:darwin": [],
  155. "//conditions:default": [
  156. "test_file_util_linux.cc",
  157. "proc_maps_linux_unittest.cc",
  158. ],
  159. })
  160. proto_library(
  161. name = "test_proto",
  162. srcs = glob([
  163. "*.proto",
  164. ],
  165. exclude = [
  166. "echo.proto",
  167. ]
  168. ),
  169. visibility = ["//visibility:public"],
  170. )
  171. cc_proto_library(
  172. name = "cc_test_proto",
  173. deps = [
  174. ":test_proto",
  175. ],
  176. visibility = ["//visibility:public"],
  177. )
  178. cc_library(
  179. name = "sstream_workaround",
  180. hdrs = [
  181. "sstream_workaround.h",
  182. ]
  183. )
  184. cc_test(
  185. name = "butil_test",
  186. srcs = TEST_BUTIL_SOURCES + [
  187. "scoped_locale.h",
  188. "multiprocess_func_list.h",
  189. "test_switches.h",
  190. ],
  191. deps = [
  192. ":sstream_workaround",
  193. ":cc_test_proto",
  194. "//:brpc",
  195. "@com_google_googletest//:gtest",
  196. ],
  197. copts = COPTS,
  198. )
  199. cc_test(
  200. name = "bvar_test",
  201. srcs = glob([
  202. "bvar_*_unittest.cpp",
  203. ],
  204. exclude = [
  205. "bvar_lock_timer_unittest.cpp",
  206. "bvar_recorder_unittest.cpp",
  207. ]),
  208. deps = [
  209. ":sstream_workaround",
  210. "//:bvar",
  211. "@com_google_googletest//:gtest",
  212. ],
  213. copts = COPTS,
  214. )
  215. cc_test(
  216. name = "bthread_test",
  217. srcs = glob([
  218. "bthread_*_unittest.cpp",
  219. ],
  220. exclude = [
  221. "bthread_cond_unittest.cpp",
  222. "bthread_execution_queue_unittest.cpp",
  223. "bthread_dispatcher_unittest.cpp",
  224. "bthread_fd_unittest.cpp",
  225. "bthread_mutex_unittest.cpp",
  226. "bthread_setconcurrency_unittest.cpp",
  227. # glog CHECK die with a fatal error
  228. "bthread_key_unittest.cpp"
  229. ]),
  230. deps = [
  231. ":sstream_workaround",
  232. "//:brpc",
  233. "@com_google_googletest//:gtest",
  234. "@com_google_googletest//:gtest_main",
  235. ],
  236. copts = COPTS,
  237. )