Fix: sink.text.pretty: check that port is connected before creating message iterator
authorSimon Marchi <simon.marchi@efficios.com>
Tue, 14 Apr 2020 15:22:17 +0000 (11:22 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Wed, 15 Apr 2020 17:03:41 +0000 (13:03 -0400)
commit5ca921cfe7243edb09f43f31081240fef0535e2b
tree3f7957c8a0f59a7ffec032751eec19b716e2e7f5
parent2467456d7a68b314d7d5ce04981b251d0b195396
Fix: sink.text.pretty: check that port is connected before creating message iterator

sink.text.pretty does not check if its input port is connected before
trying to create a message iterator on it.  This can lead to a
precondition assertion failure.  It can be reproduced with this Python
snippet.

    import bt2
    g = bt2.Graph()
    g.add_component(bt2.find_plugin('text').sink_component_classes['pretty'], 'snk')
    g.run()

The assertion failure we get is:

    04-14 11:35:27.339 1231815 1231815 F LIB/MSG-ITER create_self_component_input_port_message_iterator@iterator.c:295 Babeltrace 2 library precondition not satisfied; error is:
    04-14 11:35:27.339 1231815 1231815 F LIB/MSG-ITER create_self_component_input_port_message_iterator@iterator.c:295 Input port is not connected: port-addr=0x607000001d70, port-type=INPUT, port-name="in"
    04-14 11:35:27.339 1231815 1231815 F LIB/MSG-ITER create_self_component_input_port_message_iterator@iterator.c:295 Aborting...
    ./tests/utils/../utils/utils.sh: line 283: 1231815 Aborted (core dumped) env "${env_args[@]}" "$@"

Add a check and return an error if that happens instead.  A
corresponding test is also added.

Change-Id: Ibeed94cd6ece543817fe8a765a69cb52bbaaba76
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/3403
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/3411
src/plugins/text/pretty/pretty.c
tests/Makefile.am
tests/plugins/sink.text.pretty/test_pretty [new file with mode: 0755]
tests/plugins/sink.text.pretty/test_pretty.py [new file with mode: 0644]
This page took 0.024906 seconds and 4 git commands to generate.