diff --git a/.azure/templates/build-test.yml b/.azure/templates/build-test.yml index 45a485ba79..ba5d540755 100644 --- a/.azure/templates/build-test.yml +++ b/.azure/templates/build-test.yml @@ -115,6 +115,7 @@ steps: -DENABLE_LIFESPAN=${LIFESPAN:-on} \ -DENABLE_DEADLINE_MISSED=${DEADLINE_MISSED:-on} \ -DSKIP_DEADLINE_UPDATE={DEADLINE_UPDATE_SKIP:-off} \ + -DENABLE_TYPELIB=${TYPELIB:-on} \ -DENABLE_TYPE_DISCOVERY=${TYPE_DISCOVERY:-on} \ -DENABLE_TOPIC_DISCOVERY=${TOPIC_DISCOVERY:-on} \ -DENABLE_COVERAGE=${COVERAGE:-off} \ diff --git a/README.md b/README.md index b2b4a2f2c2..f882dc65d6 100644 --- a/README.md +++ b/README.md @@ -142,6 +142,7 @@ There are some configuration options specified using CMake defines in addition t * `-DENABLE_SECURITY=NO`: to not build the security interfaces and hooks in the core code, nor the plugins (one can enable security without OpenSSL present, you'll just have to find plugins elsewhere in that case) * `-DENABLE_LIFESPAN=NO`: to exclude support for finite lifespans QoS * `-DENABLE_DEADLINE_MISSED=NO`: to exclude support for finite deadline QoS settings +* `-DENABLE_TYPELIB=NO`: to exclude support for type library, requires also disabling type and topic discovery using `-DENABLE_TYPE_DISCOVERY=NO` and `-DENABLE_TOPIC_DISCOVERY=NO` * `-DENABLE_TYPE_DISCOVERY=NO`: to exclude support for type discovery and checking type compatibility (effectively most of XTypes), requires also disabling topic discovery using `-DENABLE_TOPIC_DISCOVERY=NO` * `-DENABLE_TOPIC_DISCOVERY=NO`: to exclude support for topic discovery * `-DENABLE_SOURCE_SPECIFIC_MULTICAST=NO`: to disable support for source-specific multicast (disabling this and `-DENABLE_IPV6=NO` may be needed for QNX builds) diff --git a/docs/manual/config/cmake_config.rst b/docs/manual/config/cmake_config.rst index 5c1b1f6722..b80015f7a6 100644 --- a/docs/manual/config/cmake_config.rst +++ b/docs/manual/config/cmake_config.rst @@ -8,7 +8,7 @@ CMake build configuration ######################### -The following table lists some configuration options specified using CMake defines (in +The following table lists some configuration options specified using CMake defines (in addition to the standard options such as ``CMAKE_BUILD_TYPE``): .. list-table:: @@ -24,33 +24,36 @@ addition to the standard options such as ``CMAKE_BUILD_TYPE``): * - ``-DBUILD_DDSPERF=NO`` - Disable building the :ref:`dsperf_tool` (|url::ddsperf_github|) tool for performance measurement. * - ``-DENABLE_SSL=NO`` - - Do not look for OpenSSL, remove TLS/TCP support and avoid building the plugins that + - Do not look for OpenSSL, remove TLS/TCP support and avoid building the plugins that implement authentication and encryption (default is ``AUTO`` to enable them if OpenSSL is found) * - ``-DENABLE_SHM=NO`` - - Do not look for |url::iceoryx_link| and disable :ref:`shared_memory` (default + - Do not look for |url::iceoryx_link| and disable :ref:`shared_memory` (default is ``AUTO`` to enable it if iceoryx is found) * - ``-DENABLE_SECURITY=NO`` - - Do not build the security interfaces and hooks in the core code, nor the plugins - (you can enable security without OpenSSL present, you'll just have to find + - Do not build the security interfaces and hooks in the core code, nor the plugins + (you can enable security without OpenSSL present, you'll just have to find plugins elsewhere in that case) * - ``-DENABLE_LIFESPAN=NO`` - Exclude support for finite lifespans QoS * - ``-DENABLE_DEADLINE_MISSED=NO`` - Exclude support for finite deadline QoS settings + * - ``-DENABLE_TYPELIB=NO`` + - Exclude support for the type library, requires also disabling type and topic discovery using + ``-DENABLE_TYPE_DISCOVERY=NO`` and ``-DENABLE_TOPIC_DISCOVERY=NO`` * - ``-DENABLE_TYPE_DISCOVERY=NO`` - - Exclude support for type discovery and checking type compatibility - (effectively most of XTypes), requires also disabling topic discovery using + - Exclude support for type discovery and checking type compatibility + (effectively most of XTypes), requires also disabling topic discovery using ``-DENABLE_TOPIC_DISCOVERY=NO`` - * - ``-DENABLE_TOPIC_DISCOVERY=NO`` + * - ``-DENABLE_TOPIC_DISCOVERY=NO`` - Exclude support for topic discovery * - ``-DENABLE_SOURCE_SPECIFIC_MULTICAST=NO`` - - Disable support for source-specific multicast (disabling this and ``-DENABLE_IPV6=NO`` + - Disable support for source-specific multicast (disabling this and ``-DENABLE_IPV6=NO`` + may be needed for QNX builds) + * - ``-DENABLE_IPV6=NO``: + - Disable ipv6 support (disabling this and ``-DENABLE_SOURCE_SPECIFIC_MULTICAST=NO`` may be needed for QNX builds) - * - ``-DENABLE_IPV6=NO``: - - Disable ipv6 support (disabling this and ``-DENABLE_SOURCE_SPECIFIC_MULTICAST=NO`` - may be needed for QNX builds) * - ``-DBUILD_IDLC_XTESTS=NO`` - - Include a set of tests for the IDL compiler that use the C back-end to compile - an IDL file at (test) runtime, and use the C compiler to build a test - application for the generated types, that is executed to do the actual testing - (not supported on Windows) + - Include a set of tests for the IDL compiler that use the C back-end to compile + an IDL file at (test) runtime, and use the C compiler to build a test + application for the generated types, that is executed to do the actual testing + (not supported on Windows) diff --git a/docs/manual/doxygen.conf.in b/docs/manual/doxygen.conf.in index fd87636b19..939f38b732 100644 --- a/docs/manual/doxygen.conf.in +++ b/docs/manual/doxygen.conf.in @@ -21,7 +21,7 @@ GENERATE_HTML = NO GENERATE_LATEX = NO GENERATE_XML = YES MACRO_EXPANSION = YES -PREDEFINED = __restrict= __attribute__= __declspec(x)= DDS_EXPORT= DDS_DEPRECATED_EXPORT= DDSRT_STATIC_ASSERT(x)= DOXYGEN_SHOULD_SKIP_THIS=1 DDS_HAS_TOPIC_DISCOVERY=1 DDS_HAS_TYPE_DISCOVERY=1 ddsrt_attribute_warn_unused_result= ddsrt_attribute_malloc= ddsrt_nonnull(x)= ddsrt_attribute_no_sanitize(x)= +PREDEFINED = __restrict= __attribute__= __declspec(x)= DDS_EXPORT= DDS_DEPRECATED_EXPORT= DDSRT_STATIC_ASSERT(x)= DOXYGEN_SHOULD_SKIP_THIS=1 DDS_HAS_TOPIC_DISCOVERY=1 DDS_HAS_TYPELIB=1 DDS_HAS_TYPE_DISCOVERY=1 ddsrt_attribute_warn_unused_result= ddsrt_attribute_malloc= ddsrt_nonnull(x)= ddsrt_attribute_no_sanitize(x)= CLASS_GRAPH = TEXT ALIASES += "component=\noop" ALIASES += "notincomponent=\noop" diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index e9ed5f220f..94c9a427fc 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -43,7 +43,7 @@ install( DESTINATION "${CMAKE_INSTALL_EXAMPLESDIR}/throughput" COMPONENT dev) -if (ENABLE_TYPE_DISCOVERY) +if (ENABLE_TYPELIB) install( FILES dyntype/dyntype.c @@ -94,7 +94,7 @@ if (ENABLE_TOPIC_DISCOVERY) add_subdirectory(listtopics) add_subdirectory(dynsub) endif () -if (ENABLE_TYPE_DISCOVERY) +if (ENABLE_TYPELIB) add_subdirectory(dyntype) endif () if (ENABLE_SHM) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ab29a3b1cd..ade3753cfa 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -29,8 +29,14 @@ option(SKIP_DEADLINE_UPDATE "Skip deadline update test" OFF) option(ENABLE_NETWORK_PARTITIONS "Enable network partition support" ON) option(ENABLE_SOURCE_SPECIFIC_MULTICAST "Enable support for source-specific multicast" ON) option(ENABLE_IPV6 "Enable ipv6 support" ON) +option(ENABLE_TYPELIB "Enable Type Library support" ON) option(ENABLE_TYPE_DISCOVERY "Enable Type Discovery support" ON) option(ENABLE_TOPIC_DISCOVERY "Enable Topic Discovery support" ON) +if(ENABLE_TYPE_DISCOVERY) + if(NOT ENABLE_TYPELIB) + message(FATAL_ERROR "ENABLE_TYPE_DISCOVERY requires ENABLE_TYPELIB to be enabled") + endif() +endif() if(ENABLE_TOPIC_DISCOVERY) if(NOT ENABLE_TYPE_DISCOVERY) message(FATAL_ERROR "ENABLE_TOPIC_DISCOVERY requires ENABLE_TYPE_DISCOVERY to be enabled") diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index ae69e65199..6e865fd845 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -93,6 +93,19 @@ set_target_properties(ddsc PROPERTIES set_target_properties(ddsc PROPERTIES EXPORT_PROPERTIES "SHM_SUPPORT_IS_AVAILABLE") +# define target property to indicate if Cyclone DDS is compiled with type library support +define_property(TARGET + PROPERTY TYPELIB_IS_AVAILABLE + BRIEF_DOCS "Indicator whether type library is available with current Cyclone DDS build configuration." + FULL_DOCS "Indicator whether type library is available with current Cyclone DDS build configuration." + ) +set_property( + TARGET ddsc + APPEND PROPERTY TYPELIB_IS_AVAILABLE "${ENABLE_TYPELIB}") +set_property( + TARGET ddsc + APPEND PROPERTY EXPORT_PROPERTIES "TYPELIB_IS_AVAILABLE") + # define target property to indicate if Cyclone DDS is compiled with type discovery define_property(TARGET PROPERTY TYPE_DISCOVERY_IS_AVAILABLE diff --git a/src/core/ddsc/CMakeLists.txt b/src/core/ddsc/CMakeLists.txt index 20a6cbd9a7..c15dc5e450 100644 --- a/src/core/ddsc/CMakeLists.txt +++ b/src/core/ddsc/CMakeLists.txt @@ -47,7 +47,7 @@ prepend(srcs_ddsc "${CMAKE_CURRENT_LIST_DIR}/src/" dds_loan.c ) -if(ENABLE_TYPE_DISCOVERY) +if(ENABLE_TYPELIB) list(APPEND srcs_ddsc "${CMAKE_CURRENT_LIST_DIR}/src/dds_dynamic_type.c") endif() @@ -100,7 +100,7 @@ prepend(hdrs_public_ddsc "$$< ddsc/dds_data_allocator.h ddsc/dds_loan_api.h) -if(ENABLE_TYPE_DISCOVERY) +if(ENABLE_TYPELIB) list(APPEND hdrs_public_ddsc "$$/dds/ddsc/dds_public_dynamic_type.h") endif() diff --git a/src/core/ddsc/include/dds/dds.h b/src/core/ddsc/include/dds/dds.h index 9b84661f4e..820a5f1898 100644 --- a/src/core/ddsc/include/dds/dds.h +++ b/src/core/ddsc/include/dds/dds.h @@ -4573,7 +4573,7 @@ dds_get_matched_publication_data ( dds_entity_t reader, dds_instance_handle_t ih); -#ifdef DDS_HAS_TYPE_DISCOVERY +#ifdef DDS_HAS_TYPELIB /** * @brief Gets the type information from endpoint information that was * retrieved by dds_get_matched_subscription_data or @@ -4595,7 +4595,8 @@ DDS_EXPORT dds_return_t dds_builtintopic_get_endpoint_type_info ( dds_builtintopic_endpoint_t * builtintopic_endpoint, const dds_typeinfo_t ** type_info); -#endif + +#endif /* DDS_HAS_TYPELIB */ /** * @brief Free the endpoint information that was retrieved by @@ -4808,7 +4809,7 @@ dds_free_typeobj ( * The operation is invoked on an inappropriate object. * @retval DDS_RETCODE_UNSUPPORTED * Cyclone DDS built without type discovery - * (cf. DDS_HAS_TYPE_DISCOVERY) + * (cf. DDS_HAS_TYPELIB) */ DDS_EXPORT dds_return_t dds_get_typeinfo ( @@ -4831,7 +4832,7 @@ dds_get_typeinfo ( * The type_info parameter is NULL * @retval DDS_RETCODE_UNSUPPORTED * Cyclone DDS built without type discovery - * (cf. DDS_HAS_TYPE_DISCOVERY) + * (cf. DDS_HAS_TYPELIB) */ DDS_EXPORT dds_return_t dds_free_typeinfo ( diff --git a/src/core/ddsc/src/dds_builtin.c b/src/core/ddsc/src/dds_builtin.c index 3e5b6e1539..374aa62b02 100644 --- a/src/core/ddsc/src/dds_builtin.c +++ b/src/core/ddsc/src/dds_builtin.c @@ -199,6 +199,8 @@ bool dds__validate_builtin_reader_qos (const dds_domain *dom, dds_entity_t topic dds_qos_policy_id_t dummy; #ifdef DDS_HAS_TYPE_DISCOVERY return ddsi_qos_match_mask_p (bwr->wr.e.gv, qos, bwr->wr.xqos, qmask, &dummy, NULL, NULL, NULL, NULL) && !qos_has_resource_limits (qos); +#elif DDS_HAS_TYPELIB + return ddsi_qos_match_mask_p (bwr->wr.e.gv, qos, bwr->wr.xqos, qmask, &dummy, NULL, NULL) && !qos_has_resource_limits (qos); #else return ddsi_qos_match_mask_p (bwr->wr.e.gv, qos, bwr->wr.xqos, qmask, &dummy) && !qos_has_resource_limits (qos); #endif diff --git a/src/core/ddsc/src/dds_entity.c b/src/core/ddsc/src/dds_entity.c index 78e4cf5d54..0fa829eaf0 100644 --- a/src/core/ddsc/src/dds_entity.c +++ b/src/core/ddsc/src/dds_entity.c @@ -30,6 +30,10 @@ #include "dds/ddsi/ddsi_endpoint.h" #include "dds/ddsi/ddsi_sertype.h" +#ifdef DDS_HAS_TYPELIB +#include "dds/ddsi/ddsi_typelib.h" +#endif + extern inline dds_entity *dds_entity_from_handle_link (struct dds_handle_link *hdllink); extern inline bool dds_entity_is_enabled (const dds_entity *e); extern inline void dds_entity_status_reset (dds_entity *e, status_mask_t t); @@ -1629,7 +1633,7 @@ dds_return_t dds_return_loan (dds_entity_t entity, void **buf, int32_t bufsz) return ret; } -#ifdef DDS_HAS_TYPE_DISCOVERY +#ifdef DDS_HAS_TYPELIB dds_return_t dds_get_typeinfo (dds_entity_t entity, dds_typeinfo_t **type_info) { @@ -1677,7 +1681,7 @@ dds_return_t dds_free_typeinfo (dds_typeinfo_t *type_info) return DDS_RETCODE_OK; } -#else +#else /* DDS_HAS_TYPELIB */ dds_return_t dds_get_typeinfo (dds_entity_t entity, dds_typeinfo_t **type_info) { @@ -1692,7 +1696,7 @@ dds_return_t dds_free_typeinfo (dds_typeinfo_t *type_info) return DDS_RETCODE_UNSUPPORTED; } -#endif /* DDS_HAS_TYPE_DISCOVERY */ +#endif /* DDS_HAS_TYPELIB */ dds_return_t dds_get_entity_sertype (dds_entity_t entity, const struct ddsi_sertype **sertype) diff --git a/src/core/ddsc/src/dds_matched.c b/src/core/ddsc/src/dds_matched.c index 4b62697907..fe3adf453c 100644 --- a/src/core/ddsc/src/dds_matched.c +++ b/src/core/ddsc/src/dds_matched.c @@ -120,7 +120,8 @@ dds_builtintopic_endpoint_t *dds_get_matched_publication_data (dds_entity_t read return ret; } -#ifdef DDS_HAS_TYPE_DISCOVERY +#ifdef DDS_HAS_TYPELIB + dds_return_t dds_builtintopic_get_endpoint_type_info (dds_builtintopic_endpoint_t * builtintopic_endpoint, const dds_typeinfo_t ** type_info) { if (builtintopic_endpoint == NULL || type_info == NULL) @@ -132,7 +133,8 @@ dds_return_t dds_builtintopic_get_endpoint_type_info (dds_builtintopic_endpoint_ *type_info = NULL; return DDS_RETCODE_OK; } -#endif + +#endif /* DDS_HAS_TYPELIB */ void dds_builtintopic_free_endpoint (dds_builtintopic_endpoint_t * builtintopic_endpoint) { diff --git a/src/core/ddsc/src/dds_sertype_default.c b/src/core/ddsc/src/dds_sertype_default.c index 828812ffbc..7e518f7d1c 100644 --- a/src/core/ddsc/src/dds_sertype_default.c +++ b/src/core/ddsc/src/dds_sertype_default.c @@ -60,7 +60,7 @@ static bool sertype_default_equal (const struct ddsi_sertype *acmn, const struct return true; } -#ifdef DDS_HAS_TYPE_DISCOVERY +#ifdef DDS_HAS_TYPELIB static ddsi_typeid_t * sertype_default_typeid (const struct ddsi_sertype *tpcmn, ddsi_typeid_kind_t kind) { @@ -90,7 +90,7 @@ static ddsi_typeinfo_t *sertype_default_typeinfo (const struct ddsi_sertype *tpc return ddsi_typeinfo_deser (tp->typeinfo_ser.data, tp->typeinfo_ser.sz); } -#endif /* DDS_HAS_TYPE_DISCOVERY */ +#endif /* DDS_HAS_TYPELIB */ static uint32_t sertype_default_hash (const struct ddsi_sertype *tpcmn) { @@ -258,7 +258,7 @@ const struct ddsi_sertype_ops dds_sertype_ops_default = { .zero_samples = sertype_default_zero_samples, .realloc_samples = sertype_default_realloc_samples, .free_samples = sertype_default_free_samples, -#ifdef DDS_HAS_TYPE_DISCOVERY +#ifdef DDS_HAS_TYPELIB .type_id = sertype_default_typeid, .type_map = sertype_default_typemap, .type_info = sertype_default_typeinfo, diff --git a/src/core/ddsc/src/dds_topic.c b/src/core/ddsc/src/dds_topic.c index 738e0c08b6..cbd63670be 100644 --- a/src/core/ddsc/src/dds_topic.c +++ b/src/core/ddsc/src/dds_topic.c @@ -228,7 +228,7 @@ static void dds_topic_close (dds_entity *e) struct dds_ktopic * const ktp = tp->m_ktopic; assert (dds_entity_kind (e->m_parent) == DDS_KIND_PARTICIPANT); dds_participant * const pp = (dds_participant *) e->m_parent; -#ifdef DDS_HAS_TYPE_DISCOVERY +#ifdef DDS_HAS_TYPELIB ddsi_type_unref_sertype (&e->m_domain->gv, tp->m_stype); #endif dds_free (tp->m_name); @@ -454,7 +454,7 @@ dds_entity_t dds_create_topic_impl ( pp = (struct dds_participant *) par_ent; } -#ifdef DDS_HAS_TYPE_DISCOVERY +#ifdef DDS_HAS_TYPELIB /* ensure that in case type information is present, both minimal and complete type identifiers are present for the top-level type */ ddsi_typeinfo_t *type_info = ddsi_sertype_typeinfo (*sertype); @@ -553,7 +553,7 @@ dds_entity_t dds_create_topic_impl ( ddsrt_mutex_unlock (&gv->sertypes_lock); } -#ifdef DDS_HAS_TYPE_DISCOVERY +#ifdef DDS_HAS_TYPELIB struct ddsi_type *type; if ((rc = ddsi_type_ref_local (gv, &type, sertype_registered, DDSI_TYPEID_KIND_MINIMAL)) != DDS_RETCODE_OK || ddsi_type_ref_local (gv, NULL, sertype_registered, DDSI_TYPEID_KIND_COMPLETE) != DDS_RETCODE_OK) @@ -591,7 +591,7 @@ dds_entity_t dds_create_topic_impl ( error: dds_delete_qos (new_qos); -#ifdef DDS_HAS_TYPE_DISCOVERY +#ifdef DDS_HAS_TYPELIB error_typeref: #endif dds_entity_unpin (&pp->m_entity); @@ -1048,14 +1048,19 @@ dds_return_t dds_get_type_name (dds_entity_t topic, char *name, size_t size) DDS_GET_STATUS(topic, inconsistent_topic, INCONSISTENT_TOPIC, total_count_change) -#ifdef DDS_HAS_TYPE_DISCOVERY +#ifdef DDS_HAS_TYPELIB dds_return_t dds_create_topic_descriptor (dds_find_scope_t scope, dds_entity_t participant, const dds_typeinfo_t *type_info, dds_duration_t timeout, dds_topic_descriptor_t **descriptor) { dds_return_t ret; +#ifdef DDS_HAS_TYPE_DISCOVERY if (scope != DDS_FIND_SCOPE_GLOBAL && scope != DDS_FIND_SCOPE_LOCAL_DOMAIN) return DDS_RETCODE_BAD_PARAMETER; +#else + if (scope != DDS_FIND_SCOPE_LOCAL_DOMAIN) + return DDS_RETCODE_BAD_PARAMETER; +#endif if (type_info == NULL || descriptor == NULL) return DDS_RETCODE_BAD_PARAMETER; @@ -1097,7 +1102,7 @@ dds_return_t dds_delete_topic_descriptor (dds_topic_descriptor_t *descriptor) return DDS_RETCODE_OK; } -#else /* DDS_HAS_TYPE_DISCOVERY */ +#else /* DDS_HAS_TYPELIB */ dds_return_t dds_create_topic_descriptor (dds_find_scope_t scope, dds_entity_t participant, const dds_typeinfo_t *type_info, dds_duration_t timeout, dds_topic_descriptor_t **descriptor) { @@ -1111,7 +1116,7 @@ dds_return_t dds_delete_topic_descriptor (dds_topic_descriptor_t *descriptor) return DDS_RETCODE_UNSUPPORTED; } -#endif /* DDS_HAS_TYPE_DISCOVERY */ +#endif /* DDS_HAS_TYPELIB */ void dds_cdrstream_desc_from_topic_desc (struct dds_cdrstream_desc *desc, const dds_topic_descriptor_t *topic_desc) { diff --git a/src/core/ddsc/src/dds_writer.c b/src/core/ddsc/src/dds_writer.c index 7a0e3d0daa..ccdc84e28f 100644 --- a/src/core/ddsc/src/dds_writer.c +++ b/src/core/ddsc/src/dds_writer.c @@ -23,6 +23,9 @@ #include "dds/ddsi/ddsi_xmsg.h" #include "dds/ddsi/ddsi_entity_index.h" #include "dds/ddsi/ddsi_security_omg.h" +#include "dds/ddsi/ddsi_tkmap.h" +#include "dds/ddsi/ddsi_statistics.h" +#include "dds/ddsi/ddsi_sertype.h" #include "dds/cdr/dds_cdrstream.h" #include "dds__writer.h" #include "dds__listener.h" @@ -31,11 +34,9 @@ #include "dds__topic.h" #include "dds__get_status.h" #include "dds__qos.h" -#include "dds/ddsi/ddsi_tkmap.h" #include "dds__whc.h" #include "dds__statistics.h" #include "dds__data_allocator.h" -#include "dds/ddsi/ddsi_statistics.h" #ifdef DDS_HAS_SHM #include "dds__shm_qos.h" diff --git a/src/core/ddsc/tests/CMakeLists.txt b/src/core/ddsc/tests/CMakeLists.txt index c933b9806a..51b117c969 100644 --- a/src/core/ddsc/tests/CMakeLists.txt +++ b/src/core/ddsc/tests/CMakeLists.txt @@ -22,7 +22,10 @@ idlc_generate(TARGET DataRepresentationTypes FILES DataRepresentationTypes.idl W idlc_generate(TARGET MinXcdrVersion FILES MinXcdrVersion.idl) idlc_generate(TARGET CdrStreamOptimize FILES CdrStreamOptimize.idl WARNINGS no-implicit-extensibility) idlc_generate(TARGET CdrStreamSkipDefault FILES CdrStreamSkipDefault.idl) -if(ENABLE_TYPE_DISCOVERY) +idlc_generate(TARGET CdrStreamKeySize FILES CdrStreamKeySize.idl) +idlc_generate(TARGET CdrStreamKeyExt FILES CdrStreamKeyExt.idl) +idlc_generate(TARGET SerdataData FILES SerdataData.idl) +if(ENABLE_TYPELIB) idlc_generate(TARGET XSpace FILES XSpace.idl XSpaceEnum.idl XSpaceMustUnderstand.idl XSpaceTypeConsistencyEnforcement.idl WARNINGS no-implicit-extensibility no-inherit-appendable) idlc_generate(TARGET XSpaceNoTypeInfo FILES XSpaceNoTypeInfo.idl NO_TYPE_INFO WARNINGS no-implicit-extensibility) idlc_generate(TARGET TypeBuilderTypes FILES TypeBuilderTypes.idl WARNINGS no-implicit-extensibility) @@ -101,18 +104,25 @@ if(ENABLE_DEADLINE_MISSED) list(APPEND ddsc_test_sources "deadline.c") endif() -if(ENABLE_TYPE_DISCOVERY) +if(ENABLE_TYPELIB) list(APPEND ddsc_test_sources - "xtypes.c" + "xtypes_common.c" + "xtypes_common.h" + "xtypes_typeinfo.c" "data_representation.c" "typebuilder.c" "dynamic_type.c" ) endif() +if(ENABLE_TYPE_DISCOVERY) + list(APPEND ddsc_test_sources + "xtypes_typelookup.c" + "xtypes_assignability.c") +endif() + if(ENABLE_TOPIC_DISCOVERY) list(APPEND ddsc_test_sources - "typelookup.c" "topic_discovery.c" "topic_find_global.c") endif() @@ -134,7 +144,7 @@ endif() target_link_libraries(cunit_ddsc PRIVATE RoundTrip Space TypesArrayKey WriteTypes InstanceHandleTypes RWData CreateWriter DataRepresentationTypes MinXcdrVersion CdrStreamOptimize CdrStreamSkipDefault ddsc) -if(ENABLE_TYPE_DISCOVERY) +if(ENABLE_TYPELIB) target_link_libraries(cunit_ddsc PRIVATE XSpace XSpaceNoTypeInfo TypeBuilderTypes DynamicTypeTypes) endif() diff --git a/src/core/ddsc/tests/dynamic_type.c b/src/core/ddsc/tests/dynamic_type.c index 28e5542375..527788d637 100644 --- a/src/core/ddsc/tests/dynamic_type.c +++ b/src/core/ddsc/tests/dynamic_type.c @@ -590,6 +590,7 @@ CU_Test (ddsc_dynamic_type, no_members, .init = dynamic_type_init, .fini = dynam dds_dynamic_type_unref (&dunion); } +#ifdef DDS_HAS_TYPE_DISCOVERY static void create_type_topic_wr (dds_entity_t pp, const char *topic_name, ddsi_typeid_t **type_id) { dds_dynamic_type_t dsubstruct = dds_dynamic_type_create (pp, (dds_dynamic_type_descriptor_t) { .kind = DDS_DYNAMIC_STRUCTURE, .name = "dynamic_substruct" }); @@ -616,9 +617,11 @@ static void create_type_topic_wr (dds_entity_t pp, const char *topic_name, ddsi_ dds_delete_topic_descriptor (descriptor); dds_dynamic_type_unref (&dstruct); } +#endif /* DDS_HAS_TYPE_DISCOVERY */ CU_Test (ddsc_dynamic_type, existing, .init = dynamic_type_init, .fini = dynamic_type_fini) { +#ifdef DDS_HAS_TYPE_DISCOVERY dds_return_t ret; char topic_name[100]; create_unique_topic_name ("ddsc_dynamic_type", topic_name, sizeof (topic_name)); @@ -684,6 +687,7 @@ CU_Test (ddsc_dynamic_type, existing, .init = dynamic_type_init, .fini = dynamic ddsrt_free (type_id2); dds_delete (domain2); +#endif /* DDS_HAS_TYPE_DISCOVERY */ } CU_Test (ddsc_dynamic_type, existing_constructing, .init = dynamic_type_init, .fini = dynamic_type_fini) diff --git a/src/core/ddsc/tests/xtypes.c b/src/core/ddsc/tests/xtypes.c deleted file mode 100644 index dc7e0f5079..0000000000 --- a/src/core/ddsc/tests/xtypes.c +++ /dev/null @@ -1,1069 +0,0 @@ -// Copyright(c) 2006 to 2022 ZettaScale Technology and others -// -// This program and the accompanying materials are made available under the -// terms of the Eclipse Public License v. 2.0 which is available at -// http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License -// v. 1.0 which is available at -// http://www.eclipse.org/org/documents/edl-v10.php. -// -// SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause - -#include -#include - -#include "dds/ddsrt/cdtors.h" -#include "dds/ddsrt/misc.h" -#include "dds/ddsrt/process.h" -#include "dds/ddsrt/threads.h" -#include "dds/ddsrt/environ.h" -#include "dds/ddsrt/atomics.h" -#include "dds/ddsrt/time.h" -#include "dds/ddsrt/heap.h" -#include "dds/ddsrt/string.h" -#include "dds/ddsi/ddsi_entity.h" -#include "dds/ddsi/ddsi_entity_index.h" -#include "dds/ddsi/ddsi_typelib.h" -#include "dds/ddsi/ddsi_xt_typelookup.h" -#include "ddsi__xt_impl.h" -#include "ddsi__addrset.h" -#include "ddsi__endpoint_match.h" -#include "ddsi__proxy_endpoint.h" -#include "ddsi__proxy_participant.h" -#include "ddsi__typelookup.h" -#include "ddsi__typewrap.h" -#include "ddsi__vendor.h" -#include "dds/cdr/dds_cdrstream.h" -#include "dds/dds.h" -#include "dds/version.h" -#include "dds__entity.h" -#include "config_env.h" -#include "test_common.h" - -#include "XSpace.h" -#include "XSpaceEnum.h" -#include "XSpaceMustUnderstand.h" -#include "XSpaceTypeConsistencyEnforcement.h" -#include "XSpaceNoTypeInfo.h" - -#define DDS_DOMAINID_PUB 0 -#define DDS_DOMAINID_SUB 1 -#define DDS_CONFIG "${CYCLONEDDS_URI}${CYCLONEDDS_URI:+,}0" - -static dds_entity_t g_domain1 = 0; -static dds_entity_t g_participant1 = 0; -static dds_entity_t g_publisher1 = 0; - -static dds_entity_t g_domain2 = 0; -static dds_entity_t g_participant2 = 0; -static dds_entity_t g_subscriber2 = 0; - -typedef void (*sample_init) (void *s); -typedef void (*sample_check) (void *s1, void *s2); -typedef void (*typeobj_modify) (dds_sequence_DDS_XTypes_TypeIdentifierTypeObjectPair *type_id_obj_seq, uint32_t kind); - -static void xtypes_init (void) -{ - /* Domains for pub and sub use a different internal domain id, but the external - * domain id in configuration is 0, so that both domains will map to the same port number. - * This allows to create two domains in a single test process. */ - char *conf1 = ddsrt_expand_envvars (DDS_CONFIG, DDS_DOMAINID_PUB); - char *conf2 = ddsrt_expand_envvars (DDS_CONFIG, DDS_DOMAINID_SUB); - g_domain1 = dds_create_domain (DDS_DOMAINID_PUB, conf1); - g_domain2 = dds_create_domain (DDS_DOMAINID_SUB, conf2); - dds_free (conf1); - dds_free (conf2); - - g_participant1 = dds_create_participant (DDS_DOMAINID_PUB, NULL, NULL); - CU_ASSERT_FATAL (g_participant1 > 0); - g_participant2 = dds_create_participant (DDS_DOMAINID_SUB, NULL, NULL); - CU_ASSERT_FATAL (g_participant2 > 0); - - g_publisher1 = dds_create_publisher (g_participant1, NULL, NULL); - CU_ASSERT_FATAL (g_publisher1 > 0); - g_subscriber2 = dds_create_subscriber (g_participant2, NULL, NULL); - CU_ASSERT_FATAL (g_subscriber2 > 0); -} - -static void xtypes_fini (void) -{ - dds_delete (g_domain2); - dds_delete (g_domain1); -} - -static bool reader_wait_for_data (dds_entity_t pp, dds_entity_t rd, dds_duration_t dur) -{ - dds_attach_t triggered; - dds_entity_t ws = dds_create_waitset (pp); - CU_ASSERT_FATAL (ws > 0); - dds_return_t ret = dds_waitset_attach (ws, rd, rd); - CU_ASSERT_EQUAL_FATAL (ret, DDS_RETCODE_OK); - ret = dds_waitset_wait (ws, &triggered, 1, dur); - if (ret > 0) - CU_ASSERT_EQUAL_FATAL (rd, (dds_entity_t)(intptr_t) triggered); - dds_delete (ws); - return ret > 0; -} - -static void do_test (const dds_topic_descriptor_t *rd_desc, const dds_qos_t *add_rd_qos, const dds_topic_descriptor_t *wr_desc, const dds_qos_t *add_wr_qos, bool assignable, sample_init fn_init, bool read_sample, sample_check fn_check) -{ - dds_return_t ret; - char topic_name[100]; - create_unique_topic_name ("ddsc_xtypes", topic_name, sizeof (topic_name)); - dds_entity_t topic_wr = dds_create_topic (g_participant1, wr_desc, topic_name, NULL, NULL); - CU_ASSERT_FATAL (topic_wr > 0); - dds_entity_t topic_rd = dds_create_topic (g_participant2, rd_desc, topic_name, NULL, NULL); - CU_ASSERT_FATAL (topic_rd > 0); - - dds_qos_t *qos = dds_create_qos (), *wrqos = dds_create_qos (), *rdqos = dds_create_qos (); - CU_ASSERT_FATAL (qos != NULL); - dds_qset_reliability (qos, DDS_RELIABILITY_RELIABLE, DDS_SECS (10)); - dds_qset_history (qos, DDS_HISTORY_KEEP_ALL, 0); - dds_qset_data_representation (qos, 1, (dds_data_representation_id_t[]) { DDS_DATA_REPRESENTATION_XCDR2 }); - dds_copy_qos (wrqos, qos); - dds_copy_qos (rdqos, qos); - - if (add_wr_qos) - dds_merge_qos (wrqos, add_wr_qos); - dds_entity_t writer = dds_create_writer (g_participant1, topic_wr, wrqos, NULL); - CU_ASSERT_FATAL (writer > 0); - - if (add_rd_qos) - dds_merge_qos (rdqos, add_rd_qos); - dds_entity_t reader = dds_create_reader (g_participant2, topic_rd, rdqos, NULL); - CU_ASSERT_FATAL (reader > 0); - - dds_delete_qos (qos); - dds_delete_qos (wrqos); - dds_delete_qos (rdqos); - - if (assignable) - { - sync_reader_writer (g_participant2, reader, g_participant1, writer); - ret = dds_set_status_mask (reader, DDS_DATA_AVAILABLE_STATUS); - CU_ASSERT_EQUAL_FATAL (ret, DDS_RETCODE_OK); - - if (fn_init) - { - void * wr_sample = dds_alloc (wr_desc->m_size); - fn_init (wr_sample); - ret = dds_write (writer, wr_sample); - CU_ASSERT_EQUAL_FATAL (ret, DDS_RETCODE_OK); - - void * rd_sample = dds_alloc (rd_desc->m_size); - void * rd_samples[1]; - rd_samples[0] = rd_sample; - dds_sample_info_t info; - bool data = reader_wait_for_data (g_participant2, reader, DDS_MSECS (500)); - CU_ASSERT_FATAL (data == read_sample); - if (data) - { - ret = dds_take (reader, rd_samples, &info, 1, 1); - CU_ASSERT_EQUAL_FATAL (ret, 1); - if (fn_check) - fn_check (wr_sample, rd_sample); - } - dds_sample_free (wr_sample, wr_desc, DDS_FREE_ALL); - dds_sample_free (rd_sample, rd_desc, DDS_FREE_ALL); - } - } - else - { - no_sync_reader_writer (g_participant2, reader, g_participant1, writer, DDS_MSECS (200)); - } -} - -/* Some basic tests */ -static void sample_init_XType1 (void *ptr) -{ - XSpace_XType1 *sample = (XSpace_XType1 *) ptr; - sample->long_1 = 1; - sample->long_2 = 2; - sample->bm_3 = XSpace_flag0 | XSpace_flag1; -} -static void sample_init_XType1a (void *ptr) -{ - XSpace_XType1a *sample = (XSpace_XType1a *) ptr; - sample->long_1 = 1; - sample->long_2 = 2; - sample->bm_3 = 3; -} -static void sample_check_XType1_1a (void *ptr1, void *ptr2) -{ - XSpace_XType1 *s_wr = (XSpace_XType1 *) ptr1; - XSpace_XType1a *s_rd = (XSpace_XType1a *) ptr2; - CU_ASSERT_EQUAL_FATAL (s_rd->long_1, s_wr->long_1); - CU_ASSERT_EQUAL_FATAL (s_rd->long_2, s_wr->long_2); - CU_ASSERT_EQUAL_FATAL (s_rd->bm_3, s_wr->bm_3); -} -static void sample_check_XType1a_1 (void *ptr1, void *ptr2) -{ - XSpace_XType1a *s_wr = (XSpace_XType1a *) ptr1; - XSpace_XType1 *s_rd = (XSpace_XType1 *) ptr2; - CU_ASSERT_EQUAL_FATAL (s_rd->long_1, s_wr->long_1); - CU_ASSERT_EQUAL_FATAL (s_rd->long_2, s_wr->long_2); - CU_ASSERT_EQUAL_FATAL (s_rd->bm_3, s_wr->bm_3); -} - -static void sample_init_XType2 (void *ptr) -{ - XSpace_XType2 *sample = (XSpace_XType2 *) ptr; - sample->long_1 = 1; - sample->long_2 = 2; -} -static void sample_init_XType2a (void *ptr) -{ - XSpace_XType2a *sample = (XSpace_XType2a *) ptr; - sample->long_1 = 1; - sample->long_2 = 2; - sample->long_3 = 3; -} -static void sample_check_XType2_2a (void *ptr1, void *ptr2) -{ - XSpace_XType2 *s_wr = (XSpace_XType2 *) ptr1; - XSpace_XType2a *s_rd = (XSpace_XType2a *) ptr2; - CU_ASSERT_EQUAL_FATAL (s_rd->long_1, s_wr->long_1); - CU_ASSERT_EQUAL_FATAL (s_rd->long_2, s_wr->long_2); - CU_ASSERT_EQUAL_FATAL (s_rd->long_3, 0); -} -static void sample_check_XType2a_2 (void *ptr1, void *ptr2) -{ - XSpace_XType2a *s_wr = (XSpace_XType2a *) ptr1; - XSpace_XType2 *s_rd = (XSpace_XType2 *) ptr2; - CU_ASSERT_EQUAL_FATAL (s_rd->long_1, s_wr->long_1); - CU_ASSERT_EQUAL_FATAL (s_rd->long_2, s_wr->long_2); -} - -static void sample_init_XType3 (void *ptr) -{ - XSpace_XType3 *sample = (XSpace_XType3 *) ptr; - sample->long_2 = 2; - sample->struct_3.long_4 = 4; - sample->struct_3.long_5 = 5; -} -static void sample_init_XType3a (void *ptr) -{ - XSpace_XType3a *sample = (XSpace_XType3a *) ptr; - sample->long_1 = 1; - sample->long_2 = 2; - sample->struct_3.long_4 = 4; -} -static void sample_check_XType3_3a (void *ptr1, void *ptr2) -{ - XSpace_XType3 *s_wr = (XSpace_XType3 *) ptr1; - XSpace_XType3a *s_rd = (XSpace_XType3a *) ptr2; - CU_ASSERT_EQUAL_FATAL (s_rd->long_1, 0); - CU_ASSERT_EQUAL_FATAL (s_rd->long_2, s_wr->long_2); - CU_ASSERT_EQUAL_FATAL (s_rd->struct_3.long_4, s_wr->struct_3.long_4); -} -static void sample_check_XType3a_3 (void *ptr1, void *ptr2) -{ - XSpace_XType3a *s_wr = (XSpace_XType3a *) ptr1; - XSpace_XType3 *s_rd = (XSpace_XType3 *) ptr2; - CU_ASSERT_EQUAL_FATAL (s_rd->long_2, s_wr->long_2); - CU_ASSERT_EQUAL_FATAL (s_rd->struct_3.long_4, s_wr->struct_3.long_4); - CU_ASSERT_EQUAL_FATAL (s_rd->struct_3.long_5, 0); -} - -static void sample_init_XType4 (void *ptr) -{ - XSpace_XType4 *sample = (XSpace_XType4 *) ptr; - uint32_t *s1 = ddsrt_malloc (999 * sizeof (*s1)); - for (uint32_t n = 0; n < 999; n++) s1[n] = n; - uint32_t *s2 = ddsrt_malloc (10 * sizeof (*s2)); - for (uint32_t n = 0; n < 10; n++) s2[n] = n; - sample->seq_1 = (dds_sequence_uint32) { ._length = 999, ._maximum = 999, ._buffer = s1, ._release = true }; - sample->seq_2 = (dds_sequence_uint32) { ._length = 10, ._maximum = 10, ._buffer = s2, ._release = true }; -} -static void sample_init_XType4a (void *ptr) -{ - XSpace_XType4a *sample = (XSpace_XType4a *) ptr; - uint32_t *s1 = ddsrt_malloc (999 * sizeof (*s1)); - for (uint32_t n = 0; n < 999; n++) s1[n] = n; - uint32_t *s2 = ddsrt_malloc (5 * sizeof (*s2)); - for (uint32_t n = 0; n < 5; n++) s2[n] = n; - sample->seq_1 = (dds_sequence_uint32) { ._length = 999, ._maximum = 999, ._buffer = s1, ._release = true }; - sample->seq_2 = (dds_sequence_uint32) { ._length = 5, ._maximum = 5, ._buffer = s2, ._release = true }; -} -static void sample_check_XType4a_4 (void *ptr1, void *ptr2) -{ - XSpace_XType4a *s_wr = (XSpace_XType4a *) ptr1; - XSpace_XType4 *s_rd = (XSpace_XType4 *) ptr2; - CU_ASSERT_FATAL (s_rd->seq_1._length == s_wr->seq_1._length && s_rd->seq_1._length == 999); - CU_ASSERT_FATAL (s_rd->seq_2._length == s_wr->seq_2._length && s_rd->seq_2._length == 5); - for (uint32_t n = 0; n < 999; n++) - CU_ASSERT_FATAL (s_rd->seq_1._buffer[n] == s_wr->seq_1._buffer[n] && s_rd->seq_1._buffer[n] == n); - for (uint32_t n = 0; n < 5; n++) - CU_ASSERT_FATAL (s_rd->seq_2._buffer[n] == s_wr->seq_2._buffer[n] && s_rd->seq_2._buffer[n] == n); -} - -static void sample_init_XType5a (void *ptr) -{ - XSpace_XType5a *sample = (XSpace_XType5a *) ptr; - for (uint32_t n = 0; n < 999; n++) sample->str_1[n] = 'a'; - for (uint32_t n = 0; n < 5; n++) sample->str_2[n] = 'a'; - sample->str_1[999] = '\0'; - sample->str_2[5] = '\0'; -} -static void sample_check_XType5a_5 (void *ptr1, void *ptr2) -{ - XSpace_XType5a *s_wr = (XSpace_XType5a *) ptr1; - XSpace_XType5 *s_rd = (XSpace_XType5 *) ptr2; - CU_ASSERT_FATAL (strlen (s_rd->str_1) == strlen (s_wr->str_1) && strlen (s_rd->str_1) == 999); - CU_ASSERT_FATAL (strlen (s_rd->str_2) == strlen (s_wr->str_2) && strlen (s_rd->str_2) == 5); - CU_ASSERT_FATAL (!strcmp (s_rd->str_1, s_wr->str_1)); - CU_ASSERT_FATAL (!strcmp (s_rd->str_2, s_wr->str_2)); -} - -#define D(n) XSpace_ ## n ## _desc -#define I(n) sample_init_ ## n -#define C(n) sample_check_ ## n -CU_TheoryDataPoints (ddsc_xtypes, basic) = { - CU_DataPoints (const char *, "mutable_bitmask", - /* | */"appendable_field", - /* | | */"appendable_nested", - /* | | | */"mutable_seq", - /* | | | | */"strlen_keys" ), - CU_DataPoints (const dds_topic_descriptor_t *, &D(XType1), &D(XType2), &D(XType3), &D(XType4), &D(XType5), ), - CU_DataPoints (const dds_topic_descriptor_t *, &D(XType1a), &D(XType2a), &D(XType3a), &D(XType4a), &D(XType5a), ), - CU_DataPoints (sample_init, I(XType1), I(XType2), I(XType3), I(XType4), NULL, ), - CU_DataPoints (sample_init, I(XType1a), I(XType2a), I(XType3a), I(XType4a), I(XType5a), ), - CU_DataPoints (sample_check, C(XType1_1a), C(XType2_2a), C(XType3_3a), NULL, NULL, ), - CU_DataPoints (sample_check, C(XType1a_1), C(XType2a_2), C(XType3a_3), C(XType4a_4), C(XType5a_5), ), -}; - -CU_Theory ((const char *descr, const dds_topic_descriptor_t *desc1, const dds_topic_descriptor_t *desc2, sample_init fn_init1, sample_init fn_init2, sample_check fn_check1, sample_check fn_check2), - ddsc_xtypes, basic, .init = xtypes_init, .fini = xtypes_fini) -{ - for (int t = 0; t <= 1; t++) - { - printf ("Running test xtypes_basic: %s (run %d/2)\n", descr, t + 1); - sample_init i = t ? fn_init2 : fn_init1; - sample_check c = t ? fn_check2 : fn_check1; - do_test (t ? desc1 : desc2, NULL, t ? desc2 : desc1, NULL, i != NULL, i, c != NULL, c); - } -} -#undef D -#undef I -#undef C - - -/* Must-understand test cases */ -static void sample_init_mu_wr1_2 (void *ptr) -{ - XSpaceMustUnderstand_wr1_2 *sample = (XSpaceMustUnderstand_wr1_2 *) ptr; - sample->f1 = 1; -} -static void sample_init_mu_wr1_3a (void *ptr) -{ - XSpaceMustUnderstand_wr1_3 *sample = (XSpaceMustUnderstand_wr1_3 *) ptr; - sample->f1 = 1; - sample->f2 = NULL; -} -static void sample_init_mu_wr1_3b (void *ptr) -{ - XSpaceMustUnderstand_wr1_3 *sample = (XSpaceMustUnderstand_wr1_3 *) ptr; - sample->f1 = 1; - sample->f2 = dds_alloc (sizeof (*sample->f2)); - *(sample->f2) = 1; -} -static void sample_init_mu_wr1_4a (void *ptr) -{ - XSpaceMustUnderstand_wr1_4 *sample = (XSpaceMustUnderstand_wr1_4 *) ptr; - sample->f1 = dds_alloc (sizeof (*sample->f1)); - *(sample->f1) = 1; -} -static void sample_init_mu_wr1_4b (void *ptr) -{ - XSpaceMustUnderstand_wr1_4 *sample = (XSpaceMustUnderstand_wr1_4 *) ptr; - sample->f1 = NULL; -} - -static void sample_init_mu_wr2_1a (void *ptr) -{ - XSpaceMustUnderstand_wr2_1 *sample = (XSpaceMustUnderstand_wr2_1 *) ptr; - sample->f1.f1 = 1; - sample->f1.f2 = NULL; -} -static void sample_init_mu_wr2_1b (void *ptr) -{ - XSpaceMustUnderstand_wr2_1 *sample = (XSpaceMustUnderstand_wr2_1 *) ptr; - sample->f1.f1 = 1; - sample->f1.f2 = dds_alloc (sizeof (*sample->f1.f2)); - *(sample->f1.f2) = 1; -} - -#define D(n) XSpaceMustUnderstand_ ## n ## _desc -#define I(n) sample_init_ ## n -CU_TheoryDataPoints (ddsc_xtypes, must_understand) = { - CU_DataPoints (const dds_topic_descriptor_t *, &D(rd1), &D(rd1), &D(rd1), &D(rd1), &D(rd1), &D(rd1), &D(rd2), &D(rd2) ), - CU_DataPoints (const dds_topic_descriptor_t *, &D(wr1_1), &D(wr1_2), &D(wr1_3), &D(wr1_3), &D(wr1_4), &D(wr1_4), &D(wr2_1), &D(wr2_1) ), - CU_DataPoints (bool, false, true, true, true, true, true, true, true ), - CU_DataPoints (sample_init, 0, I(mu_wr1_2), I(mu_wr1_3a), I(mu_wr1_3b), I(mu_wr1_4a), I(mu_wr1_4b), I(mu_wr2_1a), I(mu_wr2_1b) ), - CU_DataPoints (bool, false, true, true, false, true, true, true, false ) -}; - -CU_Theory ((const dds_topic_descriptor_t *rd_desc, const dds_topic_descriptor_t *wr_desc, bool assignable, sample_init fn_init, bool read_sample), - ddsc_xtypes, must_understand, .init = xtypes_init, .fini = xtypes_fini) -{ - printf ("Running test xtypes_must_understand: %s %s\n", wr_desc->m_typename, rd_desc->m_typename); - do_test (rd_desc, NULL, wr_desc, NULL, assignable, fn_init, read_sample, 0); -} -#undef D -#undef I - -/* Type consistency enforcement policy test cases (ignore seq/str bounds, prevent type widening, allow type coercion) */ -#define D(n) (&XSpaceTypeConsistencyEnforcement_ ## n ## _desc) -#define I(n) sample_init_tce_ ## n -#define C(n) sample_check_tce_ ## n -#define ALLOW DDS_TYPE_CONSISTENCY_ALLOW_TYPE_COERCION -#define DISALW DDS_TYPE_CONSISTENCY_DISALLOW_TYPE_COERCION -#define DT true -#define DF false -#define DDS_TD_T const dds_topic_descriptor_t * -#define DDS_TCE_T dds_type_consistency_kind_t - -CU_TheoryDataPoints (ddsc_xtypes, type_consistency_enforcement) = { - CU_DataPoints (const char *, - "wr seq bound > rd seq bound, but ignore_seq_bounds", - "wr seq bound > rd seq bound, !ignore_seq_bounds", - "wr seq unbounded > rd seq bound, !ignore_seq_bounds", - "wr seq bound < rd seq unbound, !ignore_seq_bounds", - "disallow coercion, same type", - "disallow coercion, different (assignable) type", - "wr str bound > rd str bound, but ignore_str_bounds", - "wr str bound > rd str bound, !ignore_str_bounds", - "wr str unbounded > rd str bound, !ignore_str_bounds", - "wr str bound < rd str unbound, !ignore_str_bounds", - "member names different, !ignore_member_names", - "member names different, ignore_member_names", - "union member names different, !ignore_member_names", - "union member names different, !ignore_member_names", - "widen type, !prevent_type_widening", - "widen type, prevent_type_widening", - "same members, prevent_type_widening", - "widen with optional member, prevent_type_widening", - "widen mutable type, !prevent_type_widening", - "widen mutable type, prevent_type_widening", - "widen union type, !prevent_type_widening", - "widen union type, prevent_type_widening"), - CU_DataPoints (DDS_TD_T, D(t1_1), D(t1_1), D(t1_1), D(t1_3), D(t1_1), D(t1_1), D(t2_1), D(t2_1), D(t2_1), D(t2_3), D(t3_1), D(t3_1), D(t4_1), D(t4_1), D(t5_1), D(t5_1), D(t5_1), D(t5_1), D(t6_1), D(t6_1), D(t7_1), D(t7_1) ), - CU_DataPoints (DDS_TD_T, D(t1_2), D(t1_2), D(t1_3), D(t1_1), D(t1_1), D(t1_3), D(t2_2), D(t2_2), D(t2_3), D(t2_1), D(t3_2), D(t3_2), D(t4_2), D(t4_2), D(t5_2), D(t5_2), D(t5_3), D(t5_4), D(t6_2), D(t6_2), D(t7_2), D(t7_2) ), - - CU_DataPoints (DDS_TCE_T, ALLOW , ALLOW , ALLOW , ALLOW , DISALW , DISALW , ALLOW , ALLOW , ALLOW , ALLOW , ALLOW , ALLOW , ALLOW , ALLOW , ALLOW , ALLOW , ALLOW , ALLOW , ALLOW , ALLOW , ALLOW , ALLOW ), // allow/disallow type coercion - CU_DataPoints (bool, DF , DF , DF , DF , DF , DF , DF , DF , DF , DF , DF , DF , DF , DF , false , true , true , true , false , true , false , true ), // prevent_type_widening - CU_DataPoints (bool, true , false , false , false , DT , DT , DT , DT , DT , DT , DT , DT , DT , DT , DT , DT , DT , DT , DT , DT , DT , DT ), // ignore_seq_bounds - CU_DataPoints (bool, DT , DT , DT , DT , DT , DT , true , false , false , false , DT , DT , DT , DT , DT , DT , DT , DT , DT , DT , DT , DT ), // ignore_str_bounds - CU_DataPoints (bool, DF , DF , DF , DF , DF , DF , DF , DF , DF , DF , false , true , false , true , DF , DF , DF , DF , DF , DF , DF , DF ), // ignore_member_names - CU_DataPoints (bool, DF , DF , DF , DF , DF , DF , DF , DF , DF , DF , DF , DF , DF , DF , DF , DF , DF , DF , DF , DF , DF , DF ), // force_type_validation - - CU_DataPoints (bool, true , false , false , true , true , false , true , false , false , true , false , true , false , true , true , false , false , true , true , false , true , false ), // expect match -}; - -CU_Theory ((const char *test, const dds_topic_descriptor_t *rd_desc, const dds_topic_descriptor_t *wr_desc, dds_type_consistency_kind_t kind, - bool prevent_type_widening, bool ignore_seq_bounds, bool ignore_str_bounds, bool ignore_member_names, bool force_type_validation, bool assignable), - ddsc_xtypes, type_consistency_enforcement, .init = xtypes_init, .fini = xtypes_fini) -{ - printf ("Running test xtypes_type_consistency_enforcement: %s wr %s rd %s\n", test, wr_desc->m_typename, rd_desc->m_typename); - dds_qos_t *rd_qos = dds_create_qos (); - dds_qset_type_consistency (rd_qos, kind, ignore_seq_bounds, ignore_str_bounds, ignore_member_names, prevent_type_widening, force_type_validation); - do_test (rd_desc, rd_qos, wr_desc, NULL, assignable, 0, false, 0); - dds_delete_qos (rd_qos); -} -#undef D -#undef I -#undef C -#undef ALLOW -#undef DISALLOW -#undef DT -#undef DF -#undef DDS_TD_T -#undef DDS_TCE_T - -/* Type consistency enforcement policy test case for force_type_validation */ -CU_Test (ddsc_xtypes, type_consistency_enforcement_force_validation, .init = xtypes_init, .fini = xtypes_fini) -{ - for (uint32_t n = 0; n <= 1; n++) - { - bool force_type_validation = (n == 1); - printf ("Running test type_consistency_enforcement_force_validation: force_type_validation = %s\n", force_type_validation ? "true" : "false"); - dds_qos_t *rd_qos = dds_create_qos (); - dds_qset_type_consistency (rd_qos, DDS_TYPE_CONSISTENCY_ALLOW_TYPE_COERCION, true, true, false, false, force_type_validation); - do_test (&XSpaceNoTypeInfo_t1_desc, rd_qos, &XSpaceNoTypeInfo_t1_desc, NULL, !force_type_validation, 0, false, 0); - dds_delete_qos (rd_qos); - } -} - - -/* Enum extensibility test cases */ -static void sample_init_en_wr1_1 (void *ptr) -{ - XSpaceEnum_wr1_1 *sample = (XSpaceEnum_wr1_1 *) ptr; - sample->f1 = XSpaceEnum_F1; -} -static void sample_init_en_wr2_1 (void *ptr) -{ - XSpaceEnum_wr2_1 *sample = (XSpaceEnum_wr2_1 *) ptr; - sample->f1 = XSpaceEnum_A1; -} -static void sample_init_en_wr2_3 (void *ptr) -{ - XSpaceEnumPlus_wr2_3 *sample = (XSpaceEnumPlus_wr2_3 *) ptr; - sample->f1 = XSpaceEnumPlus_A1; -} -static void sample_init_en_wr2_4 (void *ptr) -{ - XSpaceEnumMin_wr2_4 *sample = (XSpaceEnumMin_wr2_4 *) ptr; - sample->f1 = XSpaceEnumMin_A1; -} - -#define D(n) XSpaceEnum_ ## n ## _desc -#define DP(n) XSpaceEnumPlus_ ## n ## _desc -#define DM(n) XSpaceEnumMin_ ## n ## _desc -#define DL(n) XSpaceEnumLabel_ ## n ## _desc -#define I(n) sample_init_ ## n -CU_TheoryDataPoints (ddsc_xtypes, enum_extensibility) = { - CU_DataPoints (const dds_topic_descriptor_t *, &D(rd1), &D(rd1), &D(rd1), &D(rd1), &D(rd1), &D(rd2), &D(rd2), &D(rd2), &D(rd2), &D(rd2) ), - CU_DataPoints (const dds_topic_descriptor_t *, &D(wr1_1), &D(wr1_2), &DP(wr1_3), &DM(wr1_4), &DL(wr1_5), &D(wr2_1), &D(wr2_2), &DP(wr2_3), &DM(wr2_4), &DL(wr2_5) ), - CU_DataPoints (bool, true, false, false, false, false, true, false, true, true, false ), - CU_DataPoints (sample_init, I(en_wr1_1), 0, 0, 0, 0, I(en_wr2_1), 0, I(en_wr2_3), I(en_wr2_4), 0 ), - CU_DataPoints (bool, true, false, false, false, false, true, false, true, true, false ) -}; - -CU_Theory ((const dds_topic_descriptor_t *rd_desc, const dds_topic_descriptor_t *wr_desc, bool assignable, sample_init fn_init, bool read_sample), - ddsc_xtypes, enum_extensibility, .init = xtypes_init, .fini = xtypes_fini) -{ - printf ("Running test xtypes_enum: %s %s\n", wr_desc->m_typename, rd_desc->m_typename); - do_test (rd_desc, NULL, wr_desc, NULL, assignable, fn_init, read_sample, 0); -} - -#undef D -#undef DP -#undef DM -#undef DL -#undef I - - -static void typeinfo_ser (struct dds_type_meta_ser *ser, DDS_XTypes_TypeInformation *ti) -{ - dds_ostream_t os = { .m_buffer = NULL, .m_index = 0, .m_size = 0, .m_xcdr_version = DDSI_RTPS_CDR_ENC_VERSION_2 }; - xcdr2_ser (ti, &DDS_XTypes_TypeInformation_desc, &os); - ser->data = os.m_buffer; - ser->sz = os.m_index; -} - -static void typeinfo_deser (DDS_XTypes_TypeInformation **ti, const struct dds_type_meta_ser *ser) -{ - xcdr2_deser (ser->data, ser->sz, (void **) ti, &DDS_XTypes_TypeInformation_desc); -} - -static void typemap_ser (struct dds_type_meta_ser *ser, DDS_XTypes_TypeMapping *tmap) -{ - dds_ostream_t os = { .m_buffer = NULL, .m_index = 0, .m_size = 0, .m_xcdr_version = DDSI_RTPS_CDR_ENC_VERSION_2 }; - xcdr2_ser (tmap, &DDS_XTypes_TypeMapping_desc, &os); - ser->data = os.m_buffer; - ser->sz = os.m_index; -} - -static void typemap_deser (DDS_XTypes_TypeMapping **tmap, const struct dds_type_meta_ser *ser) -{ - xcdr2_deser (ser->data, ser->sz, (void **) tmap, &DDS_XTypes_TypeMapping_desc); -} - -static void test_proxy_rd_create (struct ddsi_domaingv *gv, const char *topic_name, DDS_XTypes_TypeInformation *ti, dds_return_t exp_ret, const ddsi_guid_t *pp_guid, const ddsi_guid_t *rd_guid) -{ - ddsi_plist_t *plist = ddsrt_calloc (1, sizeof (*plist)); - plist->qos.present |= DDSI_QP_TOPIC_NAME | DDSI_QP_TYPE_NAME | DDSI_QP_TYPE_INFORMATION | DDSI_QP_DATA_REPRESENTATION | DDSI_QP_LIVELINESS; - plist->qos.topic_name = ddsrt_strdup (topic_name); - plist->qos.type_name = ddsrt_strdup ("dummy"); - plist->qos.type_information = ddsi_typeinfo_dup ((struct ddsi_typeinfo *) ti); - plist->qos.data_representation.value.n = 1; - plist->qos.data_representation.value.ids = ddsrt_calloc (1, sizeof (*plist->qos.data_representation.value.ids)); - plist->qos.data_representation.value.ids[0] = DDS_DATA_REPRESENTATION_XCDR2; - plist->qos.liveliness.kind = DDS_LIVELINESS_AUTOMATIC; - plist->qos.liveliness.lease_duration = DDS_INFINITY; - - struct ddsi_thread_state * const thrst = ddsi_lookup_thread_state (); - ddsi_thread_state_awake (thrst, gv); - struct ddsi_addrset *as = ddsi_new_addrset (); - ddsi_add_locator_to_addrset (gv, as, &gv->loc_default_uc); - ddsi_ref_addrset (as); // increase refc to 2, new_proxy_participant does not add a ref - int rc = ddsi_new_proxy_participant (gv, pp_guid, 0, NULL, as, as, plist, DDS_INFINITY, DDSI_VENDORID_ECLIPSE, 0, ddsrt_time_wallclock (), 1); - CU_ASSERT_FATAL (rc); - - ddsi_xqos_mergein_missing (&plist->qos, &ddsi_default_qos_reader, ~(uint64_t)0); -#ifdef DDS_HAS_SSM - rc = ddsi_new_proxy_reader (gv, pp_guid, rd_guid, as, plist, ddsrt_time_wallclock (), 1, 0); -#else - rc = ddsi_new_proxy_reader (gv, pp_guid, rd_guid, as, plist, ddsrt_time_wallclock (), 1); -#endif - CU_ASSERT_EQUAL_FATAL (rc, exp_ret); - ddsi_plist_fini (plist); - ddsrt_free (plist); - ddsi_thread_state_asleep (thrst); -} - -static void test_proxy_rd_matches (dds_entity_t wr, bool exp_match) -{ - struct dds_entity *x; - dds_return_t rc = dds_entity_pin (wr, &x); - CU_ASSERT_EQUAL_FATAL (rc, DDS_RETCODE_OK); - struct dds_writer *dds_wr = (struct dds_writer *) x; - CU_ASSERT_EQUAL_FATAL (dds_wr->m_wr->num_readers, exp_match ? 1 : 0); - dds_entity_unpin (x); -} - -static void test_proxy_rd_fini (const ddsi_guid_t *pp_guid, const ddsi_guid_t *rd_guid) -{ - struct ddsi_domaingv *gv = get_domaingv (g_participant1); - struct ddsi_thread_state * const thrst = ddsi_lookup_thread_state (); - ddsi_thread_state_awake (thrst, gv); - ddsi_delete_proxy_reader (gv, rd_guid, ddsrt_time_wallclock (), false); - ddsi_delete_proxy_participant_by_guid (gv, pp_guid, ddsrt_time_wallclock (), false); - ddsi_thread_state_asleep (thrst); -} - -/* Invalid hashed type (with valid hash type id) as top-level type */ -CU_Test (ddsc_xtypes, invalid_top_level_local_hash, .init = xtypes_init, .fini = xtypes_fini) -{ - char topic_name[100]; - dds_topic_descriptor_t desc; - DDS_XTypes_TypeInformation *ti; - - for (uint32_t n = 0; n < 6; n++) - { - // coverity[store_writes_const_field] - memcpy (&desc, &XSpace_to_toplevel_desc, sizeof (desc)); - typeinfo_deser (&ti, &desc.type_information); - if (n % 2) - { - ddsi_typeid_fini_impl (&ti->minimal.typeid_with_size.type_id); - ddsi_typeid_copy_impl (&ti->minimal.typeid_with_size.type_id, &ti->minimal.dependent_typeids._buffer[n / 2].type_id); - } - else - { - ddsi_typeid_fini_impl (&ti->complete.typeid_with_size.type_id); - ddsi_typeid_copy_impl (&ti->complete.typeid_with_size.type_id, &ti->complete.dependent_typeids._buffer[n / 2].type_id); - } - typeinfo_ser (&desc.type_information, ti); - - create_unique_topic_name ("ddsc_xtypes", topic_name, sizeof (topic_name)); - dds_entity_t topic = dds_create_topic (g_participant1, &desc, topic_name, NULL, NULL); - CU_ASSERT_FATAL (topic < 0); - - ddsi_typeinfo_fini ((ddsi_typeinfo_t *) ti); - ddsrt_free (ti); - ddsrt_free ((void *) desc.type_information.data); - } -} - -/* Non-hashed type (with valid hash type id) as top-level type */ -CU_Test (ddsc_xtypes, invalid_top_level_local_non_hash, .init = xtypes_init, .fini = xtypes_fini) -{ - char topic_name[100]; - - dds_topic_descriptor_t desc; - // coverity[store_writes_const_field] - memcpy (&desc, &XSpace_to_toplevel_desc, sizeof (desc)); - - DDS_XTypes_TypeInformation *ti; - typeinfo_deser (&ti, &desc.type_information); - - ddsi_typeid_fini_impl (&ti->minimal.typeid_with_size.type_id); - ti->minimal.typeid_with_size.type_id._d = DDS_XTypes_TK_UINT32; - typeinfo_ser (&desc.type_information, ti); - - create_unique_topic_name ("ddsc_xtypes", topic_name, sizeof (topic_name)); - dds_entity_t topic = dds_create_topic (g_participant1, &desc, topic_name, NULL, NULL); - CU_ASSERT_FATAL (topic < 0); - - ddsi_typeinfo_fini ((ddsi_typeinfo_t *) ti); - ddsrt_free (ti); - ddsrt_free ((void *) desc.type_information.data); -} - -static void mod_toplevel (dds_sequence_DDS_XTypes_TypeIdentifierTypeObjectPair *type_id_obj_seq, uint32_t kind) -{ - assert (kind == DDS_XTypes_EK_MINIMAL); - (void) kind; - assert (type_id_obj_seq->_buffer[0].type_object._u.minimal._d == DDS_XTypes_TK_STRUCTURE); - type_id_obj_seq->_buffer[0].type_object._u.minimal._u.struct_type.member_seq._buffer[0].common.member_flags = 0x7f; -} - -static void mod_inherit (dds_sequence_DDS_XTypes_TypeIdentifierTypeObjectPair *type_id_obj_seq, uint32_t kind) -{ - assert (kind == DDS_XTypes_EK_MINIMAL); - (void) kind; - assert (type_id_obj_seq->_buffer[0].type_object._u.minimal._d == DDS_XTypes_TK_STRUCTURE); - ddsi_typeid_fini_impl (&type_id_obj_seq->_buffer[0].type_object._u.minimal._u.struct_type.header.base_type); - ddsi_typeid_copy_impl (&type_id_obj_seq->_buffer[0].type_object._u.minimal._u.struct_type.header.base_type, - &type_id_obj_seq->_buffer[0].type_object._u.minimal._u.struct_type.member_seq._buffer[0].common.member_type_id); -} - -static void mod_uniondisc (dds_sequence_DDS_XTypes_TypeIdentifierTypeObjectPair *type_id_obj_seq, uint32_t kind) -{ - assert (kind == DDS_XTypes_EK_MINIMAL); - (void) kind; - assert (type_id_obj_seq->_buffer[0].type_object._u.minimal._d == DDS_XTypes_TK_UNION); - type_id_obj_seq->_buffer[0].type_object._u.minimal._u.union_type.discriminator.common.type_id._d = DDS_XTypes_TK_FLOAT32; -} - -static void mod_unionmembers (dds_sequence_DDS_XTypes_TypeIdentifierTypeObjectPair *type_id_obj_seq, uint32_t kind) -{ - assert (kind == DDS_XTypes_EK_MINIMAL); - (void) kind; - assert (type_id_obj_seq->_buffer[0].type_object._u.minimal._d == DDS_XTypes_TK_UNION); - assert (type_id_obj_seq->_buffer[0].type_object._u.minimal._u.union_type.member_seq._length == 2); - type_id_obj_seq->_buffer[0].type_object._u.minimal._u.union_type.member_seq._buffer[0].common.member_flags |= DDS_XTypes_IS_DEFAULT; -} - -static void mod_arraybound (dds_sequence_DDS_XTypes_TypeIdentifierTypeObjectPair *type_id_obj_seq, uint32_t kind) -{ - assert (kind == DDS_XTypes_EK_MINIMAL); - (void) kind; - assert (type_id_obj_seq->_buffer[0].type_object._u.minimal._d == DDS_XTypes_TK_STRUCTURE); - assert (type_id_obj_seq->_buffer[0].type_object._u.minimal._u.struct_type.member_seq._buffer[0].common.member_type_id._d == DDS_XTypes_TI_PLAIN_ARRAY_SMALL); - type_id_obj_seq->_buffer[0].type_object._u.minimal._u.struct_type.member_seq._buffer[0].common.member_type_id._u.array_sdefn.array_bound_seq._buffer[0] = 5; -} - -static void modify_type_meta (dds_topic_descriptor_t *dst_desc, const dds_topic_descriptor_t *src_desc, typeobj_modify mod, bool update_typeinfo, uint32_t kind) -{ - // coverity[store_writes_const_field] - memcpy (dst_desc, src_desc, sizeof (*dst_desc)); - - DDS_XTypes_TypeInformation *ti = NULL; - if (update_typeinfo) - typeinfo_deser (&ti, &dst_desc->type_information); - - DDS_XTypes_TypeMapping *tmap = NULL; - typemap_deser (&tmap, &dst_desc->type_mapping); - - if (update_typeinfo) - { - assert (ti); - // confirm that top-level type is the first in type map - if (kind == DDS_XTypes_EK_MINIMAL || kind == DDS_XTypes_EK_BOTH) - { - assert (!ddsi_typeid_compare_impl (&ti->minimal.typeid_with_size.type_id, &tmap->identifier_object_pair_minimal._buffer[0].type_identifier)); - ddsi_typeid_fini_impl (&ti->minimal.typeid_with_size.type_id); - for (uint32_t n = 0; n < tmap->identifier_object_pair_minimal._length; n++) - ddsi_typeid_fini_impl (&tmap->identifier_object_pair_minimal._buffer[n].type_identifier); - } - if (kind == DDS_XTypes_EK_COMPLETE || kind == DDS_XTypes_EK_BOTH) - { - assert (!ddsi_typeid_compare_impl (&ti->complete.typeid_with_size.type_id, &tmap->identifier_object_pair_complete._buffer[0].type_identifier)); - ddsi_typeid_fini_impl (&ti->complete.typeid_with_size.type_id); - for (uint32_t n = 0; n < tmap->identifier_object_pair_complete._length; n++) - ddsi_typeid_fini_impl (&tmap->identifier_object_pair_complete._buffer[n].type_identifier); - } - } - - // modify the specified object in the type mapping - if (kind == DDS_XTypes_EK_MINIMAL || kind == DDS_XTypes_EK_BOTH) - mod (&tmap->identifier_object_pair_minimal, DDS_XTypes_EK_MINIMAL); - if (kind == DDS_XTypes_EK_COMPLETE || kind == DDS_XTypes_EK_BOTH) - mod (&tmap->identifier_object_pair_complete, DDS_XTypes_EK_COMPLETE); - - if (update_typeinfo) - { - // get hash-id for modified type and store in type map and replace top-level type id - if (kind == DDS_XTypes_EK_MINIMAL || kind == DDS_XTypes_EK_BOTH) - { - for (uint32_t n = 0; n < tmap->identifier_object_pair_minimal._length; n++) - { - ddsi_typeid_t type_id; - ddsi_typeobj_get_hash_id (&tmap->identifier_object_pair_minimal._buffer[n].type_object, &type_id); - ddsi_typeid_copy_impl (&tmap->identifier_object_pair_minimal._buffer[n].type_identifier, &type_id.x); - ddsi_typeid_fini (&type_id); - } - ddsi_typeid_copy_impl (&ti->minimal.typeid_with_size.type_id, &tmap->identifier_object_pair_minimal._buffer[0].type_identifier); - } - if (kind == DDS_XTypes_EK_COMPLETE || kind == DDS_XTypes_EK_BOTH) - { - for (uint32_t n = 0; n < tmap->identifier_object_pair_complete._length; n++) - { - ddsi_typeid_t type_id; - ddsi_typeobj_get_hash_id (&tmap->identifier_object_pair_complete._buffer[n].type_object, &type_id); - ddsi_typeid_copy_impl (&tmap->identifier_object_pair_complete._buffer[n].type_identifier, &type_id.x); - ddsi_typeid_fini (&type_id); - } - ddsi_typeid_copy_impl (&ti->complete.typeid_with_size.type_id, &tmap->identifier_object_pair_complete._buffer[0].type_identifier); - } - } - - // replace the type map and type info in the topic descriptor with updated ones - if (update_typeinfo) - typeinfo_ser (&dst_desc->type_information, ti); - typemap_ser (&dst_desc->type_mapping, tmap); - - // clean up - ddsi_typemap_fini ((ddsi_typemap_t *) tmap); - ddsrt_free (tmap); - - if (update_typeinfo) - { - ddsi_typeinfo_fini ((ddsi_typeinfo_t *) ti); - ddsrt_free (ti); - } -} - -#define D(n) XSpace_ ## n ## _desc -CU_TheoryDataPoints (ddsc_xtypes, invalid_type_object_local) = { - CU_DataPoints (const char *, "invalid flag, non-matching typeid", - /* | */"invalid flag, matching typeid", - /* | | */"invalid inheritance", - /* | | | */"invalid union discr", - /* | | | | */"union multiple default", - /* | | | | | */"array bound overflow"), - CU_DataPoints (const dds_topic_descriptor_t *, &D(to_toplevel), &D(to_toplevel), &D(to_inherit), &D(to_uniondisc), &D(to_unionmembers), &D(to_arraybound) ), - CU_DataPoints (typeobj_modify, mod_toplevel, mod_toplevel, mod_inherit, mod_uniondisc, mod_unionmembers, mod_arraybound ), - CU_DataPoints (bool, false, true, true, true, true, true ), -}; -#undef D - -CU_Theory ((const char *test_descr, const dds_topic_descriptor_t *topic_desc, typeobj_modify mod, bool matching_typeinfo), ddsc_xtypes, invalid_type_object_local, .init = xtypes_init, .fini = xtypes_fini) -{ - char topic_name[100]; - printf("Test invalid_type_object_local: %s\n", test_descr); - - dds_topic_descriptor_t desc; - modify_type_meta (&desc, topic_desc, mod, matching_typeinfo, DDS_XTypes_EK_MINIMAL); - - // test that topic creation fails - create_unique_topic_name ("ddsc_xtypes", topic_name, sizeof (topic_name)); - dds_entity_t topic = dds_create_topic (g_participant1, &desc, topic_name, NULL, NULL); - CU_ASSERT_FATAL (topic < 0); - - if (matching_typeinfo) - ddsrt_free ((void *) desc.type_information.data); - ddsrt_free ((void *) desc.type_mapping.data); -} - -/* Invalid hashed type (with valid hash type id) as top-level type for proxy endpoint */ -CU_Test (ddsc_xtypes, invalid_top_level_remote_hash, .init = xtypes_init, .fini = xtypes_fini) -{ - dds_topic_descriptor_t desc; - DDS_XTypes_TypeInformation *ti; - struct ddsi_domaingv *gv = get_domaingv (g_participant1); - char topic_name[100]; - create_unique_topic_name ("ddsc_xtypes", topic_name, sizeof (topic_name)); - - // create local topic so that types are in type lib and resolved - dds_entity_t topic = dds_create_topic (g_participant1, &XSpace_to_toplevel_desc, topic_name, NULL, NULL); - CU_ASSERT_FATAL (topic > 0); - - // create type id with invalid top-level - // coverity[store_writes_const_field] - memcpy (&desc, &XSpace_to_toplevel_desc, sizeof (desc)); - typeinfo_deser (&ti, &desc.type_information); - ddsi_typeid_fini_impl (&ti->minimal.typeid_with_size.type_id); - ddsi_typeid_copy_impl (&ti->minimal.typeid_with_size.type_id, &ti->minimal.dependent_typeids._buffer[0].type_id); - - // create proxy reader with modified type - struct ddsi_guid pp_guid, rd_guid; - gen_test_guid (gv, &pp_guid, DDSI_ENTITYID_PARTICIPANT); - gen_test_guid (gv, &rd_guid, DDSI_ENTITYID_KIND_READER_NO_KEY); - test_proxy_rd_create (gv, topic_name, ti, DDS_RETCODE_BAD_PARAMETER, &pp_guid, &rd_guid); - - // clean up - test_proxy_rd_fini (&pp_guid, &rd_guid); - ddsi_typeinfo_fini ((ddsi_typeinfo_t *) ti); - ddsrt_free (ti); -} - - -/* Invalid type object for proxy endpoint */ -#define D(n) XSpace_ ## n ## _desc -CU_TheoryDataPoints (ddsc_xtypes, invalid_type_object_remote) = { - CU_DataPoints (const char *, - /* */"invalid flag", - /* | */"invalid inheritance", - /* | | */"invalid union discr"), - CU_DataPoints (const dds_topic_descriptor_t *, &D(to_toplevel), &D(to_inherit), &D(to_uniondisc) ), - CU_DataPoints (typeobj_modify, mod_toplevel, mod_inherit, mod_uniondisc ) -}; -#undef D - -CU_Theory ((const char *test_descr, const dds_topic_descriptor_t *topic_desc, typeobj_modify mod), ddsc_xtypes, invalid_type_object_remote, .init = xtypes_init, .fini = xtypes_fini) -{ - struct ddsi_domaingv *gv = get_domaingv (g_participant1); - printf("Test invalid_type_object_remote: %s\n", test_descr); - - char topic_name[100]; - create_unique_topic_name ("ddsc_xtypes", topic_name, sizeof (topic_name)); - - // local writer - dds_entity_t topic = dds_create_topic (g_participant1, topic_desc, topic_name, NULL, NULL); - CU_ASSERT_FATAL (topic > 0); - dds_entity_t wr = dds_create_writer (g_participant1, topic, NULL, NULL); - CU_ASSERT_FATAL (wr > 0); - - dds_topic_descriptor_t desc; - modify_type_meta (&desc, topic_desc, mod, true, DDS_XTypes_EK_MINIMAL); - - DDS_XTypes_TypeInformation *ti; - typeinfo_deser (&ti, &desc.type_information); - struct ddsi_guid pp_guid, rd_guid; - gen_test_guid (gv, &pp_guid, DDSI_ENTITYID_PARTICIPANT); - gen_test_guid (gv, &rd_guid, DDSI_ENTITYID_KIND_READER_NO_KEY); - test_proxy_rd_create (gv, topic_name, ti, DDS_RETCODE_OK, &pp_guid, &rd_guid); - test_proxy_rd_matches (wr, false); - - struct ddsi_generic_proxy_endpoint **gpe_match_upd = NULL; - uint32_t n_match_upd = 0; - - DDS_XTypes_TypeMapping *tmap; - typemap_deser (&tmap, &desc.type_mapping); - DDS_Builtin_TypeLookup_Reply reply = { - .header = { .remoteEx = DDS_RPC_REMOTE_EX_OK, .relatedRequestId = { .sequence_number = { .low = 1, .high = 0 }, .writer_guid = { .guidPrefix = { 0 }, .entityId = { .entityKind = DDSI_EK_WRITER, .entityKey = { 0 } } } } }, - .return_data = { ._d = DDS_Builtin_TypeLookup_getTypes_HashId, ._u = { .getType = { ._d = DDS_RETCODE_OK, ._u = { .result = - { .types = { ._length = tmap->identifier_object_pair_minimal._length, ._maximum = tmap->identifier_object_pair_minimal._maximum, ._release = false, ._buffer = tmap->identifier_object_pair_minimal._buffer } } } } } } - }; - ddsi_tl_add_types (gv, &reply, &gpe_match_upd, &n_match_upd); - - // expect no match because of invalid types - CU_ASSERT_EQUAL_FATAL (n_match_upd, 0); - ddsrt_free (gpe_match_upd); - - struct ddsi_type *type = ddsi_type_lookup (gv, (ddsi_typeid_t *) &tmap->identifier_object_pair_minimal._buffer[0].type_identifier); - CU_ASSERT_PTR_NOT_NULL_FATAL (type); - CU_ASSERT_EQUAL_FATAL (type->state, DDSI_TYPE_INVALID); - - // clean up - test_proxy_rd_fini (&pp_guid, &rd_guid); - ddsi_typeinfo_fini ((ddsi_typeinfo_t *) ti); - ddsrt_free (ti); - ddsi_typemap_fini ((ddsi_typemap_t *) tmap); - ddsrt_free (tmap); - ddsrt_free ((void *) desc.type_information.data); - ddsrt_free ((void *) desc.type_mapping.data); -} - -static void mod_dep_test (dds_sequence_DDS_XTypes_TypeIdentifierTypeObjectPair *type_id_obj_seq, uint32_t kind) -{ - // Remove member n2 from dep_test_nested - if (kind == DDS_XTypes_EK_MINIMAL) - { - assert (type_id_obj_seq->_buffer[1].type_object._u.minimal._d == DDS_XTypes_TK_STRUCTURE); - assert (type_id_obj_seq->_buffer[1].type_object._u.minimal._u.struct_type.member_seq._length == 2); - type_id_obj_seq->_buffer[1].type_object._u.minimal._u.struct_type.member_seq._length = 1; - } - else - { - assert (type_id_obj_seq->_buffer[1].type_object._u.complete._d == DDS_XTypes_TK_STRUCTURE); - assert (type_id_obj_seq->_buffer[1].type_object._u.complete._u.struct_type.member_seq._length == 2); - type_id_obj_seq->_buffer[1].type_object._u.complete._u.struct_type.member_seq._length = 1; - } - - // Recalculate type ids for dep_test_nested and replace dep_test.f1 member type id - ddsi_typeid_t type_id; - if (kind == DDS_XTypes_EK_MINIMAL) - { - assert (type_id_obj_seq->_buffer[0].type_object._u.minimal._d == DDS_XTypes_TK_STRUCTURE); - ddsi_typeid_fini_impl (&type_id_obj_seq->_buffer[0].type_object._u.minimal._u.struct_type.member_seq._buffer[0].common.member_type_id); - ddsi_typeobj_get_hash_id (&type_id_obj_seq->_buffer[1].type_object, &type_id); - ddsi_typeid_copy_impl (&type_id_obj_seq->_buffer[0].type_object._u.minimal._u.struct_type.member_seq._buffer[0].common.member_type_id, &type_id.x); - } - else - { - assert (type_id_obj_seq->_buffer[0].type_object._u.complete._d == DDS_XTypes_TK_STRUCTURE); - ddsi_typeid_fini_impl (&type_id_obj_seq->_buffer[0].type_object._u.complete._u.struct_type.member_seq._buffer[0].common.member_type_id); - ddsi_typeobj_get_hash_id (&type_id_obj_seq->_buffer[1].type_object, &type_id); - ddsi_typeid_copy_impl (&type_id_obj_seq->_buffer[0].type_object._u.complete._u.struct_type.member_seq._buffer[0].common.member_type_id, &type_id.x); - } -} - -CU_Test (ddsc_xtypes, resolve_dep_type, .init = xtypes_init, .fini = xtypes_fini) -{ - struct ddsi_domaingv *gv = get_domaingv (g_participant1); - char topic_name[100]; - create_unique_topic_name ("ddsc_xtypes", topic_name, sizeof (topic_name)); - - // local writer - dds_entity_t topic = dds_create_topic (g_participant1, &XSpace_dep_test_desc, topic_name, NULL, NULL); - CU_ASSERT_FATAL (topic > 0); - dds_entity_t wr = dds_create_writer (g_participant1, topic, NULL, NULL); - CU_ASSERT_FATAL (wr > 0); - - dds_topic_descriptor_t desc; - modify_type_meta (&desc, &XSpace_dep_test_desc, mod_dep_test, true, DDS_XTypes_EK_BOTH); - - DDS_XTypes_TypeInformation *ti; - typeinfo_deser (&ti, &desc.type_information); - struct ddsi_guid pp_guid, rd_guid; - gen_test_guid (gv, &pp_guid, DDSI_ENTITYID_PARTICIPANT); - gen_test_guid (gv, &rd_guid, DDSI_ENTITYID_KIND_READER_NO_KEY); - test_proxy_rd_create (gv, topic_name, ti, DDS_RETCODE_OK, &pp_guid, &rd_guid); - test_proxy_rd_matches (wr, false); - - struct ddsi_generic_proxy_endpoint **gpe_match_upd = NULL; - uint32_t n_match_upd = 0; - DDS_Builtin_TypeLookup_Reply reply; - DDS_XTypes_TypeMapping *tmap; - typemap_deser (&tmap, &desc.type_mapping); - - // add proxy reader's top-level type - reply = (DDS_Builtin_TypeLookup_Reply) { - .header = { .remoteEx = DDS_RPC_REMOTE_EX_OK, .relatedRequestId = { .sequence_number = { .low = 1, .high = 0 }, .writer_guid = { .guidPrefix = { 0 }, .entityId = { .entityKind = DDSI_EK_WRITER, .entityKey = { 0 } } } } }, - .return_data = { ._d = DDS_Builtin_TypeLookup_getTypes_HashId, ._u = { .getType = { ._d = DDS_RETCODE_OK, ._u = { .result = - { .types = { ._length = 1, ._maximum = 1, ._release = false, ._buffer = &tmap->identifier_object_pair_minimal._buffer[0] } } } } } } - }; - ddsi_tl_add_types (gv, &reply, &gpe_match_upd, &n_match_upd); - // FIXME expect matching triggered (but matching would fail because deps are unresolved), this needs to be fixed in ddsi_tl_handle_reply - CU_ASSERT_EQUAL_FATAL (n_match_upd, 1); - ddsrt_free (gpe_match_upd); - - // add nested type and expect match - gpe_match_upd = NULL; - n_match_upd = 0; - reply = (DDS_Builtin_TypeLookup_Reply) { - .header = { .remoteEx = DDS_RPC_REMOTE_EX_OK, .relatedRequestId = { .sequence_number = { .low = 1, .high = 0 }, .writer_guid = { .guidPrefix = { 0 }, .entityId = { .entityKind = DDSI_EK_WRITER, .entityKey = { 0 } } } } }, - .return_data = { ._d = DDS_Builtin_TypeLookup_getTypes_HashId, ._u = { .getType = { ._d = DDS_RETCODE_OK, ._u = { .result = - { .types = { ._length = 1, ._maximum = 1, ._release = false, ._buffer = &tmap->identifier_object_pair_minimal._buffer[1] } } } } } } - }; - ddsi_tl_add_types (gv, &reply, &gpe_match_upd, &n_match_upd); - CU_ASSERT_EQUAL_FATAL (n_match_upd, 1); - - assert (gpe_match_upd); - for (uint32_t e = 0; e < n_match_upd; e++) - ddsi_update_proxy_endpoint_matching (gv, gpe_match_upd[e]); - ddsrt_free (gpe_match_upd); - - test_proxy_rd_matches (wr, true); - - // clean up - test_proxy_rd_fini (&pp_guid, &rd_guid); - ddsi_typeinfo_fini ((ddsi_typeinfo_t *) ti); - ddsrt_free (ti); - ddsi_typemap_fini ((ddsi_typemap_t *) tmap); - ddsrt_free (tmap); - ddsrt_free ((void *) desc.type_information.data); - ddsrt_free ((void *) desc.type_mapping.data); -} - -CU_Test (ddsc_xtypes, get_type_info, .init = xtypes_init, .fini = xtypes_fini) -{ - char topic_name[100]; - create_unique_topic_name ("ddsc_xtypes", topic_name, sizeof (topic_name)); - - dds_entity_t topic = dds_create_topic (g_participant1, &XSpace_XType1_desc, topic_name, NULL, NULL); - CU_ASSERT_FATAL (topic > 0); - dds_entity_t wr = dds_create_writer (g_participant1, topic, NULL, NULL); - CU_ASSERT_FATAL (wr > 0); - dds_entity_t rd = dds_create_reader (g_participant1, topic, NULL, NULL); - CU_ASSERT_FATAL (rd > 0); - - dds_typeinfo_t *type_info_tp, *type_info_wr, *type_info_rd; - dds_return_t ret; - ret = dds_get_typeinfo (topic, &type_info_tp); - CU_ASSERT_EQUAL_FATAL (ret, DDS_RETCODE_OK); - ret = dds_get_typeinfo (wr, &type_info_wr); - CU_ASSERT_EQUAL_FATAL (ret, DDS_RETCODE_OK); - ret = dds_get_typeinfo (rd, &type_info_rd); - CU_ASSERT_EQUAL_FATAL (ret, DDS_RETCODE_OK); - CU_ASSERT_FATAL (ddsi_typeinfo_equal (type_info_tp, type_info_wr, DDSI_TYPE_INCLUDE_DEPS)); - CU_ASSERT_FATAL (ddsi_typeinfo_equal (type_info_tp, type_info_rd, DDSI_TYPE_INCLUDE_DEPS)); - - dds_free_typeinfo (type_info_tp); - dds_free_typeinfo (type_info_wr); - dds_free_typeinfo (type_info_rd); -} diff --git a/src/core/ddsc/tests/xtypes_assignability.c b/src/core/ddsc/tests/xtypes_assignability.c new file mode 100644 index 0000000000..af7264bd33 --- /dev/null +++ b/src/core/ddsc/tests/xtypes_assignability.c @@ -0,0 +1,542 @@ +// Copyright(c) 2006 to 2022 ZettaScale Technology and others +// +// This program and the accompanying materials are made available under the +// terms of the Eclipse Public License v. 2.0 which is available at +// http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License +// v. 1.0 which is available at +// http://www.eclipse.org/org/documents/edl-v10.php. +// +// SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause + +#include +#include + +#include "dds/ddsrt/cdtors.h" +#include "dds/ddsrt/misc.h" +#include "dds/ddsrt/process.h" +#include "dds/ddsrt/threads.h" +#include "dds/ddsrt/environ.h" +#include "dds/ddsrt/atomics.h" +#include "dds/ddsrt/time.h" +#include "dds/ddsrt/heap.h" +#include "dds/ddsrt/string.h" +#include "dds/ddsi/ddsi_entity.h" +#include "dds/ddsi/ddsi_entity_index.h" +#include "dds/ddsi/ddsi_typelib.h" +#include "dds/ddsi/ddsi_xt_typelookup.h" +#include "ddsi__xt_impl.h" +#include "ddsi__addrset.h" +#include "ddsi__endpoint_match.h" +#include "ddsi__proxy_endpoint.h" +#include "ddsi__proxy_participant.h" +#include "ddsi__typelookup.h" +#include "ddsi__typewrap.h" +#include "ddsi__vendor.h" +#include "dds/cdr/dds_cdrstream.h" +#include "dds/dds.h" +#include "dds/version.h" +#include "dds__entity.h" +#include "config_env.h" +#include "test_common.h" + +#include "XSpace.h" +#include "XSpaceEnum.h" +#include "XSpaceMustUnderstand.h" +#include "XSpaceTypeConsistencyEnforcement.h" +#include "XSpaceNoTypeInfo.h" + +#define DDS_DOMAINID_PUB 0 +#define DDS_DOMAINID_SUB 1 +#define DDS_CONFIG "${CYCLONEDDS_URI}${CYCLONEDDS_URI:+,}0" + +static dds_entity_t g_domain1 = 0; +static dds_entity_t g_participant1 = 0; +static dds_entity_t g_publisher1 = 0; + +static dds_entity_t g_domain2 = 0; +static dds_entity_t g_participant2 = 0; +static dds_entity_t g_subscriber2 = 0; + +typedef void (*sample_init) (void *s); +typedef void (*sample_check) (void *s1, void *s2); + +static void xtypes_assignability_init (void) +{ + /* Domains for pub and sub use a different internal domain id, but the external + * domain id in configuration is 0, so that both domains will map to the same port number. + * This allows to create two domains in a single test process. */ + char *conf1 = ddsrt_expand_envvars (DDS_CONFIG, DDS_DOMAINID_PUB); + char *conf2 = ddsrt_expand_envvars (DDS_CONFIG, DDS_DOMAINID_SUB); + g_domain1 = dds_create_domain (DDS_DOMAINID_PUB, conf1); + g_domain2 = dds_create_domain (DDS_DOMAINID_SUB, conf2); + dds_free (conf1); + dds_free (conf2); + + g_participant1 = dds_create_participant (DDS_DOMAINID_PUB, NULL, NULL); + CU_ASSERT_FATAL (g_participant1 > 0); + g_participant2 = dds_create_participant (DDS_DOMAINID_SUB, NULL, NULL); + CU_ASSERT_FATAL (g_participant2 > 0); + + g_publisher1 = dds_create_publisher (g_participant1, NULL, NULL); + CU_ASSERT_FATAL (g_publisher1 > 0); + g_subscriber2 = dds_create_subscriber (g_participant2, NULL, NULL); + CU_ASSERT_FATAL (g_subscriber2 > 0); +} + +static void xtypes_assignability_fini (void) +{ + dds_delete (g_domain2); + dds_delete (g_domain1); +} + +static bool reader_wait_for_data (dds_entity_t pp, dds_entity_t rd, dds_duration_t dur) +{ + dds_attach_t triggered; + dds_entity_t ws = dds_create_waitset (pp); + CU_ASSERT_FATAL (ws > 0); + dds_return_t ret = dds_waitset_attach (ws, rd, rd); + CU_ASSERT_EQUAL_FATAL (ret, DDS_RETCODE_OK); + ret = dds_waitset_wait (ws, &triggered, 1, dur); + if (ret > 0) + CU_ASSERT_EQUAL_FATAL (rd, (dds_entity_t)(intptr_t) triggered); + dds_delete (ws); + return ret > 0; +} + +static void do_test (const dds_topic_descriptor_t *rd_desc, const dds_qos_t *add_rd_qos, const dds_topic_descriptor_t *wr_desc, const dds_qos_t *add_wr_qos, bool assignable, sample_init fn_init, bool read_sample, sample_check fn_check) +{ + dds_return_t ret; + char topic_name[100]; + create_unique_topic_name ("ddsc_xtypes_assignability", topic_name, sizeof (topic_name)); + dds_entity_t topic_wr = dds_create_topic (g_participant1, wr_desc, topic_name, NULL, NULL); + CU_ASSERT_FATAL (topic_wr > 0); + dds_entity_t topic_rd = dds_create_topic (g_participant2, rd_desc, topic_name, NULL, NULL); + CU_ASSERT_FATAL (topic_rd > 0); + + dds_qos_t *qos = dds_create_qos (), *wrqos = dds_create_qos (), *rdqos = dds_create_qos (); + CU_ASSERT_FATAL (qos != NULL); + dds_qset_reliability (qos, DDS_RELIABILITY_RELIABLE, DDS_SECS (10)); + dds_qset_history (qos, DDS_HISTORY_KEEP_ALL, 0); + dds_qset_data_representation (qos, 1, (dds_data_representation_id_t[]) { DDS_DATA_REPRESENTATION_XCDR2 }); + dds_copy_qos (wrqos, qos); + dds_copy_qos (rdqos, qos); + + if (add_wr_qos) + dds_merge_qos (wrqos, add_wr_qos); + dds_entity_t writer = dds_create_writer (g_participant1, topic_wr, wrqos, NULL); + CU_ASSERT_FATAL (writer > 0); + + if (add_rd_qos) + dds_merge_qos (rdqos, add_rd_qos); + dds_entity_t reader = dds_create_reader (g_participant2, topic_rd, rdqos, NULL); + CU_ASSERT_FATAL (reader > 0); + + dds_delete_qos (qos); + dds_delete_qos (wrqos); + dds_delete_qos (rdqos); + + if (assignable) + { + sync_reader_writer (g_participant2, reader, g_participant1, writer); + ret = dds_set_status_mask (reader, DDS_DATA_AVAILABLE_STATUS); + CU_ASSERT_EQUAL_FATAL (ret, DDS_RETCODE_OK); + + if (fn_init) + { + void * wr_sample = dds_alloc (wr_desc->m_size); + fn_init (wr_sample); + ret = dds_write (writer, wr_sample); + CU_ASSERT_EQUAL_FATAL (ret, DDS_RETCODE_OK); + + void * rd_sample = dds_alloc (rd_desc->m_size); + void * rd_samples[1]; + rd_samples[0] = rd_sample; + dds_sample_info_t info; + bool data = reader_wait_for_data (g_participant2, reader, DDS_MSECS (500)); + CU_ASSERT_FATAL (data == read_sample); + if (data) + { + ret = dds_take (reader, rd_samples, &info, 1, 1); + CU_ASSERT_EQUAL_FATAL (ret, 1); + if (fn_check) + fn_check (wr_sample, rd_sample); + } + dds_sample_free (wr_sample, wr_desc, DDS_FREE_ALL); + dds_sample_free (rd_sample, rd_desc, DDS_FREE_ALL); + } + } + else + { + no_sync_reader_writer (g_participant2, reader, g_participant1, writer, DDS_MSECS (200)); + } +} + +/* Some basic tests */ +static void sample_init_XType1 (void *ptr) +{ + XSpace_XType1 *sample = (XSpace_XType1 *) ptr; + sample->long_1 = 1; + sample->long_2 = 2; + sample->bm_3 = XSpace_flag0 | XSpace_flag1; +} +static void sample_init_XType1a (void *ptr) +{ + XSpace_XType1a *sample = (XSpace_XType1a *) ptr; + sample->long_1 = 1; + sample->long_2 = 2; + sample->bm_3 = 3; +} +static void sample_check_XType1_1a (void *ptr1, void *ptr2) +{ + XSpace_XType1 *s_wr = (XSpace_XType1 *) ptr1; + XSpace_XType1a *s_rd = (XSpace_XType1a *) ptr2; + CU_ASSERT_EQUAL_FATAL (s_rd->long_1, s_wr->long_1); + CU_ASSERT_EQUAL_FATAL (s_rd->long_2, s_wr->long_2); + CU_ASSERT_EQUAL_FATAL (s_rd->bm_3, s_wr->bm_3); +} +static void sample_check_XType1a_1 (void *ptr1, void *ptr2) +{ + XSpace_XType1a *s_wr = (XSpace_XType1a *) ptr1; + XSpace_XType1 *s_rd = (XSpace_XType1 *) ptr2; + CU_ASSERT_EQUAL_FATAL (s_rd->long_1, s_wr->long_1); + CU_ASSERT_EQUAL_FATAL (s_rd->long_2, s_wr->long_2); + CU_ASSERT_EQUAL_FATAL (s_rd->bm_3, s_wr->bm_3); +} + +static void sample_init_XType2 (void *ptr) +{ + XSpace_XType2 *sample = (XSpace_XType2 *) ptr; + sample->long_1 = 1; + sample->long_2 = 2; +} +static void sample_init_XType2a (void *ptr) +{ + XSpace_XType2a *sample = (XSpace_XType2a *) ptr; + sample->long_1 = 1; + sample->long_2 = 2; + sample->long_3 = 3; +} +static void sample_check_XType2_2a (void *ptr1, void *ptr2) +{ + XSpace_XType2 *s_wr = (XSpace_XType2 *) ptr1; + XSpace_XType2a *s_rd = (XSpace_XType2a *) ptr2; + CU_ASSERT_EQUAL_FATAL (s_rd->long_1, s_wr->long_1); + CU_ASSERT_EQUAL_FATAL (s_rd->long_2, s_wr->long_2); + CU_ASSERT_EQUAL_FATAL (s_rd->long_3, 0); +} +static void sample_check_XType2a_2 (void *ptr1, void *ptr2) +{ + XSpace_XType2a *s_wr = (XSpace_XType2a *) ptr1; + XSpace_XType2 *s_rd = (XSpace_XType2 *) ptr2; + CU_ASSERT_EQUAL_FATAL (s_rd->long_1, s_wr->long_1); + CU_ASSERT_EQUAL_FATAL (s_rd->long_2, s_wr->long_2); +} + +static void sample_init_XType3 (void *ptr) +{ + XSpace_XType3 *sample = (XSpace_XType3 *) ptr; + sample->long_2 = 2; + sample->struct_3.long_4 = 4; + sample->struct_3.long_5 = 5; +} +static void sample_init_XType3a (void *ptr) +{ + XSpace_XType3a *sample = (XSpace_XType3a *) ptr; + sample->long_1 = 1; + sample->long_2 = 2; + sample->struct_3.long_4 = 4; +} +static void sample_check_XType3_3a (void *ptr1, void *ptr2) +{ + XSpace_XType3 *s_wr = (XSpace_XType3 *) ptr1; + XSpace_XType3a *s_rd = (XSpace_XType3a *) ptr2; + CU_ASSERT_EQUAL_FATAL (s_rd->long_1, 0); + CU_ASSERT_EQUAL_FATAL (s_rd->long_2, s_wr->long_2); + CU_ASSERT_EQUAL_FATAL (s_rd->struct_3.long_4, s_wr->struct_3.long_4); +} +static void sample_check_XType3a_3 (void *ptr1, void *ptr2) +{ + XSpace_XType3a *s_wr = (XSpace_XType3a *) ptr1; + XSpace_XType3 *s_rd = (XSpace_XType3 *) ptr2; + CU_ASSERT_EQUAL_FATAL (s_rd->long_2, s_wr->long_2); + CU_ASSERT_EQUAL_FATAL (s_rd->struct_3.long_4, s_wr->struct_3.long_4); + CU_ASSERT_EQUAL_FATAL (s_rd->struct_3.long_5, 0); +} + +static void sample_init_XType4 (void *ptr) +{ + XSpace_XType4 *sample = (XSpace_XType4 *) ptr; + uint32_t *s1 = ddsrt_malloc (999 * sizeof (*s1)); + for (uint32_t n = 0; n < 999; n++) s1[n] = n; + uint32_t *s2 = ddsrt_malloc (10 * sizeof (*s2)); + for (uint32_t n = 0; n < 10; n++) s2[n] = n; + sample->seq_1 = (dds_sequence_uint32) { ._length = 999, ._maximum = 999, ._buffer = s1, ._release = true }; + sample->seq_2 = (dds_sequence_uint32) { ._length = 10, ._maximum = 10, ._buffer = s2, ._release = true }; +} +static void sample_init_XType4a (void *ptr) +{ + XSpace_XType4a *sample = (XSpace_XType4a *) ptr; + uint32_t *s1 = ddsrt_malloc (999 * sizeof (*s1)); + for (uint32_t n = 0; n < 999; n++) s1[n] = n; + uint32_t *s2 = ddsrt_malloc (5 * sizeof (*s2)); + for (uint32_t n = 0; n < 5; n++) s2[n] = n; + sample->seq_1 = (dds_sequence_uint32) { ._length = 999, ._maximum = 999, ._buffer = s1, ._release = true }; + sample->seq_2 = (dds_sequence_uint32) { ._length = 5, ._maximum = 5, ._buffer = s2, ._release = true }; +} +static void sample_check_XType4a_4 (void *ptr1, void *ptr2) +{ + XSpace_XType4a *s_wr = (XSpace_XType4a *) ptr1; + XSpace_XType4 *s_rd = (XSpace_XType4 *) ptr2; + CU_ASSERT_FATAL (s_rd->seq_1._length == s_wr->seq_1._length && s_rd->seq_1._length == 999); + CU_ASSERT_FATAL (s_rd->seq_2._length == s_wr->seq_2._length && s_rd->seq_2._length == 5); + for (uint32_t n = 0; n < 999; n++) + CU_ASSERT_FATAL (s_rd->seq_1._buffer[n] == s_wr->seq_1._buffer[n] && s_rd->seq_1._buffer[n] == n); + for (uint32_t n = 0; n < 5; n++) + CU_ASSERT_FATAL (s_rd->seq_2._buffer[n] == s_wr->seq_2._buffer[n] && s_rd->seq_2._buffer[n] == n); +} + +static void sample_init_XType5a (void *ptr) +{ + XSpace_XType5a *sample = (XSpace_XType5a *) ptr; + for (uint32_t n = 0; n < 999; n++) sample->str_1[n] = 'a'; + for (uint32_t n = 0; n < 5; n++) sample->str_2[n] = 'a'; + sample->str_1[999] = '\0'; + sample->str_2[5] = '\0'; +} +static void sample_check_XType5a_5 (void *ptr1, void *ptr2) +{ + XSpace_XType5a *s_wr = (XSpace_XType5a *) ptr1; + XSpace_XType5 *s_rd = (XSpace_XType5 *) ptr2; + CU_ASSERT_FATAL (strlen (s_rd->str_1) == strlen (s_wr->str_1) && strlen (s_rd->str_1) == 999); + CU_ASSERT_FATAL (strlen (s_rd->str_2) == strlen (s_wr->str_2) && strlen (s_rd->str_2) == 5); + CU_ASSERT_FATAL (!strcmp (s_rd->str_1, s_wr->str_1)); + CU_ASSERT_FATAL (!strcmp (s_rd->str_2, s_wr->str_2)); +} + +#define D(n) XSpace_ ## n ## _desc +#define I(n) sample_init_ ## n +#define C(n) sample_check_ ## n +CU_TheoryDataPoints (ddsc_xtypes_assignability, basic) = { + CU_DataPoints (const char *, "mutable_bitmask", + /* | */"appendable_field", + /* | | */"appendable_nested", + /* | | | */"mutable_seq", + /* | | | | */"strlen_keys" ), + CU_DataPoints (const dds_topic_descriptor_t *, &D(XType1), &D(XType2), &D(XType3), &D(XType4), &D(XType5), ), + CU_DataPoints (const dds_topic_descriptor_t *, &D(XType1a), &D(XType2a), &D(XType3a), &D(XType4a), &D(XType5a), ), + CU_DataPoints (sample_init, I(XType1), I(XType2), I(XType3), I(XType4), NULL, ), + CU_DataPoints (sample_init, I(XType1a), I(XType2a), I(XType3a), I(XType4a), I(XType5a), ), + CU_DataPoints (sample_check, C(XType1_1a), C(XType2_2a), C(XType3_3a), NULL, NULL, ), + CU_DataPoints (sample_check, C(XType1a_1), C(XType2a_2), C(XType3a_3), C(XType4a_4), C(XType5a_5), ), +}; + +CU_Theory ((const char *descr, const dds_topic_descriptor_t *desc1, const dds_topic_descriptor_t *desc2, sample_init fn_init1, sample_init fn_init2, sample_check fn_check1, sample_check fn_check2), + ddsc_xtypes_assignability, basic, .init = xtypes_assignability_init, .fini = xtypes_assignability_fini) +{ + for (int t = 0; t <= 1; t++) + { + printf ("Running test xtypes_basic: %s (run %d/2)\n", descr, t + 1); + sample_init i = t ? fn_init2 : fn_init1; + sample_check c = t ? fn_check2 : fn_check1; + do_test (t ? desc1 : desc2, NULL, t ? desc2 : desc1, NULL, i != NULL, i, c != NULL, c); + } +} +#undef D +#undef I +#undef C + + +/* Must-understand test cases */ +static void sample_init_mu_wr1_2 (void *ptr) +{ + XSpaceMustUnderstand_wr1_2 *sample = (XSpaceMustUnderstand_wr1_2 *) ptr; + sample->f1 = 1; +} +static void sample_init_mu_wr1_3a (void *ptr) +{ + XSpaceMustUnderstand_wr1_3 *sample = (XSpaceMustUnderstand_wr1_3 *) ptr; + sample->f1 = 1; + sample->f2 = NULL; +} +static void sample_init_mu_wr1_3b (void *ptr) +{ + XSpaceMustUnderstand_wr1_3 *sample = (XSpaceMustUnderstand_wr1_3 *) ptr; + sample->f1 = 1; + sample->f2 = dds_alloc (sizeof (*sample->f2)); + *(sample->f2) = 1; +} +static void sample_init_mu_wr1_4a (void *ptr) +{ + XSpaceMustUnderstand_wr1_4 *sample = (XSpaceMustUnderstand_wr1_4 *) ptr; + sample->f1 = dds_alloc (sizeof (*sample->f1)); + *(sample->f1) = 1; +} +static void sample_init_mu_wr1_4b (void *ptr) +{ + XSpaceMustUnderstand_wr1_4 *sample = (XSpaceMustUnderstand_wr1_4 *) ptr; + sample->f1 = NULL; +} + +static void sample_init_mu_wr2_1a (void *ptr) +{ + XSpaceMustUnderstand_wr2_1 *sample = (XSpaceMustUnderstand_wr2_1 *) ptr; + sample->f1.f1 = 1; + sample->f1.f2 = NULL; +} +static void sample_init_mu_wr2_1b (void *ptr) +{ + XSpaceMustUnderstand_wr2_1 *sample = (XSpaceMustUnderstand_wr2_1 *) ptr; + sample->f1.f1 = 1; + sample->f1.f2 = dds_alloc (sizeof (*sample->f1.f2)); + *(sample->f1.f2) = 1; +} + +#define D(n) XSpaceMustUnderstand_ ## n ## _desc +#define I(n) sample_init_ ## n +CU_TheoryDataPoints (ddsc_xtypes_assignability, must_understand) = { + CU_DataPoints (const dds_topic_descriptor_t *, &D(rd1), &D(rd1), &D(rd1), &D(rd1), &D(rd1), &D(rd1), &D(rd2), &D(rd2) ), + CU_DataPoints (const dds_topic_descriptor_t *, &D(wr1_1), &D(wr1_2), &D(wr1_3), &D(wr1_3), &D(wr1_4), &D(wr1_4), &D(wr2_1), &D(wr2_1) ), + CU_DataPoints (bool, false, true, true, true, true, true, true, true ), + CU_DataPoints (sample_init, 0, I(mu_wr1_2), I(mu_wr1_3a), I(mu_wr1_3b), I(mu_wr1_4a), I(mu_wr1_4b), I(mu_wr2_1a), I(mu_wr2_1b) ), + CU_DataPoints (bool, false, true, true, false, true, true, true, false ) +}; + +CU_Theory ((const dds_topic_descriptor_t *rd_desc, const dds_topic_descriptor_t *wr_desc, bool assignable, sample_init fn_init, bool read_sample), + ddsc_xtypes_assignability, must_understand, .init = xtypes_assignability_init, .fini = xtypes_assignability_fini) +{ + printf ("Running test xtypes_must_understand: %s %s\n", wr_desc->m_typename, rd_desc->m_typename); + do_test (rd_desc, NULL, wr_desc, NULL, assignable, fn_init, read_sample, 0); +} +#undef D +#undef I + +/* Type consistency enforcement policy test cases (ignore seq/str bounds, prevent type widening, allow type coercion) */ +#define D(n) (&XSpaceTypeConsistencyEnforcement_ ## n ## _desc) +#define I(n) sample_init_tce_ ## n +#define C(n) sample_check_tce_ ## n +#define ALLOW DDS_TYPE_CONSISTENCY_ALLOW_TYPE_COERCION +#define DISALW DDS_TYPE_CONSISTENCY_DISALLOW_TYPE_COERCION +#define DT true +#define DF false +#define DDS_TD_T const dds_topic_descriptor_t * +#define DDS_TCE_T dds_type_consistency_kind_t + +CU_TheoryDataPoints (ddsc_xtypes_assignability, type_consistency_enforcement) = { + CU_DataPoints (const char *, + "wr seq bound > rd seq bound, but ignore_seq_bounds", + "wr seq bound > rd seq bound, !ignore_seq_bounds", + "wr seq unbounded > rd seq bound, !ignore_seq_bounds", + "wr seq bound < rd seq unbound, !ignore_seq_bounds", + "disallow coercion, same type", + "disallow coercion, different (assignable) type", + "wr str bound > rd str bound, but ignore_str_bounds", + "wr str bound > rd str bound, !ignore_str_bounds", + "wr str unbounded > rd str bound, !ignore_str_bounds", + "wr str bound < rd str unbound, !ignore_str_bounds", + "member names different, !ignore_member_names", + "member names different, ignore_member_names", + "union member names different, !ignore_member_names", + "union member names different, !ignore_member_names", + "widen type, !prevent_type_widening", + "widen type, prevent_type_widening", + "same members, prevent_type_widening", + "widen with optional member, prevent_type_widening", + "widen mutable type, !prevent_type_widening", + "widen mutable type, prevent_type_widening", + "widen union type, !prevent_type_widening", + "widen union type, prevent_type_widening"), + CU_DataPoints (DDS_TD_T, D(t1_1), D(t1_1), D(t1_1), D(t1_3), D(t1_1), D(t1_1), D(t2_1), D(t2_1), D(t2_1), D(t2_3), D(t3_1), D(t3_1), D(t4_1), D(t4_1), D(t5_1), D(t5_1), D(t5_1), D(t5_1), D(t6_1), D(t6_1), D(t7_1), D(t7_1) ), + CU_DataPoints (DDS_TD_T, D(t1_2), D(t1_2), D(t1_3), D(t1_1), D(t1_1), D(t1_3), D(t2_2), D(t2_2), D(t2_3), D(t2_1), D(t3_2), D(t3_2), D(t4_2), D(t4_2), D(t5_2), D(t5_2), D(t5_3), D(t5_4), D(t6_2), D(t6_2), D(t7_2), D(t7_2) ), + + CU_DataPoints (DDS_TCE_T, ALLOW , ALLOW , ALLOW , ALLOW , DISALW , DISALW , ALLOW , ALLOW , ALLOW , ALLOW , ALLOW , ALLOW , ALLOW , ALLOW , ALLOW , ALLOW , ALLOW , ALLOW , ALLOW , ALLOW , ALLOW , ALLOW ), // allow/disallow type coercion + CU_DataPoints (bool, DF , DF , DF , DF , DF , DF , DF , DF , DF , DF , DF , DF , DF , DF , false , true , true , true , false , true , false , true ), // prevent_type_widening + CU_DataPoints (bool, true , false , false , false , DT , DT , DT , DT , DT , DT , DT , DT , DT , DT , DT , DT , DT , DT , DT , DT , DT , DT ), // ignore_seq_bounds + CU_DataPoints (bool, DT , DT , DT , DT , DT , DT , true , false , false , false , DT , DT , DT , DT , DT , DT , DT , DT , DT , DT , DT , DT ), // ignore_str_bounds + CU_DataPoints (bool, DF , DF , DF , DF , DF , DF , DF , DF , DF , DF , false , true , false , true , DF , DF , DF , DF , DF , DF , DF , DF ), // ignore_member_names + CU_DataPoints (bool, DF , DF , DF , DF , DF , DF , DF , DF , DF , DF , DF , DF , DF , DF , DF , DF , DF , DF , DF , DF , DF , DF ), // force_type_validation + + CU_DataPoints (bool, true , false , false , true , true , false , true , false , false , true , false , true , false , true , true , false , false , true , true , false , true , false ), // expect match +}; + +CU_Theory ((const char *test, const dds_topic_descriptor_t *rd_desc, const dds_topic_descriptor_t *wr_desc, dds_type_consistency_kind_t kind, + bool prevent_type_widening, bool ignore_seq_bounds, bool ignore_str_bounds, bool ignore_member_names, bool force_type_validation, bool assignable), + ddsc_xtypes_assignability, type_consistency_enforcement, .init = xtypes_assignability_init, .fini = xtypes_assignability_fini) +{ + printf ("Running test xtypes_type_consistency_enforcement: %s wr %s rd %s\n", test, wr_desc->m_typename, rd_desc->m_typename); + dds_qos_t *rd_qos = dds_create_qos (); + dds_qset_type_consistency (rd_qos, kind, ignore_seq_bounds, ignore_str_bounds, ignore_member_names, prevent_type_widening, force_type_validation); + do_test (rd_desc, rd_qos, wr_desc, NULL, assignable, 0, false, 0); + dds_delete_qos (rd_qos); +} +#undef D +#undef I +#undef C +#undef ALLOW +#undef DISALLOW +#undef DT +#undef DF +#undef DDS_TD_T +#undef DDS_TCE_T + +/* Type consistency enforcement policy test case for force_type_validation */ +CU_Test (ddsc_xtypes_assignability, type_consistency_enforcement_force_validation, .init = xtypes_assignability_init, .fini = xtypes_assignability_fini) +{ + for (uint32_t n = 0; n <= 1; n++) + { + bool force_type_validation = (n == 1); + printf ("Running test type_consistency_enforcement_force_validation: force_type_validation = %s\n", force_type_validation ? "true" : "false"); + dds_qos_t *rd_qos = dds_create_qos (); + dds_qset_type_consistency (rd_qos, DDS_TYPE_CONSISTENCY_ALLOW_TYPE_COERCION, true, true, false, false, force_type_validation); + do_test (&XSpaceNoTypeInfo_t1_desc, rd_qos, &XSpaceNoTypeInfo_t1_desc, NULL, !force_type_validation, 0, false, 0); + dds_delete_qos (rd_qos); + } +} + + +/* Enum extensibility test cases */ +static void sample_init_en_wr1_1 (void *ptr) +{ + XSpaceEnum_wr1_1 *sample = (XSpaceEnum_wr1_1 *) ptr; + sample->f1 = XSpaceEnum_F1; +} +static void sample_init_en_wr2_1 (void *ptr) +{ + XSpaceEnum_wr2_1 *sample = (XSpaceEnum_wr2_1 *) ptr; + sample->f1 = XSpaceEnum_A1; +} +static void sample_init_en_wr2_3 (void *ptr) +{ + XSpaceEnumPlus_wr2_3 *sample = (XSpaceEnumPlus_wr2_3 *) ptr; + sample->f1 = XSpaceEnumPlus_A1; +} +static void sample_init_en_wr2_4 (void *ptr) +{ + XSpaceEnumMin_wr2_4 *sample = (XSpaceEnumMin_wr2_4 *) ptr; + sample->f1 = XSpaceEnumMin_A1; +} + +#define D(n) XSpaceEnum_ ## n ## _desc +#define DP(n) XSpaceEnumPlus_ ## n ## _desc +#define DM(n) XSpaceEnumMin_ ## n ## _desc +#define DL(n) XSpaceEnumLabel_ ## n ## _desc +#define I(n) sample_init_ ## n +CU_TheoryDataPoints (ddsc_xtypes_assignability, enum_extensibility) = { + CU_DataPoints (const dds_topic_descriptor_t *, &D(rd1), &D(rd1), &D(rd1), &D(rd1), &D(rd1), &D(rd2), &D(rd2), &D(rd2), &D(rd2), &D(rd2) ), + CU_DataPoints (const dds_topic_descriptor_t *, &D(wr1_1), &D(wr1_2), &DP(wr1_3), &DM(wr1_4), &DL(wr1_5), &D(wr2_1), &D(wr2_2), &DP(wr2_3), &DM(wr2_4), &DL(wr2_5) ), + CU_DataPoints (bool, true, false, false, false, false, true, false, true, true, false ), + CU_DataPoints (sample_init, I(en_wr1_1), 0, 0, 0, 0, I(en_wr2_1), 0, I(en_wr2_3), I(en_wr2_4), 0 ), + CU_DataPoints (bool, true, false, false, false, false, true, false, true, true, false ) +}; + +CU_Theory ((const dds_topic_descriptor_t *rd_desc, const dds_topic_descriptor_t *wr_desc, bool assignable, sample_init fn_init, bool read_sample), + ddsc_xtypes_assignability, enum_extensibility, .init = xtypes_assignability_init, .fini = xtypes_assignability_fini) +{ + printf ("Running test xtypes_enum: %s %s\n", wr_desc->m_typename, rd_desc->m_typename); + do_test (rd_desc, NULL, wr_desc, NULL, assignable, fn_init, read_sample, 0); +} + +#undef D +#undef DP +#undef DM +#undef DL +#undef I diff --git a/src/core/ddsc/tests/xtypes_common.c b/src/core/ddsc/tests/xtypes_common.c new file mode 100644 index 0000000000..a26b11421d --- /dev/null +++ b/src/core/ddsc/tests/xtypes_common.c @@ -0,0 +1,177 @@ +// Copyright(c) 2006 to 2022 ZettaScale Technology and others +// +// This program and the accompanying materials are made available under the +// terms of the Eclipse Public License v. 2.0 which is available at +// http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License +// v. 1.0 which is available at +// http://www.eclipse.org/org/documents/edl-v10.php. +// +// SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause + +#include +#include + +#include "dds/dds.h" +#include "dds/version.h" +#include "dds/ddsrt/string.h" +#include "dds/ddsi/ddsi_typelib.h" +#include "dds/ddsi/ddsi_xt_typelookup.h" +#include "dds/ddsi/ddsi_thread.h" +#include "ddsi__xt_impl.h" +#include "ddsi__typelookup.h" +#include "ddsi__proxy_endpoint.h" +#include "ddsi__proxy_participant.h" +#include "ddsi__typewrap.h" +#include "ddsi__addrset.h" +#include "ddsi__vendor.h" +#include "test_common.h" +#include "xtypes_common.h" + +void typeinfo_ser (struct dds_type_meta_ser *ser, DDS_XTypes_TypeInformation *ti) +{ + dds_ostream_t os = { .m_buffer = NULL, .m_index = 0, .m_size = 0, .m_xcdr_version = DDSI_RTPS_CDR_ENC_VERSION_2 }; + xcdr2_ser (ti, &DDS_XTypes_TypeInformation_desc, &os); + ser->data = os.m_buffer; + ser->sz = os.m_index; +} + +void typeinfo_deser (DDS_XTypes_TypeInformation **ti, const struct dds_type_meta_ser *ser) +{ + xcdr2_deser (ser->data, ser->sz, (void **) ti, &DDS_XTypes_TypeInformation_desc); +} + +void typemap_ser (struct dds_type_meta_ser *ser, DDS_XTypes_TypeMapping *tmap) +{ + dds_ostream_t os = { .m_buffer = NULL, .m_index = 0, .m_size = 0, .m_xcdr_version = DDSI_RTPS_CDR_ENC_VERSION_2 }; + xcdr2_ser (tmap, &DDS_XTypes_TypeMapping_desc, &os); + ser->data = os.m_buffer; + ser->sz = os.m_index; +} + +void typemap_deser (DDS_XTypes_TypeMapping **tmap, const struct dds_type_meta_ser *ser) +{ + xcdr2_deser (ser->data, ser->sz, (void **) tmap, &DDS_XTypes_TypeMapping_desc); +} + +void test_proxy_rd_create (struct ddsi_domaingv *gv, const char *topic_name, DDS_XTypes_TypeInformation *ti, dds_return_t exp_ret, const ddsi_guid_t *pp_guid, const ddsi_guid_t *rd_guid) +{ + ddsi_plist_t *plist = ddsrt_calloc (1, sizeof (*plist)); + plist->qos.present |= DDSI_QP_TOPIC_NAME | DDSI_QP_TYPE_NAME | DDSI_QP_TYPE_INFORMATION | DDSI_QP_DATA_REPRESENTATION | DDSI_QP_LIVELINESS; + plist->qos.topic_name = ddsrt_strdup (topic_name); + plist->qos.type_name = ddsrt_strdup ("dummy"); + plist->qos.type_information = ddsi_typeinfo_dup ((struct ddsi_typeinfo *) ti); + plist->qos.data_representation.value.n = 1; + plist->qos.data_representation.value.ids = ddsrt_calloc (1, sizeof (*plist->qos.data_representation.value.ids)); + plist->qos.data_representation.value.ids[0] = DDS_DATA_REPRESENTATION_XCDR2; + plist->qos.liveliness.kind = DDS_LIVELINESS_AUTOMATIC; + plist->qos.liveliness.lease_duration = DDS_INFINITY; + + struct ddsi_thread_state * const thrst = ddsi_lookup_thread_state (); + ddsi_thread_state_awake (thrst, gv); + struct ddsi_addrset *as = ddsi_new_addrset (); + ddsi_add_locator_to_addrset (gv, as, &gv->loc_default_uc); + ddsi_ref_addrset (as); // increase refc to 2, new_proxy_participant does not add a ref + int rc = ddsi_new_proxy_participant (gv, pp_guid, 0, NULL, as, as, plist, DDS_INFINITY, DDSI_VENDORID_ECLIPSE, 0, ddsrt_time_wallclock (), 1); + CU_ASSERT_FATAL (rc); + + ddsi_xqos_mergein_missing (&plist->qos, &ddsi_default_qos_reader, ~(uint64_t)0); +#ifdef DDS_HAS_SSM + rc = ddsi_new_proxy_reader (gv, pp_guid, rd_guid, as, plist, ddsrt_time_wallclock (), 1, 0); +#else + rc = ddsi_new_proxy_reader (gv, pp_guid, rd_guid, as, plist, ddsrt_time_wallclock (), 1); +#endif + CU_ASSERT_EQUAL_FATAL (rc, exp_ret); + ddsi_plist_fini (plist); + ddsrt_free (plist); + ddsi_thread_state_asleep (thrst); +} + +void test_proxy_rd_fini (struct ddsi_domaingv *gv, const ddsi_guid_t *pp_guid, const ddsi_guid_t *rd_guid) +{ + struct ddsi_thread_state * const thrst = ddsi_lookup_thread_state (); + ddsi_thread_state_awake (thrst, gv); + ddsi_delete_proxy_reader (gv, rd_guid, ddsrt_time_wallclock (), false); + ddsi_delete_proxy_participant_by_guid (gv, pp_guid, ddsrt_time_wallclock (), false); + ddsi_thread_state_asleep (thrst); +} + +void xtypes_util_modify_type_meta (dds_topic_descriptor_t *dst_desc, const dds_topic_descriptor_t *src_desc, typeobj_modify mod, bool update_typeinfo, uint32_t kind) +{ + // coverity[store_writes_const_field] + memcpy (dst_desc, src_desc, sizeof (*dst_desc)); + + DDS_XTypes_TypeInformation *ti = NULL; + if (update_typeinfo) + typeinfo_deser (&ti, &dst_desc->type_information); + + DDS_XTypes_TypeMapping *tmap = NULL; + typemap_deser (&tmap, &dst_desc->type_mapping); + + if (update_typeinfo) + { + assert (ti); + // confirm that top-level type is the first in type map + if (kind == DDS_XTypes_EK_MINIMAL || kind == DDS_XTypes_EK_BOTH) + { + assert (!ddsi_typeid_compare_impl (&ti->minimal.typeid_with_size.type_id, &tmap->identifier_object_pair_minimal._buffer[0].type_identifier)); + ddsi_typeid_fini_impl (&ti->minimal.typeid_with_size.type_id); + for (uint32_t n = 0; n < tmap->identifier_object_pair_minimal._length; n++) + ddsi_typeid_fini_impl (&tmap->identifier_object_pair_minimal._buffer[n].type_identifier); + } + if (kind == DDS_XTypes_EK_COMPLETE || kind == DDS_XTypes_EK_BOTH) + { + assert (!ddsi_typeid_compare_impl (&ti->complete.typeid_with_size.type_id, &tmap->identifier_object_pair_complete._buffer[0].type_identifier)); + ddsi_typeid_fini_impl (&ti->complete.typeid_with_size.type_id); + for (uint32_t n = 0; n < tmap->identifier_object_pair_complete._length; n++) + ddsi_typeid_fini_impl (&tmap->identifier_object_pair_complete._buffer[n].type_identifier); + } + } + + // modify the specified object in the type mapping + if (kind == DDS_XTypes_EK_MINIMAL || kind == DDS_XTypes_EK_BOTH) + mod (&tmap->identifier_object_pair_minimal, DDS_XTypes_EK_MINIMAL); + if (kind == DDS_XTypes_EK_COMPLETE || kind == DDS_XTypes_EK_BOTH) + mod (&tmap->identifier_object_pair_complete, DDS_XTypes_EK_COMPLETE); + + if (update_typeinfo) + { + // get hash-id for modified type and store in type map and replace top-level type id + if (kind == DDS_XTypes_EK_MINIMAL || kind == DDS_XTypes_EK_BOTH) + { + for (uint32_t n = 0; n < tmap->identifier_object_pair_minimal._length; n++) + { + ddsi_typeid_t type_id; + ddsi_typeobj_get_hash_id (&tmap->identifier_object_pair_minimal._buffer[n].type_object, &type_id); + ddsi_typeid_copy_impl (&tmap->identifier_object_pair_minimal._buffer[n].type_identifier, &type_id.x); + ddsi_typeid_fini (&type_id); + } + ddsi_typeid_copy_impl (&ti->minimal.typeid_with_size.type_id, &tmap->identifier_object_pair_minimal._buffer[0].type_identifier); + } + if (kind == DDS_XTypes_EK_COMPLETE || kind == DDS_XTypes_EK_BOTH) + { + for (uint32_t n = 0; n < tmap->identifier_object_pair_complete._length; n++) + { + ddsi_typeid_t type_id; + ddsi_typeobj_get_hash_id (&tmap->identifier_object_pair_complete._buffer[n].type_object, &type_id); + ddsi_typeid_copy_impl (&tmap->identifier_object_pair_complete._buffer[n].type_identifier, &type_id.x); + ddsi_typeid_fini (&type_id); + } + ddsi_typeid_copy_impl (&ti->complete.typeid_with_size.type_id, &tmap->identifier_object_pair_complete._buffer[0].type_identifier); + } + } + + // replace the type map and type info in the topic descriptor with updated ones + if (update_typeinfo) + typeinfo_ser (&dst_desc->type_information, ti); + typemap_ser (&dst_desc->type_mapping, tmap); + + // clean up + ddsi_typemap_fini ((ddsi_typemap_t *) tmap); + ddsrt_free (tmap); + + if (update_typeinfo) + { + ddsi_typeinfo_fini ((ddsi_typeinfo_t *) ti); + ddsrt_free (ti); + } +} diff --git a/src/core/ddsc/tests/xtypes_common.h b/src/core/ddsc/tests/xtypes_common.h new file mode 100644 index 0000000000..f6542ceae8 --- /dev/null +++ b/src/core/ddsc/tests/xtypes_common.h @@ -0,0 +1,30 @@ +// Copyright(c) 2022 to 2023 ZettaScale Technology and others +// +// This program and the accompanying materials are made available under the +// terms of the Eclipse Public License v. 2.0 which is available at +// http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License +// v. 1.0 which is available at +// http://www.eclipse.org/org/documents/edl-v10.php. +// +// SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause + +#ifndef TEST_XTYPES_COMMON_H +#define TEST_XTYPES_COMMON_H + +#include +#include +#include "dds/dds.h" +#include "dds/version.h" +#include "ddsi__xt_impl.h" + +typedef void (*typeobj_modify) (dds_sequence_DDS_XTypes_TypeIdentifierTypeObjectPair *type_id_obj_seq, uint32_t kind); + +void typeinfo_ser (struct dds_type_meta_ser *ser, DDS_XTypes_TypeInformation *ti); +void typeinfo_deser (DDS_XTypes_TypeInformation **ti, const struct dds_type_meta_ser *ser); +void typemap_ser (struct dds_type_meta_ser *ser, DDS_XTypes_TypeMapping *tmap); +void typemap_deser (DDS_XTypes_TypeMapping **tmap, const struct dds_type_meta_ser *ser); +void test_proxy_rd_create (struct ddsi_domaingv *gv, const char *topic_name, DDS_XTypes_TypeInformation *ti, dds_return_t exp_ret, const ddsi_guid_t *pp_guid, const ddsi_guid_t *rd_guid); +void test_proxy_rd_fini (struct ddsi_domaingv *gv, const ddsi_guid_t *pp_guid, const ddsi_guid_t *rd_guid); +void xtypes_util_modify_type_meta (dds_topic_descriptor_t *dst_desc, const dds_topic_descriptor_t *src_desc, typeobj_modify mod, bool update_typeinfo, uint32_t kind); + +#endif /* TEST_XTYPES_COMMON_H */ diff --git a/src/core/ddsc/tests/xtypes_typeinfo.c b/src/core/ddsc/tests/xtypes_typeinfo.c new file mode 100644 index 0000000000..e72021e486 --- /dev/null +++ b/src/core/ddsc/tests/xtypes_typeinfo.c @@ -0,0 +1,372 @@ +// Copyright(c) 2006 to 2022 ZettaScale Technology and others +// +// This program and the accompanying materials are made available under the +// terms of the Eclipse Public License v. 2.0 which is available at +// http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License +// v. 1.0 which is available at +// http://www.eclipse.org/org/documents/edl-v10.php. +// +// SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause + +#include +#include + +#include "dds/ddsrt/cdtors.h" +#include "dds/ddsrt/misc.h" +#include "dds/ddsrt/process.h" +#include "dds/ddsrt/threads.h" +#include "dds/ddsrt/environ.h" +#include "dds/ddsrt/atomics.h" +#include "dds/ddsrt/time.h" +#include "dds/ddsrt/heap.h" +#include "dds/ddsrt/string.h" +#include "dds/ddsi/ddsi_entity.h" +#include "dds/ddsi/ddsi_entity_index.h" +#include "dds/ddsi/ddsi_typelib.h" +#include "dds/ddsi/ddsi_xt_typelookup.h" +#include "ddsi__xt_impl.h" +#include "ddsi__addrset.h" +#include "ddsi__endpoint_match.h" +#include "ddsi__proxy_endpoint.h" +#include "ddsi__proxy_participant.h" +#include "ddsi__typelookup.h" +#include "ddsi__typewrap.h" +#include "ddsi__vendor.h" +#include "dds/cdr/dds_cdrstream.h" +#include "dds/dds.h" +#include "dds/version.h" +#include "dds__entity.h" +#include "config_env.h" +#include "test_common.h" +#include "xtypes_common.h" + +#include "XSpace.h" +#include "XSpaceEnum.h" +#include "XSpaceMustUnderstand.h" +#include "XSpaceTypeConsistencyEnforcement.h" +#include "XSpaceNoTypeInfo.h" + +#define DDS_DOMAINID_PUB 0 +#define DDS_DOMAINID_SUB 1 +#define DDS_CONFIG "${CYCLONEDDS_URI}${CYCLONEDDS_URI:+,}0" + +static dds_entity_t g_domain1 = 0; +static dds_entity_t g_participant1 = 0; +static dds_entity_t g_publisher1 = 0; + +static dds_entity_t g_domain2 = 0; +static dds_entity_t g_participant2 = 0; +static dds_entity_t g_subscriber2 = 0; + +typedef void (*sample_init) (void *s); +typedef void (*sample_check) (void *s1, void *s2); + +static void xtypes_typeinfo_init (void) +{ + /* Domains for pub and sub use a different internal domain id, but the external + * domain id in configuration is 0, so that both domains will map to the same port number. + * This allows to create two domains in a single test process. */ + char *conf1 = ddsrt_expand_envvars (DDS_CONFIG, DDS_DOMAINID_PUB); + char *conf2 = ddsrt_expand_envvars (DDS_CONFIG, DDS_DOMAINID_SUB); + g_domain1 = dds_create_domain (DDS_DOMAINID_PUB, conf1); + g_domain2 = dds_create_domain (DDS_DOMAINID_SUB, conf2); + dds_free (conf1); + dds_free (conf2); + + g_participant1 = dds_create_participant (DDS_DOMAINID_PUB, NULL, NULL); + CU_ASSERT_FATAL (g_participant1 > 0); + g_participant2 = dds_create_participant (DDS_DOMAINID_SUB, NULL, NULL); + CU_ASSERT_FATAL (g_participant2 > 0); + + g_publisher1 = dds_create_publisher (g_participant1, NULL, NULL); + CU_ASSERT_FATAL (g_publisher1 > 0); + g_subscriber2 = dds_create_subscriber (g_participant2, NULL, NULL); + CU_ASSERT_FATAL (g_subscriber2 > 0); +} + +static void xtypes_typeinfo_fini (void) +{ + dds_delete (g_domain2); + dds_delete (g_domain1); +} + +/* Invalid hashed type (with valid hash type id) as top-level type */ +CU_Test (ddsc_xtypes_typeinfo, invalid_top_level_local_hash, .init = xtypes_typeinfo_init, .fini = xtypes_typeinfo_fini) +{ + char topic_name[100]; + dds_topic_descriptor_t desc; + DDS_XTypes_TypeInformation *ti; + + for (uint32_t n = 0; n < 6; n++) + { + // coverity[store_writes_const_field] + memcpy (&desc, &XSpace_to_toplevel_desc, sizeof (desc)); + typeinfo_deser (&ti, &desc.type_information); + if (n % 2) + { + ddsi_typeid_fini_impl (&ti->minimal.typeid_with_size.type_id); + ddsi_typeid_copy_impl (&ti->minimal.typeid_with_size.type_id, &ti->minimal.dependent_typeids._buffer[n / 2].type_id); + } + else + { + ddsi_typeid_fini_impl (&ti->complete.typeid_with_size.type_id); + ddsi_typeid_copy_impl (&ti->complete.typeid_with_size.type_id, &ti->complete.dependent_typeids._buffer[n / 2].type_id); + } + typeinfo_ser (&desc.type_information, ti); + + create_unique_topic_name ("ddsc_xtypes_typeinfo", topic_name, sizeof (topic_name)); + dds_entity_t topic = dds_create_topic (g_participant1, &desc, topic_name, NULL, NULL); + CU_ASSERT_FATAL (topic < 0); + + ddsi_typeinfo_fini ((ddsi_typeinfo_t *) ti); + ddsrt_free (ti); + ddsrt_free ((void *) desc.type_information.data); + } +} + +/* Non-hashed type (with valid hash type id) as top-level type */ +CU_Test (ddsc_xtypes_typeinfo, invalid_top_level_local_non_hash, .init = xtypes_typeinfo_init, .fini = xtypes_typeinfo_fini) +{ + char topic_name[100]; + + dds_topic_descriptor_t desc; + // coverity[store_writes_const_field] + memcpy (&desc, &XSpace_to_toplevel_desc, sizeof (desc)); + + DDS_XTypes_TypeInformation *ti; + typeinfo_deser (&ti, &desc.type_information); + + ddsi_typeid_fini_impl (&ti->minimal.typeid_with_size.type_id); + ti->minimal.typeid_with_size.type_id._d = DDS_XTypes_TK_UINT32; + typeinfo_ser (&desc.type_information, ti); + + create_unique_topic_name ("ddsc_xtypes_typeinfo", topic_name, sizeof (topic_name)); + dds_entity_t topic = dds_create_topic (g_participant1, &desc, topic_name, NULL, NULL); + CU_ASSERT_FATAL (topic < 0); + + ddsi_typeinfo_fini ((ddsi_typeinfo_t *) ti); + ddsrt_free (ti); + ddsrt_free ((void *) desc.type_information.data); +} + +static void mod_toplevel (dds_sequence_DDS_XTypes_TypeIdentifierTypeObjectPair *type_id_obj_seq, uint32_t kind) +{ + assert (kind == DDS_XTypes_EK_MINIMAL); + (void) kind; + assert (type_id_obj_seq->_buffer[0].type_object._u.minimal._d == DDS_XTypes_TK_STRUCTURE); + type_id_obj_seq->_buffer[0].type_object._u.minimal._u.struct_type.member_seq._buffer[0].common.member_flags = 0x7f; +} + +static void mod_inherit (dds_sequence_DDS_XTypes_TypeIdentifierTypeObjectPair *type_id_obj_seq, uint32_t kind) +{ + assert (kind == DDS_XTypes_EK_MINIMAL); + (void) kind; + assert (type_id_obj_seq->_buffer[0].type_object._u.minimal._d == DDS_XTypes_TK_STRUCTURE); + ddsi_typeid_fini_impl (&type_id_obj_seq->_buffer[0].type_object._u.minimal._u.struct_type.header.base_type); + ddsi_typeid_copy_impl (&type_id_obj_seq->_buffer[0].type_object._u.minimal._u.struct_type.header.base_type, + &type_id_obj_seq->_buffer[0].type_object._u.minimal._u.struct_type.member_seq._buffer[0].common.member_type_id); +} + +static void mod_uniondisc (dds_sequence_DDS_XTypes_TypeIdentifierTypeObjectPair *type_id_obj_seq, uint32_t kind) +{ + assert (kind == DDS_XTypes_EK_MINIMAL); + (void) kind; + assert (type_id_obj_seq->_buffer[0].type_object._u.minimal._d == DDS_XTypes_TK_UNION); + type_id_obj_seq->_buffer[0].type_object._u.minimal._u.union_type.discriminator.common.type_id._d = DDS_XTypes_TK_FLOAT32; +} + +static void mod_unionmembers (dds_sequence_DDS_XTypes_TypeIdentifierTypeObjectPair *type_id_obj_seq, uint32_t kind) +{ + assert (kind == DDS_XTypes_EK_MINIMAL); + (void) kind; + assert (type_id_obj_seq->_buffer[0].type_object._u.minimal._d == DDS_XTypes_TK_UNION); + assert (type_id_obj_seq->_buffer[0].type_object._u.minimal._u.union_type.member_seq._length == 2); + type_id_obj_seq->_buffer[0].type_object._u.minimal._u.union_type.member_seq._buffer[0].common.member_flags |= DDS_XTypes_IS_DEFAULT; +} + +static void mod_arraybound (dds_sequence_DDS_XTypes_TypeIdentifierTypeObjectPair *type_id_obj_seq, uint32_t kind) +{ + assert (kind == DDS_XTypes_EK_MINIMAL); + (void) kind; + assert (type_id_obj_seq->_buffer[0].type_object._u.minimal._d == DDS_XTypes_TK_STRUCTURE); + assert (type_id_obj_seq->_buffer[0].type_object._u.minimal._u.struct_type.member_seq._buffer[0].common.member_type_id._d == DDS_XTypes_TI_PLAIN_ARRAY_SMALL); + type_id_obj_seq->_buffer[0].type_object._u.minimal._u.struct_type.member_seq._buffer[0].common.member_type_id._u.array_sdefn.array_bound_seq._buffer[0] = 5; +} + + +#define D(n) XSpace_ ## n ## _desc +CU_TheoryDataPoints (ddsc_xtypes_typeinfo, invalid_type_object_local) = { + CU_DataPoints (const char *, "invalid flag, non-matching typeid", + /* | */"invalid flag, matching typeid", + /* | | */"invalid inheritance", + /* | | | */"invalid union discr", + /* | | | | */"union multiple default", + /* | | | | | */"array bound overflow"), + CU_DataPoints (const dds_topic_descriptor_t *, &D(to_toplevel), &D(to_toplevel), &D(to_inherit), &D(to_uniondisc), &D(to_unionmembers), &D(to_arraybound) ), + CU_DataPoints (typeobj_modify, mod_toplevel, mod_toplevel, mod_inherit, mod_uniondisc, mod_unionmembers, mod_arraybound ), + CU_DataPoints (bool, false, true, true, true, true, true ), +}; +#undef D + +CU_Theory ((const char *test_descr, const dds_topic_descriptor_t *topic_desc, typeobj_modify mod, bool matching_typeinfo), ddsc_xtypes_typeinfo, invalid_type_object_local, .init = xtypes_typeinfo_init, .fini = xtypes_typeinfo_fini) +{ + char topic_name[100]; + printf("Test invalid_type_object_local: %s\n", test_descr); + + dds_topic_descriptor_t desc; + xtypes_util_modify_type_meta (&desc, topic_desc, mod, matching_typeinfo, DDS_XTypes_EK_MINIMAL); + + // test that topic creation fails + create_unique_topic_name ("ddsc_xtypes_typeinfo", topic_name, sizeof (topic_name)); + dds_entity_t topic = dds_create_topic (g_participant1, &desc, topic_name, NULL, NULL); + CU_ASSERT_FATAL (topic < 0); + + if (matching_typeinfo) + ddsrt_free ((void *) desc.type_information.data); + ddsrt_free ((void *) desc.type_mapping.data); +} + +/* Invalid hashed type (with valid hash type id) as top-level type for proxy endpoint */ +CU_Test (ddsc_xtypes_typeinfo, invalid_top_level_remote_hash, .init = xtypes_typeinfo_init, .fini = xtypes_typeinfo_fini) +{ + dds_topic_descriptor_t desc; + DDS_XTypes_TypeInformation *ti; + struct ddsi_domaingv *gv = get_domaingv (g_participant1); + char topic_name[100]; + create_unique_topic_name ("ddsc_xtypes_typeinfo", topic_name, sizeof (topic_name)); + + // create local topic so that types are in type lib and resolved + dds_entity_t topic = dds_create_topic (g_participant1, &XSpace_to_toplevel_desc, topic_name, NULL, NULL); + CU_ASSERT_FATAL (topic > 0); + + // create type id with invalid top-level + // coverity[store_writes_const_field] + memcpy (&desc, &XSpace_to_toplevel_desc, sizeof (desc)); + typeinfo_deser (&ti, &desc.type_information); + ddsi_typeid_fini_impl (&ti->minimal.typeid_with_size.type_id); + ddsi_typeid_copy_impl (&ti->minimal.typeid_with_size.type_id, &ti->minimal.dependent_typeids._buffer[0].type_id); + + // create proxy reader with modified type + struct ddsi_guid pp_guid, rd_guid; + gen_test_guid (gv, &pp_guid, DDSI_ENTITYID_PARTICIPANT); + gen_test_guid (gv, &rd_guid, DDSI_ENTITYID_KIND_READER_NO_KEY); + test_proxy_rd_create (gv, topic_name, ti, DDS_RETCODE_BAD_PARAMETER, &pp_guid, &rd_guid); + + // clean up + test_proxy_rd_fini (gv, &pp_guid, &rd_guid); + ddsi_typeinfo_fini ((ddsi_typeinfo_t *) ti); + ddsrt_free (ti); +} + +/* Invalid type object for proxy endpoint */ +#define D(n) XSpace_ ## n ## _desc +CU_TheoryDataPoints (ddsc_typelookup, invalid_type_object_remote) = { + CU_DataPoints (const char *, + /* */"invalid flag", + /* | */"invalid inheritance", + /* | | */"invalid union discr"), + CU_DataPoints (const dds_topic_descriptor_t *, &D(to_toplevel), &D(to_inherit), &D(to_uniondisc) ), + CU_DataPoints (typeobj_modify, mod_toplevel, mod_inherit, mod_uniondisc ) +}; +#undef D + +#ifdef DDS_HAS_TYPE_DISCOVERY +static void test_proxy_rd_matches (dds_entity_t wr, bool exp_match) +{ + struct dds_entity *x; + dds_return_t rc = dds_entity_pin (wr, &x); + CU_ASSERT_EQUAL_FATAL (rc, DDS_RETCODE_OK); + struct dds_writer *dds_wr = (struct dds_writer *) x; + CU_ASSERT_EQUAL_FATAL (dds_wr->m_wr->num_readers, exp_match ? 1 : 0); + dds_entity_unpin (x); +} +#endif + +CU_Theory ((const char *test_descr, const dds_topic_descriptor_t *topic_desc, typeobj_modify mod), ddsc_typelookup, invalid_type_object_remote, .init = xtypes_typeinfo_init, .fini = xtypes_typeinfo_fini) +{ +#ifdef DDS_HAS_TYPE_DISCOVERY + struct ddsi_domaingv *gv = get_domaingv (g_participant1); + printf("Test invalid_type_object_remote: %s\n", test_descr); + + char topic_name[100]; + create_unique_topic_name ("ddsc_typelookup", topic_name, sizeof (topic_name)); + + // local writer + dds_entity_t topic = dds_create_topic (g_participant1, topic_desc, topic_name, NULL, NULL); + CU_ASSERT_FATAL (topic > 0); + dds_entity_t wr = dds_create_writer (g_participant1, topic, NULL, NULL); + CU_ASSERT_FATAL (wr > 0); + + dds_topic_descriptor_t desc; + xtypes_util_modify_type_meta (&desc, topic_desc, mod, true, DDS_XTypes_EK_MINIMAL); + + DDS_XTypes_TypeInformation *ti; + typeinfo_deser (&ti, &desc.type_information); + struct ddsi_guid pp_guid, rd_guid; + gen_test_guid (gv, &pp_guid, DDSI_ENTITYID_PARTICIPANT); + gen_test_guid (gv, &rd_guid, DDSI_ENTITYID_KIND_READER_NO_KEY); + test_proxy_rd_create (gv, topic_name, ti, DDS_RETCODE_OK, &pp_guid, &rd_guid); + test_proxy_rd_matches (wr, false); + + struct ddsi_generic_proxy_endpoint **gpe_match_upd = NULL; + uint32_t n_match_upd = 0; + + DDS_XTypes_TypeMapping *tmap; + typemap_deser (&tmap, &desc.type_mapping); + DDS_Builtin_TypeLookup_Reply reply = { + .header = { .remoteEx = DDS_RPC_REMOTE_EX_OK, .relatedRequestId = { .sequence_number = { .low = 1, .high = 0 }, .writer_guid = { .guidPrefix = { 0 }, .entityId = { .entityKind = DDSI_EK_WRITER, .entityKey = { 0 } } } } }, + .return_data = { ._d = DDS_Builtin_TypeLookup_getTypes_HashId, ._u = { .getType = { ._d = DDS_RETCODE_OK, ._u = { .result = + { .types = { ._length = tmap->identifier_object_pair_minimal._length, ._maximum = tmap->identifier_object_pair_minimal._maximum, ._release = false, ._buffer = tmap->identifier_object_pair_minimal._buffer } } } } } } + }; + ddsi_tl_add_types (gv, &reply, &gpe_match_upd, &n_match_upd); + + // expect no match because of invalid types + CU_ASSERT_EQUAL_FATAL (n_match_upd, 0); + ddsrt_free (gpe_match_upd); + + struct ddsi_type *type = ddsi_type_lookup (gv, (ddsi_typeid_t *) &tmap->identifier_object_pair_minimal._buffer[0].type_identifier); + CU_ASSERT_PTR_NOT_NULL_FATAL (type); + CU_ASSERT_EQUAL_FATAL (type->state, DDSI_TYPE_INVALID); + + // clean up + test_proxy_rd_fini (gv, &pp_guid, &rd_guid); + ddsi_typeinfo_fini ((ddsi_typeinfo_t *) ti); + ddsrt_free (ti); + ddsi_typemap_fini ((ddsi_typemap_t *) tmap); + ddsrt_free (tmap); + ddsrt_free ((void *) desc.type_information.data); + ddsrt_free ((void *) desc.type_mapping.data); +#else + (void) test_descr; + (void) topic_desc; + (void) mod; +#endif /* DDS_HAS_TYPE_DISCOVERY */ +} + +CU_Test (ddsc_xtypes_typeinfo, get_type_info, .init = xtypes_typeinfo_init, .fini = xtypes_typeinfo_fini) +{ + char topic_name[100]; + create_unique_topic_name ("ddsc_xtypes_typeinfo", topic_name, sizeof (topic_name)); + + dds_entity_t topic = dds_create_topic (g_participant1, &XSpace_XType1_desc, topic_name, NULL, NULL); + CU_ASSERT_FATAL (topic > 0); + dds_entity_t wr = dds_create_writer (g_participant1, topic, NULL, NULL); + CU_ASSERT_FATAL (wr > 0); + dds_entity_t rd = dds_create_reader (g_participant1, topic, NULL, NULL); + CU_ASSERT_FATAL (rd > 0); + + dds_typeinfo_t *type_info_tp, *type_info_wr, *type_info_rd; + dds_return_t ret; + ret = dds_get_typeinfo (topic, &type_info_tp); + CU_ASSERT_EQUAL_FATAL (ret, DDS_RETCODE_OK); + ret = dds_get_typeinfo (wr, &type_info_wr); + CU_ASSERT_EQUAL_FATAL (ret, DDS_RETCODE_OK); + ret = dds_get_typeinfo (rd, &type_info_rd); + CU_ASSERT_EQUAL_FATAL (ret, DDS_RETCODE_OK); + CU_ASSERT_FATAL (ddsi_typeinfo_equal (type_info_tp, type_info_wr, DDSI_TYPE_INCLUDE_DEPS)); + CU_ASSERT_FATAL (ddsi_typeinfo_equal (type_info_tp, type_info_rd, DDSI_TYPE_INCLUDE_DEPS)); + + dds_free_typeinfo (type_info_tp); + dds_free_typeinfo (type_info_wr); + dds_free_typeinfo (type_info_rd); +} diff --git a/src/core/ddsc/tests/typelookup.c b/src/core/ddsc/tests/xtypes_typelookup.c similarity index 72% rename from src/core/ddsc/tests/typelookup.c rename to src/core/ddsc/tests/xtypes_typelookup.c index 619386aaca..69b14673e2 100644 --- a/src/core/ddsc/tests/typelookup.c +++ b/src/core/ddsc/tests/xtypes_typelookup.c @@ -23,12 +23,16 @@ #include "dds/ddsi/ddsi_entity.h" #include "dds/ddsi/ddsi_entity_index.h" #include "ddsi__typelib.h" +#include "ddsi__typewrap.h" +#include "ddsi__typelookup.h" +#include "ddsi__endpoint_match.h" #include "dds/dds.h" #include "dds/version.h" #include "dds__domain.h" #include "dds__entity.h" #include "test_common.h" +#include "xtypes_common.h" #include "config_env.h" #include "XSpace.h" @@ -399,3 +403,115 @@ CU_Test(ddsc_typelookup, api_resolve_invalid, .init = typelookup_init, .fini = t dds_free (type_id); dds_free (type_name); } + +static void test_proxy_rd_matches (dds_entity_t wr, bool exp_match) +{ + struct dds_entity *x; + dds_return_t rc = dds_entity_pin (wr, &x); + CU_ASSERT_EQUAL_FATAL (rc, DDS_RETCODE_OK); + struct dds_writer *dds_wr = (struct dds_writer *) x; + CU_ASSERT_EQUAL_FATAL (dds_wr->m_wr->num_readers, exp_match ? 1 : 0); + dds_entity_unpin (x); +} + +static void mod_dep_test (dds_sequence_DDS_XTypes_TypeIdentifierTypeObjectPair *type_id_obj_seq, uint32_t kind) +{ + // Remove member n2 from dep_test_nested + if (kind == DDS_XTypes_EK_MINIMAL) + { + assert (type_id_obj_seq->_buffer[1].type_object._u.minimal._d == DDS_XTypes_TK_STRUCTURE); + assert (type_id_obj_seq->_buffer[1].type_object._u.minimal._u.struct_type.member_seq._length == 2); + type_id_obj_seq->_buffer[1].type_object._u.minimal._u.struct_type.member_seq._length = 1; + } + else + { + assert (type_id_obj_seq->_buffer[1].type_object._u.complete._d == DDS_XTypes_TK_STRUCTURE); + assert (type_id_obj_seq->_buffer[1].type_object._u.complete._u.struct_type.member_seq._length == 2); + type_id_obj_seq->_buffer[1].type_object._u.complete._u.struct_type.member_seq._length = 1; + } + + // Recalculate type ids for dep_test_nested and replace dep_test.f1 member type id + ddsi_typeid_t type_id; + if (kind == DDS_XTypes_EK_MINIMAL) + { + assert (type_id_obj_seq->_buffer[0].type_object._u.minimal._d == DDS_XTypes_TK_STRUCTURE); + ddsi_typeid_fini_impl (&type_id_obj_seq->_buffer[0].type_object._u.minimal._u.struct_type.member_seq._buffer[0].common.member_type_id); + ddsi_typeobj_get_hash_id (&type_id_obj_seq->_buffer[1].type_object, &type_id); + ddsi_typeid_copy_impl (&type_id_obj_seq->_buffer[0].type_object._u.minimal._u.struct_type.member_seq._buffer[0].common.member_type_id, &type_id.x); + } + else + { + assert (type_id_obj_seq->_buffer[0].type_object._u.complete._d == DDS_XTypes_TK_STRUCTURE); + ddsi_typeid_fini_impl (&type_id_obj_seq->_buffer[0].type_object._u.complete._u.struct_type.member_seq._buffer[0].common.member_type_id); + ddsi_typeobj_get_hash_id (&type_id_obj_seq->_buffer[1].type_object, &type_id); + ddsi_typeid_copy_impl (&type_id_obj_seq->_buffer[0].type_object._u.complete._u.struct_type.member_seq._buffer[0].common.member_type_id, &type_id.x); + } +} + +CU_Test (ddsc_typelookup, resolve_dep_type, .init = typelookup_init, .fini = typelookup_fini) +{ + struct ddsi_domaingv *gv = get_domaingv (g_participant1); + char topic_name[100]; + create_unique_topic_name ("ddsc_typelookup", topic_name, sizeof (topic_name)); + + // local writer + dds_entity_t topic = dds_create_topic (g_participant1, &XSpace_dep_test_desc, topic_name, NULL, NULL); + CU_ASSERT_FATAL (topic > 0); + dds_entity_t wr = dds_create_writer (g_participant1, topic, NULL, NULL); + CU_ASSERT_FATAL (wr > 0); + + dds_topic_descriptor_t desc; + xtypes_util_modify_type_meta (&desc, &XSpace_dep_test_desc, mod_dep_test, true, DDS_XTypes_EK_BOTH); + + DDS_XTypes_TypeInformation *ti; + typeinfo_deser (&ti, &desc.type_information); + struct ddsi_guid pp_guid, rd_guid; + gen_test_guid (gv, &pp_guid, DDSI_ENTITYID_PARTICIPANT); + gen_test_guid (gv, &rd_guid, DDSI_ENTITYID_KIND_READER_NO_KEY); + test_proxy_rd_create (gv, topic_name, ti, DDS_RETCODE_OK, &pp_guid, &rd_guid); + test_proxy_rd_matches (wr, false); + + struct ddsi_generic_proxy_endpoint **gpe_match_upd = NULL; + uint32_t n_match_upd = 0; + DDS_Builtin_TypeLookup_Reply reply; + DDS_XTypes_TypeMapping *tmap; + typemap_deser (&tmap, &desc.type_mapping); + + // add proxy reader's top-level type + reply = (DDS_Builtin_TypeLookup_Reply) { + .header = { .remoteEx = DDS_RPC_REMOTE_EX_OK, .relatedRequestId = { .sequence_number = { .low = 1, .high = 0 }, .writer_guid = { .guidPrefix = { 0 }, .entityId = { .entityKind = DDSI_EK_WRITER, .entityKey = { 0 } } } } }, + .return_data = { ._d = DDS_Builtin_TypeLookup_getTypes_HashId, ._u = { .getType = { ._d = DDS_RETCODE_OK, ._u = { .result = + { .types = { ._length = 1, ._maximum = 1, ._release = false, ._buffer = &tmap->identifier_object_pair_minimal._buffer[0] } } } } } } + }; + ddsi_tl_add_types (gv, &reply, &gpe_match_upd, &n_match_upd); + // FIXME expect matching triggered (but matching would fail because deps are unresolved), this needs to be fixed in ddsi_tl_handle_reply + CU_ASSERT_EQUAL_FATAL (n_match_upd, 1); + ddsrt_free (gpe_match_upd); + + // add nested type and expect match + gpe_match_upd = NULL; + n_match_upd = 0; + reply = (DDS_Builtin_TypeLookup_Reply) { + .header = { .remoteEx = DDS_RPC_REMOTE_EX_OK, .relatedRequestId = { .sequence_number = { .low = 1, .high = 0 }, .writer_guid = { .guidPrefix = { 0 }, .entityId = { .entityKind = DDSI_EK_WRITER, .entityKey = { 0 } } } } }, + .return_data = { ._d = DDS_Builtin_TypeLookup_getTypes_HashId, ._u = { .getType = { ._d = DDS_RETCODE_OK, ._u = { .result = + { .types = { ._length = 1, ._maximum = 1, ._release = false, ._buffer = &tmap->identifier_object_pair_minimal._buffer[1] } } } } } } + }; + ddsi_tl_add_types (gv, &reply, &gpe_match_upd, &n_match_upd); + CU_ASSERT_EQUAL_FATAL (n_match_upd, 1); + + assert (gpe_match_upd); + for (uint32_t e = 0; e < n_match_upd; e++) + ddsi_update_proxy_endpoint_matching (gv, gpe_match_upd[e]); + ddsrt_free (gpe_match_upd); + + test_proxy_rd_matches (wr, true); + + // clean up + test_proxy_rd_fini (gv, &pp_guid, &rd_guid); + ddsi_typeinfo_fini ((ddsi_typeinfo_t *) ti); + ddsrt_free (ti); + ddsi_typemap_fini ((ddsi_typemap_t *) tmap); + ddsrt_free (tmap); + ddsrt_free ((void *) desc.type_information.data); + ddsrt_free ((void *) desc.type_mapping.data); +} diff --git a/src/core/ddsi/CMakeLists.txt b/src/core/ddsi/CMakeLists.txt index ffa7bf3596..343f06d13e 100644 --- a/src/core/ddsi/CMakeLists.txt +++ b/src/core/ddsi/CMakeLists.txt @@ -50,7 +50,6 @@ set(srcs_ddsi ddsi_acknack.c ddsi_list_genptr.c ddsi_wraddrset.c - ddsi_typelib.c ddsi_entity.c ddsi_endpoint_match.c ddsi_participant.c @@ -111,7 +110,6 @@ set(hdrs_ddsi ddsi_xqos.h ddsi_ownip.h ddsi_config.h - ddsi_typelib.h ddsi_entity.h ddsi_endpoint_match.h ddsi_participant.h @@ -182,7 +180,6 @@ set(hdrs_private_ddsi ddsi__time.h ddsi__topic.h ddsi__tran.h - ddsi__typelib.h ddsi__udp.h ddsi__vendor.h ddsi__vnet.h @@ -229,6 +226,17 @@ if(ENABLE_DEADLINE_MISSED) ddsi_deadline.h ) endif() +if(ENABLE_TYPELIB) + list(APPEND srcs_ddsi + ddsi_typelib.c + ) + list(APPEND hdrs_ddsi + ddsi_typelib.h + ) + list(APPEND hdrs_private_ddsi + ddsi__typelib.h + ) +endif() if(ENABLE_TOPIC_DISCOVERY) list(APPEND srcs_ddsi ddsi_discovery_topic.c @@ -237,19 +245,16 @@ if(ENABLE_TOPIC_DISCOVERY) ddsi__discovery_topic.h ) endif() -if(ENABLE_TYPE_DISCOVERY) +if(ENABLE_TYPELIB) list(APPEND srcs_ddsi ddsi_xt_typeinfo.c - ddsi_xt_typelookup.c ddsi_xt_typemap.c - ddsi_typelookup.c ddsi_typewrap.c ddsi_typebuilder.c ddsi_dynamic_type.c ) list(APPEND hdrs_ddsi ddsi_xt_typeinfo.h - ddsi_xt_typelookup.h ddsi_xt_typemap.h ddsi_typewrap.h ddsi_typebuilder.h @@ -257,10 +262,21 @@ if(ENABLE_TYPE_DISCOVERY) ) list(APPEND hdrs_private_ddsi ddsi__xt_impl.h - ddsi__typelookup.h ddsi__dynamic_type.h ) endif() +if(ENABLE_TYPE_DISCOVERY) + list(APPEND srcs_ddsi + ddsi_xt_typelookup.c + ddsi_typelookup.c + ) + list(APPEND hdrs_ddsi + ddsi_xt_typelookup.h + ) + list(APPEND hdrs_private_ddsi + ddsi__typelookup.h + ) +endif() if(ENABLE_SECURITY) list(APPEND srcs_ddsi ddsi_security_msg.c diff --git a/src/core/ddsi/include/dds/ddsi/ddsi_domaingv.h b/src/core/ddsi/include/dds/ddsi/ddsi_domaingv.h index f51d2cad8f..6aaedfb9f1 100644 --- a/src/core/ddsi/include/dds/ddsi/ddsi_domaingv.h +++ b/src/core/ddsi/include/dds/ddsi/ddsi_domaingv.h @@ -315,7 +315,7 @@ struct ddsi_domaingv { ddsrt_mutex_t sertypes_lock; struct ddsrt_hh *sertypes; -#ifdef DDS_HAS_TYPE_DISCOVERY +#ifdef DDS_HAS_TYPELIB ddsrt_mutex_t typelib_lock; ddsrt_avl_tree_t typelib; ddsrt_avl_tree_t typedeps; diff --git a/src/core/ddsi/include/dds/ddsi/ddsi_endpoint.h b/src/core/ddsi/include/dds/ddsi/ddsi_endpoint.h index 2b7bfa1464..c40d7548ab 100644 --- a/src/core/ddsi/include/dds/ddsi/ddsi_endpoint.h +++ b/src/core/ddsi/include/dds/ddsi/ddsi_endpoint.h @@ -45,7 +45,7 @@ enum ddsi_liveliness_changed_data_extra { struct ddsi_endpoint_common { struct ddsi_participant *pp; ddsi_guid_t group_guid; -#ifdef DDS_HAS_TYPE_DISCOVERY +#ifdef DDS_HAS_TYPELIB struct ddsi_type_pair *type_pair; #endif }; diff --git a/src/core/ddsi/include/dds/ddsi/ddsi_entity.h b/src/core/ddsi/include/dds/ddsi/ddsi_entity.h index d40414cabf..3dc70412e0 100644 --- a/src/core/ddsi/include/dds/ddsi/ddsi_entity.h +++ b/src/core/ddsi/include/dds/ddsi/ddsi_entity.h @@ -50,7 +50,7 @@ typedef struct ddsi_status_cb_data typedef void (*ddsi_status_cb_t) (void *entity, const ddsi_status_cb_data_t *data); typedef struct ddsi_type_pair -#ifdef DDS_HAS_TYPE_DISCOVERY +#ifdef DDS_HAS_TYPELIB { struct ddsi_type *minimal; struct ddsi_type *complete; diff --git a/src/core/ddsi/include/dds/ddsi/ddsi_proxy_endpoint.h b/src/core/ddsi/include/dds/ddsi/ddsi_proxy_endpoint.h index 2deb2c0844..b85c1ceb71 100644 --- a/src/core/ddsi/include/dds/ddsi/ddsi_proxy_endpoint.h +++ b/src/core/ddsi/include/dds/ddsi/ddsi_proxy_endpoint.h @@ -40,7 +40,7 @@ struct ddsi_proxy_endpoint_common ddsi_guid_t group_guid; /* 0:0:0:0 if not available */ ddsi_vendorid_t vendor; /* cached from proxypp->vendor */ ddsi_seqno_t seq; /* sequence number of most recent SEDP message */ -#ifdef DDS_HAS_TYPE_DISCOVERY +#ifdef DDS_HAS_TYPELIB struct ddsi_type_pair *type_pair; #endif #ifdef DDS_HAS_SECURITY diff --git a/src/core/ddsi/include/dds/ddsi/ddsi_qosmatch.h b/src/core/ddsi/include/dds/ddsi/ddsi_qosmatch.h index cf7f55e8ad..0227da09b5 100644 --- a/src/core/ddsi/include/dds/ddsi/ddsi_qosmatch.h +++ b/src/core/ddsi/include/dds/ddsi/ddsi_qosmatch.h @@ -42,9 +42,11 @@ bool ddsi_qos_match_mask_p ( const dds_qos_t *wr_qos, uint64_t mask, dds_qos_policy_id_t *reason -#ifdef DDS_HAS_TYPE_DISCOVERY +#ifdef DDS_HAS_TYPELIB , const struct ddsi_type_pair *rd_type_pair , const struct ddsi_type_pair *wr_type_pair +#endif +#ifdef DDS_HAS_TYPE_DISCOVERY , bool *rd_typeid_req_lookup , bool *wr_typeid_req_lookup #endif @@ -56,9 +58,11 @@ bool ddsi_qos_match_p ( const dds_qos_t *rd_qos, const dds_qos_t *wr_qos, dds_qos_policy_id_t *reason -#ifdef DDS_HAS_TYPE_DISCOVERY +#ifdef DDS_HAS_TYPELIB , const struct ddsi_type_pair *rd_type_pair , const struct ddsi_type_pair *wr_type_pair +#endif +#ifdef DDS_HAS_TYPE_DISCOVERY , bool *rd_typeid_req_lookup , bool *wr_typeid_req_lookup #endif diff --git a/src/core/ddsi/include/dds/ddsi/ddsi_serdata.h b/src/core/ddsi/include/dds/ddsi/ddsi_serdata.h index 9451524ae8..ddc6c5a18a 100644 --- a/src/core/ddsi/include/dds/ddsi/ddsi_serdata.h +++ b/src/core/ddsi/include/dds/ddsi/ddsi_serdata.h @@ -17,7 +17,6 @@ #include "dds/ddsrt/iovec.h" #include "dds/ddsi/ddsi_sertype.h" #include "dds/ddsi/ddsi_keyhash.h" -#include "dds/ddsi/ddsi_typelib.h" #if defined (__cplusplus) extern "C" { diff --git a/src/core/ddsi/include/dds/ddsi/ddsi_sertype.h b/src/core/ddsi/include/dds/ddsi/ddsi_sertype.h index 83d8bc3909..2c660c14d2 100644 --- a/src/core/ddsi/include/dds/ddsi/ddsi_sertype.h +++ b/src/core/ddsi/include/dds/ddsi/ddsi_sertype.h @@ -16,7 +16,6 @@ #include "dds/ddsrt/avl.h" #include "dds/ddsi/ddsi_xqos.h" #include "dds/ddsi/ddsi_typewrap.h" -#include "dds/ddsi/ddsi_typelib.h" #include "dds/ddsc/dds_public_alloc.h" #include "dds/cdr/dds_cdrstream.h" #include "dds/export.h" diff --git a/src/core/ddsi/include/dds/ddsi/ddsi_topic.h b/src/core/ddsi/include/dds/ddsi/ddsi_topic.h index 4681e18b2d..0dce66e0d8 100644 --- a/src/core/ddsi/include/dds/ddsi/ddsi_topic.h +++ b/src/core/ddsi/include/dds/ddsi/ddsi_topic.h @@ -16,7 +16,10 @@ #include "dds/ddsi/ddsi_domaingv.h" #include "dds/ddsi/ddsi_entity.h" + +#ifdef DDS_HAS_TOPIC_DISCOVERY #include "dds/ddsi/ddsi_typelib.h" +#endif #if defined (__cplusplus) extern "C" { diff --git a/src/core/ddsi/include/dds/ddsi/ddsi_typebuilder.h b/src/core/ddsi/include/dds/ddsi/ddsi_typebuilder.h index 016f8a2bee..4f1670ac14 100644 --- a/src/core/ddsi/include/dds/ddsi/ddsi_typebuilder.h +++ b/src/core/ddsi/include/dds/ddsi/ddsi_typebuilder.h @@ -22,16 +22,12 @@ extern "C" { #endif -#ifdef DDS_HAS_TYPE_DISCOVERY - /** @component dynamic_types */ dds_return_t ddsi_topic_descriptor_from_type (struct ddsi_domaingv *gv, dds_topic_descriptor_t *desc, const struct ddsi_type *type); /** @component dynamic_types */ void ddsi_topic_descriptor_fini (dds_topic_descriptor_t *desc); -#endif /* DDS_HAS_TYPE_DISCOVERY */ - #if defined (__cplusplus) } #endif diff --git a/src/core/ddsi/include/dds/ddsi/ddsi_typelib.h b/src/core/ddsi/include/dds/ddsi/ddsi_typelib.h index d8d732f055..c062882c8a 100644 --- a/src/core/ddsi/include/dds/ddsi/ddsi_typelib.h +++ b/src/core/ddsi/include/dds/ddsi/ddsi_typelib.h @@ -25,11 +25,10 @@ extern "C" { #endif -#ifdef DDS_HAS_TYPE_DISCOVERY - struct ddsi_domaingv; struct ddsi_sertype; struct ddsi_type; +enum ddsi_type_include_deps; typedef enum ddsi_type_request { DDSI_TYPE_NO_REQUEST, @@ -43,7 +42,7 @@ struct ddsi_typeid_str { /** @component type_system */ -DDS_EXPORT bool ddsi_typeinfo_equal (const ddsi_typeinfo_t *a, const ddsi_typeinfo_t *b, ddsi_type_include_deps_t deps); +DDS_EXPORT bool ddsi_typeinfo_equal (const ddsi_typeinfo_t *a, const ddsi_typeinfo_t *b, enum ddsi_type_include_deps deps); /** @component type_system */ DDS_EXPORT ddsi_typeid_t *ddsi_typeinfo_typeid (const ddsi_typeinfo_t *type_info, ddsi_typeid_kind_t kind); @@ -103,7 +102,7 @@ void ddsi_type_unref_sertype (struct ddsi_domaingv *gv, const struct ddsi_sertyp struct ddsi_typeobj *ddsi_type_get_typeobj (struct ddsi_domaingv *gv, const struct ddsi_type *type); /** @component type_system */ -bool ddsi_type_resolved (struct ddsi_domaingv *gv, const struct ddsi_type *type, ddsi_type_include_deps_t resolved_kind); +bool ddsi_type_resolved (struct ddsi_domaingv *gv, const struct ddsi_type *type, enum ddsi_type_include_deps resolved_kind); /** @component type_system */ struct ddsi_domaingv *ddsi_type_get_gv (const struct ddsi_type *type); @@ -111,6 +110,9 @@ struct ddsi_domaingv *ddsi_type_get_gv (const struct ddsi_type *type); /** @component type_system */ DDS_XTypes_TypeKind ddsi_type_get_kind (const struct ddsi_type *type); + +#ifdef DDS_HAS_TYPELIB + /** * @brief Waits for the provided type to be resolved * @component type_system @@ -118,7 +120,9 @@ DDS_XTypes_TypeKind ddsi_type_get_kind (const struct ddsi_type *type); * In case the type is succesfully resolved (or was already resolved), this * function increases the refcount for this type. Caller should do the unref. */ -dds_return_t ddsi_wait_for_type_resolved (struct ddsi_domaingv *gv, const ddsi_typeid_t *type_id, dds_duration_t timeout, struct ddsi_type **type, ddsi_type_include_deps_t resolved_kind, ddsi_type_request_t request); +dds_return_t ddsi_wait_for_type_resolved (struct ddsi_domaingv *gv, const ddsi_typeid_t *type_id, dds_duration_t timeout, struct ddsi_type **type, enum ddsi_type_include_deps resolved_kind, ddsi_type_request_t request); + +#endif /** * @brief Returns the type lookup meta object for the provided type identifier. @@ -137,8 +141,6 @@ DDS_EXPORT struct ddsi_type * ddsi_type_lookup (struct ddsi_domaingv *gv, const */ DDS_EXPORT int ddsi_type_compare (const struct ddsi_type *a, const struct ddsi_type *b); -#endif /* DDS_HAS_TYPE_DISCOVERY */ - #if defined (__cplusplus) } #endif diff --git a/src/core/ddsi/include/dds/ddsi/ddsi_typewrap.h b/src/core/ddsi/include/dds/ddsi/ddsi_typewrap.h index a63feacc0b..ea7283729c 100644 --- a/src/core/ddsi/include/dds/ddsi/ddsi_typewrap.h +++ b/src/core/ddsi/include/dds/ddsi/ddsi_typewrap.h @@ -23,7 +23,7 @@ extern "C" { #endif -#ifdef DDS_HAS_TYPE_DISCOVERY +#ifdef DDS_HAS_TYPELIB #define DDS_XTypes_TRY_CONSTRUCT_INVALID 0 #define DDS_XTypes_TRY_CONSTRUCT_DISCARD DDS_XTypes_TRY_CONSTRUCT1 @@ -87,14 +87,14 @@ DDS_EXPORT void ddsi_typeid_fini (ddsi_typeid_t *type_id); /** @component xtypes_wrapper */ void ddsi_typeobj_fini (ddsi_typeobj_t *typeobj); -#else /* DDS_HAS_TYPE_DISCOVERY */ +#else /* DDS_HAS_TYPELIB */ typedef void ddsi_typeid_t; typedef int ddsi_typeid_kind_t; typedef void ddsi_typemap_t; typedef void ddsi_typeinfo_t; -#endif /* DDS_HAS_TYPE_DISCOVERY */ +#endif /* DDS_HAS_TYPELIB */ #if defined (__cplusplus) } diff --git a/src/core/ddsi/include/dds/ddsi/ddsi_xqos.h b/src/core/ddsi/include/dds/ddsi/ddsi_xqos.h index 5f1e1584fd..e772fea6af 100644 --- a/src/core/ddsi/include/dds/ddsi/ddsi_xqos.h +++ b/src/core/ddsi/include/dds/ddsi/ddsi_xqos.h @@ -258,7 +258,7 @@ struct dds_qos { /* xx */char *topic_name; /* xx */char *type_name; /* xx */char *entity_name; -#ifdef DDS_HAS_TYPE_DISCOVERY +#ifdef DDS_HAS_TYPELIB /* xx */struct ddsi_typeinfo *type_information; #endif /* PublisherQos, SubscriberQos: */ diff --git a/src/core/ddsi/src/ddsi__serdata_cdr.h b/src/core/ddsi/src/ddsi__serdata_cdr.h index a2d582d051..1de6bd66f5 100644 --- a/src/core/ddsi/src/ddsi__serdata_cdr.h +++ b/src/core/ddsi/src/ddsi__serdata_cdr.h @@ -15,9 +15,7 @@ #include "dds/ddsrt/avl.h" #include "dds/ddsi/ddsi_freelist.h" #include "dds/ddsi/ddsi_serdata.h" -#include "dds/ddsi/ddsi_typelib.h" #include "ddsi__protocol.h" -#include "ddsi__typelookup.h" #include "dds/cdr/dds_cdrstream.h" #include "dds/dds.h" diff --git a/src/core/ddsi/src/ddsi__typelib.h b/src/core/ddsi/src/ddsi__typelib.h index d7b9f78e1e..a4076f761c 100644 --- a/src/core/ddsi/src/ddsi__typelib.h +++ b/src/core/ddsi/src/ddsi__typelib.h @@ -26,8 +26,6 @@ extern "C" { #endif -#ifdef DDS_HAS_TYPE_DISCOVERY - extern const ddsrt_avl_treedef_t ddsi_typelib_treedef; extern const ddsrt_avl_treedef_t ddsi_typedeps_treedef; extern const ddsrt_avl_treedef_t ddsi_typedeps_reverse_treedef; @@ -37,6 +35,7 @@ struct ddsi_sertype; struct ddsi_type; struct ddsi_type_pair; struct ddsi_generic_proxy_endpoint; +enum ddsi_type_include_deps; enum ddsi_type_state { DDSI_TYPE_UNRESOLVED, @@ -99,7 +98,7 @@ void ddsi_type_unreg_proxy (struct ddsi_domaingv *gv, struct ddsi_type *type, co void ddsi_type_unref_locked (struct ddsi_domaingv *gv, struct ddsi_type *type); /** @component type_system */ -bool ddsi_type_resolved_locked (struct ddsi_domaingv *gv, const struct ddsi_type *type, ddsi_type_include_deps_t resolved_kind); +bool ddsi_type_resolved_locked (struct ddsi_domaingv *gv, const struct ddsi_type *type, enum ddsi_type_include_deps resolved_kind); /** @component type_system */ void ddsi_type_free (struct ddsi_type *type); @@ -141,8 +140,6 @@ struct ddsi_type * ddsi_type_lookup_locked (struct ddsi_domaingv *gv, const ddsi */ void ddsi_type_get_gpe_matches (struct ddsi_domaingv *gv, const struct ddsi_type *type, struct ddsi_generic_proxy_endpoint ***gpe_match_upd, uint32_t *n_match_upd); -#endif /* DDS_HAS_TYPE_DISCOVERY */ - #if defined (__cplusplus) } #endif diff --git a/src/core/ddsi/src/ddsi__typelookup.h b/src/core/ddsi/src/ddsi__typelookup.h index a0886c97a6..6bf221b612 100644 --- a/src/core/ddsi/src/ddsi__typelookup.h +++ b/src/core/ddsi/src/ddsi__typelookup.h @@ -13,8 +13,6 @@ #include "dds/features.h" -#ifdef DDS_HAS_TYPE_DISCOVERY - #include #include "dds/ddsrt/time.h" #include "dds/ddsrt/hopscotch.h" @@ -40,6 +38,7 @@ struct ddsi_serdata; struct ddsi_sertype; struct ddsi_type; struct ddsi_generic_proxy_endpoint; +enum ddsi_type_include_deps; /** * @component type_lookup @@ -47,7 +46,7 @@ struct ddsi_generic_proxy_endpoint; * Send a type lookup request message in order to request type information for the * provided type identifier. */ -bool ddsi_tl_request_type (struct ddsi_domaingv * const gv, const ddsi_typeid_t *type_id, const ddsi_guid_t *proxypp_guid, ddsi_type_include_deps_t deps); +bool ddsi_tl_request_type (struct ddsi_domaingv * const gv, const ddsi_typeid_t *type_id, const ddsi_guid_t *proxypp_guid, enum ddsi_type_include_deps deps); /** * @component type_lookup @@ -78,5 +77,5 @@ void ddsi_tl_handle_reply (struct ddsi_domaingv *gv, struct ddsi_serdata *sample #if defined (__cplusplus) } #endif -#endif /* DDS_HAS_TYPE_DISCOVERY */ + #endif /* DDSI__TYPELOOKUP_H */ diff --git a/src/core/ddsi/src/ddsi__typewrap.h b/src/core/ddsi/src/ddsi__typewrap.h index 500bfc1ce0..440056a0fa 100644 --- a/src/core/ddsi/src/ddsi__typewrap.h +++ b/src/core/ddsi/src/ddsi__typewrap.h @@ -24,8 +24,6 @@ extern "C" { #endif -#ifdef DDS_HAS_TYPE_DISCOVERY - #define XT_FLAG_EXTENSIBILITY_MASK 0x7 #define DDS_XTypes_TRY_CONSTRUCT_INVALID 0 @@ -83,8 +81,6 @@ void ddsi_xt_copy (struct ddsi_domaingv *gv, struct xt_type *dst, const struct x /** @component xtypes_wrapper */ void ddsi_xt_get_namehash (DDS_XTypes_NameHash name_hash, const char *name); -#endif /* DDS_HAS_TYPE_DISCOVERY */ - #if defined (__cplusplus) } #endif diff --git a/src/core/ddsi/src/ddsi_discovery_endpoint.c b/src/core/ddsi/src/ddsi_discovery_endpoint.c index 161c11c9fa..4a3ffb486a 100644 --- a/src/core/ddsi/src/ddsi_discovery_endpoint.c +++ b/src/core/ddsi/src/ddsi_discovery_endpoint.c @@ -110,7 +110,7 @@ static int sedp_write_endpoint_impl struct ddsi_writer *wr, int alive, const ddsi_guid_t *guid, const struct ddsi_endpoint_common *epcommon, const dds_qos_t *xqos, struct ddsi_addrset *as, ddsi_security_info_t *security -#ifdef DDS_HAS_TYPE_DISCOVERY +#ifdef DDS_HAS_TYPELIB , const struct ddsi_sertype *sertype #endif ) @@ -239,7 +239,7 @@ static int sedp_write_endpoint_impl } #endif -#ifdef DDS_HAS_TYPE_DISCOVERY +#ifdef DDS_HAS_TYPELIB assert (sertype); if ((ps.qos.type_information = ddsi_sertype_typeinfo (sertype))) ps.qos.present |= DDSI_QP_TYPE_INFORMATION; @@ -270,7 +270,7 @@ int ddsi_sedp_write_writer (struct ddsi_writer *wr) security = &tmp; } #endif -#ifdef DDS_HAS_TYPE_DISCOVERY +#ifdef DDS_HAS_TYPELIB return sedp_write_endpoint_impl (sedp_wr, 1, &wr->e.guid, &wr->c, wr->xqos, as, security, wr->type); #else return sedp_write_endpoint_impl (sedp_wr, 1, &wr->e.guid, &wr->c, wr->xqos, as, security); @@ -312,7 +312,7 @@ int ddsi_sedp_write_reader (struct ddsi_reader *rd) security = &tmp; } #endif -#ifdef DDS_HAS_TYPE_DISCOVERY +#ifdef DDS_HAS_TYPELIB const int ret = sedp_write_endpoint_impl (sedp_wr, 1, &rd->e.guid, &rd->c, rd->xqos, as, security, rd->type); #else const int ret = sedp_write_endpoint_impl (sedp_wr, 1, &rd->e.guid, &rd->c, rd->xqos, as, security); @@ -327,7 +327,7 @@ int ddsi_sedp_dispose_unregister_writer (struct ddsi_writer *wr) { unsigned entityid = ddsi_determine_publication_writer(wr); struct ddsi_writer *sedp_wr = ddsi_get_sedp_writer (wr->c.pp, entityid); -#ifdef DDS_HAS_TYPE_DISCOVERY +#ifdef DDS_HAS_TYPELIB return sedp_write_endpoint_impl (sedp_wr, 0, &wr->e.guid, NULL, NULL, NULL, NULL, NULL); #else return sedp_write_endpoint_impl (sedp_wr, 0, &wr->e.guid, NULL, NULL, NULL, NULL); @@ -342,7 +342,7 @@ int ddsi_sedp_dispose_unregister_reader (struct ddsi_reader *rd) { unsigned entityid = ddsi_determine_subscription_writer(rd); struct ddsi_writer *sedp_wr = ddsi_get_sedp_writer (rd->c.pp, entityid); -#ifdef DDS_HAS_TYPE_DISCOVERY +#ifdef DDS_HAS_TYPELIB return sedp_write_endpoint_impl (sedp_wr, 0, &rd->e.guid, NULL, NULL, NULL, NULL, NULL); #else return sedp_write_endpoint_impl (sedp_wr, 0, &rd->e.guid, NULL, NULL, NULL, NULL); diff --git a/src/core/ddsi/src/ddsi_endpoint.c b/src/core/ddsi/src/ddsi_endpoint.c index 700995d402..1b3a57571e 100644 --- a/src/core/ddsi/src/ddsi_endpoint.c +++ b/src/core/ddsi/src/ddsi_endpoint.c @@ -416,7 +416,7 @@ static bool is_onlylocal_endpoint (struct ddsi_participant *pp, const char *topi static void endpoint_common_init (struct ddsi_entity_common *e, struct ddsi_endpoint_common *c, struct ddsi_domaingv *gv, enum ddsi_entity_kind kind, const struct ddsi_guid *guid, const struct ddsi_guid *group_guid, struct ddsi_participant *pp, bool onlylocal, const struct ddsi_sertype *sertype) { -#ifndef DDS_HAS_TYPE_DISCOVERY +#ifndef DDS_HAS_TYPELIB DDSRT_UNUSED_ARG (sertype); #endif ddsi_entity_common_init (e, gv, guid, kind, ddsrt_time_wallclock (), DDSI_VENDORID_ECLIPSE, pp->e.onlylocal || onlylocal); @@ -426,7 +426,7 @@ static void endpoint_common_init (struct ddsi_entity_common *e, struct ddsi_endp else memset (&c->group_guid, 0, sizeof (c->group_guid)); -#ifdef DDS_HAS_TYPE_DISCOVERY +#ifdef DDS_HAS_TYPELIB c->type_pair = ddsrt_malloc (sizeof (*c->type_pair)); /* Referencing the top-level type shouldn't fail at this point. The sertype that is passed, @@ -449,7 +449,7 @@ static void endpoint_common_fini (struct ddsi_entity_common *e, struct ddsi_endp if (c->pp) { ddsi_unref_participant (c->pp, &e->guid); -#ifdef DDS_HAS_TYPE_DISCOVERY +#ifdef DDS_HAS_TYPELIB if (c->type_pair) { ddsi_type_unref (e->gv, c->type_pair->minimal); @@ -1023,7 +1023,7 @@ struct ddsi_local_orphan_writer *ddsi_new_local_orphan_writer (struct ddsi_domai wr->c.pp = NULL; memset (&wr->c.group_guid, 0, sizeof (wr->c.group_guid)); -#ifdef DDS_HAS_TYPE_DISCOVERY +#ifdef DDS_HAS_TYPELIB wr->c.type_pair = NULL; #endif @@ -1313,7 +1313,7 @@ dds_return_t ddsi_delete_writer (struct ddsi_domaingv *gv, const struct ddsi_gui ddsrt_mtime_to_sec_usec (&tsec, &tusec, tsched); GVLOGDISC ("delete_writer(guid "PGUIDFMT") - unack'ed samples, will delete when ack'd or at t = %"PRId32".%06"PRId32"\n", PGUID (*guid), tsec, tusec); - + struct ddsi_delete_writer_xevent_cb_arg arg = { .wr_guid = wr->e.guid }; ddsi_qxev_callback (gv->xevents, tsched, ddsi_delete_writer_xevent_cb, &arg, sizeof (arg), false); } diff --git a/src/core/ddsi/src/ddsi_endpoint_match.c b/src/core/ddsi/src/ddsi_endpoint_match.c index 0a112bd2d3..6d5fcf5463 100644 --- a/src/core/ddsi/src/ddsi_endpoint_match.c +++ b/src/core/ddsi/src/ddsi_endpoint_match.c @@ -166,7 +166,7 @@ static void reader_qos_mismatch (struct ddsi_reader * rd, dds_qos_policy_id_t re } static bool topickind_qos_match_p_lock (struct ddsi_domaingv *gv, struct ddsi_entity_common *rd, const dds_qos_t *rdqos, struct ddsi_entity_common *wr, const dds_qos_t *wrqos, dds_qos_policy_id_t *reason -#ifdef DDS_HAS_TYPE_DISCOVERY +#ifdef DDS_HAS_TYPELIB , const struct ddsi_type_pair *rd_type_pair, const struct ddsi_type_pair *wr_type_pair #endif ) @@ -204,6 +204,8 @@ static bool topickind_qos_match_p_lock (struct ddsi_domaingv *gv, struct ddsi_en proxypp_guid = &((struct ddsi_generic_proxy_endpoint *) wr)->c.proxypp->e.guid; } } +#elif DDS_HAS_TYPELIB + bool ret = ddsi_qos_match_p (gv, rdqos, wrqos, reason, rd_type_pair, wr_type_pair); #else bool ret = ddsi_qos_match_p (gv, rdqos, wrqos, reason); #endif @@ -260,7 +262,7 @@ static void connect_writer_with_proxy_reader (struct ddsi_writer *wr, struct dds return; if (wr->e.onlylocal) return; -#ifdef DDS_HAS_TYPE_DISCOVERY +#ifdef DDS_HAS_TYPELIB if (!isb0 && !topickind_qos_match_p_lock (gv, &prd->e, prd->c.xqos, &wr->e, wr->xqos, &reason, prd->c.type_pair, wr->c.type_pair)) #else if (!isb0 && !topickind_qos_match_p_lock (gv, &prd->e, prd->c.xqos, &wr->e, wr->xqos, &reason)) @@ -302,7 +304,7 @@ static void connect_proxy_writer_with_reader (struct ddsi_proxy_writer *pwr, str return; if (rd->e.onlylocal) return; -#ifdef DDS_HAS_TYPE_DISCOVERY +#ifdef DDS_HAS_TYPELIB if (!isb0 && !topickind_qos_match_p_lock (rd->e.gv, &rd->e, rd->xqos, &pwr->e, pwr->c.xqos, &reason, rd->c.type_pair, pwr->c.type_pair)) #else if (!isb0 && !topickind_qos_match_p_lock (rd->e.gv, &rd->e, rd->xqos, &pwr->e, pwr->c.xqos, &reason)) @@ -372,7 +374,7 @@ static void connect_writer_with_reader (struct ddsi_writer *wr, struct ddsi_read return; if (ignore_local_p (&wr->e.guid, &rd->e.guid, wr->xqos, rd->xqos)) return; -#ifdef DDS_HAS_TYPE_DISCOVERY +#ifdef DDS_HAS_TYPELIB if (!topickind_qos_match_p_lock (wr->e.gv, &rd->e, rd->xqos, &wr->e, wr->xqos, &reason, rd->c.type_pair, wr->c.type_pair)) #else if (!topickind_qos_match_p_lock (wr->e.gv, &rd->e, rd->xqos, &wr->e, wr->xqos, &reason)) diff --git a/src/core/ddsi/src/ddsi_init.c b/src/core/ddsi/src/ddsi_init.c index 2822f6bbd9..909b8e8e1b 100644 --- a/src/core/ddsi/src/ddsi_init.c +++ b/src/core/ddsi/src/ddsi_init.c @@ -961,7 +961,7 @@ static uint32_t topic_definition_hash_wrap (const void *tpd) { return ddsi_topic_definition_hash (tpd); } -#endif /* DDS_HAS_TYPE_DISCOVERY */ +#endif /* DDS_HAS_TOPIC_DISCOVERY */ static void reset_deaf_mute (struct ddsi_domaingv *gv, struct ddsi_xevent *xev, UNUSED_ARG (struct ddsi_xpack *xp), UNUSED_ARG (void *varg), UNUSED_ARG (ddsrt_mtime_t tnow)) { @@ -1317,7 +1317,7 @@ int ddsi_init (struct ddsi_domaingv *gv) ddsrt_mutex_init (&gv->sertypes_lock); gv->sertypes = ddsrt_hh_new (1, ddsi_sertype_hash_wrap, ddsi_sertype_equal_wrap); -#ifdef DDS_HAS_TYPE_DISCOVERY +#ifdef DDS_HAS_TYPELIB ddsrt_mutex_init (&gv->typelib_lock); ddsrt_cond_init (&gv->typelib_resolved_cond); ddsrt_avl_init (&ddsi_typelib_treedef, &gv->typelib); @@ -1658,7 +1658,7 @@ int ddsi_init (struct ddsi_domaingv *gv) #endif ddsrt_mutex_destroy (&gv->new_topic_lock); ddsrt_cond_destroy (&gv->new_topic_cond); -#ifdef DDS_HAS_TYPE_DISCOVERY +#ifdef DDS_HAS_TYPELIB ddsrt_avl_free (&ddsi_typelib_treedef, &gv->typelib, 0); ddsrt_avl_free (&ddsi_typedeps_treedef, &gv->typedeps, 0); ddsrt_avl_free (&ddsi_typedeps_reverse_treedef, &gv->typedeps_reverse, 0); @@ -1979,7 +1979,7 @@ void ddsi_fini (struct ddsi_domaingv *gv) ddsrt_hh_free (gv->topic_defs); ddsrt_mutex_destroy (&gv->topic_defs_lock); #endif /* DDS_HAS_TOPIC_DISCOVERY */ -#ifdef DDS_HAS_TYPE_DISCOVERY +#ifdef DDS_HAS_TYPELIB #ifndef NDEBUG { assert(ddsrt_avl_is_empty(&gv->typelib)); @@ -1991,7 +1991,7 @@ void ddsi_fini (struct ddsi_domaingv *gv) ddsrt_avl_free (&ddsi_typedeps_treedef, &gv->typedeps, 0); ddsrt_avl_free (&ddsi_typedeps_reverse_treedef, &gv->typedeps_reverse, 0); ddsrt_mutex_destroy (&gv->typelib_lock); -#endif /* DDS_HAS_TYPE_DISCOVERY */ +#endif /* DDS_HAS_TYPELIB */ #ifndef NDEBUG { struct ddsrt_hh_iter it; diff --git a/src/core/ddsi/src/ddsi_plist.c b/src/core/ddsi/src/ddsi_plist.c index 5c3f90f7c0..06fc7195b6 100644 --- a/src/core/ddsi/src/ddsi_plist.c +++ b/src/core/ddsi/src/ddsi_plist.c @@ -794,7 +794,7 @@ static bool print_data_representation (char * __restrict *buf, size_t * __restri return prtf (buf, bufsize, ")"); } -#ifdef DDS_HAS_TYPE_DISCOVERY +#ifdef DDS_HAS_TYPELIB static dds_return_t deser_type_information (void * __restrict dst, struct flagset *flagset, uint64_t flag, const struct dd * __restrict dd, struct ddsi_domaingv const * const gv) { @@ -881,7 +881,7 @@ static bool print_type_information (char * __restrict *buf, size_t * __restrict ddsi_make_typeid_str (&tpstrc, ddsi_typeinfo_complete_typeid (*x))); } -#endif /* DDS_HAS_TYPE_DISCOVERY */ +#endif /* DDS_HAS_TYPELIB */ // The XE1 .. XE3 codes are the only ones dealing with an enumerated type and are // assumed to map to the same type, which would traditionally be an "int", but in @@ -2040,7 +2040,7 @@ static const struct piddesc piddesc_omg[] = { { DDSI_PID_DATA_REPRESENTATION, PDF_QOS | PDF_FUNCTION, DDSI_QP_DATA_REPRESENTATION, "DATA_REPRESENTATION", offsetof (struct ddsi_plist, qos.data_representation), membersize (struct ddsi_plist, qos.data_representation), { .f = { .deser = deser_data_representation, .ser = ser_data_representation, .valid = valid_data_representation, .equal = equal_data_representation, .unalias = unalias_data_representation, .fini = fini_data_representation, .print = print_data_representation } }, 0 }, -#ifdef DDS_HAS_TYPE_DISCOVERY +#ifdef DDS_HAS_TYPELIB { DDSI_PID_TYPE_INFORMATION, PDF_QOS | PDF_FUNCTION, DDSI_QP_TYPE_INFORMATION, "TYPE_INFORMATION", offsetof (struct ddsi_plist, qos.type_information), membersize (struct ddsi_plist, qos.type_information), { .f = { .deser = deser_type_information, .ser = ser_type_information, .valid = valid_type_information, .unalias = unalias_type_information, .fini = fini_type_information, .equal = equal_type_information, .print = print_type_information } }, 0 }, @@ -2184,7 +2184,7 @@ struct piddesc_index { FIXME: should compute them at build-time */ #define DEFAULT_PROC_ARRAY_SIZE 20 -#ifdef DDS_HAS_TYPE_DISCOVERY +#ifdef DDS_HAS_TYPELIB #define DEFAULT_OMG_PIDS_ARRAY_SIZE (DDSI_PID_TYPE_INFORMATION + 1) #else #define DEFAULT_OMG_PIDS_ARRAY_SIZE (DDSI_PID_TYPE_CONSISTENCY_ENFORCEMENT + 1) @@ -2223,7 +2223,7 @@ static const struct piddesc_index piddesc_vendor_index[] = { /* List of entries that require unalias, fini processing; initialized by ddsi_plist_init_tables; will assert when table too small or too large */ -#ifdef DDS_HAS_TYPE_DISCOVERY +#ifdef DDS_HAS_TYPELIB static const struct piddesc *piddesc_unalias[18 + SECURITY_PROC_ARRAY_SIZE]; static const struct piddesc *piddesc_fini[18 + SECURITY_PROC_ARRAY_SIZE]; #else diff --git a/src/core/ddsi/src/ddsi_proxy_endpoint.c b/src/core/ddsi/src/ddsi_proxy_endpoint.c index d7255b9c76..5f873664c1 100644 --- a/src/core/ddsi/src/ddsi_proxy_endpoint.c +++ b/src/core/ddsi/src/ddsi_proxy_endpoint.c @@ -70,7 +70,7 @@ static int proxy_endpoint_common_init (struct ddsi_entity_common *e, struct ddsi c->as = ddsi_ref_addrset (as); c->vendor = proxypp->vendor; c->seq = seq; -#ifdef DDS_HAS_TYPE_DISCOVERY +#ifdef DDS_HAS_TYPELIB if (plist->qos.present & DDSI_QP_TYPE_INFORMATION) { if ((c->type_pair = ddsrt_calloc (1, sizeof (*c->type_pair))) == NULL) @@ -99,12 +99,12 @@ static int proxy_endpoint_common_init (struct ddsi_entity_common *e, struct ddsi ret = ddsi_ref_proxy_participant (proxypp, c); -#ifdef DDS_HAS_TYPE_DISCOVERY +#ifdef DDS_HAS_TYPELIB err: #endif if (ret != DDS_RETCODE_OK) { -#ifdef DDS_HAS_TYPE_DISCOVERY +#ifdef DDS_HAS_TYPELIB if (c->type_pair != NULL) { if (c->type_pair->minimal) @@ -162,12 +162,12 @@ static bool has_iceoryx_address (struct ddsi_domaingv * const gv, struct ddsi_ad } #endif /* DDS_HAS_SHM */ -#ifdef DDS_HAS_TYPE_DISCOVERY +#ifdef DDS_HAS_TYPELIB bool ddsi_is_proxy_endpoint (const struct ddsi_entity_common *e) { return e->kind == DDSI_EK_PROXY_READER || e->kind == DDSI_EK_PROXY_WRITER; } -#endif /* DDS_HAS_TYPE_DISCOVERY */ +#endif /* DDS_HAS_TYPELIB */ void ddsi_send_entityid_to_prd (struct ddsi_proxy_reader *prd, const ddsi_guid_t *guid) { @@ -382,7 +382,7 @@ static void gc_delete_proxy_writer (struct ddsi_gcreq *gcreq) ELOGDISC (pwr, "gc_delete_proxy_writer (%p, "PGUIDFMT")\n", (void *) gcreq, PGUID (pwr->e.guid)); ddsi_gcreq_free (gcreq); -#ifdef DDS_HAS_TYPE_DISCOVERY +#ifdef DDS_HAS_TYPELIB if (pwr->c.type_pair != NULL) { ddsi_type_unref (pwr->e.gv, pwr->c.type_pair->minimal); @@ -459,7 +459,7 @@ int ddsi_delete_proxy_writer (struct ddsi_domaingv *gv, const struct ddsi_guid * ddsi_local_reader_ary_setinvalid (&pwr->rdary); GVLOGDISC ("- deleting\n"); ddsi_builtintopic_write_endpoint (gv->builtin_topic_interface, &pwr->e, timestamp, false); -#ifdef DDS_HAS_TYPE_DISCOVERY +#ifdef DDS_HAS_TYPELIB /* Unregister from type before removing from entity index, because a tl_lookup_reply could be pending and will trigger an update of the endpoint matching for all endpoints that are registered for the type. This call removes this proxy writer @@ -731,7 +731,7 @@ static void gc_delete_proxy_reader (struct ddsi_gcreq *gcreq) ELOGDISC (prd, "gc_delete_proxy_reader (%p, "PGUIDFMT")\n", (void *) gcreq, PGUID (prd->e.guid)); ddsi_gcreq_free (gcreq); -#ifdef DDS_HAS_TYPE_DISCOVERY +#ifdef DDS_HAS_TYPELIB if (prd->c.type_pair != NULL) { ddsi_type_unref (prd->e.gv, prd->c.type_pair->minimal); @@ -776,7 +776,7 @@ int ddsi_delete_proxy_reader (struct ddsi_domaingv *gv, const struct ddsi_guid * return DDS_RETCODE_BAD_PARAMETER; } ddsi_builtintopic_write_endpoint (gv->builtin_topic_interface, &prd->e, timestamp, false); -#ifdef DDS_HAS_TYPE_DISCOVERY +#ifdef DDS_HAS_TYPELIB /* Unregister the proxy guid with the ddsi_type before removing from entity index, because a tl_lookup_reply could be pending and will trigger an update of the endpoint matching for all endpoints that diff --git a/src/core/ddsi/src/ddsi_proxy_participant.c b/src/core/ddsi/src/ddsi_proxy_participant.c index 4175f6b198..c693e7d039 100644 --- a/src/core/ddsi/src/ddsi_proxy_participant.c +++ b/src/core/ddsi/src/ddsi_proxy_participant.c @@ -12,6 +12,7 @@ #include #include +#include "dds/dds.h" #include "dds/ddsrt/heap.h" #include "dds/ddsrt/avl.h" #include "dds/ddsi/ddsi_domaingv.h" diff --git a/src/core/ddsi/src/ddsi_qosmatch.c b/src/core/ddsi/src/ddsi_qosmatch.c index f8c8c46199..ed3ee4e442 100644 --- a/src/core/ddsi/src/ddsi_qosmatch.c +++ b/src/core/ddsi/src/ddsi_qosmatch.c @@ -68,7 +68,7 @@ static int partitions_match_p (const dds_qos_t *a, const dds_qos_t *b) } } -#ifdef DDS_HAS_TYPE_DISCOVERY +#ifdef DDS_HAS_TYPELIB static uint32_t is_endpoint_type_resolved (struct ddsi_domaingv *gv, char *type_name, const ddsi_type_pair_t *type_pair, bool *req_lookup, const char *entity) ddsrt_nonnull((1, 2, 3)); @@ -105,7 +105,7 @@ static uint32_t is_endpoint_type_resolved (struct ddsi_domaingv *gv, char *type_ return compl_resolved ? DDS_XTypes_EK_COMPLETE : DDS_XTypes_EK_MINIMAL; } -#endif /* DDS_HAS_TYPE_DISCOVERY */ +#endif /* DDS_HAS_TYPELIB */ static int data_representation_match_p (const dds_qos_t *rd_qos, const dds_qos_t *wr_qos) { @@ -121,7 +121,7 @@ static int data_representation_match_p (const dds_qos_t *rd_qos, const dds_qos_t return 0; } -#ifdef DDS_HAS_TYPE_DISCOVERY +#ifdef DDS_HAS_TYPELIB static bool type_pair_has_id (const ddsi_type_pair_t *pair) { return pair && (pair->minimal || pair->complete); @@ -134,9 +134,11 @@ bool ddsi_qos_match_mask_p ( const dds_qos_t *wr_qos, uint64_t mask, dds_qos_policy_id_t *reason -#ifdef DDS_HAS_TYPE_DISCOVERY +#ifdef DDS_HAS_TYPELIB , const struct ddsi_type_pair *rd_type_pair , const struct ddsi_type_pair *wr_type_pair +#endif +#ifdef DDS_HAS_TYPE_DISCOVERY , bool *rd_typeid_req_lookup , bool *wr_typeid_req_lookup #endif @@ -154,6 +156,9 @@ bool ddsi_qos_match_mask_p ( *rd_typeid_req_lookup = false; if (wr_typeid_req_lookup != NULL) *wr_typeid_req_lookup = false; +#elif DDS_HAS_TYPELIB + bool *rd_typeid_req_lookup = NULL; + bool *wr_typeid_req_lookup = NULL; #endif mask &= rd_qos->present & wr_qos->present; @@ -214,7 +219,7 @@ bool ddsi_qos_match_mask_p ( return false; } -#ifdef DDS_HAS_TYPE_DISCOVERY +#ifdef DDS_HAS_TYPELIB if (!type_pair_has_id (rd_type_pair) || !type_pair_has_id (wr_type_pair)) { // Type info missing on either or both: automatic failure if "force type validation" @@ -277,9 +282,11 @@ bool ddsi_qos_match_p ( const dds_qos_t *rd_qos, const dds_qos_t *wr_qos, dds_qos_policy_id_t *reason -#ifdef DDS_HAS_TYPE_DISCOVERY +#ifdef DDS_HAS_TYPELIB , const struct ddsi_type_pair *rd_type_pair , const struct ddsi_type_pair *wr_type_pair +#endif +#ifdef DDS_HAS_TYPE_DISCOVERY , bool *rd_typeid_req_lookup , bool *wr_typeid_req_lookup #endif @@ -288,6 +295,8 @@ bool ddsi_qos_match_p ( dds_qos_policy_id_t dummy; #ifdef DDS_HAS_TYPE_DISCOVERY return ddsi_qos_match_mask_p (gv, rd_qos, wr_qos, ~(uint64_t)0, reason ? reason : &dummy, rd_type_pair, wr_type_pair, rd_typeid_req_lookup, wr_typeid_req_lookup); +#elif DDS_HAS_TYPELIB + return ddsi_qos_match_mask_p (gv, rd_qos, wr_qos, ~(uint64_t)0, reason ? reason : &dummy, rd_type_pair, wr_type_pair); #else return ddsi_qos_match_mask_p (gv, rd_qos, wr_qos, ~(uint64_t)0, reason ? reason : &dummy); #endif diff --git a/src/core/ddsi/src/ddsi_sertype_plist.c b/src/core/ddsi/src/ddsi_sertype_plist.c index 11bbe0d919..dcfe94fcb0 100644 --- a/src/core/ddsi/src/ddsi_sertype_plist.c +++ b/src/core/ddsi/src/ddsi_sertype_plist.c @@ -19,7 +19,6 @@ #include "dds/ddsi/ddsi_plist.h" #include "dds/ddsi/ddsi_sertype.h" #include "ddsi__serdata_plist.h" -#include "ddsi__typelookup.h" static bool sertype_plist_equal (const struct ddsi_sertype *acmn, const struct ddsi_sertype *bcmn) { diff --git a/src/core/ddsi/src/ddsi_sertype_pserop.c b/src/core/ddsi/src/ddsi_sertype_pserop.c index 572dc06371..f57f469040 100644 --- a/src/core/ddsi/src/ddsi_sertype_pserop.c +++ b/src/core/ddsi/src/ddsi_sertype_pserop.c @@ -20,7 +20,6 @@ #include "dds/ddsi/ddsi_sertype.h" #include "ddsi__plist_generic.h" #include "ddsi__serdata_pserop.h" -#include "ddsi__typelookup.h" static bool sertype_pserop_equal (const struct ddsi_sertype *acmn, const struct ddsi_sertype *bcmn) { diff --git a/src/core/ddsi/src/ddsi_typelib.c b/src/core/ddsi/src/ddsi_typelib.c index 578251d587..0517397508 100644 --- a/src/core/ddsi/src/ddsi_typelib.c +++ b/src/core/ddsi/src/ddsi_typelib.c @@ -10,8 +10,6 @@ #include "dds/features.h" -#ifdef DDS_HAS_TYPE_DISCOVERY - #include #include #include "dds/ddsrt/heap.h" @@ -696,11 +694,15 @@ dds_return_t ddsi_type_ref_local (struct ddsi_domaingv *gv, struct ddsi_type **t goto err; } +#ifdef DDS_HAS_TYPELIB if (resolved) { GVTRACE ("type %s resolved\n", ddsi_make_typeid_str_impl (&tistr, type_id)); ddsrt_cond_broadcast (&gv->typelib_resolved_cond); } +#else + (void) resolved; +#endif ddsrt_mutex_unlock (&gv->typelib_lock); if (gpe_match_upd != NULL) @@ -1436,6 +1438,9 @@ void ddsi_type_pair_free (struct ddsi_type_pair *type_pair) ddsrt_free (type_pair); } + +#ifdef DDS_HAS_TYPELIB + static dds_return_t check_type_resolved_impl_locked (struct ddsi_domaingv *gv, const ddsi_typeid_t *type_id, dds_duration_t timeout, struct ddsi_type **type, ddsi_type_include_deps_t resolved_kind, bool *resolved) { dds_return_t ret = DDS_RETCODE_OK; @@ -1487,9 +1492,13 @@ dds_return_t ddsi_wait_for_type_resolved (struct ddsi_domaingv *gv, const ddsi_t if (ret != DDS_RETCODE_OK || resolved) return ret; +#ifdef DDS_HAS_TYPE_DISCOVERY // TODO: provide proxy pp guid to ddsi_tl_request_type so that request can be sent to a specific node if (request == DDSI_TYPE_SEND_REQUEST && !ddsi_tl_request_type (gv, type_id, NULL, resolved_kind)) return DDS_RETCODE_PRECONDITION_NOT_MET; +#else + assert (request == DDSI_TYPE_NO_REQUEST); +#endif ddsrt_mutex_lock (&gv->typelib_lock); ret = wait_for_type_resolved_impl_locked (gv, timeout, *type, resolved_kind); @@ -1498,4 +1507,4 @@ dds_return_t ddsi_wait_for_type_resolved (struct ddsi_domaingv *gv, const ddsi_t return ret; } -#endif /* DDS_HAS_TYPE_DISCOVERY */ +#endif /* DDS_HAS_TYPELIB */ diff --git a/src/core/xtests/symbol_export/symbol_export.c b/src/core/xtests/symbol_export/symbol_export.c index d6d3aacad8..5494fc4a71 100644 --- a/src/core/xtests/symbol_export/symbol_export.c +++ b/src/core/xtests/symbol_export/symbol_export.c @@ -51,6 +51,9 @@ #include "dds/ddsi/ddsi_xqos.h" #include "dds/ddsi/ddsi_serdata.h" #include "dds/ddsi/ddsi_gc.h" +#ifdef DDS_HAS_TYPELIB +#include "dds/ddsi/ddsi_typelib.h" +#endif #ifdef DDS_HAS_SECURITY #include "dds/security/core/dds_security_serialize.h" @@ -228,7 +231,7 @@ int main (int argc, char **argv) dds_get_matched_subscription_data (1, 1); dds_get_matched_publications (1, ptr, 0); dds_get_matched_publication_data (1, 1); -#ifdef DDS_HAS_TYPE_DISCOVERY +#ifdef DDS_HAS_TYPELIB dds_builtintopic_get_endpoint_type_info (ptr, ptr); #endif dds_builtintopic_free_endpoint (ptr); @@ -409,7 +412,7 @@ int main (int argc, char **argv) dds_get_requested_deadline_missed_status (1, ptr); dds_get_requested_incompatible_qos_status (1, ptr); -#ifdef DDS_HAS_TYPE_DISCOVERY +#ifdef DDS_HAS_TYPELIB // dds_public_dynamic_type.h dds_dynamic_member_set_external (ptr, 0, 0); dds_dynamic_member_set_hashid (ptr, 0, ptr); @@ -641,7 +644,7 @@ int main (int argc, char **argv) ddsi_serdata_from_loaned_sample (ptr, 0, ptr); #endif -#ifdef DDS_HAS_TYPE_DISCOVERY +#ifdef DDS_HAS_TYPELIB // ddsi_typewrap.h ddsi_typeid_compare (ptr, ptr); ddsi_typeid_copy (ptr, ptr); diff --git a/src/ddsrt/CMakeLists.txt b/src/ddsrt/CMakeLists.txt index 54e2b61999..dbfc86a320 100644 --- a/src/ddsrt/CMakeLists.txt +++ b/src/ddsrt/CMakeLists.txt @@ -310,7 +310,7 @@ set(DDSRT_WITH_LWIP ${WITH_LWIP}) set(DDSRT_WITH_FREERTOS ${WITH_FREERTOS}) foreach(feature SSL SECURITY LIFESPAN DEADLINE_MISSED NETWORK_PARTITIONS - SSM TYPE_DISCOVERY TOPIC_DISCOVERY SHM) + SSM TYPELIB TYPE_DISCOVERY TOPIC_DISCOVERY SHM) set(DDS_HAS_${feature} ${ENABLE_${feature}}) endforeach() diff --git a/src/ddsrt/include/dds/features.h.in b/src/ddsrt/include/dds/features.h.in index 0193c986f0..32b5c582d5 100644 --- a/src/ddsrt/include/dds/features.h.in +++ b/src/ddsrt/include/dds/features.h.in @@ -29,6 +29,9 @@ /* Whether or not features dependent on OpenSSL are included */ #cmakedefine DDS_HAS_SSL 1 +/* Whether or not support for type library is included */ +#cmakedefine DDS_HAS_TYPELIB 1 + /* Whether or not support for type discovery is included */ #cmakedefine DDS_HAS_TYPE_DISCOVERY 1 diff --git a/src/tools/idlc/CMakeLists.txt b/src/tools/idlc/CMakeLists.txt index da7e741874..30272ea47d 100644 --- a/src/tools/idlc/CMakeLists.txt +++ b/src/tools/idlc/CMakeLists.txt @@ -26,7 +26,7 @@ set(sources src/descriptor.c src/types.c) -if(ENABLE_TYPE_DISCOVERY) +if(ENABLE_TYPELIB) list(APPEND headers src/descriptor_type_meta.h) list(APPEND sources src/descriptor_type_meta.c) endif() diff --git a/src/tools/idlc/src/descriptor.c b/src/tools/idlc/src/descriptor.c index 5d940bcf4b..3be2d2b871 100644 --- a/src/tools/idlc/src/descriptor.c +++ b/src/tools/idlc/src/descriptor.c @@ -2333,7 +2333,7 @@ static int print_flags(FILE *fp, struct descriptor *descriptor, bool type_info) if (fixed_size) vec[len++] = "DDS_TOPIC_FIXED_SIZE"; -#ifdef DDS_HAS_TYPE_DISCOVERY +#ifdef DDS_HAS_TYPELIB if (type_info) vec[len++] = "DDS_TOPIC_XTYPES_METADATA"; #else @@ -2388,7 +2388,7 @@ static int print_descriptor(FILE *fp, struct descriptor *descriptor, bool type_i if (idl_fprintf(fp, fmt, descriptor->n_opcodes, type) < 0) return -1; -#ifdef DDS_HAS_TYPE_DISCOVERY +#ifdef DDS_HAS_TYPELIB if (type_info) { fmt = ",\n" " .type_information = { .data = TYPE_INFO_CDR_%1$s, .sz = TYPE_INFO_CDR_SZ_%1$s },\n" /* CDR serialized XTypes TypeInformation object */ @@ -2663,7 +2663,7 @@ generate_descriptor( { ret = IDL_RETCODE_NO_MEMORY; goto err_print; } if (print_keys(generator->source.handle, &descriptor, inst_count) < 0) { ret = IDL_RETCODE_NO_MEMORY; goto err_print; } -#ifdef DDS_HAS_TYPE_DISCOVERY +#ifdef DDS_HAS_TYPELIB if (generator->config.c.generate_type_info && print_type_meta_ser(generator->source.handle, pstate, node) < 0) { ret = IDL_RETCODE_NO_MEMORY; goto err_print; } if (print_descriptor(generator->source.handle, &descriptor, generator->config.c.generate_type_info) < 0) diff --git a/src/tools/idlc/src/descriptor_type_meta.c b/src/tools/idlc/src/descriptor_type_meta.c index 1dcda61ad9..683632b1b9 100644 --- a/src/tools/idlc/src/descriptor_type_meta.c +++ b/src/tools/idlc/src/descriptor_type_meta.c @@ -20,6 +20,10 @@ #include "dds/ddsi/ddsi_typewrap.h" #include "dds/ddsi/ddsi_xt_typeinfo.h" #include "dds/ddsi/ddsi_xt_typemap.h" +#ifdef DDS_HAS_TYPELIB +#include "dds/ddsi/ddsi_typelib.h" +#endif + #include "dds/cdr/dds_cdrstream.h" #include "dds/ddsc/dds_opcodes.h" diff --git a/src/tools/idlc/src/idlc.c b/src/tools/idlc/src/idlc.c index e6e3a0282b..9bb7b64b74 100644 --- a/src/tools/idlc/src/idlc.c +++ b/src/tools/idlc/src/idlc.c @@ -68,7 +68,7 @@ static struct { bool werror; int help; int version; -#ifdef DDS_HAS_TYPE_DISCOVERY +#ifdef DDS_HAS_TYPELIB int no_type_info; #endif /* (emulated) command line options for mcpp */ @@ -629,7 +629,7 @@ static const idlc_option_t *compopts[] = { "Attempts to recreate directory structure matching input. " "Use without the -o option will compile IDL files in-place. " "Fail-silent if root_dir is not a parent of input" }, -#ifdef DDS_HAS_TYPE_DISCOVERY +#ifdef DDS_HAS_TYPELIB &(idlc_option_t){ IDLC_FLAG, { .flag = &config.no_type_info }, 't', "", "", "Don't generate type information in the topic descriptor" }, @@ -693,7 +693,7 @@ int main(int argc, char *argv[]) config.disable_warnings.size = 0; config.disable_warnings.count = 0; config.werror = false; -#ifdef DDS_HAS_TYPE_DISCOVERY +#ifdef DDS_HAS_TYPELIB config.no_type_info = 0; #endif @@ -784,11 +784,11 @@ int main(int argc, char *argv[]) if(idl_normalize_path(config.base_dir, &generator_config.base_dir) < 0) goto err_generate; } -#ifdef DDS_HAS_TYPE_DISCOVERY +#ifdef DDS_HAS_TYPELIB if(!config.no_type_info) generator_config.generate_type_info = true; generator_config.generate_typeinfo_typemap = generate_type_meta_ser; -#endif // DDS_HAS_TYPE_DISCOVERY +#endif // DDS_HAS_TYPELIB if (gen.generate) ret = gen.generate(pstate, &generator_config); diff --git a/src/tools/idlc/tests/CMakeLists.txt b/src/tools/idlc/tests/CMakeLists.txt index 0dc8763a75..0fcd6b4da6 100644 --- a/src/tools/idlc/tests/CMakeLists.txt +++ b/src/tools/idlc/tests/CMakeLists.txt @@ -19,7 +19,7 @@ set(sources test_common.c descriptor.c) -if(ENABLE_TYPE_DISCOVERY) +if(ENABLE_TYPELIB) list(APPEND sources ../src/descriptor_type_meta.c type_meta.c) diff --git a/src/tools/idlc/tests/type_meta.c b/src/tools/idlc/tests/type_meta.c index 21330b9250..11b07577ca 100644 --- a/src/tools/idlc/tests/type_meta.c +++ b/src/tools/idlc/tests/type_meta.c @@ -28,7 +28,7 @@ #include "CUnit/Theory.h" -#ifdef DDS_HAS_TYPE_DISCOVERY +#ifdef DDS_HAS_TYPELIB static void *calloc_no_fail (size_t count, size_t size) { @@ -1028,4 +1028,4 @@ CU_Test(idlc_type_meta, type_obj_annotations) -#endif /* DDS_HAS_TYPE_DISCOVERY */ +#endif /* DDS_HAS_TYPELIB */ diff --git a/src/tools/idlc/xtests/CMakeLists.txt b/src/tools/idlc/xtests/CMakeLists.txt index 1c92e27e63..6983b5b640 100644 --- a/src/tools/idlc/xtests/CMakeLists.txt +++ b/src/tools/idlc/xtests/CMakeLists.txt @@ -96,7 +96,7 @@ if(MSVC) set(_libs "${_libs}\\;${_windows_kit_libs}/um/${CMAKE_MSVC_ARCH}") endif() -if(ENABLE_TYPE_DISCOVERY) +if(ENABLE_TYPELIB) set(_type_meta 1) endif()