tests: reduce excessive whitespace
I know that clang-format is happy to align the macro trailing
backslashes, but enough is enough. Also, having a source file "correctly
formatted" by a tool is not a good thing if the text starts at column
105.
Also, clang changed the AlignEscapedNewlinesLeft to an enum
AlignEscapedNewlines, and IMHO this new option is what makes most sense.
Still, it would try to rewrap some stuff for me, but I think this is a
good step.
Change-Id: Id03e489ada2b51ba4698ce263f0a915cebf27ef6
diff --git a/tests/dbus-helpers/dbus_rauc_server.cpp b/tests/dbus-helpers/dbus_rauc_server.cpp
index ff5cbcc..b5436ad 100644
--- a/tests/dbus-helpers/dbus_rauc_server.cpp
+++ b/tests/dbus-helpers/dbus_rauc_server.cpp
@@ -10,15 +10,15 @@
const std::string objectPathManager = "/";
}
-#define PROGRESS(perc, msg, depth) \
+#define PROGRESS(perc, msg, depth) \
m_propProgress = sdbus::make_struct(perc, std::string(msg), depth); \
m_manager->emitPropertiesChangedSignal(interfaceManager, {"Progress"});
-#define OPERATION(op) \
+#define OPERATION(op) \
m_propOperation = op; \
m_manager->emitPropertiesChangedSignal(interfaceManager, {"Operation"});
-#define LAST_ERROR(msg) \
+#define LAST_ERROR(msg) \
m_propLastError = msg; \
m_manager->emitPropertiesChangedSignal(interfaceManager, {"LastError"});
@@ -72,7 +72,8 @@
throw sdbus::Error("org.gtk.GDBus.UnmappedGError.Quark._g_2dio_2derror_2dquark.Code30", "Already processing a different method");
}
});
- m_manager->registerMethod("InstallBundle").onInterface(interfaceManager).implementedAs([this]([[maybe_unused]] const std::string& source, [[maybe_unused]] const std::map<std::string, sdbus::Variant>& args) {
+ m_manager->registerMethod("InstallBundle").onInterface(interfaceManager).implementedAs(
+ [this]([[maybe_unused]] const std::string& source, [[maybe_unused]] const std::map<std::string, sdbus::Variant>& args) {
std::lock_guard<std::mutex> lock(m_mtx);
if (!m_operationInProgress) {
m_operationInProgress = true;
diff --git a/tests/hardware_thresholds.cpp b/tests/hardware_thresholds.cpp
index d86c790..4f0671c 100644
--- a/tests/hardware_thresholds.cpp
+++ b/tests/hardware_thresholds.cpp
@@ -17,22 +17,22 @@
MAKE_MOCK1(record, void(State));
};
-#define EVENTS_INIT \
+#define EVENTS_INIT \
trompeloeil::sequence seq; \
- Transitions eventLog; \
+ Transitions eventLog; \
Watcher w(thr);
-#define EXPECT_EVENT(E, STATE) \
- { \
- auto statusChange = E; \
- REQUIRE(statusChange); \
+#define EXPECT_EVENT(E, STATE) \
+ { \
+ auto statusChange = E; \
+ REQUIRE(statusChange); \
REQUIRE(statusChange == STATE); \
}
-#define EXPECT_NONE(E) \
- { \
- auto statusChange = E; \
+#define EXPECT_NONE(E) \
+ { \
+ auto statusChange = E; \
REQUIRE(!statusChange); \
}
diff --git a/tests/health_systemd-units.cpp b/tests/health_systemd-units.cpp
index b6cfbe6..fc7929e 100644
--- a/tests/health_systemd-units.cpp
+++ b/tests/health_systemd-units.cpp
@@ -21,8 +21,11 @@
using namespace std::chrono_literals;
-#define REQUIRE_NEW_ALARM_INVENTORY_UNIT(UNIT) REQUIRE_NEW_ALARM_INVENTORY_RESOURCE(alarmsWatcher, "velia-alarms:systemd-unit-failure", "", UNIT)
-#define REQUIRE_ALARM_RPC(UNIT, SEVERITY, TEXT) REQUIRE_NEW_ALARM(alarmsWatcher, "velia-alarms:systemd-unit-failure", "", UNIT, SEVERITY, TEXT)
+#define REQUIRE_NEW_ALARM_INVENTORY_UNIT(UNIT) \
+ REQUIRE_NEW_ALARM_INVENTORY_RESOURCE(alarmsWatcher, "velia-alarms:systemd-unit-failure", "", UNIT)
+
+#define REQUIRE_ALARM_RPC(UNIT, SEVERITY, TEXT) \
+ REQUIRE_NEW_ALARM(alarmsWatcher, "velia-alarms:systemd-unit-failure", "", UNIT, SEVERITY, TEXT)
TEST_CASE("systemd unit state monitoring (alarms)")
{
diff --git a/tests/sysrepo-helpers/alarms.h b/tests/sysrepo-helpers/alarms.h
index 45cdd41..4267388 100644
--- a/tests/sysrepo-helpers/alarms.h
+++ b/tests/sysrepo-helpers/alarms.h
@@ -77,19 +77,24 @@
};
// checks if the alarm is contained in AlarmInventory
-#define WITH_ALARM_IN_INVENTORY(INV, ALARM_TYPE, ALARM_QUALIFIER, RESOURCE, SEVERITY) LR_WITH(INV.contains(ALARM_TYPE, ALARM_QUALIFIER, RESOURCE, SEVERITY))
+#define WITH_ALARM_IN_INVENTORY(INV, ALARM_TYPE, ALARM_QUALIFIER, RESOURCE, SEVERITY) \
+ LR_WITH(INV.contains(ALARM_TYPE, ALARM_QUALIFIER, RESOURCE, SEVERITY))
// inserts the alarm in AlarmInventory as a side effect
-#define INSERT_INTO_INVENTORY(INV, ALARM_TYPE, ALARM_QUALIFIER, RESOURCE, SEVERITIES) LR_SIDE_EFFECT(INV.add(ALARM_TYPE, ALARM_QUALIFIER, RESOURCE, SEVERITIES))
+#define INSERT_INTO_INVENTORY(INV, ALARM_TYPE, ALARM_QUALIFIER, RESOURCE, SEVERITIES) \
+ LR_SIDE_EFFECT(INV.add(ALARM_TYPE, ALARM_QUALIFIER, RESOURCE, SEVERITIES))
#define REQUIRE_NEW_ALARM_INVENTORY_ENTRY(WATCHER, ALARM_TYPE, ALARM_QUALIFIER, RESOURCES, SEVERITIES, WILL_CLEAR, DESCRIPTION) \
- REQUIRE_DATASTORE_CHANGE(WATCHER.datastoreWatcher, constructAlarmInventoryChange(ALARM_TYPE, ALARM_QUALIFIER, RESOURCES, SEVERITIES, WILL_CLEAR, DESCRIPTION)) \
+ REQUIRE_DATASTORE_CHANGE(WATCHER.datastoreWatcher, \
+ constructAlarmInventoryChange(ALARM_TYPE, ALARM_QUALIFIER, RESOURCES, SEVERITIES, WILL_CLEAR, DESCRIPTION)) \
.INSERT_INTO_INVENTORY(WATCHER.alarmInventory, ALARM_TYPE, ALARM_QUALIFIER, RESOURCES, SEVERITIES)
#define REQUIRE_NEW_ALARM_INVENTORY_RESOURCE(WATCHER, ALARM_TYPE, ALARM_QUALIFIER, RESOURCE) \
REQUIRE_DATASTORE_CHANGE(WATCHER.datastoreWatcher, \
(ValueChanges{ \
- {"/ietf-alarms:alarms/alarm-inventory/alarm-type[alarm-type-id='" ALARM_TYPE "'][alarm-type-qualifier='" ALARM_QUALIFIER "']/resource[1]", RESOURCE}, \
+ {"/ietf-alarms:alarms/alarm-inventory/alarm-type" \
+ "[alarm-type-id='" ALARM_TYPE "'][alarm-type-qualifier='" ALARM_QUALIFIER "']/resource[1]", \
+ RESOURCE}, \
})) \
.INSERT_INTO_INVENTORY(WATCHER.alarmInventory, ALARM_TYPE, ALARM_QUALIFIER, (std::set<std::string>{RESOURCE}), (std::set<std::string>{}))
diff --git a/tests/sysrepo-helpers/notifications.cpp b/tests/sysrepo-helpers/notifications.cpp
index 756943e..bcd8582 100644
--- a/tests/sysrepo-helpers/notifications.cpp
+++ b/tests/sysrepo-helpers/notifications.cpp
@@ -9,20 +9,21 @@
#include "sysrepo-helpers/common.h"
NotificationWatcher::NotificationWatcher(sysrepo::Session& session, const std::string& xpath)
- : m_sub{session.onNotification(moduleFromXpath(xpath),
- [this, xpath](sysrepo::Session, uint32_t, const sysrepo::NotificationType type, const std::optional<libyang::DataNode> tree, const sysrepo::NotificationTimeStamp) {
- if (type != sysrepo::NotificationType::Realtime) {
- return;
- }
- Values data;
- for (const auto& it : tree->findPath(xpath)->childrenDfs()) {
- if (!it.isTerm()) {
- continue;
- }
- data[it.path().substr(xpath.size() + 1 /* trailing slash */)] = std::visit(libyang::ValuePrinter{}, it.asTerm().value());
- }
- notified(data);
- },
- xpath)}
+ : m_sub{session.onNotification(
+ moduleFromXpath(xpath),
+ [this, xpath](sysrepo::Session, uint32_t, const sysrepo::NotificationType type, const std::optional<libyang::DataNode> tree, const sysrepo::NotificationTimeStamp) {
+ if (type != sysrepo::NotificationType::Realtime) {
+ return;
+ }
+ Values data;
+ for (const auto& it : tree->findPath(xpath)->childrenDfs()) {
+ if (!it.isTerm()) {
+ continue;
+ }
+ data[it.path().substr(xpath.size() + 1 /* trailing slash */)] = std::visit(libyang::ValuePrinter{}, it.asTerm().value());
+ }
+ notified(data);
+ },
+ xpath)}
{
}
diff --git a/tests/sysrepo_ietf-hardware.cpp b/tests/sysrepo_ietf-hardware.cpp
index 50911d0..e69a459 100644
--- a/tests/sysrepo_ietf-hardware.cpp
+++ b/tests/sysrepo_ietf-hardware.cpp
@@ -14,9 +14,16 @@
using namespace std::literals;
#define COMPONENT(RESOURCE) "/ietf-hardware:hardware/component[name='" RESOURCE "']"
-#define REQUIRE_ALARM_INVENTORY_ADD_ALARM(ALARM_TYPE, RESOURCE) REQUIRE_NEW_ALARM_INVENTORY_ENTRY(alarmWatcher, ALARM_TYPE, "", (std::set<std::string>{COMPONENT(RESOURCE)}), (std::set<std::string>{}), std::nullopt, std::nullopt)
-#define REQUIRE_ALARM_INVENTORY_ADD_RESOURCE(ALARM_TYPE, RESOURCE) REQUIRE_NEW_ALARM_INVENTORY_RESOURCE(alarmWatcher, ALARM_TYPE, "", COMPONENT(RESOURCE))
-#define REQUIRE_ALARM_RPC(ALARM_TYPE, RESOURCE, SEVERITY, TEXT) REQUIRE_NEW_ALARM(alarmWatcher, ALARM_TYPE, "", COMPONENT(RESOURCE), SEVERITY, TEXT)
+
+#define REQUIRE_ALARM_INVENTORY_ADD_ALARM(ALARM_TYPE, RESOURCE) \
+ REQUIRE_NEW_ALARM_INVENTORY_ENTRY(alarmWatcher, ALARM_TYPE, "", (std::set<std::string>{COMPONENT(RESOURCE)}), \
+ (std::set<std::string>{}), std::nullopt, std::nullopt)
+
+#define REQUIRE_ALARM_INVENTORY_ADD_RESOURCE(ALARM_TYPE, RESOURCE) \
+ REQUIRE_NEW_ALARM_INVENTORY_RESOURCE(alarmWatcher, ALARM_TYPE, "", COMPONENT(RESOURCE))
+
+#define REQUIRE_ALARM_RPC(ALARM_TYPE, RESOURCE, SEVERITY, TEXT) \
+ REQUIRE_NEW_ALARM(alarmWatcher, ALARM_TYPE, "", COMPONENT(RESOURCE), SEVERITY, TEXT)
TEST_CASE("IETF Hardware with sysrepo")
{
@@ -58,12 +65,17 @@
auto ietfHardware = std::make_shared<velia::ietf_hardware::IETFHardware>();
ietfHardware->registerDataReader(StaticData("ne", std::nullopt, {{"class", "iana-hardware:chassis"}, {"mfg-name", "CESNET"s}}));
ietfHardware->registerDataReader(SysfsValue<SensorType::Temperature>("ne:temperature-cpu", "ne", sysfsTempCpu, 1));
- ietfHardware->registerDataReader(SysfsValue<SensorType::Power>("ne:power", "ne", sysfsPower, 1, Thresholds<int64_t>{
- .criticalLow = OneThreshold<int64_t>{8'000'000, 500'000},
- .warningLow = OneThreshold<int64_t>{10'000'000, 500'000},
- .warningHigh = OneThreshold<int64_t>{20'000'000, 500'000},
- .criticalHigh = OneThreshold<int64_t>{22'000'000, 500'000},
- }));
+ ietfHardware->registerDataReader(SysfsValue<SensorType::Power>(
+ "ne:power",
+ "ne",
+ sysfsPower,
+ 1,
+ Thresholds<int64_t>{
+ .criticalLow = OneThreshold<int64_t>{8'000'000, 500'000},
+ .warningLow = OneThreshold<int64_t>{10'000'000, 500'000},
+ .warningHigh = OneThreshold<int64_t>{20'000'000, 500'000},
+ .criticalHigh = OneThreshold<int64_t>{22'000'000, 500'000},
+ }));
/* Some data readers (like our PSU reader, see the FspYhPsu test) may set oper-state to enabled/disabled depending on whether the device is present and Some
* data might not even be pushed (e.g. the child sensors).
@@ -203,7 +215,8 @@
.IN_SEQUENCE(seq1);
REQUIRE_ALARM_RPC("velia-alarms:sensor-missing-alarm", "ne:psu", "critical", "PSU missing.").IN_SEQUENCE(seq1);
REQUIRE_ALARM_RPC("velia-alarms:sensor-low-value-alarm", "ne:power", "cleared", "Sensor value crossed low threshold.").IN_SEQUENCE(seq1);
- REQUIRE_ALARM_RPC("velia-alarms:sensor-missing-alarm", "ne:psu:child", "warning", "Sensor value not reported. Maybe the sensor was unplugged?").IN_SEQUENCE(seq1);
+ REQUIRE_ALARM_RPC("velia-alarms:sensor-missing-alarm", "ne:psu:child", "warning",
+ "Sensor value not reported. Maybe the sensor was unplugged?").IN_SEQUENCE(seq1);
REQUIRE_CALL(*sysfsTempCpu, attribute("temp1_input")).LR_RETURN(cpuTempValue).TIMES(AT_LEAST(1));
REQUIRE_CALL(*sysfsPower, attribute("power1_input")).LR_RETURN(powerValue).TIMES(AT_LEAST(1));
cpuTempValue = 222;
@@ -293,8 +306,10 @@
{COMPONENT("ne:power") "/sensor-data/oper-status", "nonoperational"},
}))
.IN_SEQUENCE(seq1);
- REQUIRE_ALARM_RPC("velia-alarms:sensor-nonoperational", "ne:power", "warning", "Sensor is nonoperational. The values it reports may not be relevant.").IN_SEQUENCE(seq1);
- REQUIRE_ALARM_RPC("velia-alarms:sensor-high-value-alarm", "ne:power", "critical", "Sensor value crossed high threshold.").IN_SEQUENCE(seq1);
+ REQUIRE_ALARM_RPC("velia-alarms:sensor-nonoperational", "ne:power", "warning",
+ "Sensor is nonoperational. The values it reports may not be relevant.").IN_SEQUENCE(seq1);
+ REQUIRE_ALARM_RPC("velia-alarms:sensor-high-value-alarm", "ne:power", "critical",
+ "Sensor value crossed high threshold.").IN_SEQUENCE(seq1);
powerValue = 2'999'999'999;
waitForCompletionAndBitMore(seq1);
@@ -315,7 +330,8 @@
{COMPONENT("ne:power") "/sensor-data/oper-status", "ok"},
}))
.IN_SEQUENCE(seq1);
- REQUIRE_ALARM_RPC("velia-alarms:sensor-nonoperational", "ne:power", "cleared", "Sensor is nonoperational. The values it reports may not be relevant.").IN_SEQUENCE(seq1);
+ REQUIRE_ALARM_RPC("velia-alarms:sensor-nonoperational", "ne:power", "cleared",
+ "Sensor is nonoperational. The values it reports may not be relevant.").IN_SEQUENCE(seq1);
powerValue = -999'999'999;
waitForCompletionAndBitMore(seq1);
}
diff --git a/tests/test_log_setup.h b/tests/test_log_setup.h
index 8541f04..86984e2 100644
--- a/tests/test_log_setup.h
+++ b/tests/test_log_setup.h
@@ -13,22 +13,22 @@
#include "utils/sysrepo.h"
#include "utils/log.h"
-#define IMPL_TEST_INIT_LOGS_1 \
- spdlog::drop_all(); \
+#define IMPL_TEST_INIT_LOGS_1 \
+ spdlog::drop_all(); \
auto test_logger = std::make_shared<spdlog::sinks::ansicolor_stderr_sink_mt>(); \
velia::utils::initLogs(test_logger);
-#define IMPL_TEST_INIT_LOGS_2 \
+#define IMPL_TEST_INIT_LOGS_2 \
spdlog::set_pattern("%S.%e [%t %n %L] %v"); \
- spdlog::set_level(spdlog::level::trace); \
+ spdlog::set_level(spdlog::level::trace); \
spdlog::get("sysrepo")->set_level(spdlog::level::info); \
- trompeloeil::stream_tracer tracer {std::cout};
+ trompeloeil::stream_tracer tracer{std::cout};
-#define TEST_INIT_LOGS \
+#define TEST_INIT_LOGS \
IMPL_TEST_INIT_LOGS_1 \
IMPL_TEST_INIT_LOGS_2
-#define TEST_SYSREPO_INIT_LOGS \
- IMPL_TEST_INIT_LOGS_1 \
+#define TEST_SYSREPO_INIT_LOGS \
+ IMPL_TEST_INIT_LOGS_1 \
velia::utils::initLogsSysrepo(); \
IMPL_TEST_INIT_LOGS_2