Currently, `clock_classes_are_compatible()` returns a bool indicating if
the clock classes referenced in the current batch of messages are
compatible with the clock classes seen previously by the iterator. If
there is any incompatibility, whatever the reason, the
"message-clock-classes-are-compatible" post-condition check is
triggered.
A subsequent patch will want to test each individual clock class
incompatibility case, which is not easy if they all produce a message
with the same condition id.
Change `clock_classes_are_compatible_one()` to directly do the
post-condition checks, and give a unique name to each check.
Rename to `assert_post_dev_clock_classes_are_compatible_one`, in line
with the existing `assert_post_dev_expected_packet()` & co.
Adjust and rename `clock_classes_are_compatible()` accordingly.
Change-Id: I38937422f731c0cfebad70f183be97144d43e121
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11954
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
+#define NEXT_METHOD_NAME "bt_message_iterator_class_next_method"
+
+#ifdef BT_DEV_MODE
+
/*
* When a new stream begins, verify that the clock class tied to this
* stream is compatible with what we've seen before.
*/
/*
* When a new stream begins, verify that the clock class tied to this
* stream is compatible with what we've seen before.
*/
-bool clock_classes_are_compatible_one(struct bt_message_iterator *iterator,
+void assert_post_dev_clock_classes_are_compatible_one(
+ struct bt_message_iterator *iterator,
const struct bt_message *msg)
{
enum bt_message_type message_type = bt_message_get_type(msg);
const struct bt_message *msg)
{
enum bt_message_type message_type = bt_message_get_type(msg);
if (message_type == BT_MESSAGE_TYPE_STREAM_BEGINNING) {
const struct bt_message_stream *stream_msg = (struct bt_message_stream *) msg;
if (message_type == BT_MESSAGE_TYPE_STREAM_BEGINNING) {
const struct bt_message_stream *stream_msg = (struct bt_message_stream *) msg;
break;
case CLOCK_EXPECTATION_NONE:
break;
case CLOCK_EXPECTATION_NONE:
- if (clock_class) {
- BT_ASSERT_COND_DEV_MSG(
- "Expecting no clock class, got one: %![cc-]+K",
- clock_class);
- result = false;
- goto end;
- }
-
+ BT_ASSERT_POST_DEV(NEXT_METHOD_NAME,
+ "stream-class-has-no-clock-class", !clock_class,
+ "Expecting no clock class, got one: %![cc-]+K",
+ clock_class);
break;
case CLOCK_EXPECTATION_ORIGIN_UNIX:
break;
case CLOCK_EXPECTATION_ORIGIN_UNIX:
- if (!clock_class) {
- BT_ASSERT_COND_DEV_MSG(
- "Expecting a clock class, got none.");
- result = false;
- goto end;
- }
+ BT_ASSERT_POST_DEV(NEXT_METHOD_NAME,
+ "stream-class-has-clock-class-with-unix-epoch-origin", clock_class,
+ "Expecting a clock class with Unix epoch origin, got none.");
- if (!bt_clock_class_origin_is_unix_epoch(clock_class)) {
- BT_ASSERT_COND_DEV_MSG(
- "Expecting a clock class with Unix epoch origin: %![cc-]+K",
- clock_class);
- result = false;
- goto end;
- }
+ BT_ASSERT_POST_DEV(NEXT_METHOD_NAME,
+ "clock-class-has-unix-epoch-origin",
+ bt_clock_class_origin_is_unix_epoch(clock_class),
+ "Expecting a clock class with Unix epoch origin: %![cc-]+K",
+ clock_class);
break;
case CLOCK_EXPECTATION_ORIGIN_OTHER_UUID:
break;
case CLOCK_EXPECTATION_ORIGIN_OTHER_UUID:
- if (!clock_class) {
- BT_ASSERT_COND_DEV_MSG(
- "Expecting a clock class, got none.");
- result = false;
- goto end;
- }
+ BT_ASSERT_POST_DEV(NEXT_METHOD_NAME,
+ "stream-class-has-clock-class-with-uuid", clock_class,
+ "Expecting a clock class with UUID, got none.");
- if (bt_clock_class_origin_is_unix_epoch(clock_class)) {
- BT_ASSERT_COND_DEV_MSG(
- "Expecting a clock class without Unix epoch origin: %![cc-]+K",
- clock_class);
- result = false;
- goto end;
- }
+ BT_ASSERT_POST_DEV(NEXT_METHOD_NAME,
+ "clock-class-has-non-unix-epoch-origin",
+ !bt_clock_class_origin_is_unix_epoch(clock_class),
+ "Expecting a clock class without Unix epoch origin: %![cc-]+K",
+ clock_class);
- if (!clock_class_uuid) {
- BT_ASSERT_COND_DEV_MSG(
- "Expecting a clock class with UUID: %![cc-]+K",
- clock_class);
- result = false;
- goto end;
- }
+ BT_ASSERT_POST_DEV(NEXT_METHOD_NAME,
+ "clock-class-has-uuid",
+ clock_class_uuid,
+ "Expecting a clock class with UUID, got one without UUID: %![cc-]+K",
+ clock_class);
- if (bt_uuid_compare(iterator->clock_expectation.uuid, clock_class_uuid)) {
- BT_ASSERT_COND_DEV_MSG(
- "Expecting a clock class with UUID, got one "
+ BT_ASSERT_POST_DEV(NEXT_METHOD_NAME,
+ "clock-class-has-expected-uuid",
+ !bt_uuid_compare(iterator->clock_expectation.uuid, clock_class_uuid),
+ "Expecting a clock class with UUID, got one "
"with a different UUID: %![cc-]+K, expected-uuid=%!u",
clock_class, iterator->clock_expectation.uuid);
"with a different UUID: %![cc-]+K, expected-uuid=%!u",
clock_class, iterator->clock_expectation.uuid);
- result = false;
- goto end;
- }
break;
case CLOCK_EXPECTATION_ORIGIN_OTHER_NO_UUID:
break;
case CLOCK_EXPECTATION_ORIGIN_OTHER_NO_UUID:
- if (!clock_class) {
- BT_ASSERT_COND_DEV_MSG(
- "Expecting clock class %![cc-]+K, got none.",
- iterator->clock_expectation.clock_class);
- result = false;
- goto end;
- }
-
- if (clock_class != iterator->clock_expectation.clock_class) {
- BT_ASSERT_COND_DEV_MSG(
- "Expecting clock class %![cc-]+K, got %![cc-]+K.",
- iterator->clock_expectation.clock_class,
- clock_class);
- result = false;
- goto end;
- }
+ BT_ASSERT_POST_DEV(NEXT_METHOD_NAME,
+ "stream-class-has-clock-class", clock_class,
+ "Expecting a clock class, got none.");
+ BT_ASSERT_POST_DEV(NEXT_METHOD_NAME,
+ "clock-class-is-expected",
+ clock_class == iterator->clock_expectation.clock_class,
+ "Expecting clock class %![cc-]+K, got %![cc-]+K.",
+ iterator->clock_expectation.clock_class,
+ clock_class);
-
- result = true;
-
-end:
- return result;
-bool clock_classes_are_compatible(
+void assert_post_dev_clock_classes_are_compatible(
struct bt_message_iterator *iterator,
bt_message_array_const msgs, uint64_t msg_count)
{
uint64_t i;
struct bt_message_iterator *iterator,
bt_message_array_const msgs, uint64_t msg_count)
{
uint64_t i;
for (i = 0; i < msg_count; i++) {
for (i = 0; i < msg_count; i++) {
- if (!clock_classes_are_compatible_one(iterator, msgs[i])) {
- result = false;
- goto end;
- }
+ assert_post_dev_clock_classes_are_compatible_one(iterator, msgs[i]);
-
- result = true;
-
-end:
- return result;
static
const bt_stream *get_stream_from_msg(const struct bt_message *msg)
{
static
const bt_stream *get_stream_from_msg(const struct bt_message *msg)
{
-#endif
-
-#define NEXT_METHOD_NAME "bt_message_iterator_class_next_method"
static
void assert_post_dev_expected_sequence(struct bt_message_iterator *iterator,
const struct bt_message *msg)
static
void assert_post_dev_expected_sequence(struct bt_message_iterator *iterator,
const struct bt_message *msg)
bt_common_func_status_string(status), *user_count);
if (status == BT_FUNC_STATUS_OK) {
bt_common_func_status_string(status), *user_count);
if (status == BT_FUNC_STATUS_OK) {
- BT_ASSERT_POST_DEV(NEXT_METHOD_NAME,
- "message-clock-classes-are-compatible",
- clock_classes_are_compatible(iterator, msgs,
- *user_count),
- "Clocks are not compatible");
+ BT_IF_DEV_MODE(assert_post_dev_clock_classes_are_compatible(
+ iterator, msgs, *user_count));
+
BT_ASSERT_POST_DEV(NEXT_METHOD_NAME,
"message-clock-snapshots-are-monotonic",
clock_snapshots_are_monotonic(iterator, msgs,
BT_ASSERT_POST_DEV(NEXT_METHOD_NAME,
"message-clock-snapshots-are-monotonic",
clock_snapshots_are_monotonic(iterator, msgs,