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
7 changes: 6 additions & 1 deletion .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,15 @@ build --java_runtime_version=remotejdk_17
build --tool_java_runtime_version=remotejdk_17
build --credential_helper=*.qnx.com=%workspace%/scripts/internal/qnx_creds.py

# Treat warnings as errors, except in external code
build --copt=-Wall
build --copt=-Wextra
build --copt=-Werror
build --per_file_copt=external/.*@-Wno-error

# Common test flags for all platforms
test --test_output=errors
test --@score_baselibs//score/json:base_library=nlohmann
test --cxxopt=-Wno-deprecated-declarations

# Coverage configuration for C++
coverage --features=coverage
Expand Down
5 changes: 2 additions & 3 deletions examples/c_supervised_app/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ load("@rules_cc//cc:defs.bzl", "cc_binary")

cc_binary(
name = "c_supervised_app",
srcs = [
"main.c",
],
srcs = ["main.c"],
copts = ["-std=gnu11"],
linkopts = select({
"@platforms//os:qnx": [
"-lsocket",
Expand Down
9 changes: 7 additions & 2 deletions examples/c_supervised_app/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <time.h>

#include <score/mw/lifecycle/alive.h>
#include <score/mw/lifecycle/report_running.h>
Expand All @@ -29,6 +29,11 @@ static void signal_handler(int signal)
}
}

const struct timespec interval = {
.tv_sec = 0,
.tv_nsec = 50000000,
};

int main(void)
{
signal(SIGINT, signal_handler);
Expand All @@ -51,7 +56,7 @@ int main(void)
while (!exit_requested)
{
score_lcm_alive_report_alive(alive);
usleep(50000);
nanosleep(&interval, NULL);
}

score_lcm_alive_deinitialize(alive);
Expand Down
2 changes: 1 addition & 1 deletion examples/control_application/control_daemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ void signalHandler(int) {
exitRequested = true;
}

int main(int argc, char** argv) {
int main() {
signal(SIGINT, signalHandler);
signal(SIGTERM, signalHandler);

Expand Down
4 changes: 2 additions & 2 deletions score/health_monitor/src/cpp/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,12 @@ class TimeRange
SCORE_LANGUAGE_FUTURECPP_PRECONDITION(min_ms_ <= max_ms_);
}

const uint32_t min_ms() const
uint32_t min_ms() const
{
return min_ms_.count();
}

const uint32_t max_ms() const
uint32_t max_ms() const
{
return max_ms_.count();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ inline score::concurrency::InterruptibleFuture<void> GetErrorFuture(ExecErrc err
}

ControlClient::ControlClient() noexcept {
static std::function<void(const score::lcm::ExecutionErrorEvent&)> undefinedStateCallback = [](const score::lcm::ExecutionErrorEvent& event) {};
static std::function<void(const score::lcm::ExecutionErrorEvent&)> undefinedStateCallback =
[]([[maybe_unused]] const score::lcm::ExecutionErrorEvent& event) {};

try {
control_client_impl_ = std::make_unique<ControlClientImpl>(undefinedStateCallback);
} catch (...) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ namespace
{
/// @brief Prefix for all log messages
// coverity[autosar_cpp14_a2_10_4_violation:FALSE] Empty namespace ensures uniqueness for cpp file scope
static constexpr const char* kLogPrefix{"Factory for FlatCfg AR24-11:"};
static constexpr const std::string_view kLogPrefix{"Factory for FlatCfg AR24-11:"};

std::unique_ptr<char[]> read_flatbuffer_file(const std::string& f_filename_r)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ namespace
{
/// @brief Prefix for all log messages
// coverity[autosar_cpp14_a2_10_4_violation:FALSE] Empty namespace ensures uniqueness for cpp file scope
static constexpr const char* kLogPrefix{"Factory for FlatCfg MachineConfig:"};
static constexpr const std::string_view kLogPrefix{"Factory for FlatCfg MachineConfig:"};

/// @brief Update a field in case the provided value is not the flatbuffer default value
/// @note In case of optional integer values in flatbuffer files, the flatbuffer API will just return 0 if the value was
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ using NanoSecondType = timers::NanoSecondType;

namespace
{
static constexpr char const* kLogPrefix{"Factory for FlatCfg MachineConfig:"};
static constexpr const std::string_view kLogPrefix{"Factory for FlatCfg MachineConfig:"};
} // namespace

MachineConfigFactory::MachineConfigFactory() noexcept(true) : watchdog::IDeviceConfigFactory()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -930,10 +930,8 @@ bool ConfigurationManager::checkOrSetFlatConfigEnvVar(const std::string& name, c
if (setenv(name.c_str(), path.c_str(), overwrite_) == 0)
{
result = true;
}
else
{
LM_LOG_DEBUG() << name.c_str() << "not set, so default flat config binary path loaded";
} else {
LM_LOG_DEBUG() << name << "not set, so default flat config binary path loaded";
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace

template <typename T>
score::cpp::expected<T, IConfigLoader::Error> requireScalarValue(const ::flatbuffers::Optional<T>& field,
const char* field_name)
const std::string_view field_name)
{
if (!field.has_value())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ namespace details
// --- Range validation ---

template <typename TargetT>
score::cpp::expected<TargetT, IConfigLoader::Error> validateRange(int64_t value, const char* field_name)
score::cpp::expected<TargetT, IConfigLoader::Error> validateRange(int64_t value, const std::string_view field_name)
{
// Asserts ensure that std::numeric_limits<TargetT>::min() and std::numeric_limits<TargetT>::max() can be
// safely cast to int64_t for the range check:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ TEST_F(ProcessStateClient_UT, ProcessStateClient_QueueOneProcess_Succeeds)
.id = score::lcm::IdentifierHash("Process1"),
.processStateId = score::lcm::ProcessState::kRunning,
.processGroupStateId = score::lcm::IdentifierHash("PGState1"),
.systemClockTimestamp = {},
};

// Queue one process
Expand Down Expand Up @@ -91,6 +92,7 @@ TEST_F(ProcessStateClient_UT, ProcessStateClient_QueueMaxNumberOfProcesses_Succe
.id = score::lcm::IdentifierHash("Process" + std::to_string(i)),
.processStateId = score::lcm::ProcessState::kRunning,
.processGroupStateId = score::lcm::IdentifierHash("PGState" + std::to_string(i)),
.systemClockTimestamp = {},
};
bool queued = notifier_->queuePosixProcess(process);
ASSERT_TRUE(queued) << "Failed to queue process at index " << i;
Expand Down Expand Up @@ -121,6 +123,7 @@ TEST_F(ProcessStateClient_UT, ProcessStateClient_QueueOneProcessTooMany_Fails)
.id = score::lcm::IdentifierHash("Process1"),
.processStateId = score::lcm::ProcessState::kRunning,
.processGroupStateId = score::lcm::IdentifierHash("PGState1"),
.systemClockTimestamp = {},
};

// Fill the buffer to capacity
Expand All @@ -130,6 +133,7 @@ TEST_F(ProcessStateClient_UT, ProcessStateClient_QueueOneProcessTooMany_Fails)
.id = score::lcm::IdentifierHash("Process" + std::to_string(i)),
.processStateId = score::lcm::ProcessState::kRunning,
.processGroupStateId = score::lcm::IdentifierHash("PGState" + std::to_string(i)),
.systemClockTimestamp = {},
};
bool queued = notifier_->queuePosixProcess(proc);
ASSERT_TRUE(queued) << "Failed to queue process at index " << i;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ bool WatchdogImpl::init(std::int64_t f_cycleTimeInNs, const IDeviceConfigFactory
{
isSuccess = false;
watchdogDevices.clear();
LM_LOG_ERROR() << "Watchdog: Watchdog initialization failed:" << e.what();
LM_LOG_ERROR() << "Watchdog: Watchdog initialization failed:" << std::string(e.what());
}
return isSuccess;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ TEST(ComplexMonitoring, ComponentComplexMonitoring)
// When heartbeats are no longer sent...
}

int main(int argc, char** argv)
int main()
{
TestRunner(__FILE__, TerminationBehavior::kContinue).RunTests();
// Then expect kill due to recovery action (verified by control client)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ TEST(ComplexMonitoring, ControlClientMock)
}
}

int main(int argc, char** argv)
int main()
{
return TestRunner(__FILE__, TerminationBehavior::kWait, TerminationNotification::kTestEnd).RunTests();
}
2 changes: 1 addition & 1 deletion tests/integration/crash_on_startup/control_client_mock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ TEST(CrashOnStartup, ControlClientMock)
}
}

int main(int argc, char** argv)
int main()
{
return TestRunner(__FILE__, TerminationBehavior::kWait, TerminationNotification::kTestEnd).RunTests();
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ TEST(RecoveryActionComplexRepFailure, ControlClientMock) {
TEST_STEP("Activate RunTarget Off") { client.ActivateRunTarget("Off"); }
}

int main(int argc, char **argv) {
int main() {
return TestRunner(__FILE__, TerminationBehavior::kContinue,
TerminationNotification::kTestEnd)
.RunTests();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ TEST(ProcessCrashMonitoring, ControlClientMock)
}
}

int main(int argc, char** argv)
int main()
{
return TestRunner(__FILE__, TerminationBehavior::kWait, TerminationNotification::kTestEnd).RunTests();
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ TEST(RecoveryActionSimpleRepFailure, ControlClientMock) {
TEST_STEP("Activate RunTarget Off") { client.ActivateRunTarget("Off"); }
}

int main(int argc, char **argv) {
int main() {
return TestRunner(__FILE__, TerminationBehavior::kContinue,
TerminationNotification::kTestEnd)
.RunTests();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ TEST(MissingBinaryFailure, ControlClientMock)
}
}

int main(int argc, char** argv)
int main()
{
return TestRunner(__FILE__, TerminationBehavior::kContinue, TerminationNotification::kTestEnd).RunTests();
}
2 changes: 1 addition & 1 deletion tests/integration/smoke/control_daemon_mock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ TEST(Smoke, Daemon)
}
}

int main(int argc, char** argv)
int main()
{
return TestRunner(__FILE__, TerminationBehavior::kWait, TerminationNotification::kTestEnd).RunTests();
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ TEST(SwitchRunTarget, ControlClientMock)
}
}

int main(int argc, char** argv)
int main()
{
return TestRunner(__FILE__, TerminationBehavior::kWait, TerminationNotification::kTestEnd).RunTests();
}
4 changes: 2 additions & 2 deletions tests/utils/test_helper/complex_reporting_process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ char **g_argv;
class LifecycleApp final : public score::mw::lifecycle::Application {
public:
std::int32_t
Initialize(const score::mw::lifecycle::ApplicationContext &appCtx) override {
Initialize([[maybe_unused]] const score::mw::lifecycle::ApplicationContext &appCtx) override {
optind = 1;

return 0;
}

std::int32_t Run(const score::cpp::stop_token &stopToken) override {
std::int32_t Run([[maybe_unused]] const score::cpp::stop_token &stopToken) override {
return EXIT_SUCCESS;
}
};
Expand Down
Loading