diff options
author | msmit <msmit@remedy.nl> | 2011-06-10 15:02:00 +0000 |
---|---|---|
committer | msmit <msmit@remedy.nl> | 2011-06-10 15:02:00 +0000 |
commit | f2b21e7c332de838214a617c07256c88777cc2c4 (patch) | |
tree | cf97ac552119cdb9799dc99f5504098c81b56200 | |
parent | 00e610c46972e0da3dd47b06a2b6327651c3cfae (diff) | |
download | ATCD-f2b21e7c332de838214a617c07256c88777cc2c4.tar.gz |
Fri Jun 10 15:01:15 UTC 2011 Marcel Smit <msmit@remedy.nl>
* bin/ciao_tests.lst:
* connectors/dds4ccm/tests/TypeSupport:
* connectors/dds4ccm/tests/TypeSupport/TypeSupport.mpc:
* connectors/dds4ccm/tests/TypeSupport/main.cpp:
* connectors/dds4ccm/tests/TypeSupport/run_test.pl:
Added a new (regular C++) which tests the TypeSupport class and its
internal type factory administration.
-rw-r--r-- | CIAO/ChangeLog | 10 | ||||
-rw-r--r-- | CIAO/bin/ciao_tests.lst | 1 | ||||
-rw-r--r-- | CIAO/connectors/dds4ccm/tests/TypeSupport/TypeSupport.mpc | 11 | ||||
-rw-r--r-- | CIAO/connectors/dds4ccm/tests/TypeSupport/main.cpp | 201 | ||||
-rwxr-xr-x | CIAO/connectors/dds4ccm/tests/TypeSupport/run_test.pl | 25 |
5 files changed, 248 insertions, 0 deletions
diff --git a/CIAO/ChangeLog b/CIAO/ChangeLog index b15fc3d31c8..e84f707c6cc 100644 --- a/CIAO/ChangeLog +++ b/CIAO/ChangeLog @@ -1,3 +1,13 @@ +Fri Jun 10 15:01:15 UTC 2011 Marcel Smit <msmit@remedy.nl> + + * bin/ciao_tests.lst: + * connectors/dds4ccm/tests/TypeSupport: + * connectors/dds4ccm/tests/TypeSupport/TypeSupport.mpc: + * connectors/dds4ccm/tests/TypeSupport/main.cpp: + * connectors/dds4ccm/tests/TypeSupport/run_test.pl: + Added a new (regular C++) which tests the TypeSupport class and its + internal type factory administration. + Fri Jun 10 14:54:14 UTC 2011 Marcel Smit <msmit@remedy.nl> * connectors/dds4ccm/impl/ndds/TypeSupport.h: diff --git a/CIAO/bin/ciao_tests.lst b/CIAO/bin/ciao_tests.lst index 385939b7b5d..f8a2dfe0ec6 100644 --- a/CIAO/bin/ciao_tests.lst +++ b/CIAO/bin/ciao_tests.lst @@ -131,6 +131,7 @@ TAO/CIAO/connectors/dds4ccm/tests/MemLeakDetection/TypeRegistration/descriptors/ TAO/CIAO/connectors/dds4ccm/tests/LateBinding/ReadGet/descriptors/run_test.pl: !STATIC !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO !NOXERCES !ACE_FOR_TAO !ST NDDS TAO/CIAO/connectors/dds4ccm/tests/LateBinding/UpdateWrite/descriptors/run_test.pl: !STATIC !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO !NOXERCES !ACE_FOR_TAO !ST NDDS TAO/CIAO/connectors/dds4ccm/tests/Proxies/ReadWrite/descriptors/run_test.pl: !STATIC !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO !NOXERCES !ACE_FOR_TAO !ST NDDS +TAO/CIAO/connectors/dds4ccm/tests/TypeSupport/run_test.pl: !STATIC !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO !NOXERCES !ACE_FOR_TAO !ST NDDS TAO/CIAO/connectors/dds4ccm/tutorials/Shapes/Shapes_asm/Deployment/scripts/run_test.pl: !STATIC !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO !NOXERCES !ACE_FOR_TAO !ST NDDS TAO/CIAO/connectors/dds4ccm/performance-tests/Latency/descriptors/run_test.pl: !STATIC !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO !NOXERCES !ACE_FOR_TAO !ST NDDS TAO/CIAO/connectors/dds4ccm/performance-tests/DDSLatency/descriptors/run_test_dds.pl: !ACE_FOR_TAO !ST NDDS diff --git a/CIAO/connectors/dds4ccm/tests/TypeSupport/TypeSupport.mpc b/CIAO/connectors/dds4ccm/tests/TypeSupport/TypeSupport.mpc new file mode 100644 index 00000000000..15c362de6aa --- /dev/null +++ b/CIAO/connectors/dds4ccm/tests/TypeSupport/TypeSupport.mpc @@ -0,0 +1,11 @@ +// $Id$ + +project(DDS_TypeSupport_Test) : taoexe, typecode, dds4ccm_base { + includes += $(CIAO_ROOT) + exename = typesupport_test + requires += dds4ccm_ndds + + Source_Files { + main.cpp + } +}
\ No newline at end of file diff --git a/CIAO/connectors/dds4ccm/tests/TypeSupport/main.cpp b/CIAO/connectors/dds4ccm/tests/TypeSupport/main.cpp new file mode 100644 index 00000000000..9d9309ae5be --- /dev/null +++ b/CIAO/connectors/dds4ccm/tests/TypeSupport/main.cpp @@ -0,0 +1,201 @@ +// $Id$ + +#include "ace/OS_main.h" +#include "ace/Log_Msg.h" +#include "ace/Env_Value_T.h" + +#include "dds4ccm/impl/ndds/TypeSupport.h" +#include "dds4ccm/impl/ndds/DomainParticipant.h" +#include "dds4ccm/impl/ndds/DomainParticipantFactory.h" + +typedef ::CIAO::NDDS::DDS_DomainParticipantFactory_i + DomainParticipantFactory; + +class TestTypeFactory : public ::CIAO::NDDS::DDS_TypeFactory_i +{ + virtual DDS::DataWriter_ptr create_datawriter (DDSDataWriter* , + ::DDS::DomainParticipant_ptr , + ::DDS::Publisher_ptr ) + { + return ::DDS::DataWriter::_nil (); + } + + virtual DDS::DataReader_ptr create_datareader (DDSDataReader* , + ::DDS::DomainParticipant_ptr , + ::DDS::Subscriber_ptr ) + { + return ::DDS::DataReader::_nil (); + } +}; + +int +ACE_TMAIN (int , ACE_TCHAR **) +{ +#if (CIAO_DDS4CCM_NDDS != 1) + ACE_DEBUG ((LM_DEBUG, "RTI DDS only test\n")); + return 0; +#endif + + int ret = 0; + + try + { + int domain_id = 0; + ACE_Env_Value<int> id (ACE_TEXT("DDS4CCM_DEFAULT_DOMAIN_ID"), domain_id); + domain_id = id; + + DomainParticipantFactory pf; + + ::DDS::DomainParticipantQos qos; + ::DDS::DomainParticipant_var dp1 = pf.create_participant ( + domain_id, + qos, + ::DDS::DomainParticipantListener::_nil (), + 0); + + ::DDS::DomainParticipant_var dp2 = pf.create_participant ( + domain_id, + qos, + ::DDS::DomainParticipantListener::_nil (), + 0); + + const char * type1 = "DataType1"; + const char * type2 = "DataType2"; + + TestTypeFactory * f1 = 0; + TestTypeFactory * f2 = 0; + + ACE_NEW_THROW_EX (f1, + TestTypeFactory (), + ::CORBA::NO_MEMORY ()); + ACE_NEW_THROW_EX (f2, + TestTypeFactory (), + ::CORBA::NO_MEMORY ()); + + + // Register the the first factory + if (::CIAO::NDDS::DDS_TypeSupport_i::register_type(type1, f1, dp1.in())) + { + ACE_DEBUG ((LM_DEBUG, "OK - Type <%C> for DP1 succesfully registered\n", + type1)); + } + else + { + ACE_ERROR ((LM_ERROR, "ERROR - Type <%C> for DP1 could not be registered\n", + type1)); + ++ret; + } + // Register the same factory again + if (::CIAO::NDDS::DDS_TypeSupport_i::register_type(type1, f1, dp1.in())) + { + ACE_ERROR ((LM_ERROR, "ERROR - Type <%C> for DP1 could be registered\n", + type1)); + ++ret; + } + else + { + ACE_DEBUG ((LM_DEBUG, "OK - Type <%C> for DP1 could not be registered\n", + type1)); + } + // Register the same factory again but with another name + if (::CIAO::NDDS::DDS_TypeSupport_i::register_type(type2, f1, dp1.in())) + { + ACE_DEBUG ((LM_DEBUG, "OK - Type <%C> for DP1 could be registered\n", + type2)); + } + else + { + ACE_ERROR ((LM_ERROR, "ERROR - Type <%C> for DP1 could not be registered\n", + type2)); + ++ret; + } + + // Unregister an unused factory by using an unused domain participant + ::CIAO::NDDS::DDS_TypeFactory_i * tmp = ::CIAO::NDDS::DDS_TypeSupport_i::unregister_type(type1, dp2.in()); + + if (tmp) + { + ACE_ERROR ((LM_ERROR, "ERROR - Unregistered type <%C> for DP2 could be unregistered\n", + type2)); + ++ret; + } + else + { + ACE_DEBUG ((LM_DEBUG, "OK - Unregistered Type <%C> for DP2 could not be unregistered\n", + type2)); + } + + // Unregister a registered type by using a used domain participant + tmp = ::CIAO::NDDS::DDS_TypeSupport_i::unregister_type(type1, dp1.in()); + + if (tmp) + { + ACE_DEBUG ((LM_DEBUG, "OK - Unregistered type <%C> for DP1 could be unregistered\n", + type2)); + } + else + { + ACE_ERROR ((LM_ERROR, "ERROR - Unregistered Type <%C> for DP1 could not be unregistered\n", + type2)); + ++ret; + } + + // Unregister a the same type and domain participant again + tmp = ::CIAO::NDDS::DDS_TypeSupport_i::unregister_type(type1, dp1.in()); + + if (tmp) + { + ACE_ERROR ((LM_ERROR, "ERROR - Unregistered type <%C> for DP1 could be unregistered\n", + type2)); + ++ret; + } + else + { + ACE_DEBUG ((LM_DEBUG, "OK - Unregistered Type <%C> for DP1 could not be unregistered\n", + type2)); + } + + // Call Close on TypeSupport. This should remove the last remaining entry. + ::CIAO::NDDS::DDS_TypeSupport_i::close(); + + // Unregister the type and domain participant which should be removed by 'close' + tmp = ::CIAO::NDDS::DDS_TypeSupport_i::unregister_type(type2, dp1.in()); + + if (tmp) + { + ACE_ERROR ((LM_ERROR, "ERROR - Unregistered type <%C> for DP1 could be unregistered\n", + type2)); + ++ret; + } + else + { + ACE_DEBUG ((LM_DEBUG, "OK - Unregistered Type <%C> for DP1 could not be unregistered\n", + type2)); + } + + delete f1; + delete f2; + } + catch (const ::CORBA::Exception& e) + { + e._tao_print_exception ("ACE_TMAIN - Caught unexpected " + "CORBA exception\n"); + return 1; + } + catch (...) + { + ACE_ERROR ((LM_ERROR, "ACE_TMAIN - ERROR: Caught unexpected " + "exception\n")); + return 1; + } + if (ret == 0) + { + ACE_DEBUG ((LM_DEBUG, "Test passed !\n")); + } + else + { + ACE_ERROR ((LM_ERROR, "%d errors found during test. \n", + ret)); + } + return ret; +}
\ No newline at end of file diff --git a/CIAO/connectors/dds4ccm/tests/TypeSupport/run_test.pl b/CIAO/connectors/dds4ccm/tests/TypeSupport/run_test.pl new file mode 100755 index 00000000000..6620ac3085c --- /dev/null +++ b/CIAO/connectors/dds4ccm/tests/TypeSupport/run_test.pl @@ -0,0 +1,25 @@ +eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' + & eval 'exec perl -S $0 $argv:q' + if 0; + +# $Id$ +# -*- perl -*- + +use lib "$ENV{ACE_ROOT}/bin"; +use PerlACE::TestTarget; + +my $program = PerlACE::TestTarget::create_target (1) || die "Create target 1 failed\n"; + +$PROG = $program->CreateProcess ("typesupport_test", ""); +$program_status = $PROG->Spawn (); + +if ($program_status != 0) { + print STDERR "ERROR: GroupDataPolicy returned $program_status\n"; + exit 1; +} + +sleep ($program->ProcessStartWaitInterval()); + +$program_status = $PROG->Kill (); + +exit 0; |