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
3 changes: 2 additions & 1 deletion score/launch_manager/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************
load("@rules_cc//cc:defs.bzl", "cc_library")
load("//tests/utils/bazel:unit_test.bzl", "lm_cc_test")

package(default_visibility = ["//visibility:public"])

Expand Down Expand Up @@ -70,7 +71,7 @@ cc_library(
],
)

cc_test(
lm_cc_test(
name = "exec_error_domain_UT",
srcs = ["src/exec_error_domain_UT.cpp"],
visibility = ["//visibility:private"],
Expand Down
3 changes: 2 additions & 1 deletion score/launch_manager/src/alive/src/details/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************
load("@rules_cc//cc:defs.bzl", "cc_library")
load("//tests/utils/bazel:unit_test.bzl", "lm_cc_test")

cc_test(
lm_cc_test(
name = "AliveImpl_UT",
srcs = ["AliveImpl_UT.cpp"],
deps = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************
load("@rules_cc//cc:defs.bzl", "cc_library")
load("//tests/utils/bazel:unit_test.bzl", "lm_cc_test")

cc_library(
name = "data_structures",
Expand Down Expand Up @@ -56,7 +57,7 @@ cc_library(
],
)

cc_test(
lm_cc_test(
name = "MonitorIfDaemon_UT",
srcs = [
"MonitorIfDaemon_UT.cpp",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************
load("@rules_cc//cc:defs.bzl", "cc_library")
load("//tests/utils/bazel:unit_test.bzl", "lm_cc_test")

cc_library(
name = "supervision_cfg",
Expand Down Expand Up @@ -57,7 +58,7 @@ cc_library(
],
)

cc_test(
lm_cc_test(
name = "Alive_UT",
srcs = ["Alive_UT.cpp"],
deps = [
Expand Down
4 changes: 2 additions & 2 deletions score/launch_manager/src/daemon/src/common/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************
load("@rules_cc//cc:defs.bzl", "cc_test")
load("//tests/utils/bazel:unit_test.bzl", "lm_cc_test")

cc_library(
name = "identifier_hash",
Expand All @@ -25,7 +25,7 @@ cc_library(
visibility = ["//score:__subpackages__"],
)

cc_test(
lm_cc_test(
name = "identifier_hash_UT",
srcs = ["identifier_hash_UT.cpp"],
deps = [
Expand Down
15 changes: 8 additions & 7 deletions score/launch_manager/src/daemon/src/common/concurrency/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
#
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test")
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library")
load("//tests/utils/bazel:unit_test.bzl", "lm_cc_test")

cc_library(
name = "workerthread",
Expand Down Expand Up @@ -38,7 +39,7 @@ cc_library(
],
)

cc_test(
lm_cc_test(
name = "fixed_size_queue_test",
srcs = ["fixed_size_queue_test.cpp"],
visibility = ["//tests:__subpackages__"],
Expand Down Expand Up @@ -96,7 +97,7 @@ cc_library(
],
)

cc_test(
lm_cc_test(
name = "mpsc_bounded_queue_test",
srcs = ["mpsc_bounded_queue_test.cpp"],
visibility = ["//tests:__subpackages__"],
Expand All @@ -106,7 +107,7 @@ cc_test(
],
)

cc_test(
lm_cc_test(
name = "mpsc_bounded_queue_tsan_test",
srcs = ["mpsc_bounded_queue_test.cpp"],
copts = [
Expand All @@ -127,7 +128,7 @@ cc_test(
],
)

cc_test(
lm_cc_test(
name = "mpmc_concurrent_queue_test",
srcs = ["mpmc_concurrent_queue_test.cpp"],
visibility = ["//tests:__subpackages__"],
Expand All @@ -137,7 +138,7 @@ cc_test(
],
)

cc_test(
lm_cc_test(
name = "mpmc_concurrent_queue_helgrind_test",
srcs = ["mpmc_concurrent_queue_test.cpp"],
data = ["mpmc_concurrent_queue_test_helgrind.supp"],
Expand All @@ -151,7 +152,7 @@ cc_test(
],
)

cc_test(
lm_cc_test(
name = "mpmc_concurrent_queue_tsan_test",
srcs = ["mpmc_concurrent_queue_test.cpp"],
copts = [
Expand Down
9 changes: 5 additions & 4 deletions score/launch_manager/src/daemon/src/configuration/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# *******************************************************************************
load("@rules_cc//cc:defs.bzl", "cc_library")
load("@score_baselibs//score/flatbuffers/bazel:codegen.bzl", "generate_cpp")
load("//tests/utils/bazel:unit_test.bzl", "lm_cc_test")

filegroup(
name = "new_lm_flatcfg_fbs",
Expand All @@ -35,7 +36,7 @@ cc_library(
deps = ["@score_baselibs//score/language/futurecpp"],
)

cc_test(
lm_cc_test(
name = "config_UT",
srcs = ["details/config_UT.cpp"],
visibility = ["//score:__subpackages__"],
Expand Down Expand Up @@ -94,7 +95,7 @@ cc_library(
],
)

cc_test(
lm_cc_test(
name = "flatbuffer_type_converters_UT",
srcs = ["details/flatbuffer_type_converters_UT.cpp"],
visibility = ["//tests:__subpackages__"],
Expand All @@ -105,7 +106,7 @@ cc_test(
],
)

cc_test(
lm_cc_test(
name = "flatbuffer_config_loader_UT",
srcs = ["details/flatbuffer_config_loader_UT.cpp"],
visibility = ["//tests:__subpackages__"],
Expand Down Expand Up @@ -159,7 +160,7 @@ cc_library(
],
)

cc_test(
lm_cc_test(
name = "configuration_adapter_UT",
srcs = ["configuration_adapter_UT.cpp"],
visibility = ["//tests:__subpackages__"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************
load("@rules_cc//cc:defs.bzl", "cc_library")
load("//tests/utils/bazel:unit_test.bzl", "lm_cc_test")

cc_library(
name = "process_info_node",
Expand Down Expand Up @@ -67,7 +68,7 @@ cc_library(
],
)

cc_test(
lm_cc_test(
name = "safeprocessmap_UT",
timeout = "long",
srcs = ["safeprocessmap_UT.cpp"],
Expand All @@ -92,7 +93,7 @@ cc_library(
],
)

cc_test(
lm_cc_test(
name = "oshandler_UT",
srcs = ["oshandler_UT.cpp"],
deps = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
#
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************
load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test")
load("@rules_cc//cc:defs.bzl", "cc_library")
load("//tests/utils/bazel:unit_test.bzl", "lm_cc_test")

cc_library(
name = "posix_process",
Expand Down Expand Up @@ -72,7 +73,7 @@ cc_library(
],
)

cc_test(
lm_cc_test(
name = "process_state_client_ut",
srcs = ["process_state_client_ut.cpp"],
tags = ["no-tsan"],
Expand Down
5 changes: 3 additions & 2 deletions score/launch_manager/src/daemon/src/recovery_client/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
#
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************
load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test")
load("@rules_cc//cc:defs.bzl", "cc_library")
load("//tests/utils/bazel:unit_test.bzl", "lm_cc_test")

cc_library(
name = "recovery_client",
Expand All @@ -32,7 +33,7 @@ cc_library(
],
)

cc_test(
lm_cc_test(
name = "recovery_client_UT",
srcs = ["recovery_client_UT.cpp"],
deps = [
Expand Down
3 changes: 2 additions & 1 deletion score/launch_manager/src/lifecycle_client/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# *******************************************************************************
load("@rules_cc//cc:defs.bzl", "cc_library")
load("@score_baselibs//score/language/safecpp:toolchain_features.bzl", "COMPILER_WARNING_FEATURES")
load("//tests/utils/bazel:unit_test.bzl", "lm_cc_test")

cc_library(
name = "lifecycle_client",
Expand Down Expand Up @@ -209,7 +210,7 @@ cc_library(
],
)

cc_test(
lm_cc_test(
name = "runapplication_UT",
srcs = ["src/runapplication_UT.cpp"],
deps = [
Expand Down
25 changes: 25 additions & 0 deletions score/launch_manager/src/testing/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# *******************************************************************************
# Copyright (c) 2026 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0
#
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************
load("@rules_cc//cc:defs.bzl", "cc_library")

cc_library(
name = "testing_assertion_handler",
testonly = True,
srcs = ["assertion_handler.cpp"],
hdrs = ["assertion_handler.hpp"],
include_prefix = "score/mw/launch_manager/testing",
strip_include_prefix = "/score/launch_manager/src/testing",
visibility = ["//score/launch_manager:__subpackages__"],
deps = ["@score_baselibs//score/language/futurecpp"],
alwayslink = True,
)
27 changes: 27 additions & 0 deletions score/launch_manager/src/testing/assertion_handler.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/********************************************************************************
* Copyright (c) 2026 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0
*
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/

#include "score/mw/launch_manager/testing/assertion_handler.hpp"

namespace
{

// Registers the assertion handler at static-initialization time so every unit
// test binary that links this library gets diagnostic output on assertion failure
// without any explicit setup call.
const bool kAssertionHandlerRegistered = []() noexcept {
score::lcm::testing::registerAssertionHandler();
return true;
}();

} // namespace
40 changes: 40 additions & 0 deletions score/launch_manager/src/testing/assertion_handler.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/********************************************************************************
* Copyright (c) 2026 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0
*
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/

#pragma once

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

everywhere else we use #ifdefs so please change this.


#include <score/assert.hpp>

#include <iostream>
#include <sstream>

namespace score::lcm::testing
{

inline void registerAssertionHandler() noexcept

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we can use the same assertion handler for the daemon as tests.

Would move this maybe into //score/launch_manager/src/daemon/src/common:assertion_handler and then also link it for the daemons cc_binary.

{
score::cpp::set_assertion_handler([](const score::cpp::handler_parameters& params) {
std::ostringstream msg;
msg << "Assertion failed: " << (params.condition != nullptr ? params.condition : "")
<< "\n Location: " << (params.file != nullptr ? params.file : "?") << ":" << params.line
<< " (" << (params.function != nullptr ? params.function : "?") << ")";
if (params.message != nullptr)
{
msg << "\n Message: " << params.message;
}
msg << "\n";
std::cerr << msg.str();
});
}

} // namespace score::lcm::testing
34 changes: 34 additions & 0 deletions tests/utils/bazel/unit_test.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# *******************************************************************************
# Copyright (c) 2026 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0
#
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************
"""Bazel macros for LCM unit tests."""

load("@rules_cc//cc:defs.bzl", "cc_test")

def lm_cc_test(name, deps = [], **kwargs):
"""Wrapper around cc_test that auto-registers the LCM assertion handler.

All arguments are forwarded to cc_test unchanged. The assertion handler
library is injected so that assertion failures in any unit test binary
print a diagnostic message before aborting, without requiring any
explicit setup call in test code.

Args:
name: Test target name.
deps: Additional dependencies (assertion handler is appended automatically).
**kwargs: Forwarded verbatim to cc_test.
"""
cc_test(
name = name,
deps = deps + ["//score/launch_manager/src/testing:testing_assertion_handler"],
**kwargs
)
Loading