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
43 changes: 29 additions & 14 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,34 +33,41 @@ jobs:
build_type: [Release, Debug]
os_compiler: [
# ubuntu 22
{os: ubuntu-22.04, name: GCC 10, cc: gcc-10, cxx: g++-10, package: false},
{os: ubuntu-22.04, name: GCC 11, cc: gcc-11, cxx: g++-11, package: false},
{os: ubuntu-22.04, name: GCC 12, cc: gcc-12, cxx: g++-12, package: false},
{os: ubuntu-22.04, name: Clang 13, cc: clang-13, cxx: clang++-13, tidy: clang-tidy-13, package: false},
{os: ubuntu-22.04, name: Clang 14, cc: clang-14, cxx: clang++-14, tidy: clang-tidy-14, package: false},
{os: ubuntu-22.04, name: Clang 15, cc: clang-15, cxx: clang++-15, tidy: clang-tidy-15, package: false},
{os: ubuntu-22.04, name: GCC 10, cc: gcc-10, cxx: g++-10},
{os: ubuntu-22.04, name: GCC 11, cc: gcc-11, cxx: g++-11},
{os: ubuntu-22.04, name: GCC 12, cc: gcc-12, cxx: g++-12},
{os: ubuntu-22.04, name: Clang 13, cc: clang-13, cxx: clang++-13, tidy: clang-tidy-13},
{os: ubuntu-22.04, name: Clang 14, cc: clang-14, cxx: clang++-14, tidy: clang-tidy-14},
{os: ubuntu-22.04, name: Clang 15, cc: clang-15, cxx: clang++-15, tidy: clang-tidy-15},

# ubuntu 24
{os: ubuntu-24.04, name: GCC 12, cc: gcc-12, cxx: g++-12, package: false},
{os: ubuntu-24.04, name: GCC 13, cc: gcc-13, cxx: g++-13, package: false},
{os: ubuntu-24.04, name: GCC 12, cc: gcc-12, cxx: g++-12},
{os: ubuntu-24.04, name: GCC 13, cc: gcc-13, cxx: g++-13},
{os: ubuntu-24.04, name: GCC 14, cc: gcc-14, cxx: g++-14, package: true},
{os: ubuntu-24.04, name: Clang 16, cc: clang-16, cxx: clang++-16, tidy: clang-tidy-16, package: false},
{os: ubuntu-24.04, name: Clang 17, cc: clang-17, cxx: clang++-17, tidy: clang-tidy-17, package: false},
{os: ubuntu-24.04, name: Clang 16, cc: clang-16, cxx: clang++-16, tidy: clang-tidy-16},
{os: ubuntu-24.04, name: Clang 17, cc: clang-17, cxx: clang++-17, tidy: clang-tidy-17},
{os: ubuntu-24.04, name: Clang 18, cc: clang-18, cxx: clang++-18, tidy: clang-tidy-18, package: true},
]
cmake_args: [""]
code_coverage: [false]
include:
# ASAN/TSAN builds
- os_compiler: {os: ubuntu-24.04, name: Clang 18 (ASAN), cc: clang-18, cxx: clang++-18, tidy: clang-tidy-18 }
build_type: Debug
cmake_args: "-DLIBBASE_BUILD_ASAN=ON"
run_all: true
- os_compiler: {os: ubuntu-24.04, name: Clang 18 (TSAN), cc: clang-18, cxx: clang++-18, tidy: clang-tidy-18 }
build_type: Debug
cmake_args: "-DLIBBASE_BUILD_TSAN=ON"
run_all: true

# Code coverage builds
- os_compiler: {os: ubuntu-24.04, name: CodeCoverage (gcov), cc: gcc-13, cxx: g++-13}
build_type: Debug
cmake_args: "-DLIBBASE_CODE_COVERAGE=ON"
code_coverage: true
package: false
- os_compiler: {os: ubuntu-24.04, name: CodeCoverage (llvm-cov), cc: clang-18, cxx: clang++-18, tidy: clang-tidy-18, llvm-cov: llvm-cov-18, llvm-profdata: llvm-profdata-18 }
build_type: Debug
cmake_args: "-DLIBBASE_CODE_COVERAGE=ON"
code_coverage: true
package: false

env:
CC: ${{ matrix.os_compiler.cc }}
Expand Down Expand Up @@ -111,6 +118,14 @@ jobs:
- name: Testing
run: ctest --test-dir build --output-on-failure --timeout 15

# (Optional) Run other tests and examples
- name: (Optional) Run performance tests
if: ${{ matrix.run_all }}
run: ./build/tests/perf/libbase_perf_tests
- name: (Optional) Run examples
if: ${{ matrix.run_all }}
run: ./build/examples/simple/simple

# (Optional) Generate code coverage report and upload it
# - 'gcov'-based is used with CI
# - 'llvm-cov'-based is uploaded as an artifact
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ else()
endif()

option(LIBBASE_BUILD_ASAN "Build with Address Sanitizer enabled" OFF)
option(LIBBASE_BUILD_TSAN "Build with Thread Sanitizer enabled" OFF)


#
Expand Down
8 changes: 7 additions & 1 deletion CMakeModules/SetupCompileFlags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,14 @@ function(SETUP_COMPILE_FLAGS)
set(CLANG_TIDY_PROPERTIES "CXX_CLANG_TIDY;${CLANG_TIDY_EXE}")
endif()

if(LIBBASE_BUILD_ASAN AND LIBBASE_BUILD_TSAN)
message(FATAL_ERROR "Cann't use ASAN and TSAN within same build")
endif()

if(LIBBASE_BUILD_ASAN)
set(SANITIZE_FLAGS ";-fsanitize=address")
set(SANITIZE_FLAGS ";-fsanitize=address,undefined")
elseif(LIBBASE_BUILD_TSAN)
set(SANITIZE_FLAGS ";-fsanitize=thread")
endif()

if(NOT CONFIGURED_ONCE)
Expand Down
2 changes: 1 addition & 1 deletion src/base/synchronization/waitable_event.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ void WaitableEvent::Signal() {
{
std::lock_guard<std::mutex> guard{mutex_};
is_signaled_ = true;
cond_var_.notify_one();
}
cond_var_.notify_one();
}

bool WaitableEvent::IsSignaled() {
Expand Down
4 changes: 2 additions & 2 deletions tests/perf/base/threading/thread_perftests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ void TestDoubleThreaded(base::SequencedTaskRunner* tr1,
}

void BM_TestSingleThreaded(benchmark::State& state) {
base::WaitableEvent event{base::WaitableEvent::ResetPolicy::kAutomatic};
base::Thread t1;
t1.Start();
base::WaitableEvent event{base::WaitableEvent::ResetPolicy::kAutomatic};

for (auto _ : state) {
TestSingleThreaded(t1.TaskRunner().get(), 1000, &event);
Expand All @@ -41,11 +41,11 @@ void BM_TestSingleThreaded(benchmark::State& state) {
}

void BM_TestDoubleThreaded(benchmark::State& state) {
base::WaitableEvent event{base::WaitableEvent::ResetPolicy::kAutomatic};
base::Thread t1;
base::Thread t2;
t1.Start();
t2.Start();
base::WaitableEvent event{base::WaitableEvent::ResetPolicy::kAutomatic};

for (auto _ : state) {
TestDoubleThreaded(t2.TaskRunner().get(), t1.TaskRunner().get(), 1000,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace {

const base::TimeDelta kZero = base::TimeDelta{};

base::TimeTicks g_now_mocked;
std::atomic<base::TimeTicks> g_now_mocked;

base::TimeTicks GetMockedTimeTicks() {
return g_now_mocked;
Expand Down