case BT_CLOCK_CORRELATION_VALIDATOR_ERROR_TYPE_EXPECTING_NO_CLOCK_CLASS_GOT_ONE:
BT_ASSERT_POST_DEV(NEXT_METHOD_NAME,
"stream-class-has-no-clock-class", false,
- "Expecting no clock class, got one.");
+ "Expecting no clock class, got one: %![cc-]+K",
+ actual_clock_cls);
+
case BT_CLOCK_CORRELATION_VALIDATOR_ERROR_TYPE_EXPECTING_ORIGIN_UNIX_GOT_NO_CLOCK_CLASS:
BT_ASSERT_POST_DEV(NEXT_METHOD_NAME,
"stream-class-has-clock-class-with-unix-epoch-origin", false,
- "Expecting a clock class, got none.");
+ "Expecting a clock class with Unix epoch origin, got none.");
+
case BT_CLOCK_CORRELATION_VALIDATOR_ERROR_TYPE_EXPECTING_ORIGIN_UNIX_GOT_UNKNOWN_ORIGIN:
BT_ASSERT_POST_DEV(NEXT_METHOD_NAME,
"clock-class-has-unix-epoch-origin", false,
- "Expecting a clock class with Unix epoch origin: %![cc-]+K",
+ "Expecting a clock class with Unix epoch origin, got one with "
+ "unknown origin: %![cc-]+K",
actual_clock_cls);
+
case BT_CLOCK_CORRELATION_VALIDATOR_ERROR_TYPE_EXPECTING_ORIGIN_UNKNOWN_WITH_UUID_GOT_NO_CLOCK_CLASS:
BT_ASSERT_POST_DEV(NEXT_METHOD_NAME,
"stream-class-has-clock-class-with-uuid", false,
- "Expecting a clock class, got none.");
+ "Expecting a clock class with unknown origin and a specific UUID, "
+ "got none: expected-uuid=%!u",
+ bt_clock_class_get_uuid(ref_clock_cls));
+
case BT_CLOCK_CORRELATION_VALIDATOR_ERROR_TYPE_EXPECTING_ORIGIN_UNKNOWN_WITH_UUID_GOT_UNIX_ORIGIN:
BT_ASSERT_POST_DEV(NEXT_METHOD_NAME,
- "clock-class-has-non-unix-epoch-origin", false,
- "Expecting a clock class without Unix epoch origin: %![cc-]+K",
- actual_clock_cls);
+ "clock-class-has-unknown-origin", false,
+ "Expecting a clock class with unknown origin and a specific UUID, "
+ "got one with Unix epoch origin: %![cc-]+K, expected-uuid=%!u",
+ actual_clock_cls, bt_clock_class_get_uuid(ref_clock_cls));
+
case BT_CLOCK_CORRELATION_VALIDATOR_ERROR_TYPE_EXPECTING_ORIGIN_UNKNOWN_WITH_UUID_GOT_WITHOUT_UUID:
BT_ASSERT_POST_DEV(NEXT_METHOD_NAME,
"clock-class-has-uuid", false,
- "Expecting a clock class with UUID: %![cc-]+K",
- actual_clock_cls);
+ "Expecting a clock class with unknown origin and a specific UUID, "
+ "got one without a UUID: %![cc-]+K, expected-uuid=%!u",
+ actual_clock_cls, bt_clock_class_get_uuid(ref_clock_cls));
+
case BT_CLOCK_CORRELATION_VALIDATOR_ERROR_TYPE_EXPECTING_ORIGIN_UNKNOWN_WITH_UUID_GOT_OTHER_UUID:
BT_ASSERT_POST_DEV(NEXT_METHOD_NAME,
"clock-class-has-expected-uuid", false,
- "Expecting a clock class with UUID, got one with a different UUID: "
- "%![cc-]+K, expected-uuid=%!u",
+ "Expecting a clock class with unknown origin and a specific UUID, "
+ "got one with a different UUID: %![cc-]+K, expected-uuid=%!u",
actual_clock_cls, bt_clock_class_get_uuid(ref_clock_cls));
case BT_CLOCK_CORRELATION_VALIDATOR_ERROR_TYPE_EXPECTING_ORIGIN_UNKNOWN_WITHOUT_UUID_GOT_NO_CLOCK_CLASS:
BT_ASSERT_POST_DEV(NEXT_METHOD_NAME,
"stream-class-has-clock-class", false,
- "Expecting a clock class, got none.");
+ "Expecting a clock class, got none: %![expected-cc-]+K",
+ ref_clock_cls);
+
case BT_CLOCK_CORRELATION_VALIDATOR_ERROR_TYPE_EXPECTING_ORIGIN_UNKNOWN_WITHOUT_UUID_GOT_OTHER_CLOCK_CLASS:
BT_ASSERT_POST_DEV(NEXT_METHOD_NAME,
"clock-class-is-expected", false,
const auto actualClkCls = error.actualClockCls();
const auto refClkCls = error.refClockCls();
+ const auto formatClkClsOrigin = [](const bt2::ConstClockClass clockCls,
+ const char * const prefix) {
+ return fmt::format("{}clock-class-origin-is-unix-epoch={}", prefix,
+ clockCls.origin().isUnixEpoch());
+ };
+ const auto formatClkClsUuid = [](const bt2::ConstClockClass clockCls,
+ const char * const prefix) {
+ if (const auto uuid = clockCls.uuid()) {
+ return fmt::format("{}clock-class-uuid={}", prefix, *uuid);
+ } else {
+ return fmt::format("{}clock-class-uuid=(none)", prefix);
+ }
+ };
+ const auto formatExpClkClsUuid = [&] {
+ return formatClkClsUuid(*refClkCls, "expected-");
+ };
+ const auto formatClkCls = [&](const bt2::ConstClockClass clockCls,
+ const char * const prefix) {
+ return fmt::format("{}clock-class-addr={}, {}clock-class-name={}, {}, {}", prefix,
+ fmt::ptr(clockCls.libObjPtr()), prefix, clockCls.name(),
+ formatClkClsOrigin(clockCls, prefix),
+ formatClkClsUuid(clockCls, prefix));
+ };
+ const auto formatActClkCls = [&] {
+ return formatClkCls(*actualClkCls, "");
+ };
+ const auto formatExpClkCls = [&] {
+ return formatClkCls(*refClkCls, "expected-");
+ };
+ const auto formatStreamCls = [&](const bool withTrailingComma) {
+ if (const auto streamCls = error.streamCls()) {
+ return fmt::format(
+ "stream-class-addr={}, stream-class-name=\"{}\", stream-class-id={}{}",
+ fmt::ptr(streamCls->libObjPtr()), streamCls->name(), streamCls->id(),
+ withTrailingComma ? ", " : "");
+ } else {
+ return std::string {};
+ }
+ };
switch (error.type()) {
case Type::ExpectingNoClockClassGotOne:
- BT_CPPLOGE_APPEND_CAUSE_AND_THROW(
- bt2::Error,
- "Expecting no clock class, but got one: clock-class-addr={}, clock-class-name={}",
- fmt::ptr(actualClkCls->libObjPtr()), actualClkCls->name());
+ BT_CPPLOGE_APPEND_CAUSE_AND_THROW(bt2::Error, "Expecting no clock class, got one: {}{}",
+ formatStreamCls(true), formatActClkCls());
case Type::ExpectingOriginUnixGotNoClockClass:
- case Type::ExpectingOriginUnknownWithUuidGotNoClockClass:
- case Type::ExpectingOriginUnknownWithoutUuidGotNoClockClass:
BT_CPPLOGE_APPEND_CAUSE_AND_THROW(
- bt2::Error,
- "Expecting a clock class, but got none: stream-class-addr={}, "
- "stream-class-name=\"{}\", stream-class-id={}",
- fmt::ptr(error.streamCls()->libObjPtr()), error.streamCls()->name(),
- error.streamCls()->id());
+ bt2::Error, "Expecting a clock class with Unix epoch origin, got none: {}",
+ formatStreamCls(false));
case Type::ExpectingOriginUnixGotUnknownOrigin:
BT_CPPLOGE_APPEND_CAUSE_AND_THROW(
bt2::Error,
- "Expecting a clock class having a Unix epoch origin, but got one not having a Unix "
- "epoch origin: clock-class-addr={}, clock-class-name={}",
- fmt::ptr(actualClkCls->libObjPtr()), actualClkCls->name());
+ "Expecting a clock class with Unix epoch origin, got one with unknown "
+ "origin: {}{}",
+ formatStreamCls(true), formatActClkCls());
+
+ case Type::ExpectingOriginUnknownWithUuidGotNoClockClass:
+ BT_CPPLOGE_APPEND_CAUSE_AND_THROW(
+ bt2::Error,
+ "Expecting a clock class with unknown origin and a specific UUID, got none: {}",
+ formatStreamCls(true), formatExpClkClsUuid());
case Type::ExpectingOriginUnknownWithUuidGotUnixOrigin:
BT_CPPLOGE_APPEND_CAUSE_AND_THROW(
bt2::Error,
- "Expecting a clock class not having a Unix epoch origin, "
- "but got one having a Unix epoch origin: "
- "clock-class-addr={}, clock-class-name={}",
- fmt::ptr(actualClkCls->libObjPtr()), actualClkCls->name());
+ "Expecting a clock class with unknown origin and a specific UUID, got one "
+ "with Unix epoch origin: {}{}, {}",
+ formatStreamCls(true), formatActClkCls(), formatExpClkClsUuid());
case Type::ExpectingOriginUnknownWithUuidGotWithoutUuid:
BT_CPPLOGE_APPEND_CAUSE_AND_THROW(
bt2::Error,
- "Expecting a clock class with a UUID, but got one without a UUID: "
- "clock-class-addr={}, clock-class-name={}",
- fmt::ptr(actualClkCls->libObjPtr()), actualClkCls->name());
+ "Expecting a clock class with unknown origin and a specific UUID, got one "
+ "without a UUID: {}{}, {}",
+ formatStreamCls(true), formatActClkCls(), formatExpClkClsUuid());
case Type::ExpectingOriginUnknownWithUuidGotOtherUuid:
BT_CPPLOGE_APPEND_CAUSE_AND_THROW(
bt2::Error,
- "Expecting a clock class with a specific UUID, but got one with a different UUID: "
- "clock-class-addr={}, clock-class-name={}, expected-uuid=\"{}\", uuid=\"{}\"",
- fmt::ptr(actualClkCls->libObjPtr()), actualClkCls->name(), *refClkCls->uuid(),
- *actualClkCls->uuid());
+ "Expecting a clock class with unknown origin and a specific UUID, got one with "
+ "a different UUID: {}{}, {}",
+ formatStreamCls(true), formatActClkCls(), formatExpClkClsUuid());
+
+ case Type::ExpectingOriginUnknownWithoutUuidGotNoClockClass:
+ BT_CPPLOGE_APPEND_CAUSE_AND_THROW(bt2::Error, "Expecting a clock class, got none: {}{}",
+ formatStreamCls(true), formatExpClkCls());
case Type::ExpectingOriginUnknownWithoutUuidGotOtherClockClass:
- BT_CPPLOGE_APPEND_CAUSE_AND_THROW(
- bt2::Error,
- "Unexpected clock class: "
- "expected-clock-class-addr={}, expected-clock-class-name={}, "
- "actual-clock-class-addr={}, actual-clock-class-name={}",
- fmt::ptr(refClkCls->libObjPtr()), refClkCls->name(),
- fmt::ptr(actualClkCls->libObjPtr()), actualClkCls->name());
+ BT_CPPLOGE_APPEND_CAUSE_AND_THROW(bt2::Error, "Unexpected clock class: {}{}, {}",
+ formatStreamCls(true), formatActClkCls(),
+ formatExpClkCls());
}
}
}
[](const bt2::SelfComponent self) {
return self.createClockClass();
},
- "message-iterator-class-next-method:clock-class-has-non-unix-epoch-origin");
+ "message-iterator-class-next-method:clock-class-has-unknown-origin");
addValidCases(
[](const bt2::SelfComponent self) {
[](const bt2::SelfComponent self) {
return self.createClockClass();
},
- "no clock class followed by clock class", "Expecting no clock class, but got one"},
+ "no clock class followed by clock class", "Expecting no clock class, got one"},
{[](const bt2::SelfComponent self) {
return self.createClockClass();
},
noClockClass, "clock class with Unix epoch origin followed by no clock class",
- "Expecting a clock class, but got none"},
+ "Expecting a clock class with Unix epoch origin, got none"},
{[](const bt2::SelfComponent self) {
return self.createClockClass();
clockCls->originIsUnixEpoch(false);
return clockCls;
},
- "clock class with Unix epoch origin followed by clock class with other origin",
- "Expecting a clock class having a Unix epoch origin, but got one not having a Unix epoch origin"},
+ "clock class with Unix epoch origin followed by clock class with unknown origin",
+ "Expecting a clock class with Unix epoch origin, got one with unknown origin"},
{[](const bt2::SelfComponent self) {
const auto clockCls = self.createClockClass();
clockCls->originIsUnixEpoch(false).uuid(uuidA);
return clockCls;
},
- noClockClass, "clock class with other origin and a UUID followed by no clock class",
- "Expecting a clock class, but got none"},
+ noClockClass, "clock class with unknown origin and a UUID followed by no clock class",
+ "Expecting a clock class with unknown origin and a specific UUID, got none"},
{[](const bt2::SelfComponent self) {
const auto clockCls = self.createClockClass();
[](const bt2::SelfComponent self) {
return self.createClockClass();
},
- "clock class with other origin and a UUID followed by clock class with Unix epoch origin",
- "Expecting a clock class not having a Unix epoch origin, but got one having a Unix epoch origin"},
+ "clock class with unknown origin and a UUID followed by clock class with Unix epoch origin",
+ "Expecting a clock class with unknown origin and a specific UUID, got one with Unix epoch origin"},
{[](const bt2::SelfComponent self) {
const auto clockCls = self.createClockClass();
clockCls->originIsUnixEpoch(false);
return clockCls;
},
- "clock class with other origin and a UUID followed by clock class with other origin and no UUID",
- "Expecting a clock class with a UUID, but got one without a UUID"},
+ "clock class with unknown origin and a UUID followed by clock class with unknown origin and no UUID",
+ "Expecting a clock class with unknown origin and a specific UUID, got one without a UUID"},
{[](const bt2::SelfComponent self) {
const auto clockCls = self.createClockClass();
clockCls->originIsUnixEpoch(false).uuid(uuidB);
return clockCls;
},
- "clock class with other origin and a UUID followed by clock class with other origin and another UUID",
- "Expecting a clock class with a specific UUID, but got one with a different UUID"},
+ "clock class with unknown origin and a UUID followed by clock class with unknown origin and another UUID",
+ "Expecting a clock class with unknown origin and a specific UUID, got one with a different UUID"},
{[](const bt2::SelfComponent self) {
const auto clockCls = self.createClockClass();
clockCls->originIsUnixEpoch(false);
return clockCls;
},
- noClockClass, "clock class with other origin and no UUID followed by no clock class",
- "Expecting a clock class, but got none"},
+ noClockClass, "clock class with unknown origin and no UUID followed by no clock class",
+ "Expecting a clock class, got none"},
{[](const bt2::SelfComponent self) {
const auto clockCls = self.createClockClass();
clockCls->originIsUnixEpoch(false);
return clockCls;
},
- "clock class with other origin and no UUID followed by different clock class",
+ "clock class with unknown origin and no UUID followed by different clock class",
"Unexpected clock class"},
};