/* * (c) Copyright, Real-Time Innovations, 2023. * All rights reserved. * * No duplications, whole or partial, manual or electronic, may be made * without express written permission. Any such copies, or * revisions thereof, must display this notice unaltered. * This code contains trade secrets of Real-Time Innovations, Inc. */ #ifndef ddsctesthelpers_testContext_h #define ddsctesthelpers_testContext_h #include "rtitest/test_context.h" #include "ddsctesthelpers/test_helper.h" #include "ddsctesttypes/Foo.h" #include "ddsctesttypes/FooPlugin.h" #include "ddsctesttypes/FooSupport.h" #include "ddsctesttypes/Raw1k.h" #include "ddsctesttypes/Raw1kPlugin.h" #include "ddsctesttypes/Raw1kSupport.h" #ifdef __cplusplus extern "C" { #endif #ifndef TEST_DOMAIN #define TEST_DOMAIN 0 #endif /* Test Stop Watch */ struct DDSCTestStopWatch { struct RTIClock *_clock; RTIBool _running; struct RTINtpTime _startTime; struct RTINtpTime _stopTime; }; extern DDSCTESTDllExport void DDSCTestStopWatch_initialize( struct DDSCTestStopWatch *self, struct RTIClock *clock); extern DDSCTESTDllExport RTIBool DDSCTestStopWatch_start(struct DDSCTestStopWatch *self); extern DDSCTESTDllExport RTIBool DDSCTestStopWatch_stop(struct DDSCTestStopWatch *self); extern DDSCTESTDllExport RTIBool DDSCTestStopWatch_getElapsedTime( struct DDSCTestStopWatch *self, struct DDS_Duration_t *elapsedTime); /* -------------------------------------------------------------------------- */ /* Context Information */ struct DDSCTestContext { struct RTITestContext base; struct RTIOsapiSemaphore *syncSem; DDS_WaitSet *syncWaitSet; struct RTIClock *clock; int isInitialized; struct DDSCTestStopWatch stopWatch; }; extern DDSCTESTDllExport DDS_ReturnCode_t DDSCTester_getParticipantQos( DDS_DomainParticipantFactory *factory, struct DDS_DomainParticipantQos *participantQos); extern DDSCTESTDllExport RTIBool DDSCTestContext_initialize(struct DDSCTestContext *self); extern DDSCTESTDllExport void DDSCTestContext_finalize( struct DDSCTestContext *self); extern DDSCTESTDllExport struct DDSCTestContext *DDSCTestContext_new(void); extern DDSCTESTDllExport void DDSCTestContext_delete( struct DDSCTestContext *self); extern DDSCTESTDllExport RTIBool DDSCTestContext_wait( struct DDSCTestContext *self, const struct RTINtpTime *timeout); extern DDSCTESTDllExport RTIBool DDSCTestContext_signal(struct DDSCTestContext *self); extern DDSCTESTDllExport int DDSCTestContext_getCurrentMatchedReaderCount( DDS_DataWriter *writer); extern DDSCTESTDllExport int DDSCTestContext_getCurrentMatchedWriterCount( DDS_DataReader *reader); /** * @ingroup DDSCTestHelpers * @brief Get the current count of alive writers matched with the given reader * @param reader The reader whose alive writer count we need * @return The count of alive writers */ extern DDSCTESTDllExport DDS_Long DDSCTestContext_getCurrentAliveWriterCount(DDS_DataReader *reader); extern DDSCTESTDllExport DDS_ReturnCode_t DDSCTestContext_waitForReadersAdv( int numReaders, DDS_DataWriter *writer, int timeoutSecs, RTIBool exactMatching, RTIBool timeoutIsExpected); /** * @ingroup DDSCTestHelpers * @brief Does an active wait until numReaders readers are discovered by writer, * or during timeoutSecs until failure. * @param numReaders \b In. The number of readers we expect to discover. * @param writer \b In. The DataWriter to monitor. * @param timeoutSecs \b In. Time to wait until numReaders readers are * discovered, in seconds. * @return DDS_RETCODE_OK if numReaders readers are discovered, another return * code if something goes wrong or the timeout is reached before all expected * readers are discovered. */ extern DDSCTESTDllExport DDS_ReturnCode_t DDSCTestContext_waitForReaders( int numReaders, DDS_DataWriter *writer, int timeoutSecs); extern DDSCTESTDllExport DDS_ReturnCode_t DDSCTestContext_waitForWritersAdv( int numWriters, DDS_DataReader *reader, int timeoutSecs, RTIBool exactMatching, RTIBool timeoutIsExpected); /** @internal * Wait for up to the given timeout period for the number of alive writers for * the given reader to match the expected value * * @param expectedNumWriters The number of alive writers we are expecting * @param reader The reader that is matched with the writers * @param timeoutSecs The maximum period to wait to see if the expected number * of alive writers is found * @param exactMatching Whether the expected number of alive writers must be * matched exactly or if the actual number can exceed the expected number * @param timeoutIsExpected Indicates whether the function is expected to * timeout * @return Return code indicating success, timeout, or other failure */ extern DDSCTESTDllExport DDS_ReturnCode_t DDSCTestContext_waitForAliveWritersAdv( int expectedNumWriters, DDS_DataReader *reader, int timeoutSecs, RTIBool exactMatching, RTIBool timeoutIsExpected); /** * @ingroup DDSCTestHelpers * @brief Does an active wait until numWriters writers are discovered by reader, * or during timeoutSecs until failure. * @param numWriters \b In. The number of writers we expect to discover. * @param reader \b In. The DataReader to monitor. * @param timeoutSecs \b In. Time to wait until numWriter writers are * discovered, in seconds. * @return DDS_RETCODE_OK if numWriters writers are discovered, another return * code if something goes wrong or the timeout is reached before all expected * writers are discovered. */ extern DDSCTESTDllExport DDS_ReturnCode_t DDSCTestContext_waitForWriters( int numWriters, DDS_DataReader *reader, int timeoutSecs); /** @internal * @ingroup DDSCTestHelpers * @brief Does an active wait until numWriters alive writers are discovered by * reader, or during timeoutSecs until failure. * @param expectedNumWriters \b In. The number of alive writers we expect to * discover. * @param reader \b In. The DataReader to monitor. * @param timeoutSecs \b In. Time to wait until numWriter alive writers are * discovered, in seconds. * @return DDS_RETCODE_OK if numWriters alive writers are discovered, another * return code if something goes wrong or the timeout is reached before all * expected alive writers are discovered. */ extern DDSCTESTDllExport DDS_ReturnCode_t DDSCTestContext_waitForAliveWriters( int expectedNumWriters, DDS_DataReader *reader, int timeoutSecs); extern DDSCTESTDllExport DDS_ReturnCode_t DDSCTestContext_waitFordata( const struct DDSCTestContext *self, int numSamples, DDS_DataReader *reader, int timeoutSecs); extern DDSCTESTDllExport DDS_ReturnCode_t DDSCTestContextHelper_waitForUnacknowledgedSampleCount( DDS_Long unacknowledgedSampleCount, DDS_DataWriter *writer, int timeoutSecs); extern DDSCTESTDllExport DDS_ReturnCode_t DDSCTestContextHelper_waitForReliableReaderActivityChanged( DDS_Long activeCount, DDS_Long inactiveCount, DDS_DataWriter *writer, int timeoutSecs); extern DDSCTESTDllExport DDS_Long DDSCTestContext_getMatchingPublicationsLength( const struct DDSCTestContext *self, DDS_DataReader *reader); extern DDSCTESTDllExport DDS_ReturnCode_t DDSCTestContext_waitMatchingPublications( const struct DDSCTestContext *self, DDS_DataReader *reader, int expectedMatchingPublicationsLength); extern DDSCTESTDllExport DDS_Long DDSCTestContext_getMatchingSubscriptionsLength( const struct DDSCTestContext *self, DDS_DataWriter *writer); extern DDSCTESTDllExport DDS_ReturnCode_t DDSCTestContext_waitMatchingSubscriptions( const struct DDSCTestContext *self, DDS_DataWriter *writer, int expectedMatchingSubscriptionsLength); extern DDSCTESTDllExport RTIBool DDSCTestContext_isParticipantDiscoveredWithHandle( DDS_DomainParticipant *participant, const DDS_InstanceHandle_t *remoteParticipantHandle); extern DDSCTESTDllExport RTIBool DDSCTestContext_isParticipantDiscovered( DDS_DomainParticipant *participant, DDS_DomainParticipant *remoteParticipant); /* * Similar to DDSCTestContext_isParticipantDiscovered, but will * also count participants that have only been partially discovered (may * be pending configuration or authentication). * * @param participant Participant * @param remoteParticipant Remote participant to check if discovvered. * * @return RTI_TRUE if participant has been partially discovered, RTI_FALSE * if the participant has not been partially discovered at all. */ extern DDSCTESTDllExport RTIBool DDSCTestContext_isParticipantPartiallyDiscovered( DDS_DomainParticipant *participant, DDS_DomainParticipant *remoteParticipant); extern DDSCTESTDllExport RTIBool DDSCTestContext_waitForParticipantDiscoveryWithTime( DDS_DomainParticipant *localParticipant, DDS_DomainParticipant *remoteParticipant, unsigned int sec); extern DDSCTESTDllExport RTIBool DDSCTestContext_waitForParticipantDiscovery( DDS_DomainParticipant *localParticipant, DDS_DomainParticipant *remoteParticipant); extern DDSCTESTDllExport DDS_LongLong DDSCTestContext_getReceivedSampleCount( const struct DDSCTestContext *self, DDS_DataReader *reader); extern DDSCTESTDllExport RTIBool DDSCTestContext_waitForReceivedSampleCount( const struct DDSCTestContext *self, DDS_DataReader *reader, DDS_LongLong receivedSampleCount); /* * Wait for the local participant to discover an expected number of * remote participants. This only counts participants that are fully discovered. * * @param expected Number of expected remote participants * @param participant Pointer to local participant * @param discPartSeqPtr Out. Will contain list of instance handles of * remote participants if not NULL. Can be NULL if you do not need the * list of remote participants * @param maxSeconds Maximum number of seconds to wait for expected participant * count * * @return RTI_TRUE if participant discovered expected number of remote * participants, RTI_FALSE otherwise. */ extern DDSCTESTDllExport RTIBool DDSCTestContext_waitForDiscoveredParticipants( int expected, DDS_DomainParticipant *participant, struct DDS_InstanceHandleSeq *discPartSeqPtr, int maxSeconds); /* * Wait for the local participant to discover an expected number of * remote participants. This only counts participants that are partially * discovered (bootstrap received but not config). * * @param expected Number of expected remote participants * @param participant Pointer to local participant * @param discPartSeqPtr Out. Will contain list of instance handles of * remote participants if not NULL. Can be NULL if you do not need the * list of remote participants * @param maxSeconds Maximum number of seconds to wait for expected participant * count * * @return RTI_TRUE if participant discovered expected number of remote * participants, RTI_FALSE otherwise. */ extern DDSCTESTDllExport RTIBool DDSCTestContext_waitForPartiallyDiscoveredParticipants( int expected, DDS_DomainParticipant *participant, struct DDS_InstanceHandleSeq *discPartSeqPtr, int maxSeconds); /* -------------------------------------------------------------------------- */ /* DDSCPubSubTesterContext */ struct DDSCPubSubDataReaderListenerData { struct DDSCTestContext *testContext; RTIBool error; int numberOfSamplesReceived; int numberOfNotValidSamplesReceived; int numberOfDisposeSamplesReceived; int numberOfNotAliveNoWritersSamplesReceived; int numberOfInvalidAliveSamplesReceived; int noWritersGenerationCount; int disposedGenerationCount; struct DDS_SampleLostStatus lostStatus; struct DDS_SampleRejectedStatus rejectedStatus; RTIBool doRead; RTIBool keyed; RTIBool blockInDataAvailable; /* When enabled, the listener will log additional info in debug mode */ RTIBool additionalLogInfoIsEnabled; /* Used when additionalLogInfo is enabled to include a reader id */ int additionalLogInfoReaderId; struct RTIOsapiSemaphore *syncSem; int numberOfMatches; struct DDS_LivelinessChangedStatus livelinessChangedStatus; RTIBool requestedIncompatibleQos; }; #define DDSCPubSubDataReaderListenerData_INITIALIZER \ { \ NULL, /* testContext */ \ RTI_FALSE, /* error */ \ 0, /* numberOfSamplesReceived */ \ 0, /* numberOfNotValidSamplesReceived */ \ 0, /* numberOfDisposeSamplesReceived */ \ 0, /* numberOfNotAliveNoWritersSamplesReceived */ \ 0, /* numberOfInvalidAliveSamplesReceived */ \ 0, /* noWritersGenerationCount */ \ 0, /* disposedGenerationCount */ \ DDS_SampleLostStatus_INITIALIZER, /* lostStatus */ \ DDS_SampleRejectedStatus_INITIALIZER, /* rejectedStatus */ \ RTI_FALSE, /* doRead */ \ RTI_TRUE, /* keyed */ \ RTI_FALSE, /* blockInDataAvailable */ \ RTI_FALSE, /* additionalLogInfoIsEnabled */ \ -1, /* additionalLogInfoReaderId */ \ NULL, /* syncSem */ \ 0, /* numberOfMatches */ \ DDS_LivelinessChangedStatus_INITIALIZER, /* livelinessChangedStatus \ */ \ RTI_FALSE /* requestedIncompatibleQos */ \ } extern DDSCTESTDllExport void DDSCPubSubDataReaderListenerData_reset( struct DDSCPubSubDataReaderListenerData *listener_data); extern DDSCTESTDllExport void DDSCPubSubDataReaderListener_onDataAvailable( void *listener_data, DDS_DataReader *reader); extern DDSCTESTDllExport void DDSCPubSubDataReaderListener_onSampleLost( void *listener_data, DDS_DataReader *reader, const struct DDS_SampleLostStatus *status); extern DDSCTESTDllExport void DDSCPubSubDataReaderListener_onSampleRejected( void *listener_data, DDS_DataReader *reader, const struct DDS_SampleRejectedStatus *status); extern DDSCTESTDllExport void DDSCPubSubDataReaderListener_onSubscriptionMatched( void *listener_data, DDS_DataReader *reader, const struct DDS_SubscriptionMatchedStatus *status); extern DDSCTESTDllExport void DDSCPubSubDataReaderListener_onLivelinessChanged( void *listener_data, DDS_DataReader *reader, const struct DDS_LivelinessChangedStatus *status); extern DDSCTESTDllExport void DDSCPubSubDataReaderListener_onRequestedIncompatibleQoS( void *listener_data, DDS_DataReader *reader, const struct DDS_RequestedIncompatibleQosStatus *status); struct DDSCPubSubTestContext { struct DDSCTestContext *baseContext; DDS_DomainParticipantFactory *factory; DDS_DomainParticipant *pubParticipant; DDS_DomainParticipant *subParticipant; DDS_Publisher *publisher; DDS_Subscriber *subscriber; DDS_Topic *keyedPubTopic; DDS_Topic *keyedSubTopic; DDS_DataWriter *writer; DDS_Topic *unkeyedPubTopic; DDS_Topic *unkeyedSubTopic; DDS_DataReader *reader; void *keyedInstance; void *unkeyedInstance; DDS_Boolean oldEnableEntities; struct RTINtpTime livelinessLossTime; DDS_Boolean shmemEnabled; struct DDSCPubSubDataReaderListenerData readerListenerData; struct DDS_DataReaderListener readerListener; struct FooSeq unkeyedDataSeq; struct Raw1kSeq keyedDataSeq; struct DDS_SampleInfoSeq infoSeq; RTIBool loanedSeq; struct DDS_SampleInfo sampleInfo; }; struct DDSCPubSubTestContextTypeCfg_t { struct PRESTypePlugin *typePlugin; const char *typeName; const char *topicName; void *registrationData; }; struct DDSCPubSubTestContextTypeConfig { struct DDSCPubSubTestContextTypeCfg_t keyed; struct DDSCPubSubTestContextTypeCfg_t unkeyed; }; #define DDSCPubSubTestContextTypeConfig_INITIALIZER \ { \ { NULL, NULL, NULL, NULL }, \ { NULL, NULL, NULL, NULL } \ } #define DDSCPubSubTestContextTypeConfig_initialize_keyed( \ typeConfig, \ keyedType) \ { \ typeConfig.keyed.typePlugin = keyedType##Plugin_new(); \ typeConfig.keyed.typeName = #keyedType "Type"; \ typeConfig.keyed.topicName = #keyedType "Topic"; \ } #define DDSCPubSubTestContextTypeConfig_initialize_unkeyed( \ typeConfig, \ unkeyedType) \ { \ typeConfig.unkeyed.typePlugin = unkeyedType##Plugin_new(); \ typeConfig.unkeyed.typeName = #unkeyedType "Type"; \ typeConfig.unkeyed.topicName = #unkeyedType "Topic"; \ } extern DDSCTESTDllExport RTIBool DDSCPubSubTestContext_forceLivelinessLoss( struct DDSCPubSubTestContext *self, RTIBool pubParticipant, struct RTIClock *mockClock, RTIBool waitForLivelinessLoss, DDS_TransportBuiltinKind transportKind); extern DDSCTESTDllExport RTIBool DDSCPubSubTestContext_restoreLiveliness( struct DDSCPubSubTestContext *self, RTIBool pubParticipant, struct RTIClock *mockClock, RTIBool waitForLivelinessRestoration, DDS_TransportBuiltinKind transportKind); extern DDSCTESTDllExport RTIBool DDSCPubSubTestContext_returnLoan(struct DDSCPubSubTestContext *context); extern DDSCTESTDllExport RTIBool DDSCPubSubTestContext_delete( struct DDSCPubSubTestContext *context) RTI_NODISCARD; struct DDSCPubSubTestContextProperty { RTIBool disableShmem; /* If disableShmem is FALSE, but this is TRUE, SHMEM is disabled only in * the subParticipant. */ RTIBool disableShmemInSubParticipant; /* If enabled and the architecture supports IPv6, we will use the IPv6 * version of the built-in transport if available. */ RTIBool useIpv6; RTIBool disableType; /* Profile name applied to the participants created by the context. * It overwrites the global profile name */ const char *participantLibraryName; const char *participantProfileName; /* Profile name applied to all entities created by the context */ const char *globalLibraryName; const char *globalProfileName; const struct DDS_DomainParticipantQos *participantQos; /* * If you set createEntitiesDisabled to true, then creating a context sets * the autoenable_created_entities factory QoS, and deleting the context * restores the autoenable_created_entities factory QoS. If you create more * than one context, it is important that you delete them in the opposite * order of creation. That is, the first context to be created must be the * last one to be deleted (because it stores the original value of the * autoenable_created_entities factory QoS, so that value is the one that * must be restored last). */ RTIBool createEntitiesDisabled; /* If enabled, the participants will be configured to assert/check * liveliness within a short period. (Default: false) */ RTIBool useShortParticipantLiveliness; /* If enabled, the liveliness readers will be created as reliable readers. * (Default: false) */ RTIBool useReliableLivelinessReaders; /* If enabled, the participant id of each participant will be automatically * calculated. If now, it will be manually set by TestContext. * (Default: true) */ RTIBool useAutoParticipantId; int builtinTypeMaxSize; RTIBool topicPresentation; RTIBool coherentAccess; RTIBool pubParticipantCrossEndian; RTIBool subParticipantCrossEndian; /* If enabled disables all builtin transports in the participant creation */ RTIBool disableBuiltinTransports; /* * Indicates if accept_unknown_peers can be overwritten by the context * when creating a participant based on SHMEM settings. */ RTIBool overwriteAcceptUnknownPeers; }; #define DDSCPubSubTestContextProperty_INITIALIZER \ { \ RTI_FALSE, /* disableShmem*/ \ RTI_FALSE, /* disableShmemInSubParticipant */ \ RTI_FALSE, /* useIpv6 */ \ RTI_FALSE, /* disableType */ \ NULL, /* participantLibraryName */ \ NULL, /* participantProfileName */ \ NULL, /* globalLibraryName */ \ NULL, /* globalProfileName */ \ NULL, /* participantQos */ \ RTI_FALSE, /* createEntitiesDisabled */ \ RTI_FALSE, /* useShortParticipantLiveliness */ \ RTI_FALSE, /* useReliableLivelinessReaders */ \ RTI_TRUE, /* useAutoParticipantId */ \ -1, /* builtinTypeMaxSize */ \ RTI_TRUE, /* topicPresentation */ \ RTI_FALSE, /* coherentAccess */ \ RTI_FALSE, /* pubParticipantCrossEndian */ \ RTI_FALSE, /* subParticipantCrossEndian */ \ RTI_FALSE, /* disableBuiltinTransports */ \ RTI_TRUE /* overwriteAcceptUnknownPeers */ \ } extern DDSCTESTDllExport RTIBool DDSCPubSubTestContext_createWriterDisabled( struct DDSCPubSubTestContext *context, const struct DDS_DataWriterQos *writerQos, struct DDS_DataWriterListener *listener, DDS_StatusMask listenerMask); extern DDSCTESTDllExport RTIBool DDSCPubSubTestContext_createWriter( struct DDSCPubSubTestContext *context, const struct DDS_DataWriterQos *writerQos, struct DDS_DataWriterListener *listener, DDS_StatusMask listenerMask); extern DDSCTESTDllExport RTIBool DDSCPubSubTestContext_deleteSubscriber(struct DDSCPubSubTestContext *context); extern DDSCTESTDllExport RTIBool DDSCPubSubTestContext_deletePublisher(struct DDSCPubSubTestContext *context); extern DDSCTESTDllExport RTIBool DDSCPubSubTestContext_deleteReader(struct DDSCPubSubTestContext *context); extern DDSCTESTDllExport RTIBool DDSCPubSubTestContext_deleteWriter(struct DDSCPubSubTestContext *context); extern DDSCTESTDllExport RTIBool DDSCPubSubTestContext_getReliableWriterQos( struct DDSCPubSubTestContext *context, struct DDS_DataWriterQos *writerQos); extern DDSCTESTDllExport RTIBool DDSCPubSubTestContext_createReliableWriter( struct DDSCPubSubTestContext *context, struct DDS_DataWriterListener *listener, DDS_StatusMask listenerMask); extern DDSCTESTDllExport RTIBool DDSCPubSubTestContext_createReaderDisabled( struct DDSCPubSubTestContext *context, const struct DDS_DataReaderQos *readerQos, struct DDS_DataReaderListener *listener, DDS_StatusMask listenerMask); extern DDSCTESTDllExport RTIBool DDSCPubSubTestContext_createReader( struct DDSCPubSubTestContext *context, const struct DDS_DataReaderQos *readerQos, struct DDS_DataReaderListener *listener, DDS_StatusMask listenerMask); extern DDSCTESTDllExport RTIBool DDSCPubSubTestContext_getReliableReaderQos( struct DDSCPubSubTestContext *context, struct DDS_DataReaderQos *readerQos); extern DDSCTESTDllExport RTIBool DDSCPubSubTestContext_createReliableReader( struct DDSCPubSubTestContext *context, struct DDS_DataReaderListener *listener, DDS_StatusMask listenerMask); extern DDSCTESTDllExport RTIBool DDSCPubSubTestContext_createReaderWithDefaultListener( struct DDSCPubSubTestContext *context, const struct DDS_DataReaderQos *qos); extern DDSCTESTDllExport RTIBool DDSCPubSubTestContext_getTestDefaultParticipantQos( struct DDS_DomainParticipantQos *participantQos, const struct DDSCPubSubTestContextProperty *property); extern DDSCTESTDllExport RTIBool DDSCPubSubTestContext_createTopicWithQos( struct DDSCPubSubTestContext *context, struct DDSCPubSubTestContextTypeConfig *typeConfig, struct DDS_TopicQos *topicQos, RTIBool isPub); extern DDSCTESTDllExport RTIBool DDSCPubSubTestContext_createTopic( struct DDSCPubSubTestContext *context, struct DDSCPubSubTestContextTypeConfig *typeConfig, RTIBool isPub); extern DDSCTESTDllExport RTIBool DDSCPubSubTestContext_createPubOrSub( struct DDSCPubSubTestContext *context, const struct DDSCPubSubTestContextProperty *property, RTIBool isPub); extern DDSCTESTDllExport struct DDSCPubSubTestContext * DDSCPubSubTestContext_createI( const char *METHOD_NAME, int id, struct DDSCPubSubTestContextTypeConfig *typeConfig, const struct DDSCPubSubTestContextProperty *property, RTIBool createParticipants); extern DDSCTESTDllExport struct DDSCPubSubTestContext * DDSCPubSubTestContext_create( const char *METHOD_NAME, int id, struct DDSCPubSubTestContextTypeConfig *typeConfig, const struct DDSCPubSubTestContextProperty *property); extern DDSCTESTDllExport RTIBool DDSCPubSubTestContext_createPubParticipantWithTypeConfig( struct DDSCPubSubTestContext *context, int id, struct DDSCPubSubTestContextTypeConfig *typeConfig, const struct DDSCPubSubTestContextProperty *property); extern DDSCTESTDllExport RTIBool DDSCPubSubTestContext_createSubParticipantWithTypeConfig( struct DDSCPubSubTestContext *context, int id, struct DDSCPubSubTestContextTypeConfig *typeConfig, const struct DDSCPubSubTestContextProperty *property); extern DDSCTESTDllExport RTIBool DDSCPubSubTestContext_createPubParticipant( struct DDSCPubSubTestContext *context, int domainId, RTIBool keyed, const struct DDSCPubSubTestContextProperty *property); extern DDSCTESTDllExport RTIBool DDSCPubSubTestContext_createSubParticipant( struct DDSCPubSubTestContext *context, int domainId, RTIBool keyed, const struct DDSCPubSubTestContextProperty *property); extern DDSCTESTDllExport void DDSCPubSubTestContext_initializeListener( struct DDSCPubSubTestContext *context); extern DDSCTESTDllExport RTIBool DDSCPubSubTestContext_waitForReadersAndWriters( struct DDSCPubSubTestContext *context, int numReaders, int numWriters); extern DDSCTESTDllExport RTIBool DDSCPubSubTestContext_waitForReaderAndWriter( struct DDSCPubSubTestContext *context); extern DDSCTESTDllExport DDS_Boolean DDSCPubSubTestContext_getReceivedInteger( struct DDSCPubSubTestContext *context, int *receivedInteger, /* out */ int sampleIndex); extern DDSCTESTDllExport const struct DDS_SampleInfo * DDSCPubSubTestContext_getReceivedSampleInfo( struct DDSCPubSubTestContext *context, int sampleIndex); extern DDSCTESTDllExport int DDSCPubSubTestContext_read( struct DDSCPubSubTestContext *context, RTIBool doTake, DDS_ReadCondition *rCond); extern DDSCTESTDllExport DDS_ReturnCode_t DDSCPubSubTestContext_unregisterInstance( struct DDSCPubSubTestContext *context, DDS_DataWriter *writer, unsigned int instanceToUnregister); extern DDSCTESTDllExport DDS_ReturnCode_t DDSCPubSubTestContext_disposeInstance( struct DDSCPubSubTestContext *context, DDS_DataWriter *writer, int instanceToDispose); extern DDSCTESTDllExport DDS_ReturnCode_t DDSCPubSubTestContext_disposeInstanceWithTimestamp( struct DDSCPubSubTestContext *context, DDS_DataWriter *writer, int instanceToDispose, const struct DDS_Time_t *sourceTimestamp); extern DDSCTESTDllExport DDS_ReturnCode_t DDSCPubSubTestContext_writeInstance( struct DDSCPubSubTestContext *context, DDS_DataWriter *writer, int instanceToWrite); extern DDSCTESTDllExport DDS_ReturnCode_t DDSCPubSubTestContext_writeInstanceWithTimestamp( struct DDSCPubSubTestContext *context, DDS_DataWriter *writer, int instanceToWrite, const struct DDS_Time_t *sourceTimestamp); extern DDSCTESTDllExport DDS_ReturnCode_t DDSCPubSubTestContext_writeNumSamples( struct DDSCPubSubTestContext *context, DDS_DataWriter *writer, unsigned int numSamples, unsigned int numInstances); extern DDSCTESTDllExport DDS_ReturnCode_t DDSCPubSubTestContext_writeWithTimestamp( struct DDSCPubSubTestContext *context, DDS_DataWriter *writer, void *data, const DDS_InstanceHandle_t *instanceHandle, struct DDS_Time_t *sourceTimestamp); /** * @brief Writes data to a DDS data writer with specified parameters. * * This function writes data to the specified DDS data writer using the provided * parameters. * * @param[in] context The test context. * @param[in] writer The DDS data writer. * @param[in] data The data to be written. * @param[inout] params The write parameters. * * @return The return code indicating the success or failure of the write operation. */ extern DDSCTESTDllExport DDS_ReturnCode_t DDSCPubSubTestContext_writeWithParams( struct DDSCPubSubTestContext *context, DDS_DataWriter *writer, const void *data, struct DDS_WriteParams_t *params); extern DDSCTESTDllExport DDS_ReturnCode_t DDSCPubSubTestContext_disposeWithParams( struct DDSCPubSubTestContext *context, DDS_DataWriter *writer, const void *data, struct DDS_WriteParams_t *params); extern DDSCTESTDllExport DDS_ReturnCode_t DDSCPubSubTestContext_readNextSample( struct DDSCPubSubTestContext *context, RTIBool doTake); extern DDSCTESTDllExport int DDSCPubSubTestContext_readInstance( struct DDSCPubSubTestContext *context, RTIBool doTake, int id); extern DDSCTESTDllExport struct DDSCPubSubTestContext * DDSCPubSubTestContext_newEx( const char *METHOD_NAME, int domainId, RTIBool keyed, const struct DDSCPubSubTestContextProperty *property, RTIBool createParticipants); extern DDSCTESTDllExport struct DDSCPubSubTestContext * DDSCPubSubTestContext_new( const char *FUNCTION_NAME, int domainId, RTIBool keyed, const struct DDSCPubSubTestContextProperty *property); /** * @brief Configures the ODBC writer history properties. * * All the properties are set at the Participant level if participantQos is * provided. Otherwise, they are set at the DataWriter level. * * When useClassLevelProperties is set to RTI_TRUE, the properties are set at * the class level. Otherwise, they are set at the plugin instance level. * * Class level: dds.data_writer.history.odbc_plugin.username * Plugin instance level: dds.data_writer.history.odbc_plugin.builtin.username */ extern DDSCTESTDllExport RTIBool DDSCTestCommon_configureOdbcWriterHistory( struct DDS_DomainParticipantQos *participantQos, struct DDS_DataWriterQos *writerQos, const struct RTITestSetting *setting, RTIBool inMemoryOdbc, RTIBool useClassLevelProperties); /** * @brief Enable durable writer history by setting storage_settings.enable * to DDS_BOOLEAN_TRUE and storage_settings.file_name to a test file name. */ extern DDSCTESTDllExport RTIBool DDSCTestCommon_enableDurableWriterHistory( const struct RTITestSetting *setting, struct DDS_DataWriterQos *writerQos); /* -------------------------------------------------------------------------- */ /* DDSCScenarioTester */ typedef enum { DDSCScenarioTester_NO_OP, DDSCScenarioTester_WAIT_PEERS, /* param == reader | writer (0 | 1) */ DDSCScenarioTester_WRITE, DDSCScenarioTester_DISPOSE, DDSCScenarioTester_WAIT, DDSCScenarioTester_WAIT_W_COND, /* param == index of condition */ DDSCScenarioTester_WAIT_RC, /* wait for matching read condition */ DDSCScenarioTester_WAIT_MATCHING_SUBSCRIPTIONS, /* param == expected subscriptions */ DDSCScenarioTester_WAIT_MATCHING_PUBLICATIONS, /* param == expected publications */ DDSCScenarioTester_IGNORE_ENTITY, /* param == reader | writer (0 | 1) */ DDSCScenarioTester_READ, DDSCScenarioTester_TAKE, DDSCScenarioTester_READ_INSTANCE, DDSCScenarioTester_TAKE_INSTANCE, DDSCScenarioTester_READ_NEXT_INSTANCE, DDSCScenarioTester_TAKE_NEXT_INSTANCE, DDSCScenarioTester_READ_W_COND, /* param == index of condition */ DDSCScenarioTester_TAKE_W_COND, /* param == index of condition */ DDSCScenarioTester_READ_INSTANCE_W_COND, /* param == index of condition */ DDSCScenarioTester_TAKE_INSTANCE_W_COND, /* param == index of condition */ DDSCScenarioTester_READ_NEXT_INSTANCE_W_COND,/* param == index of condition */ DDSCScenarioTester_TAKE_NEXT_INSTANCE_W_COND,/* param == index of condition */ DDSCScenarioTester_CREATE_QUERY_CONDITION, DDSCScenarioTester_SET_QUERY_CONDITION_PARAM_1,/* param == index of condition */ DDSCScenarioTester_SET_QUERY_CONDITION_PARAM_2,/* param == index of condition */ DDSCScenarioTester_ASSERT_READCONDITION_STATUS, /* param == matching bit mask */ /* pseudo-ops */ DDSCScenarioTester_COMMON_KEYED_READ_TAKE, DDSCScenarioTester_COMMON_UNKEYED_READ_TAKE } DDSCScenarioTester_op; struct DDSCScenarioTester_data { int value; int instance; }; /* configuration of read|take mask, or of a ReadCondition */ struct DDSCScenarioTester_readConditionCfg_t { DDS_SampleStateMask sample_state; DDS_ViewStateMask view_state; DDS_InstanceStateMask instance_state; }; /* a single step of the unit test */ struct DDSCScenarioTester_operation { DDSCScenarioTester_op op; RTIBool success; int param; /* operation dependent parameter */ struct DDSCScenarioTester_readConditionCfg_t read_mask; int rep_count; /* negative rep_count interpreted to use UNLIMITED on read, and abs(rep_count) for seq length */ /* data - single data for write & read instance ID for read_instance, read_next_instance timeout - timeout value for wait */ union { struct DDSCScenarioTester_data data; struct DDS_Duration_t timeout; } u; /* pointer to data for: array of data for multi-data write and read single or array of data for all read_instance, read_next_instance */ struct DDSCScenarioTester_data *data_ptr; }; /* configuration for read (filter_expression == NULL) or query condition */ struct DDSCScenarioTester_filterCfg_t { struct DDSCScenarioTester_readConditionCfg_t filter_states; char *filter_expression; /* The filter input parameter when using SET_QUERY_CONDITION_PARAM_1 */ char *filter_parameter_0; /* The filter input parameter when using SET_QUERY_CONDITION_PARAM_2 */ char *filter_parameter_1; /* If RTI_TRUE, we force the use of evaluateOnSerialized for evaluating * samples. This is useful for testing the code path followed by APIs that * rely on the serialized form of the samples (e.g., Java). */ RTIBool force_filter_on_serialized; /* If RTI_TRUE, the QueryCondition will always pass for not-alive samples, * independently of any value cached in the filter. */ RTIBool querycondition_pass_not_alive_samples; }; /* configuration for one scenario of the unit test */ struct DDSCScenarioTester_config { DDS_PresentationQosPolicyAccessScopeKind access_scope; DDS_HistoryQosPolicyKind history_kind; /* DDS_DataWriterProtocolQosPolicy's serialize key with dispose */ RTIBool serialize_key_with_dispose; /* DDS_DataReaderProtocolQosPolicy's propagate dispose of unregister */ RTIBool propagate_dispose_of_unregistered_instances; DDS_Long history_depth; DDS_Long max_samples; DDS_Long max_samples_per_instance; RTIBool useWaitSet; /* to insure delay multi-sample should NOT use WaitSet */ RTIBool keyed; /* keyed or unkeyed */ RTIBool createMonitorReadConditions; RTIBool enableEntities; /* True: v1 writer, false: v2 writer */ RTIBool useV1Writer; int allocThreshold; }; #define DDSCScenarioTester_rep_count_to_read_count(x__) \ ((x__) < 0 ? DDS_LENGTH_UNLIMITED : (x__)) #define DDS_SCENARIO_TESTER_LENGTH_UNLIMITED (-1) #define DDS_TEST_CONTEXT_ANY_SAMPLE_STATE \ (DDS_READ_SAMPLE_STATE | DDS_NOT_READ_SAMPLE_STATE) #define DDS_TEST_CONTEXT_ANY_VIEW_STATE \ (DDS_NEW_VIEW_STATE | DDS_NOT_NEW_VIEW_STATE) #define DDS_TEST_CONTEXT_ANY_INSTANCE_STATE \ (DDS_ALIVE_INSTANCE_STATE | DDS_NOT_ALIVE_DISPOSED_INSTANCE_STATE \ | DDS_NOT_ALIVE_NO_WRITERS_INSTANCE_STATE) #define DDSC_SCENARIO_TESTER_READ_CONDITION_COMBINATIONS 12 extern DDSCTESTDllExport RTIBool DDSCScenarioTester( const struct RTITestSetting *setting, const struct DDSCScenarioTester_config *cfg, const struct DDSCScenarioTester_operation *sequence, const struct DDSCScenarioTester_filterCfg_t *filterCfg, const char *METHOD_NAME); /* -------------------------------------------------------------------------- */ /* Topic Query */ extern DDSCTESTDllExport int DDSCTestHelper_getWriterSessionSampleCount( struct DDSCPubSubTestContext *context, RTIBool topicQuerySession); extern DDSCTESTDllExport RTIBool DDSCTestHelper_getTopicQueryTestWriterQos( struct DDSCPubSubTestContext *testContext, struct DDS_DataWriterQos *writerQos); extern DDSCTESTDllExport RTIBool DDSCTestHelper_getTopicQueryTestReaderQos( struct DDSCPubSubTestContext *testContext, struct DDS_DataReaderQos *readerQos); /* * Used with DDSCTestContextRelatedEntityTestObjects_write to log number * of related entity discovery messages. */ struct DDSCTestContextRelatedEntityTestObjectsLoggerDeviceData { /* * Number of messages logged when running * PRESPsService_onLinkEndpointWithRelatedGuid when the local reader can * be linked. */ int linkRelatedMessageCount; /* * Number of messages logged when posting the * PRESPsService_onLinkEndpointWithRelatedGuid event from * PRESPsServiceLink_setMatchToCompatible. */ int notReadyToLinkMessageCount; }; #define DDSCTestContextRelatedEntityTestObjectsLoggerDeviceData_INITIALIZER \ { \ 0, /* linkRelatedMessageCount*/ \ 0 /* notReadyToLinkMessageCount */ \ } /* * Structure used by tests in BuiltinTester and DomainDiscoveryTester that * set related entity GUIDs. */ struct DDSCTestContextRelatedEntityTestObjects { /* Test context */ struct DDSCPubSubTestContext *context; /* Writer, belongs to subParticipant */ DDS_DataWriter *subWriter; /* Reader, belongs to pubParticipant */ DDS_DataReader *pubReader; /* Key of context->writer */ DDS_InstanceHandle_t pubWriterKey; /* Key of pubReader */ DDS_InstanceHandle_t pubReaderKey; /* Key of context->reader */ DDS_InstanceHandle_t subReaderKey; /* Key of subWriter */ DDS_InstanceHandle_t subWriterKey; struct DDS_DomainParticipantQos participantQos; /* Used to corrupt packets to stop endpoint discovery from occurring */ struct MIGGeneratorListener tamperingListener; /* * Configures tampering listener, contains info like what writer OID * to corrupt and when to stop corrupting */ struct DDSCTestHelperTamperingListenerData tamperingListenerData; /* Used to check for log messages from events */ NDDS_Config_Logger *logger; RTIBool loggingConfigurationIsCached; struct NDDS_Config_LoggerDevice loggingDevice; struct DDSCTestContextRelatedEntityTestObjectsLoggerDeviceData loggingDeviceData; }; #define DDSCTestContextRelatedEntityTestObjects_INITIALIZER \ { \ NULL, /* context */ \ NULL, /* subWriter */ \ NULL, /* pubReader */ \ DDS_HANDLE_NIL, /* pubWriterKey */ \ DDS_HANDLE_NIL, /* pubReaderKey */ \ DDS_HANDLE_NIL, /* subReaderKey */ \ DDS_HANDLE_NIL, /* subWriterKey */ \ DDS_DomainParticipantQos_INITIALIZER, /* participantQos */ \ MIGGeneratorListener_INITIALIZER, /* tamperingListener */ \ DDSCTestHelperTamperingListenerData_INITIALIZER, /* tamperingListenerData \ */ \ NULL /* logger */, RTI_FALSE, /* loggingConfigurationIsCached \ */ \ NDDS_Config_LoggerDevice_INITIALIZER, /* loggingDevice */ \ DDSCTestContextRelatedEntityTestObjectsLoggerDeviceData_INITIALIZER /* loggingDeviceData */ \ } /* * Initializes the members of a DDSCTestContextRelatedEntityTestObjects. * This creates 2 participants, each with a reader and the writer. Each writer * has the reader's GUID as its related entity GUID, and each reader has * the writer's GUID as its related entity GUID. * * @param objects DDSCTestContextRelatedEntityTestObjects to initialize * @param domainId domain for participants to use * @param delayReaderDiscovery If TRUE we will set the tampering listener to * tamper DATA(R)s * @param delayWriterDiscovery If TRUE we will set the tampering listener to * tamper DATA(W)s * @param tamperDirected If TRUE and either delayReaderDiscovery or * delayWriterDiscovery are TRUE, we will only tamper messages directed to * context->pubParticipant. If FALSE and either delayReaderDiscovery or * delayWriterDiscovery are TRUE, we will tamper all messages. * * @return RTI_TRUE if success, RTI_FALSE if failure */ RTIBool DDSCTestContextRelatedEntityTestObjects_initialize( struct DDSCTestContextRelatedEntityTestObjects *objects, DDS_DomainId_t domainId, RTIBool delayReaderDiscovery, RTIBool delayWriterDiscovery, RTIBool tamperDirected); /* * Delete the objects in a DDSCTestContextRelatedEntityTestObjects. * * @param objects DDSCTestContextRelatedEntityTestObjects to delete * * @return RTI_TRUE if success, RTI_FALSE if failure */ RTIBool DDSCTestContextRelatedEntityTestObjects_finalize( struct DDSCTestContextRelatedEntityTestObjects *objects); /** * @brief All of the DynamicDataTests that use the pubsub context set the same * values in the DDSCPubSubTestContextProperty. So we've refactored that to a * single function here * * @param property The property to initialize * @param participantQos The participant Qos to configure. If NULL, only * the context will be configured. * @param useTypeObjectV2 RTI_TRUE to configure the participant to use Type * Object V2, RTI_FALSE to use Type Object V1 * * @return RTI_TRUE if successful, RTI_FALSE otherwise */ RTIBool DDSCPubSubTestContextProperty_initializeForDynamicData( struct DDSCPubSubTestContextProperty *property, struct DDS_DomainParticipantQos *participantQos, RTIBool useTypeObjectV2); #ifdef __cplusplus } #endif #endif /* ddsctesthelpers_testContext_h */