Replace assert() -> BT_ASSERT() and some preconditions with BT_ASSERT_PRE()
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Wed, 28 Feb 2018 23:37:29 +0000 (18:37 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 3 May 2019 22:19:33 +0000 (18:19 -0400)
commit8b45963bc7e8fa499b97079008156a51c35bba86
tree018cda4427185fd50ebbae3dd7e39099a04e04ae
parentd244c559056c44c46916e4799b1c6fa6311484fa
Replace assert() -> BT_ASSERT() and some preconditions with BT_ASSERT_PRE()

In the whole project: replace assert() with BT_ASSERT(), and include
<babeltrace/assert-internal.h> instead of <assert.h>. This means that,
from now on, logic/postcondition assertions are disabled by default: you
need to enable them explicitly with `BABELTRACE_DEBUG_MODE=1` when
configuring the project.

In the library: replace the precondition checks which actively occur
while a graph is running with BT_ASSERT_PRE() or other helpers that are
only enabled in developer mode. Those are mostly checks for `bt_event`,
`bt_packet`, `bt_field`, `bt_notification`, and `bt_value` objects.

Frozen and validation flags for those objects are now only handled in
developer mode. The concept of set/unset fields is also only handled in
developer mode. This is why some internal functions have their name
prefixed with `_` and a macro is used instead to do nothing when in
non-developer mode (e.g., bt_field_freeze() calls _bt_field_freeze() in
developer mode and does nothing in non-developer mode).

The transformation of unconditional run-time precondition checks to
using BT_ASSERT_PRE() is not done for the notification iterator object.
This is a separate concern with different challenges which will be
implemented in a subsequent patch.

Tests which check that API functions fail when preconditions are not
satisfied in `tests/lib/test_bt_values.c` and
`tests/lib/test_ctf_writer.c` are removed. From my point of view,
checking for those preconditions is not part of the API now: it is only
a service provided for developers in developer mode. In other words,
because a library user cannot expect a specific reaction when not
satisfying the required preconditions, you cannot unit-test them either.
What is important is to validate that the library works as expected when
used as expected.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
112 files changed:
bindings/python/bt2/bt2/native_bt.i
bindings/python/bt2/bt2/native_btcomponentclass.i
bindings/python/bt2/bt2/native_btconnection.i
bindings/python/bt2/bt2/native_btgraph.i
bindings/python/bt2/bt2/native_btnotifiter.i
bindings/python/bt2/bt2/native_btport.i
bindings/python/bt2/bt2/native_bttrace.i
cli/babeltrace-cfg-cli-args-connect.c
cli/babeltrace-cfg-cli-args.c
cli/babeltrace-log.c
cli/babeltrace.c
common/common.c
include/babeltrace/bitfield-internal.h
include/babeltrace/compat/stdio-internal.h
include/babeltrace/ctf-ir/event-class-internal.h
include/babeltrace/ctf-ir/event-internal.h
include/babeltrace/ctf-ir/field-path-internal.h
include/babeltrace/ctf-ir/field-types-internal.h
include/babeltrace/ctf-ir/fields-internal.h
include/babeltrace/ctf-ir/fields.h
include/babeltrace/ctf-ir/packet-internal.h
include/babeltrace/ctf-ir/stream-class-internal.h
include/babeltrace/ctf-ir/stream-internal.h
include/babeltrace/ctf-writer/serialize-internal.h
include/babeltrace/graph/clock-class-priority-map-internal.h
include/babeltrace/graph/component-internal.h
include/babeltrace/graph/connection-internal.h
include/babeltrace/graph/graph-internal.h
include/babeltrace/graph/notification-discarded-elements-internal.h
include/babeltrace/graph/notification-event-internal.h
include/babeltrace/graph/notification-internal.h
include/babeltrace/graph/notification-iterator-internal.h
include/babeltrace/graph/notification-packet-internal.h
include/babeltrace/graph/notification-stream-internal.h
include/babeltrace/object-internal.h
include/babeltrace/plugin/plugin-internal.h
include/babeltrace/ref-internal.h
include/babeltrace/values-internal.h
include/babeltrace/values.h
lib/ctf-ir/attributes.c
lib/ctf-ir/clock-class.c
lib/ctf-ir/event-class.c
lib/ctf-ir/event.c
lib/ctf-ir/field-path.c
lib/ctf-ir/field-types.c
lib/ctf-ir/fields.c
lib/ctf-ir/packet.c
lib/ctf-ir/resolve.c
lib/ctf-ir/stream-class.c
lib/ctf-ir/stream.c
lib/ctf-ir/trace.c
lib/ctf-ir/utils.c
lib/ctf-writer/clock.c
lib/ctf-writer/serialize.c
lib/ctf-writer/writer.c
lib/graph/clock-class-priority-map.c
lib/graph/component-class-sink-colander.c
lib/graph/component-class.c
lib/graph/component.c
lib/graph/connection.c
lib/graph/graph.c
lib/graph/iterator.c
lib/graph/notification/discarded-elements.c
lib/graph/notification/event.c
lib/graph/notification/heap.c
lib/graph/notification/inactivity.c
lib/graph/notification/notification.c
lib/graph/notification/packet.c
lib/graph/notification/stream.c
lib/graph/port.c
lib/graph/sink.c
lib/lib-logging.c
lib/plugin/plugin-so.c
lib/plugin/plugin.c
lib/prio_heap/prio_heap.c
lib/values.c
logging/log.c
plugins/ctf/common/btr/btr.c
plugins/ctf/common/metadata/decoder.c
plugins/ctf/common/metadata/parser.y
plugins/ctf/common/metadata/visitor-generate-ir.c
plugins/ctf/common/metadata/visitor-parent-links.c
plugins/ctf/common/metadata/visitor-semantic-validator.c
plugins/ctf/common/notif-iter/notif-iter.c
plugins/ctf/fs-sink/write.c
plugins/ctf/fs-sink/writer.c
plugins/ctf/fs-src/data-stream-file.c
plugins/ctf/fs-src/fs.c
plugins/ctf/fs-src/metadata.c
plugins/ctf/fs-src/query.c
plugins/ctf/lttng-live/data-stream.c
plugins/ctf/lttng-live/lttng-live.c
plugins/ctf/lttng-live/metadata.c
plugins/ctf/lttng-live/viewer-connection.c
plugins/libctfcopytrace/clock-fields.c
plugins/libctfcopytrace/ctfcopytrace.c
plugins/lttng-utils/copy.c
plugins/lttng-utils/debug-info.c
plugins/lttng-utils/plugin.c
plugins/text/dmesg/dmesg.c
plugins/text/pretty/pretty.c
plugins/text/pretty/print.c
plugins/utils/counter/counter.c
plugins/utils/dummy/dummy.c
plugins/utils/muxer/muxer.c
plugins/utils/trimmer/copy.c
plugins/utils/trimmer/iterator.c
plugins/utils/trimmer/trimmer.c
python-plugin-provider/python-plugin-provider.c
tests/lib/test_bt_values.c
tests/lib/test_cc_prio_map.c
tests/lib/test_ctf_writer.c
This page took 0.036308 seconds and 4 git commands to generate.