diff --git a/include/fastrtps/rtps/messages/CDRMessage.hpp b/include/fastrtps/rtps/messages/CDRMessage.hpp index 89c07c8aade..1c934201fba 100644 --- a/include/fastrtps/rtps/messages/CDRMessage.hpp +++ b/include/fastrtps/rtps/messages/CDRMessage.hpp @@ -157,7 +157,7 @@ inline bool CDRMessage::readSequenceNumberSet(CDRMessage_t* msg,SequenceNumberSe { bool valid = true; valid &=CDRMessage::readSequenceNumber(msg,&sns->base); - uint32_t numBits; + uint32_t numBits = 0; valid &=CDRMessage::readUInt32(msg,&numBits); int32_t bitmap; SequenceNumber_t seqNum; @@ -183,7 +183,7 @@ inline bool CDRMessage::readFragmentNumberSet(CDRMessage_t* msg, FragmentNumberS { bool valid = true; valid &= CDRMessage::readUInt32(msg, &fns->base); - uint32_t numBits; + uint32_t numBits = 0; valid &= CDRMessage::readUInt32(msg, &numBits); int32_t bitmap; FragmentNumber_t fragNum; diff --git a/src/cpp/rtps/messages/RTPSMessageGroup.cpp b/src/cpp/rtps/messages/RTPSMessageGroup.cpp index 7040c2284d6..bb22ec2589a 100644 --- a/src/cpp/rtps/messages/RTPSMessageGroup.cpp +++ b/src/cpp/rtps/messages/RTPSMessageGroup.cpp @@ -118,7 +118,7 @@ void get_participants_from_endpoints(const std::vector& endpoints, std:: { participants.clear(); - for (auto& endpoint : endpoints) + for (const GUID_t& endpoint : endpoints) { if (std::find(participants.begin(), participants.end(), endpoint.guidPrefix) == participants.end()) participants.push_back(endpoint.guidPrefix); diff --git a/test/blackbox/BlackboxTests.cpp b/test/blackbox/BlackboxTests.cpp index ee6940fdb38..46e6e2bf477 100644 --- a/test/blackbox/BlackboxTests.cpp +++ b/test/blackbox/BlackboxTests.cpp @@ -1094,7 +1094,7 @@ BLACKBOXTEST(BlackBox, AsyncPubSubWithFlowController64kb) slowWriter.send(data); // In 1 second only one of the messages has time to arrive std::this_thread::sleep_for(std::chrono::milliseconds(500)); - ASSERT_EQ(reader.getReceivedCount(), 1); + ASSERT_EQ(reader.getReceivedCount(), 1u); } BLACKBOXTEST(BlackBox, AsyncPubSubAsReliableData300kbInLossyConditions) diff --git a/test/certs/governance.txt b/test/certs/governance.txt index 825eae59502..095532e2347 100644 --- a/test/certs/governance.txt +++ b/test/certs/governance.txt @@ -1,5 +1,4 @@ openssl smime -sign -in governance.xml -text -out governance.smime -signer maincacert.pem -inkey maincakey.pem - openssl smime -sign -in permissions.xml -text -out permissions.smime -signer maincacert.pem -inkey maincakey.pem diff --git a/test/certs/governance_helloworld_all_enable.smime b/test/certs/governance_helloworld_all_enable.smime new file mode 100644 index 00000000000..efb07ff31c6 --- /dev/null +++ b/test/certs/governance_helloworld_all_enable.smime @@ -0,0 +1,72 @@ +MIME-Version: 1.0 +Content-Type: multipart/signed; protocol="application/x-pkcs7-signature"; micalg="sha-256"; boundary="----164906A0CF14A77A8223B425D3824F71" + +This is an S/MIME signed message + +------164906A0CF14A77A8223B425D3824F71 +Content-Type: text/plain + + + + + + + + 0 + 230 + + + false + true + ENCRYPT + ENCRYPT + ENCRYPT + + + HelloWorldTopic_* + true + true + true + true + ENCRYPT + ENCRYPT + + + + + + + +------164906A0CF14A77A8223B425D3824F71 +Content-Type: application/x-pkcs7-signature; name="smime.p7s" +Content-Transfer-Encoding: base64 +Content-Disposition: attachment; filename="smime.p7s" + +MIIEegYJKoZIhvcNAQcCoIIEazCCBGcCAQExDzANBglghkgBZQMEAgEFADALBgkq +hkiG9w0BBwGgggJAMIICPDCCAeOgAwIBAgIJALZwpgo2sxthMAoGCCqGSM49BAMC +MIGaMQswCQYDVQQGEwJFUzELMAkGA1UECAwCTUExFDASBgNVBAcMC1RyZXMgQ2Fu +dG9zMREwDwYDVQQKDAhlUHJvc2ltYTERMA8GA1UECwwIZVByb3NpbWExHjAcBgNV +BAMMFWVQcm9zaW1hIE1haW4gVGVzdCBDQTEiMCAGCSqGSIb3DQEJARYTbWFpbmNh +QGVwcm9zaW1hLmNvbTAeFw0xNzA5MDYwOTAzMDNaFw0yNzA5MDQwOTAzMD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AwIESDBGAiEAzh8X2N5oodm27sbFCmV79kbVEv3e ++uDsXpEUEzCmZaMCIQDDCIUmQ4Z0t+LVOOdzRCo72pmnKDZhT2HsX8Hnk3D7aw== + +------164906A0CF14A77A8223B425D3824F71-- + diff --git a/test/certs/governance_helloworld_all_enable.xml b/test/certs/governance_helloworld_all_enable.xml new file mode 100644 index 00000000000..86327572335 --- /dev/null +++ b/test/certs/governance_helloworld_all_enable.xml @@ -0,0 +1,31 @@ + + + + + + + 0 + 230 + + + false + true + ENCRYPT + ENCRYPT + ENCRYPT + + + HelloWorldTopic_* + true + true + true + true + ENCRYPT + ENCRYPT + + + + + + diff --git a/test/certs/permissions_helloworld.smime b/test/certs/permissions_helloworld.smime new file mode 100644 index 00000000000..3762139dbc7 --- /dev/null +++ b/test/certs/permissions_helloworld.smime @@ -0,0 +1,88 @@ +MIME-Version: 1.0 +Content-Type: multipart/signed; protocol="application/x-pkcs7-signature"; micalg="sha-256"; boundary="----1F82A5302084D025100F3FD8FDAD15C3" + +This is an S/MIME signed message + +------1F82A5302084D025100F3FD8FDAD15C3 +Content-Type: text/plain + + + + + + emailAddress=mainpub@eprosima.com, CN=Main Publisher, OU=eProsima, O=eProsima, ST=MA, C=ES + + 2013-06-01T13:00:00 + 2038-06-01T13:00:00 + + + + + 0 + 230 + + + + + HelloWorldTopic_* + + + + DENY + + + emailAddress=mainsub@eprosima.com, CN=Main Subscriber, OU=eProsima, O=eProsima, ST=MA, C=ES + + 2013-06-01T13:00:00 + 2038-06-01T13:00:00 + + + + + 0 + 230 + + + + + HelloWorldTopic_* + + + + DENY + + + + +------1F82A5302084D025100F3FD8FDAD15C3 +Content-Type: application/x-pkcs7-signature; name="smime.p7s" +Content-Transfer-Encoding: base64 +Content-Disposition: attachment; filename="smime.p7s" + +MIIEeQYJKoZIhvcNAQcCoIIEajCCBGYCAQExDzANBglghkgBZQMEAgEFADALBgkq +hkiG9w0BBwGgggJAMIICPDCCAeOgAwIBAgIJALZwpgo2sxthMAo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DxcNMTgxMTMwMTE1NzM0WjAvBgkqhkiG9w0BCQQxIgQg8Jau +J4cuVYqsY6gXCm3V1AubIShOsMGUP2ei1KmLiK4weQYJKoZIhvcNAQkPMWwwajAL +BglghkgBZQMEASowCwYJYIZIAWUDBAEWMAsGCWCGSAFlAwQBAjAKBggqhkiG9w0D +BzAOBggqhkiG9w0DAgICAIAwDQYIKoZIhvcNAwICAUAwBwYFKw4DAgcwDQYIKoZI +hvcNAwICASgwCgYIKoZIzj0EAwIERzBFAiBv3W4P/l1EOSHqzKaozvRFUL6E/K4I +CUOktT7YbkzWEQIhALKDGdtcwvwNUBkpUugccEQyaunDFc672Vcq3J1V8tek + +------1F82A5302084D025100F3FD8FDAD15C3-- + diff --git a/test/certs/permissions_helloworld.xml b/test/certs/permissions_helloworld.xml new file mode 100644 index 00000000000..638ceb7a3ae --- /dev/null +++ b/test/certs/permissions_helloworld.xml @@ -0,0 +1,47 @@ + + + + + emailAddress=mainpub@eprosima.com, CN=Main Publisher, OU=eProsima, O=eProsima, ST=MA, C=ES + + 2013-06-01T13:00:00 + 2038-06-01T13:00:00 + + + + + 0 + 230 + + + + + HelloWorldTopic_* + + + + DENY + + + emailAddress=mainsub@eprosima.com, CN=Main Subscriber, OU=eProsima, O=eProsima, ST=MA, C=ES + + 2013-06-01T13:00:00 + 2038-06-01T13:00:00 + + + + + 0 + 230 + + + + + HelloWorldTopic_* + + + + DENY + + + diff --git a/test/communication/CMakeLists.txt b/test/communication/CMakeLists.txt index b7021ca2bf0..f9028b4e210 100644 --- a/test/communication/CMakeLists.txt +++ b/test/communication/CMakeLists.txt @@ -43,23 +43,121 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER) AND fastcdr_FOUND) target_include_directories(SimpleCommunicationSubscriber PRIVATE ${PROJECT_SOURCE_DIR}/test/blackbox) target_link_libraries(SimpleCommunicationSubscriber fastrtps fastcdr ${CMAKE_DL_LIBS}) + ############################################################################### + # Necessary files + ############################################################################### + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/simple_communication.py + ${CMAKE_CURRENT_BINARY_DIR}/simple_communication.py COPYONLY) + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/liveliness_assertion.py + ${CMAKE_CURRENT_BINARY_DIR}/liveliness_assertion.py COPYONLY) + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/simple_besteffort.xml + ${CMAKE_CURRENT_BINARY_DIR}/simple_besteffort.xml COPYONLY) + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/simple_reliable.xml + ${CMAKE_CURRENT_BINARY_DIR}/simple_reliable.xml COPYONLY) + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/simple_reliable_besteffort.xml + ${CMAKE_CURRENT_BINARY_DIR}/simple_reliable_besteffort.xml COPYONLY) + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/simple_secure_besteffort_pub.xml + ${CMAKE_CURRENT_BINARY_DIR}/simple_secure_besteffort_pub.xml COPYONLY) + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/simple_secure_besteffort_sub.xml + ${CMAKE_CURRENT_BINARY_DIR}/simple_secure_besteffort_sub.xml COPYONLY) + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/liveliness_assertion.xml + ${CMAKE_CURRENT_BINARY_DIR}/liveliness_assertion.xml COPYONLY) + if(SECURITY) + configure_file(${PROJECT_SOURCE_DIR}/test/certs/maincacert.pem + ${CMAKE_CURRENT_BINARY_DIR}/maincacert.pem COPYONLY) + configure_file(${PROJECT_SOURCE_DIR}/test/certs/mainpubcert.pem + ${CMAKE_CURRENT_BINARY_DIR}/mainpubcert.pem COPYONLY) + configure_file(${PROJECT_SOURCE_DIR}/test/certs/mainpubkey.pem + ${CMAKE_CURRENT_BINARY_DIR}/mainpubkey.pem COPYONLY) + configure_file(${PROJECT_SOURCE_DIR}/test/certs/mainsubcert.pem + ${CMAKE_CURRENT_BINARY_DIR}/mainsubcert.pem COPYONLY) + configure_file(${PROJECT_SOURCE_DIR}/test/certs/mainsubkey.pem + ${CMAKE_CURRENT_BINARY_DIR}/mainsubkey.pem COPYONLY) + configure_file(${PROJECT_SOURCE_DIR}/test/certs/governance_helloworld_all_enable.smime + ${CMAKE_CURRENT_BINARY_DIR}/governance_helloworld_all_enable.smime COPYONLY) + configure_file(${PROJECT_SOURCE_DIR}/test/certs/permissions_helloworld.smime + ${CMAKE_CURRENT_BINARY_DIR}/permissions_helloworld.smime COPYONLY) + endif() + if(PYTHONINTERP_FOUND) - add_test(NAME SimpleCommunication - COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/simple_communication.py) + add_test(NAME SimpleCommunicationBestEffort + COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/simple_communication.py) + + # Set test with label NoMemoryCheck + set_property(TEST SimpleCommunicationBestEffort PROPERTY LABELS "NoMemoryCheck") + + set_property(TEST SimpleCommunicationBestEffort PROPERTY ENVIRONMENT + "SIMPLE_COMMUNICATION_PUBLISHER_BIN=$") + set_property(TEST SimpleCommunicationBestEffort APPEND PROPERTY ENVIRONMENT + "SIMPLE_COMMUNICATION_SUBSCRIBER_BIN=$") + set_property(TEST SimpleCommunicationBestEffort APPEND PROPERTY ENVIRONMENT + "XML_FILE=simple_besteffort.xml") + if(WIN32) + string(REPLACE ";" "\\;" WIN_PATH "$ENV{PATH}") + set_property(TEST SimpleCommunicationBestEffort APPEND PROPERTY ENVIRONMENT + "PATH=$\\;$\\;${WIN_PATH}") + endif() + + add_test(NAME SimpleCommunicationReliable + COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/simple_communication.py) # Set test with label NoMemoryCheck - set_property(TEST SimpleCommunication PROPERTY LABELS "NoMemoryCheck") + set_property(TEST SimpleCommunicationReliable PROPERTY LABELS "NoMemoryCheck") - set_property(TEST SimpleCommunication PROPERTY ENVIRONMENT + set_property(TEST SimpleCommunicationReliable PROPERTY ENVIRONMENT "SIMPLE_COMMUNICATION_PUBLISHER_BIN=$") - set_property(TEST SimpleCommunication APPEND PROPERTY ENVIRONMENT + set_property(TEST SimpleCommunicationReliable APPEND PROPERTY ENVIRONMENT "SIMPLE_COMMUNICATION_SUBSCRIBER_BIN=$") + set_property(TEST SimpleCommunicationReliable APPEND PROPERTY ENVIRONMENT + "XML_FILE=simple_reliable.xml") if(WIN32) string(REPLACE ";" "\\;" WIN_PATH "$ENV{PATH}") - set_property(TEST SimpleCommunication APPEND PROPERTY ENVIRONMENT + set_property(TEST SimpleCommunicationReliable APPEND PROPERTY ENVIRONMENT "PATH=$\\;$\\;${WIN_PATH}") endif() + add_test(NAME SimpleCommunicationReliableBestEffort + COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/simple_communication.py) + + # Set test with label NoMemoryCheck + set_property(TEST SimpleCommunicationReliableBestEffort PROPERTY LABELS "NoMemoryCheck") + + set_property(TEST SimpleCommunicationReliableBestEffort PROPERTY ENVIRONMENT + "SIMPLE_COMMUNICATION_PUBLISHER_BIN=$") + set_property(TEST SimpleCommunicationReliableBestEffort APPEND PROPERTY ENVIRONMENT + "SIMPLE_COMMUNICATION_SUBSCRIBER_BIN=$") + set_property(TEST SimpleCommunicationReliableBestEffort APPEND PROPERTY ENVIRONMENT + "XML_FILE=simple_reliable_besteffort.xml") + if(WIN32) + string(REPLACE ";" "\\;" WIN_PATH "$ENV{PATH}") + set_property(TEST SimpleCommunicationReliableBestEffort APPEND PROPERTY ENVIRONMENT + "PATH=$\\;$\\;${WIN_PATH}") + endif() + + if(SECURITY) + add_test(NAME SimpleCommunicationSecureBestEffort + COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/simple_communication.py) + + # Set test with label NoMemoryCheck + set_property(TEST SimpleCommunicationSecureBestEffort PROPERTY LABELS "NoMemoryCheck") + + set_property(TEST SimpleCommunicationSecureBestEffort PROPERTY ENVIRONMENT + "SIMPLE_COMMUNICATION_PUBLISHER_BIN=$") + set_property(TEST SimpleCommunicationSecureBestEffort APPEND PROPERTY ENVIRONMENT + "SIMPLE_COMMUNICATION_SUBSCRIBER_BIN=$") + set_property(TEST SimpleCommunicationSecureBestEffort APPEND PROPERTY ENVIRONMENT + "XML_FILE_PUB=simple_secure_besteffort_pub.xml") + set_property(TEST SimpleCommunicationSecureBestEffort APPEND PROPERTY ENVIRONMENT + "XML_FILE_SUB=simple_secure_besteffort_sub.xml") + set_property(TEST SimpleCommunicationSecureBestEffort APPEND PROPERTY ENVIRONMENT + "EXTRA_PUB_ARG=--wait 2") + if(WIN32) + string(REPLACE ";" "\\;" WIN_PATH "$ENV{PATH}") + set_property(TEST SimpleCommunicationSecureBestEffort APPEND PROPERTY ENVIRONMENT + "PATH=$\\;$\\;${WIN_PATH}") + endif() + endif() + add_test(NAME LivelinessAssertion COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/liveliness_assertion.py) diff --git a/test/communication/Publisher.cpp b/test/communication/Publisher.cpp index 5c6219aa949..1ea6488b452 100644 --- a/test/communication/Publisher.cpp +++ b/test/communication/Publisher.cpp @@ -102,7 +102,8 @@ int main(int argc, char** argv) { int arg_count = 1; bool exit_on_lost_liveliness = false; - uint32_t seed = 7800; + uint32_t seed = 7800, wait = 0; + char* xml_file = nullptr; while(arg_count < argc) { @@ -120,14 +121,38 @@ int main(int argc, char** argv) seed = strtol(argv[arg_count], nullptr, 10); } + else if(strcmp(argv[arg_count], "--wait") == 0) + { + if(++arg_count >= argc) + { + std::cout << "--wait expects a parameter" << std::endl; + return -1; + } + + wait = strtol(argv[arg_count], nullptr, 10); + } + else if(strcmp(argv[arg_count], "--xmlfile") == 0) + { + if(++arg_count >= argc) + { + std::cout << "--xmlfile expects a parameter" << std::endl; + return -1; + } + + xml_file = argv[arg_count]; + } ++arg_count; } + if(xml_file) + { + Domain::loadXMLProfilesFile(xml_file); + } + ParticipantAttributes participant_attributes; + Domain::getDefaultParticipantAttributes(participant_attributes); participant_attributes.rtps.builtin.domainId = seed % 230; - participant_attributes.rtps.builtin.leaseDuration.seconds = 3; - participant_attributes.rtps.builtin.leaseDuration_announcementperiod.seconds = 1; ParListener participant_listener(exit_on_lost_liveliness); Participant* participant = Domain::createParticipant(participant_attributes, &participant_listener); @@ -145,10 +170,10 @@ int main(int argc, char** argv) //CREATE THE PUBLISHER PublisherAttributes publisher_attributes; + Domain::getDefaultPublisherAttributes(publisher_attributes); publisher_attributes.topic.topicKind = NO_KEY; publisher_attributes.topic.topicDataType = type.getName(); publisher_attributes.topic.topicName = topic.str(); - publisher_attributes.qos.m_reliability.kind = RELIABLE_RELIABILITY_QOS; Publisher* publisher = Domain::createPublisher(participant, publisher_attributes, &listener); if(publisher == nullptr) { @@ -156,9 +181,10 @@ int main(int argc, char** argv) return 1; } + if(wait > 0) { std::unique_lock lock(listener.mutex_); - listener.cv_.wait(lock, [&]{return listener.matched_ > 0;}); + listener.cv_.wait(lock, [&]{return listener.matched_ >= wait;}); } HelloWorld data; diff --git a/test/communication/Subscriber.cpp b/test/communication/Subscriber.cpp index 0d6891fdc28..e6cad4d86b3 100644 --- a/test/communication/Subscriber.cpp +++ b/test/communication/Subscriber.cpp @@ -79,6 +79,7 @@ int main(int argc, char** argv) int arg_count = 1; bool notexit = false; uint32_t seed = 7800; + char* xml_file = nullptr; while(arg_count < argc) { @@ -96,14 +97,28 @@ int main(int argc, char** argv) seed = strtol(argv[arg_count], nullptr, 10); } + else if(strcmp(argv[arg_count], "--xmlfile") == 0) + { + if(++arg_count >= argc) + { + std::cout << "--xmlfile expects a parameter" << std::endl; + return -1; + } + + xml_file = argv[arg_count]; + } ++arg_count; } + if(xml_file) + { + Domain::loadXMLProfilesFile(xml_file); + } + ParticipantAttributes participant_attributes; + Domain::getDefaultParticipantAttributes(participant_attributes); participant_attributes.rtps.builtin.domainId = seed % 230; - participant_attributes.rtps.builtin.leaseDuration.seconds = 3; - participant_attributes.rtps.builtin.leaseDuration_announcementperiod.seconds = 1; Participant* participant = Domain::createParticipant(participant_attributes); if(participant==nullptr) return 1; @@ -121,10 +136,10 @@ int main(int argc, char** argv) //CREATE THE SUBSCRIBER SubscriberAttributes subscriber_attributes; + Domain::getDefaultSubscriberAttributes(subscriber_attributes); subscriber_attributes.topic.topicKind = NO_KEY; subscriber_attributes.topic.topicDataType = type.getName(); subscriber_attributes.topic.topicName = topic.str(); - subscriber_attributes.qos.m_reliability.kind = RELIABLE_RELIABILITY_QOS; Subscriber* subscriber = Domain::createSubscriber(participant, subscriber_attributes, &listener); if(subscriber == nullptr) diff --git a/test/communication/liveliness_assertion.py b/test/communication/liveliness_assertion.py index 07889458d5d..8fd306e433c 100644 --- a/test/communication/liveliness_assertion.py +++ b/test/communication/liveliness_assertion.py @@ -12,15 +12,30 @@ # See the License for the specific language governing permissions and # limitations under the License. -import sys, os, subprocess +import sys, os, subprocess, glob + +script_dir = os.path.dirname(os.path.realpath(__file__)) publisher_command = os.environ.get("SIMPLE_COMMUNICATION_PUBLISHER_BIN") +if not publisher_command: + publisher_files = glob.glob(os.path.join(script_dir, "**/SimpleCommunicationPublisher*"), recursive=True) + publisher_command = next(iter(publisher_files), None) assert publisher_command subscriber_command = os.environ.get("SIMPLE_COMMUNICATION_SUBSCRIBER_BIN") +if not subscriber_command: + subscriber_files = glob.glob(os.path.join(script_dir, "**/SimpleCommunicationSubscriber*"), recursive=True) + subscriber_command = next(iter(subscriber_files), None) assert subscriber_command +xml_file = os.environ.get("XML_FILE") +if xml_file: + real_xml_file = os.path.join(script_dir, xml_file) +else: + real_xml_file = os.path.join(script_dir, "liveliness_assertion.xml") -subscriber_proc = subprocess.Popen([subscriber_command, "--seed", str(os.getpid()), "--notexit"]) -publisher_proc = subprocess.Popen([publisher_command, "--seed", str(os.getpid()), "--exit_on_lost_liveliness"], stdout=subprocess.PIPE) +subscriber_proc = subprocess.Popen([subscriber_command, "--seed", str(os.getpid()), "--notexit", + "--xmlfile", real_xml_file]) +publisher_proc = subprocess.Popen([publisher_command, "--seed", str(os.getpid()), "--exit_on_lost_liveliness", + "--xmlfile", real_xml_file], stdout=subprocess.PIPE) while True: line = publisher_proc.stdout.readline() diff --git a/test/communication/liveliness_assertion.xml b/test/communication/liveliness_assertion.xml new file mode 100644 index 00000000000..825bc918608 --- /dev/null +++ b/test/communication/liveliness_assertion.xml @@ -0,0 +1,20 @@ + + + + + + + + + 3 + + + + + 1 + + + + + + diff --git a/test/communication/simple_besteffort.xml b/test/communication/simple_besteffort.xml new file mode 100644 index 00000000000..e78905764c1 --- /dev/null +++ b/test/communication/simple_besteffort.xml @@ -0,0 +1,18 @@ + + + + + + BEST_EFFORT + + + + + + + + BEST_EFFORT + + + + diff --git a/test/communication/simple_communication.py b/test/communication/simple_communication.py index 79f5b1f15b4..07fb36a0eab 100644 --- a/test/communication/simple_communication.py +++ b/test/communication/simple_communication.py @@ -12,18 +12,62 @@ # See the License for the specific language governing permissions and # limitations under the License. -import sys, os, subprocess +import sys, os, subprocess, glob + +script_dir = os.path.dirname(os.path.realpath(__file__)) publisher_command = os.environ.get("SIMPLE_COMMUNICATION_PUBLISHER_BIN") +if not publisher_command: + publisher_files = glob.glob(os.path.join(script_dir, "**/SimpleCommunicationPublisher*"), recursive=True) + pf = iter(publisher_files) + publisher_command = next(pf, None) + while publisher_command and (not os.path.isfile(publisher_command) or not os.access(publisher_command, + os.X_OK)): + publisher_command = next(pf, None) assert publisher_command subscriber_command = os.environ.get("SIMPLE_COMMUNICATION_SUBSCRIBER_BIN") +if not subscriber_command: + subscriber_files = glob.glob(os.path.join(script_dir, "**/SimpleCommunicationSubscriber*"), recursive=True) + pf = iter(subscriber_files) + subscriber_command = next(pf, None) + while subscriber_command and (not os.path.isfile(subscriber_command) or not os.access(subscriber_command, + os.X_OK)): + subscriber_command = next(pf, None) assert subscriber_command -subscriber_proc = subprocess.Popen([subscriber_command, "--seed", str(os.getpid())]) -publisher_proc = subprocess.Popen([publisher_command, "--seed", str(os.getpid())]) +extra_pub_arg = os.environ.get("EXTRA_PUB_ARG") +if extra_pub_arg: + extra_pub_args = extra_pub_arg.split() +else: + extra_pub_args = [] + +real_xml_file_pub = None +real_xml_file_sub = None +xml_file = os.environ.get("XML_FILE") +if xml_file: + real_xml_file_pub = os.path.join(script_dir, xml_file) + real_xml_file_sub = os.path.join(script_dir, xml_file) +else: + xml_file_pub = os.environ.get("XML_FILE_PUB") + if xml_file_pub: + real_xml_file_pub = os.path.join(script_dir, xml_file_pub) + xml_file_sub = os.environ.get("XML_FILE_SUB") + if xml_file_sub: + real_xml_file_sub = os.path.join(script_dir, xml_file_sub) + +subscriber1_proc = subprocess.Popen([subscriber_command, "--seed", str(os.getpid())] + + (["--xmlfile", real_xml_file_sub] if real_xml_file_sub else [])) +publisher_proc = subprocess.Popen([publisher_command, "--seed", str(os.getpid())] + + (["--xmlfile", real_xml_file_pub] if real_xml_file_pub else []) + + extra_pub_args) +subscriber2_proc = subprocess.Popen([subscriber_command, "--seed", str(os.getpid())] + + (["--xmlfile", real_xml_file_sub] if real_xml_file_sub else [])) -subscriber_proc.communicate() -retvalue = subscriber_proc.returncode +subscriber1_proc.communicate() +retvalue = subscriber1_proc.returncode +subscriber2_proc.communicate() +if retvalue == 0: + retvalue = subscriber2_proc.returncode publisher_proc.kill() diff --git a/test/communication/simple_reliable.xml b/test/communication/simple_reliable.xml new file mode 100644 index 00000000000..95770d83cc7 --- /dev/null +++ b/test/communication/simple_reliable.xml @@ -0,0 +1,18 @@ + + + + + + RELIABLE + + + + + + + + RELIABLE + + + + diff --git a/test/communication/simple_reliable_besteffort.xml b/test/communication/simple_reliable_besteffort.xml new file mode 100644 index 00000000000..cc7749af5be --- /dev/null +++ b/test/communication/simple_reliable_besteffort.xml @@ -0,0 +1,18 @@ + + + + + + RELIABLE + + + + + + + + BEST_EFFORT + + + + diff --git a/test/communication/simple_secure_besteffort_pub.xml b/test/communication/simple_secure_besteffort_pub.xml new file mode 100644 index 00000000000..964f7715e59 --- /dev/null +++ b/test/communication/simple_secure_besteffort_pub.xml @@ -0,0 +1,61 @@ + + + + + + + + + dds.sec.auth.plugin + builtin.PKI-DH + + + + dds.sec.auth.builtin.PKI-DH.identity_ca + file://maincacert.pem + + + dds.sec.auth.builtin.PKI-DH.identity_certificate + file://mainpubcert.pem + + + dds.sec.auth.builtin.PKI-DH.private_key + file://mainpubkey.pem + + + + dds.sec.access.plugin + builtin.Access-Permissions + + + + dds.sec.access.builtin.Access-Permissions.permissions_ca + file://maincacert.pem + + + dds.sec.access.builtin.Access-Permissions.governance + file://governance_helloworld_all_enable.smime + + + dds.sec.access.builtin.Access-Permissions.permissions + file://permissions_helloworld.smime + + + + dds.sec.crypto.plugin + builtin.AES-GCM-GMAC + + + + + + + + + + BEST_EFFORT + + + + + diff --git a/test/communication/simple_secure_besteffort_sub.xml b/test/communication/simple_secure_besteffort_sub.xml new file mode 100644 index 00000000000..368aeba4c5c --- /dev/null +++ b/test/communication/simple_secure_besteffort_sub.xml @@ -0,0 +1,61 @@ + + + + + + + + + dds.sec.auth.plugin + builtin.PKI-DH + + + + dds.sec.auth.builtin.PKI-DH.identity_ca + file://maincacert.pem + + + dds.sec.auth.builtin.PKI-DH.identity_certificate + file://mainsubcert.pem + + + dds.sec.auth.builtin.PKI-DH.private_key + file://mainsubkey.pem + + + + dds.sec.access.plugin + builtin.Access-Permissions + + + + dds.sec.access.builtin.Access-Permissions.permissions_ca + file://maincacert.pem + + + dds.sec.access.builtin.Access-Permissions.governance + file://governance_helloworld_all_enable.smime + + + dds.sec.access.builtin.Access-Permissions.permissions + file://permissions_helloworld.smime + + + + dds.sec.crypto.plugin + builtin.AES-GCM-GMAC + + + + + + + + + + BEST_EFFORT + + + + +