From 5b3c8f0f3165deadcbf5782c3d73f5eb9d8724df Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Tue, 7 Nov 2023 23:11:55 +0000 Subject: [PATCH] Fix comparator.rb --- utils/bt_plugins/comparator.rb | 37 ++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/utils/bt_plugins/comparator.rb b/utils/bt_plugins/comparator.rb index 40ad911b..acd976b4 100644 --- a/utils/bt_plugins/comparator.rb +++ b/utils/bt_plugins/comparator.rb @@ -8,16 +8,23 @@ def consume_method(_self_component) # and compare events fields # If the number of message consumed by message iterator are differnts # an error is raised - stack_messages = [[], []] - @message_iterators.each_with_index { |message_iterator, i| - message_iterator.next_messages.each { |m| - stack_messages[i] << m.event if m.type == :BT_MESSAGE_TYPE_EVENT - } - } + @message_iterators.each_with_index do |message_iterator, i| + message_iterator.next_messages.each do |m| + @stack_messages[i] << m.event if m.type == :BT_MESSAGE_TYPE_EVENT + end + end + end + + def initialize_method(self_component, _configuration, _params, _data) + @stack_messages = [[], []] + self_component.add_input_port('in0') + self_component.add_input_port('in1') + end - stack_messages.transpose.each { |i, j| - %w[payload specific_context common_context].each { |tf| + def finalize_method(_self_component) + @stack_messages.transpose.each do |i, j| + %w[payload specific_context common_context].each do |tf| i_value = i.send("get_#{tf}_field") i_value = i_value.value if i_value j_value = j.send("get_#{tf}_field") @@ -26,20 +33,15 @@ def consume_method(_self_component) pp({ in0: i_value, in1: j_value }) raise "Traces for #{tf} fields are different!" end - } - } - end - - def initialize_method(self_component, _configuration, _params, _data) - self_component.add_input_port('in0') - self_component.add_input_port('in1') + end + end end def graph_is_configured_method(self_component) - @message_iterators = self_component.get_input_port_count.times.map { |i| + @message_iterators = self_component.get_input_port_count.times.map do |i| p = self_component.get_input_port_by_index(i) self_component.create_message_iterator(p) - } + end end def create_component_class @@ -47,6 +49,7 @@ def create_component_class consume_method: lambda(&method(:consume_method))) component_class.initialize_method = lambda(&method(:initialize_method)) + component_class.finalize_method = lambda(&method(:finalize_method)) component_class.graph_is_configured_method = lambda(&method(:graph_is_configured_method)) component_class end