Skip to content
Open
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
17 changes: 17 additions & 0 deletions .github/workflows/ci-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,23 @@ jobs:
- uses: actions/checkout@v2
- run: bazel build --verbose_failures --action_env=CC=clang --define with_mesalink=false --define with_glog=true --define with_thrift=true --define with_debug_bthread_sche_safety=true --define with_debug_lock=true --define with_asan=true -- //... -//example/...

gcc-bazel-unittest:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- name: run bazel tests
run: bazel test --test_output=errors --verbose_failures --test_timeout=900 --define=with_glog=false --define=BRPC_WITH_GLOG=false -- //test/...

clang-bazel-unittest:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

StackTraceTest.find_symbol seems to fail in clang14. It is recommended to use clang12 with sudo apt-get install -y clang-12 lldb-12 lld-12.

Copy link
Contributor

@chenBright chenBright Aug 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And --action_env=CC=clang-12.

runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- run: |
sudo apt-get update && sudo apt-get install -y clang-12 lldb-12 lld-12 libgtest-dev cmake gdb libstdc++6-11-dbg
shell: bash
- name: run bazel tests
run: bazel test --test_output=errors --verbose_failures --action_env=CC=clang-12 --define=with_glog=false --define=BRPC_WITH_GLOG=false -- //test/...

clang-unittest:
runs-on: ubuntu-22.04
steps:
Expand Down
27 changes: 27 additions & 0 deletions test/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,19 @@
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@rules_cc//cc:defs.bzl", "cc_library", "cc_proto_library", "cc_test")
load("@hedron_compile_commands//:refresh_compile_commands.bzl", "refresh_compile_commands")
load("//test:brpc_unit_test.bzl", "generate_brpc_unit_tests")
load("//test:flat_runfiles.bzl", "flat_runfiles")

flat_runfiles(
name = "root_test_assets",
srcs = [
"cert1.crt",
"cert1.key",
"cert2.crt",
"cert2.key",
"jsonout",
],
)

COPTS = [
"-D__STDC_FORMAT_MACROS",
Expand Down Expand Up @@ -201,6 +214,20 @@ cc_test(
],
)

generate_brpc_unit_tests(
name = "brpc_test",
srcs = glob(["brpc_*_unittest.cpp"]),
copts = COPTS,
data = [":root_test_assets"],
deps = [
":cc_test_proto",
":sstream_workaround",
":gperftools_helper",
"//:brpc",
"@com_google_googletest//:gtest",
"@com_google_googletest//:gtest_main",
],
)

cc_test(
name = "bvar_test",
Expand Down
4 changes: 2 additions & 2 deletions test/brpc_alpn_protocol_unittest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@

#include "gtest/gtest.h"
#include "gflags/gflags.h"

#include "brpc/channel.h"
#include "brpc/details/ssl_helper.h"
#include "brpc/server.h"
#include "butil/endpoint.h"
#include "butil/fd_guard.h"
#include "butil/logging.h"
#include "echo.pb.h"

DEFINE_string(listen_addr, "0.0.0.0:8011", "Server listen address.");
Expand All @@ -48,7 +48,7 @@ class EchoServerImpl : public test::EchoService {
response->set_message(request->message());

brpc::Controller* cntl = static_cast<brpc::Controller*>(controller);
LOG(NOTICE) << "protocol:" << cntl->request_protocol();
LOG(INFO) << "protocol:" << cntl->request_protocol();
}
};

Expand Down
3 changes: 1 addition & 2 deletions test/brpc_http_rpc_protocol_unittest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
// Date: Sun Jul 13 15:04:18 CST 2014

#include <cstddef>
#include <google/protobuf/stubs/logging.h>
#include <string>
#include <sys/ioctl.h>
#include <sys/socket.h>
Expand Down Expand Up @@ -1128,7 +1127,7 @@ class UploadServiceImpl : public ::test::UploadService {
private:
void check_header(brpc::Controller* cntl) {
const std::string* test_header = cntl->http_request().GetHeader(TEST_PROGRESSIVE_HEADER);
GOOGLE_CHECK_NOTNULL(test_header);
CHECK(test_header != NULL);
CHECK_EQ(*test_header, TEST_PROGRESSIVE_HEADER_VAL);
}
};
Expand Down
32 changes: 32 additions & 0 deletions test/brpc_unit_test.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

def generate_brpc_unit_tests(name, srcs, deps, copts, data = []):
tests = []
for s in srcs:
tgt = s.replace(".cpp", "")
native.cc_test(
name = tgt,
srcs = [s],
copts = copts,
data = data,
deps = deps,
)
tests.append(":" + tgt)

native.test_suite(
name = name,
tests = tests,
)
27 changes: 27 additions & 0 deletions test/flat_runfiles.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

def _flat_runfiles_impl(ctx):
r = ctx.runfiles()
for f in ctx.files.srcs:
r = r.merge(ctx.runfiles(symlinks = {f.basename: f}))
return DefaultInfo(runfiles = r)

flat_runfiles = rule(
implementation = _flat_runfiles_impl,
attrs = {
"srcs": attr.label_list(allow_files = True),
},
)
Loading