The following test fails currently when building with
BABELTRACE_DEV_MODE off:
FAIL: test_finalize (test_message_iterator.UserMessageIteratorTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File ".../babeltrace/tests/bindings/python/bt2/test_message_iterator.py", line 67, in test_finalize
self.assertTrue(finalized)
AssertionError: False is not true
The test verifies that the _finalize method (in Python) of an input port
message iterator is called when the iterator is destroyed. The failure
shows that the method is not getting called.
The issue is that
bt_self_component_port_input_message_iterator_try_finalize doesn't call
the finalize method if the iterator state is
BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_NON_INITIALIZED.
However, the iterator state is only set when in dev mode. In non-dev
mode, the state is left to its initial value of
BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_NON_INITIALIZED.
Fix this by setting the state of the iterator regardless of whether we
are in dev mode or not.
Change-Id: I158c9d913777eba117ed0d32e82db5a1b29f50ab
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1385
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins
(_iter)->state == BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_LAST_SEEKING_RETURNED_ERROR, \
"Message iterator is in the wrong state: %!+i", _iter)
(_iter)->state == BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_LAST_SEEKING_RETURNED_ERROR, \
"Message iterator is in the wrong state: %!+i", _iter)
-void _set_self_comp_port_input_msg_iterator_state(
+void set_self_comp_port_input_msg_iterator_state(
struct bt_self_component_port_input_message_iterator *iterator,
enum bt_self_component_port_input_message_iterator_state state)
{
struct bt_self_component_port_input_message_iterator *iterator,
enum bt_self_component_port_input_message_iterator_state state)
{
iterator->state = state;
}
iterator->state = state;
}
-#ifdef BT_DEV_MODE
-# define set_self_comp_port_input_msg_iterator_state _set_self_comp_port_input_msg_iterator_state
-#else
-# define set_self_comp_port_input_msg_iterator_state(_a, _b) ((void) _a); ((void) _b);
-#endif
-
static
void destroy_base_message_iterator(struct bt_object *obj)
{
static
void destroy_base_message_iterator(struct bt_object *obj)
{
/*
* There is no way that this iterator could have been finalized
* during its "next" method, as the only way to do this is to
/*
* There is no way that this iterator could have been finalized
* during its "next" method, as the only way to do this is to
*/
BT_ASSERT(iterator->state ==
BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_ACTIVE);
*/
BT_ASSERT(iterator->state ==
BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_ACTIVE);
switch (status) {
case BT_MESSAGE_ITERATOR_STATUS_OK:
switch (status) {
case BT_MESSAGE_ITERATOR_STATUS_OK:
-void _set_iterator_state_after_seeking(
+void set_iterator_state_after_seeking(
struct bt_self_component_port_input_message_iterator *iterator,
enum bt_message_iterator_status status)
{
struct bt_self_component_port_input_message_iterator *iterator,
enum bt_message_iterator_status status)
{
set_self_comp_port_input_msg_iterator_state(iterator, new_state);
}
set_self_comp_port_input_msg_iterator_state(iterator, new_state);
}
-#ifdef BT_DEV_MODE
-# define set_iterator_state_after_seeking _set_iterator_state_after_seeking
-#else
-# define set_iterator_state_after_seeking(_iter, _status) ((void) _iter); ((void) _status);
-#endif
-
enum bt_message_iterator_status
bt_self_component_port_input_message_iterator_seek_beginning(
struct bt_self_component_port_input_message_iterator *iterator)
enum bt_message_iterator_status
bt_self_component_port_input_message_iterator_seek_beginning(
struct bt_self_component_port_input_message_iterator *iterator)
BT_LOGD("User method returned: status=%s",
bt_message_iterator_status_string(status));
BT_LOGD("User method returned: status=%s",
bt_message_iterator_status_string(status));
/*
* The user's "next" method must not do any action which
* would change the iterator's state.
*/
BT_ASSERT(iterator->state ==
BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_ACTIVE);
/*
* The user's "next" method must not do any action which
* would change the iterator's state.
*/
BT_ASSERT(iterator->state ==
BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_ACTIVE);
switch (status) {
case BT_MESSAGE_ITERATOR_STATUS_OK:
switch (status) {
case BT_MESSAGE_ITERATOR_STATUS_OK: