Changeset 67:e360f4cae176 in finroc_plugins_data_ports


Ignore:
Timestamp:
05.06.2014 23:25:48 (5 years ago)
Author:
Max Reichardt <mreichardt@…>
Branch:
default
Phase:
public
Message:

Fixed issue: When calling Dequeue() on ports with cheap copy types, returned pointer can now be null (instead of containing default value). Udpated make.xml and tranformed test programs into proper unit tests. Moved benchmarks to finroc_project_benchmarks.

Files:
2 deleted
3 edited
3 moved

Legend:

Unmodified
Added
Removed
  • api/tPortDataPointerImplementation.h

    r46 r67  
    189189public: 
    190190 
    191   inline tPortDataPointerImplementation() : 
     191  inline tPortDataPointerImplementation(bool null_pointer = true) : 
    192192    buffer(), // Initializes even fundamental types 
    193     timestamp(rrlib::time::cNO_TIME) 
     193    timestamp(rrlib::time::cNO_TIME), 
     194    null_pointer(null_pointer) 
    194195  { 
    195196  } 
     
    197198  inline tPortDataPointerImplementation(typename tPortImplementation::tPortBase::tLockingManagerPointer& pointer, optimized::tCheapCopyPort& port) : 
    198199    buffer(tPortImplementation::ToValue(pointer->GetObject().template GetData<typename tPortImplementation::tPortBuffer>(), port.GetUnit())), 
    199     timestamp(pointer->GetTimestamp()) 
     200    timestamp(pointer->GetTimestamp()), 
     201    null_pointer(false) 
    200202  { 
    201203  } 
     
    203205  inline tPortDataPointerImplementation(const T& value, const rrlib::time::tTimestamp timestamp) : 
    204206    buffer(value), 
    205     timestamp(timestamp) 
     207    timestamp(timestamp), 
     208    null_pointer(false) 
    206209  { 
    207210  } 
     
    210213  inline tPortDataPointerImplementation(tPortDataPointerImplementation && other) : 
    211214    buffer(), // Initializes even fundamental types 
    212     timestamp(rrlib::time::cNO_TIME) 
     215    timestamp(rrlib::time::cNO_TIME), 
     216    null_pointer(false) 
    213217  { 
    214218    std::swap(buffer, other.buffer); 
    215219    std::swap(timestamp, other.timestamp); 
     220    std::swap(null_pointer, other.null_pointer); 
    216221  } 
    217222 
     
    221226    std::swap(buffer, other.buffer); 
    222227    std::swap(timestamp, other.timestamp); 
     228    std::swap(null_pointer, other.null_pointer); 
    223229    return *this; 
    224230  } 
     
    226232  void Deserialize(rrlib::serialization::tInputStream& stream) 
    227233  { 
    228     stream.ReadBoolean(); 
    229     stream >> *Get(); 
    230     stream >> this->timestamp; 
     234    this->null_pointer = !stream.ReadBoolean(); 
     235    if (!this->null_pointer) 
     236    { 
     237      stream >> buffer; 
     238      stream >> timestamp; 
     239    } 
    231240  } 
    232241 
    233242  inline T* Get() 
    234243  { 
    235     return &buffer; 
     244    return null_pointer ? nullptr : &buffer; 
    236245  } 
    237246 
    238247  inline const T* Get() const 
    239248  { 
    240     return &buffer; 
     249    return null_pointer ? nullptr : &buffer; 
    241250  } 
    242251 
     
    248257  void Serialize(rrlib::serialization::tOutputStream& stream) const 
    249258  { 
    250     stream.WriteBoolean(true); 
    251     stream << *Get(); 
    252     stream << GetTimestamp(); 
     259    stream.WriteBoolean(Get()); 
     260    if (Get()) 
     261    { 
     262      stream << buffer; 
     263      stream << timestamp; 
     264    } 
    253265  } 
    254266 
     
    268280  /*! Wrapped time stamp */ 
    269281  rrlib::time::tTimestamp timestamp; 
     282 
     283  /*! Is this a null pointer? (required for dequeueing) */ 
     284  bool null_pointer; 
    270285}; 
    271286 
  • api/tPortImplementation.h

    r63 r67  
    242242  static inline tPortDataPointer<T> GetUnusedBuffer(optimized::tCheapCopyPort& port) 
    243243  { 
    244     return tPortDataPointerImplementation<T, true>(); 
     244    return tPortDataPointerImplementation<T, true>(false); 
    245245  } 
    246246 
  • make.xml

    r44 r67  
    1 <?xml version="1.0" encoding="UTF-8" standalone="no"?> 
     1<?xml version="1.0" encoding="UTF-8"?> 
     2<!DOCTYPE targets PUBLIC "-//RRLIB//DTD make 14.05" "http://finroc.org/xml/14.05/make.dtd"> 
    23<targets> 
    34 
    4   <finrocplugin> 
     5  <library> 
    56    <sources> 
    67      definitions.h 
     
    1617      optimized/* 
    1718    </sources> 
    18   </finrocplugin> 
     19  </library> 
    1920 
    20   <finrocplugin name="api"> 
     21  <library name="api"> 
    2122    <sources> 
    2223      tGenericPort.h 
     
    3334      api/* 
    3435    </sources> 
    35   </finrocplugin> 
     36  </library> 
    3637 
    37   <testprogram name="benchmark_simple"> 
     38  <program name="initial_pushing"> 
    3839    <sources> 
    39       test/benchmark_simple.cpp 
     40      tests/initial_pushing.cpp 
    4041    </sources> 
    41   </testprogram> 
    42    
    43   <!--testprogram name="port_queues"> 
    44     <sources> 
    45       test/port_queues.cpp 
    46     </sources> 
    47   </testprogram--> 
     42  </program> 
    4843 
    49   <testprogram name="initial_pushing"> 
    50     <sources> 
    51       test/initial_pushing.cpp 
    52     </sources> 
    53   </testprogram> 
    54    
    55   <testprogram name="basic_realtime"> 
    56     <sources> 
    57       test/basic_realtime.cpp 
    58     </sources> 
    59   </testprogram> 
    60  
    61   <testprogram name="configuration"> 
     44  <!--program name="configuration"> 
    6245    <sources> 
    6346      test/configuration.cpp 
    6447    </sources> 
    65   </testprogram> 
     48  </program--> 
    6649   
    67   <testprogram name="collection"> 
     50  <program name="collection"> 
    6851    <sources> 
    69       test/test_collection.cpp 
     52      tests/test_collection.cpp 
    7053    </sources> 
    71   </testprogram> 
     54  </program> 
    7255   
    7356 
  • tests/initial_pushing.cpp

    r58 r67  
    2020// 
    2121//---------------------------------------------------------------------- 
    22 /*!\file    plugins/data_ports/test/initial_pushing.cpp 
     22/*!\file    plugins/data_ports/tests/initial_pushing.cpp 
    2323 * 
    2424 * \author  Max Reichardt 
     
    3434//---------------------------------------------------------------------- 
    3535#include "core/tRuntimeEnvironment.h" 
    36  
    3736#include "rrlib/util/demangle.h" 
     37#include "rrlib/util/tUnitTestSuite.h" 
    3838 
    3939//---------------------------------------------------------------------- 
     
    5151// Namespace usage 
    5252//---------------------------------------------------------------------- 
    53 using namespace finroc::core; 
    54 using namespace finroc::data_ports; 
     53 
     54//---------------------------------------------------------------------- 
     55// Namespace declaration 
     56//---------------------------------------------------------------------- 
     57namespace finroc 
     58{ 
     59namespace data_ports 
     60{ 
    5561 
    5662//---------------------------------------------------------------------- 
     
    7379  if (buffer == expected) 
    7480  { 
    75     FINROC_LOG_PRINT(USER, "Port '", port.GetName(), "' has value '", buffer, "' - as expected"); 
     81    FINROC_LOG_PRINT(DEBUG_VERBOSE_1, "Port '", port.GetName(), "' has value '", buffer, "' - as expected"); 
    7682  } 
    7783  else 
    7884  { 
    7985    FINROC_LOG_PRINT(ERROR, "Port '", port.GetName(), "' has value '", buffer, "' - expected '", expected, "'"); 
     86    RRLIB_UNIT_TESTS_ASSERT_MESSAGE("Failed", false); 
    8087  } 
    8188} 
     
    8491void TestInitialPushing(const std::array<T, 9>& test_values) 
    8592{ 
    86   tFrameworkElement* parent = new tFrameworkElement(&tRuntimeEnvironment::GetInstance(), "Test"); 
    87   FINROC_LOG_PRINT(USER, "\nChecking initial pushing for type ", rrlib::util::Demangle(typeid(T).name())); 
     93  core::tFrameworkElement* parent = new core::tFrameworkElement(&core::tRuntimeEnvironment::GetInstance(), "Test"); 
     94  FINROC_LOG_PRINT(DEBUG_VERBOSE_1, "\nChecking initial pushing for type ", rrlib::util::Demangle(typeid(T).name())); 
    8895 
    8996  // Create initial set of ports 
    9097  tOutputPort<T> output_port("Output Port", parent); 
    9198  tInputPort<T> input_port("Input Port", parent); 
    92   tOutputPort<T> output_port_reverse("Output Port with reverse pushing", tFrameworkElement::tFlag::PUSH_STRATEGY_REVERSE, parent); 
    93   tFrameworkElement::InitAll(); 
     99  tOutputPort<T> output_port_reverse("Output Port with reverse pushing", core::tFrameworkElement::tFlag::PUSH_STRATEGY_REVERSE, parent); 
     100  core::tFrameworkElement::InitAll(); 
    94101 
    95102  // Fill output port with something 
     
    115122 
    116123  // now for a complex net 
    117   FINROC_LOG_PRINT(USER, "\nNow for a complex net..."); 
     124  FINROC_LOG_PRINT(DEBUG_VERBOSE_1, "\nNow for a complex net..."); 
    118125 
    119126  // o1->o2 
    120   tOutputPort<T> o1("o1", tFrameworkElement::tFlag::ACCEPTS_DATA, parent); // flag makes this also a proxy port 
    121   tFrameworkElement::InitAll(); 
     127  tOutputPort<T> o1("o1", core::tFrameworkElement::tFlag::ACCEPTS_DATA, parent); // flag makes this also a proxy port 
     128  core::tFrameworkElement::InitAll(); 
    122129  o1.Publish(test_values[3]); 
    123   tInputPort<T> o2("o2", tFrameworkElement::tFlag::EMITS_DATA, parent); // flag makes this also a proxy port 
    124   tFrameworkElement::InitAll(); 
     130  tInputPort<T> o2("o2", core::tFrameworkElement::tFlag::EMITS_DATA, parent); // flag makes this also a proxy port 
     131  core::tFrameworkElement::InitAll(); 
    125132  o1.ConnectTo(o2); 
    126133  CheckPortValue(o2, test_values[3]); 
     
    129136  tInputPort<T> o3("o3", parent); 
    130137  o2.ConnectTo(o3); 
    131   tFrameworkElement::InitAll(); 
     138  core::tFrameworkElement::InitAll(); 
    132139  o2.SetPushStrategy(false); 
    133140  o3.SetPushStrategy(false); 
     
    138145 
    139146  // o0->o1->o2->o3 
    140   tOutputPort<T> o0("o0", tFrameworkElement::tFlag::ACCEPTS_DATA, parent); // flag makes this also a proxy port 
    141   tFrameworkElement::InitAll(); 
     147  tOutputPort<T> o0("o0", core::tFrameworkElement::tFlag::ACCEPTS_DATA, parent); // flag makes this also a proxy port 
     148  core::tFrameworkElement::InitAll(); 
    142149  o0.Publish(test_values[5]); 
    143   o0.ConnectTo(o1, tAbstractPort::tConnectDirection::TO_TARGET); 
     150  o0.ConnectTo(o1, core::tAbstractPort::tConnectDirection::TO_TARGET); 
    144151  CheckPortValue(o3, test_values[5]); 
    145152 
     
    147154  //              \            . 
    148155  //               o4->o5 
    149   tInputPort<T> o4("o4", tFrameworkElement::tFlag::EMITS_DATA, parent); // flag makes this also a proxy port 
     156  tInputPort<T> o4("o4", core::tFrameworkElement::tFlag::EMITS_DATA, parent); // flag makes this also a proxy port 
    150157  tInputPort<T> o5("o5", parent); 
    151   tFrameworkElement::InitAll(); 
     158  core::tFrameworkElement::InitAll(); 
    152159  o4.ConnectTo(o5); 
    153   o2.ConnectTo(o4, tAbstractPort::tConnectDirection::TO_TARGET); 
     160  o2.ConnectTo(o4, core::tAbstractPort::tConnectDirection::TO_TARGET); 
    154161  CheckPortValue(o5, test_values[5]); 
    155162  tOutputPort<T> o6("o6", parent); 
    156   tFrameworkElement::InitAll(); 
     163  core::tFrameworkElement::InitAll(); 
    157164  o6.Publish(test_values[6]); 
    158165  o6.ConnectTo(o0); 
     
    163170  //        /     \            . 
    164171  //      o7->o8   o4->o5 
    165   tOutputPort<T> o7("o7", tFrameworkElement::tFlag::ACCEPTS_DATA, parent); // flag makes this also a proxy port 
    166   tFrameworkElement::InitAll(); 
     172  tOutputPort<T> o7("o7", core::tFrameworkElement::tFlag::ACCEPTS_DATA, parent); // flag makes this also a proxy port 
     173  core::tFrameworkElement::InitAll(); 
    167174  o7.Publish(test_values[7]); 
    168175  tInputPort<T> o8("o8", parent, tQueueSettings(true, 5)); 
    169   tFrameworkElement::InitAll(); 
     176  core::tFrameworkElement::InitAll(); 
    170177  o7.ConnectTo(o8); 
    171178  CheckPortValue(o8, test_values[7]); 
    172   o7.ConnectTo(o1, tAbstractPort::tConnectDirection::TO_TARGET); 
     179  o7.ConnectTo(o1, core::tAbstractPort::tConnectDirection::TO_TARGET); 
    173180  CheckPortValue(o1, test_values[6]); 
    174181 
    175182  tPortBuffers<tPortDataPointer<const T>> queue_fragment = o8.DequeueAllBuffers(); 
    176   while (!queue_fragment.Empty()) 
    177   { 
    178     FINROC_LOG_PRINT(ERROR, "o8 queue is not empty as expected."); 
    179     queue_fragment.PopAny(); 
    180   } 
     183  RRLIB_UNIT_TESTS_ASSERT_MESSAGE("o8 queue is not empty as expected.", queue_fragment.Empty()); 
    181184 
    182185  // o6->o0->o1->o2->o3 
     
    184187  //  o9->o7->o8   o4->o5 
    185188  tOutputPort<T> o9("o9", parent); 
    186   tFrameworkElement::InitAll(); 
     189  core::tFrameworkElement::InitAll(); 
    187190  o9.Publish(test_values[8]); 
    188191  o9.ConnectTo(o7); 
     
    194197} 
    195198 
    196 int main(int, char**) 
    197 { 
    198   TestInitialPushing<int>({{11, 22, 33, 44, 55, 66, 77, 88, 99}}); 
    199   TestInitialPushing<finroc::data_ports::numeric::tNumber>({{11, 22, 33, 44, 55, 66, 77, 88, 99}}); 
    200   TestInitialPushing<std::string>({{"11", "22", "33", "44", "55", "66", "77", "88", "99"}}); 
    201   return 0; 
    202 } 
     199class InitialPushTest : public rrlib::util::tUnitTestSuite 
     200{ 
     201  RRLIB_UNIT_TESTS_BEGIN_SUITE(InitialPushTest); 
     202  RRLIB_UNIT_TESTS_ADD_TEST(Test); 
     203  RRLIB_UNIT_TESTS_END_SUITE; 
     204 
     205  void Test() 
     206  { 
     207    TestInitialPushing<int>({{11, 22, 33, 44, 55, 66, 77, 88, 99}}); 
     208    TestInitialPushing<finroc::data_ports::numeric::tNumber>({{11, 22, 33, 44, 55, 66, 77, 88, 99}}); 
     209    TestInitialPushing<std::string>({{"11", "22", "33", "44", "55", "66", "77", "88", "99"}}); 
     210  } 
     211}; 
     212 
     213RRLIB_UNIT_TESTS_REGISTER_SUITE(InitialPushTest); 
     214 
     215//---------------------------------------------------------------------- 
     216// End of namespace declaration 
     217//---------------------------------------------------------------------- 
     218} 
     219} 
  • tests/test_collection.cpp

    r46 r67  
    2020// 
    2121//---------------------------------------------------------------------- 
    22 /*!\file    plugins/data_ports/test/test_collection.cpp 
     22/*!\file    plugins/data_ports/tests/test_collection.cpp 
    2323 * 
    2424 * \author  Max Reichardt 
     
    3535//---------------------------------------------------------------------- 
    3636#include "core/tRuntimeEnvironment.h" 
     37#include "rrlib/util/tUnitTestSuite.h" 
    3738 
    3839//---------------------------------------------------------------------- 
     
    5253// Namespace usage 
    5354//---------------------------------------------------------------------- 
    54 using namespace finroc::core; 
    55 using namespace finroc::data_ports; 
     55 
     56//---------------------------------------------------------------------- 
     57// Namespace declaration 
     58//---------------------------------------------------------------------- 
     59namespace finroc 
     60{ 
     61namespace data_ports 
     62{ 
    5663 
    5764//---------------------------------------------------------------------- 
     
    6976void TestPortChains() 
    7077{ 
    71   FINROC_LOG_PRINT(USER, "\nTesting forwarding data among port chains"); 
    72   tFrameworkElement* parent = new tFrameworkElement(&finroc::core::tRuntimeEnvironment::GetInstance(), "TestPortChains"); 
     78  FINROC_LOG_PRINT(DEBUG_VERBOSE_1, "\nTesting forwarding data among port chains"); 
     79  core::tFrameworkElement* parent = new core::tFrameworkElement(&core::tRuntimeEnvironment::GetInstance(), "TestPortChains"); 
    7380 
    7481  // Create ports 
     
    97104    // Publish data 
    98105    tPortDataPointer<std::string> unused_buffer = output_port1.GetUnusedBuffer(); 
    99     *unused_buffer = "Test"; 
     106    std::string test_string2 = "Test" + std::to_string(i); 
     107    *unused_buffer = test_string2; 
    100108    output_port1.Publish(unused_buffer); 
    101109 
     
    103111    output_port2.Publish(input_port1.GetPointer()); 
    104112    output_port3.Publish(input_port2.GetPointer()); 
     113    RRLIB_UNIT_TESTS_ASSERT(test_string2 == *input_port3.GetPointer()); 
    105114 
    106115    if (i > 10) 
     
    108117      output_port2.Publish(test_string); 
    109118      output_port3.Publish(input_port2.GetPointer()); 
     119      RRLIB_UNIT_TESTS_ASSERT(test_string == *input_port3.GetPointer()); 
     120      RRLIB_UNIT_TESTS_ASSERT(test_string == *input_port2.GetPointer()); 
     121      RRLIB_UNIT_TESTS_ASSERT(test_string2 == *input_port1.GetPointer()); 
    110122    } 
    111123  } 
     
    117129void TestPortQueues(const T& value1, const T& value2, const T& value3) 
    118130{ 
    119   FINROC_LOG_PRINT(USER, "\nTesting port queue basic operation for type ", (rrlib::rtti::tDataType<T>()).GetName()); 
    120   tFrameworkElement* parent = new tFrameworkElement(&finroc::core::tRuntimeEnvironment::GetInstance(), "TestPortQueue"); 
     131  FINROC_LOG_PRINT(DEBUG_VERBOSE_1, "\nTesting port queue basic operation for type ", (rrlib::rtti::tDataType<T>()).GetName()); 
     132  core::tFrameworkElement* parent = new core::tFrameworkElement(&core::tRuntimeEnvironment::GetInstance(), "TestPortQueue"); 
    121133 
    122134  tOutputPort<T> output_port("Output Port", parent); 
     
    127139  parent->Init(); 
    128140 
    129   FINROC_LOG_PRINT(USER, " Enqueueing three values"); 
     141  FINROC_LOG_PRINT(DEBUG_VERBOSE_1, " Enqueueing three values"); 
    130142  output_port.Publish(value1); 
    131143  output_port.Publish(value2); 
    132144  output_port.Publish(value3); 
    133145 
    134   FINROC_LOG_PRINT(USER, " Dequeueing five values FIFO"); 
     146  FINROC_LOG_PRINT(DEBUG_VERBOSE_1, " Dequeueing five values FIFO"); 
    135147  for (size_t i = 0; i < 5; ++i) 
    136148  { 
     
    138150    if (result) 
    139151    { 
    140       FINROC_LOG_PRINT(USER, "  Dequeued ", *result); 
     152      FINROC_LOG_PRINT(DEBUG_VERBOSE_1, "  Dequeued ", *result); 
    141153    } 
    142154    else 
    143155    { 
    144       FINROC_LOG_PRINT(USER, "  Dequeued nothing"); 
    145     } 
    146   } 
    147  
    148   FINROC_LOG_PRINT(USER, " Dequeueing all values at once"); 
     156      FINROC_LOG_PRINT(DEBUG_VERBOSE_1, "  Dequeued nothing"); 
     157    } 
     158    RRLIB_UNIT_TESTS_ASSERT((i == 0 && value1 == *result) || (i == 1 && value2 == *result) || (i == 2 && value3 == *result) || (i > 2 && (!result))); 
     159  } 
     160 
     161  FINROC_LOG_PRINT(DEBUG_VERBOSE_1, " Dequeueing all values at once"); 
    149162  tPortBuffers<tPortDataPointer<const T>> dequeued = input_port_all.DequeueAllBuffers(); 
     163  size_t i = 0; 
    150164  while (!dequeued.Empty()) 
    151165  { 
    152     FINROC_LOG_PRINT(USER, "  Dequeued ", *dequeued.PopFront()); 
     166    T result = *dequeued.PopFront(); 
     167    FINROC_LOG_PRINT(DEBUG_VERBOSE_1, "  Dequeued ", result); 
     168    RRLIB_UNIT_TESTS_ASSERT((i == 0 && value1 == result) || (i == 1 && value2 == result) || (i == 2 && value3 == result)); 
     169    i++; 
    153170  } 
    154171 
     
    166183    void OnPortChange(const T& value, tChangeContext& change_context) 
    167184    { 
    168       FINROC_LOG_PRINT(USER, "  Port Changed: ", value); 
     185      FINROC_LOG_PRINT(DEBUG_VERBOSE_1, "  Port Changed: ", value); 
     186      value1 = value; 
     187      calls++; 
    169188    } 
    170189    void OnPortChange(tPortDataPointer<const T>& value, tChangeContext& change_context) 
    171190    { 
    172       FINROC_LOG_PRINT(USER, "  Port Changed (tPortDataPointer): ", *value); 
     191      FINROC_LOG_PRINT(DEBUG_VERBOSE_1, "  Port Changed (tPortDataPointer): ", *value); 
     192      value2 = *value; 
     193      calls++; 
    173194    } 
    174195    void OnPortChange(const rrlib::rtti::tGenericObject& value, tChangeContext& change_context) 
    175196    { 
    176       FINROC_LOG_PRINT(USER, "  Port Changed Generic: ", value); 
     197      FINROC_LOG_PRINT(DEBUG_VERBOSE_1, "  Port Changed Generic: ", value); 
     198      calls++; 
    177199    } 
    178200    void OnPortChange(tPortDataPointer<const rrlib::rtti::tGenericObject>& value, tChangeContext& change_context) 
    179201    { 
    180       FINROC_LOG_PRINT(USER, "  Port Changed Generic (tPortDataPointer): ", *value); 
     202      FINROC_LOG_PRINT(DEBUG_VERBOSE_1, "  Port Changed Generic (tPortDataPointer): ", *value); 
     203      calls++; 
    181204    } 
    182205    void OnPortChange(tChangeContext& change_context) 
    183206    { 
    184       FINROC_LOG_PRINT(USER, "  Port Changed Simple"); 
    185     } 
     207      FINROC_LOG_PRINT(DEBUG_VERBOSE_1, "  Port Changed Simple"); 
     208      calls++; 
     209    } 
     210 
     211    T value1, value2; 
     212    size_t calls; 
     213 
     214    tListener() : value1(), value2(), calls(0) {} 
    186215  }; 
    187216 
    188   FINROC_LOG_PRINT(USER, "\nTesting port listeners for type ", (rrlib::rtti::tDataType<T>()).GetName()); 
     217  FINROC_LOG_PRINT(DEBUG_VERBOSE_1, "\nTesting port listeners for type ", (rrlib::rtti::tDataType<T>()).GetName()); 
    189218  tListener listener; 
    190   tFrameworkElement* parent = new tFrameworkElement(&finroc::core::tRuntimeEnvironment::GetInstance(), "TestPortListeners"); 
     219  core::tFrameworkElement* parent = new core::tFrameworkElement(&core::tRuntimeEnvironment::GetInstance(), "TestPortListeners"); 
    191220 
    192221  tOutputPort<T> output_port("Output Port", parent); 
     
    204233  output_port.Publish(publish_value); 
    205234 
     235  RRLIB_UNIT_TESTS_ASSERT(listener.value1 == publish_value && listener.value2 == publish_value && listener.calls == 6); 
     236 
    206237  parent->ManagedDelete(); 
    207238} 
    208239 
    209 int main(int, char**) 
    210 { 
    211   TestPortChains(); 
    212   TestPortQueues<int>(1, 2, 3); 
    213   TestPortQueues<std::string>("1", "2", "3"); 
    214   TestPortListeners<int>(1); 
    215   TestPortListeners<std::string>("test"); 
    216  
    217   tThreadLocalBufferManagement local_buffers; 
    218   TestPortChains(); 
    219   TestPortQueues<int>(1, 2, 3); 
    220   TestPortListeners<int>(1); 
    221  
    222   return 0; 
    223 } 
     240class DataPortsTestCollection : public rrlib::util::tUnitTestSuite 
     241{ 
     242  RRLIB_UNIT_TESTS_BEGIN_SUITE(DataPortsTestCollection); 
     243  RRLIB_UNIT_TESTS_ADD_TEST(Test); 
     244  RRLIB_UNIT_TESTS_END_SUITE; 
     245 
     246  void Test() 
     247  { 
     248    TestPortChains(); 
     249    TestPortQueues<int>(1, 2, 3); 
     250    TestPortQueues<std::string>("1", "2", "3"); 
     251    TestPortListeners<int>(1); 
     252    TestPortListeners<std::string>("test"); 
     253 
     254    tThreadLocalBufferManagement local_buffers; 
     255    TestPortChains(); 
     256    TestPortQueues<int>(1, 2, 3); 
     257    TestPortListeners<int>(1); 
     258  } 
     259}; 
     260 
     261RRLIB_UNIT_TESTS_REGISTER_SUITE(DataPortsTestCollection); 
     262 
     263//---------------------------------------------------------------------- 
     264// End of namespace declaration 
     265//---------------------------------------------------------------------- 
     266} 
     267} 
Note: See TracChangeset for help on using the changeset viewer.