src.ctf.fs: support no packet beg/end CS and no discarded events/packets
This patch makes `src.ctf.fs` support CTF traces where a packet context
field class has or does not have the `timestamp_begin`, `timestamp_end`,
`events_discarded`, and `packet_seq_num` members. The corresponding
trace IR stream class's properties are set accordingly.
This fixes a bug having those base conditions:
1. Stream class has a default clock class.
2. Packet context's `timestamp_begin` and `timestamp_end` members
are missing.
Then:
a) Because of 1., it was mandatory to set the default clock snapshot of
packet beginning and end messages. It was also mandatory to set the
default clock snapshots of discarded events/packets messages.
b) Because we didn't have the packet beginning and end times (because of
2.), we used 0 for the first packet's beginning default clock
snapshot.
c) Because CTF uses the packet beginning/end times to set the discarded
events ranges, and because of b), we also used 0 as a discarded
events message's beginning default clock snapshot if the events were
discarded during the first packet.
0 is wrong for both b) and c): it's not 0, we just don't know the value.
It is wrong to tell a downstream component that events were possibly
discarded from 0 to another time because we just don't know those times.
I'm adding two test traces to make this code covered:
`no-packet-context`:
No packet context at all, which means no packet beginning/end times,
no discarded events, and no discarded packets.
`ev-disc-no-ts-begin-end`:
A packet context with an `events_discarded` member, but without the
`timestamp_begin` and `timestamp_end` members.
In this case, when there's a discarded events message, events are
known to have been discarded contextually, between two other
messages with a default clock snapshot, but not at a specific time.
`sink.text.pretty` prints:
WARNING: Tracer discarded 17 events (unknown time range) in
trace "ev-disc-no-ts-begin-end" (no UUID) within stream
"/path/to/babeltrace/tests/ctf-traces/succeed/ev-disc-no-ts-begin-end/stream"
(stream class ID: 0, stream ID: 0).
while Babeltrace 1.5 prints:
[warning] Tracer discarded 17 events between
[19:00:00.
000000000] and [19:00:00.
000000000] in trace UUID
0000000000000000, at path:
"tests/ctf-traces/succeed/ev-disc-no-ts-begin-end", within
stream id 0, at relative path: "stream". You should consider
recording a new trace with larger buffers or with fewer events
enabled.
which is not exact.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ieebf679a67bd0089e48708372caf934cc27573dc
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1368
Tested-by: jenkins
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>