Trace class destruction listeners currently receive a _TraceClass. I
think it's a mistake, in that they should receive a _TraceClassConst.
Fix that, tweak the tests to test it. Test the same thing for trace
destruction listeners (they didn't suffer from the same issue).
Change-Id: I4651ffc44c916d64f6e6f2944fa856b4ed5bb5f6
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11447
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
(cherry picked from commit
2d6b60ff29423b918ac791f35d4f259178107cc1)
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11709
CI-Build: Philippe Proulx <eeppeliteloop@gmail.com>
def _trace_class_destruction_listener_from_native(
user_listener, handle, trace_class_ptr
):
- trace_class = _TraceClass._create_from_ptr_and_get_ref(trace_class_ptr)
+ trace_class = _TraceClassConst._create_from_ptr_and_get_ref(trace_class_ptr)
user_listener(trace_class)
handle._invalidate()
num_trace_class_destroyed_calls += 1
def on_trace_destruction(trace):
+ nonlocal type_of_passed_trace
+ type_of_passed_trace = type(trace)
+
nonlocal num_trace_destroyed_calls
num_trace_destroyed_calls += 1
num_trace_class_destroyed_calls = 0
num_trace_destroyed_calls = 0
+ type_of_passed_trace = None
trace_class = get_default_trace_class()
stream_class = trace_class.create_stream_class()
self.assertEqual(num_trace_class_destroyed_calls, 0)
self.assertEqual(num_trace_destroyed_calls, 1)
+ self.assertIs(type_of_passed_trace, bt2_trace._TraceConst)
del trace_class
def test_destruction_listener(self):
def on_trace_class_destruction(trace_class):
+ nonlocal type_of_passed_trace_class
+ type_of_passed_trace_class = type(trace_class)
+
nonlocal num_destruct_calls
num_destruct_calls += 1
+ type_of_passed_trace_class = None
num_destruct_calls = 0
trace_class = get_default_trace_class()
del trace_class
self.assertEqual(num_destruct_calls, 1)
+ self.assertIs(type_of_passed_trace_class, bt2_trace_class._TraceClassConst)
def test_remove_destruction_listener_wrong_type(self):
trace_class = get_default_trace_class()