add torture test for read, query conditions

The "rhc" test runs a random sequence of operations (writes, reads, &c.)
through an RHC with conditions attached to it.  All possible state masks
are used, and query conditions are tried with a condition that only
tests the key value, and one that tests attribute values.  It depends on
the internal checking logic of the RHC, which is currently enabled only
in Debug builds because of the associated run-time overhead.

Signed-off-by: Erik Boasson <eb@ilities.com>
This commit is contained in:
Erik Boasson 2019-02-10 18:29:21 +01:00
parent a1e827cf7e
commit 1c963b5c3b
26 changed files with 1454 additions and 198 deletions

View file

@ -18,11 +18,11 @@
extern "C" {
#endif
extern const ut_avlTreedef_t dds_domaintree_def;
extern DDS_EXPORT const ut_avlTreedef_t dds_domaintree_def;
extern dds_domain * dds_domain_create (dds_domainid_t id);
extern void dds_domain_free (dds_domain * domain);
extern dds_domain * dds_domain_find_locked (dds_domainid_t id);
DDS_EXPORT dds_domain * dds_domain_create (dds_domainid_t id);
DDS_EXPORT void dds_domain_free (dds_domain * domain);
DDS_EXPORT dds_domain * dds_domain_find_locked (dds_domainid_t id);
#if defined (__cplusplus)
}

View file

@ -19,7 +19,8 @@
extern "C" {
#endif
_Check_return_ dds_entity_t
_Check_return_
DDS_EXPORT dds_entity_t
dds_entity_init(
_In_ dds_entity * e,
_When_(kind != DDS_KIND_PARTICIPANT, _Notnull_)
@ -30,10 +31,10 @@ dds_entity_init(
_In_opt_ const dds_listener_t *listener,
_In_ uint32_t mask);
void
DDS_EXPORT void
dds_entity_add_ref(
_In_ dds_entity *e);
void
DDS_EXPORT void
dds_entity_add_ref_nolock(
_In_ dds_entity *e);
@ -56,82 +57,82 @@ dds_entity_add_ref_nolock(
qualifier_ dds__retcode_t type_##_lock (dds_entity_t hdl, type_ **x); \
qualifier_ void type_##_unlock (type_ *x);
inline bool dds_entity_is_enabled (const dds_entity *e) {
DDS_EXPORT inline bool dds_entity_is_enabled (const dds_entity *e) {
return (e->m_flags & DDS_ENTITY_ENABLED) != 0;
}
void dds_entity_status_set (dds_entity *e, uint32_t t);
DDS_EXPORT void dds_entity_status_set (dds_entity *e, uint32_t t);
inline void dds_entity_status_reset (dds_entity *e, uint32_t t) {
DDS_EXPORT inline void dds_entity_status_reset (dds_entity *e, uint32_t t) {
e->m_trigger &= ~t;
}
inline bool dds_entity_status_match (const dds_entity *e, uint32_t t) {
DDS_EXPORT inline bool dds_entity_status_match (const dds_entity *e, uint32_t t) {
return (e->m_trigger & t) != 0;
}
inline dds_entity_kind_t dds_entity_kind (const dds_entity *e) {
DDS_EXPORT inline dds_entity_kind_t dds_entity_kind (const dds_entity *e) {
return (dds_entity_kind_t) (e->m_hdl & DDS_ENTITY_KIND_MASK);
}
inline dds_entity_kind_t dds_entity_kind_from_handle (dds_entity_t hdl) {
DDS_EXPORT inline dds_entity_kind_t dds_entity_kind_from_handle (dds_entity_t hdl) {
return (hdl > 0) ? (dds_entity_kind_t) (hdl & DDS_ENTITY_KIND_MASK) : DDS_KIND_DONTCARE;
}
void dds_entity_status_signal (dds_entity *e);
DDS_EXPORT void dds_entity_status_signal (dds_entity *e);
void dds_entity_invoke_listener (const dds_entity *entity, enum dds_status_id which, const void *vst);
DDS_EXPORT void dds_entity_invoke_listener (const dds_entity *entity, enum dds_status_id which, const void *vst);
_Check_return_ dds__retcode_t
_Check_return_ DDS_EXPORT dds__retcode_t
dds_valid_hdl(
_In_ dds_entity_t hdl,
_In_ dds_entity_kind_t kind);
_Acquires_exclusive_lock_(*e)
_Check_return_ dds__retcode_t
_Check_return_ DDS_EXPORT dds__retcode_t
dds_entity_lock(
_In_ dds_entity_t hdl,
_In_ dds_entity_kind_t kind,
_Out_ dds_entity **e);
_Releases_exclusive_lock_(e)
void
DDS_EXPORT void
dds_entity_unlock(
_Inout_ dds_entity *e);
_Check_return_ dds__retcode_t
_Check_return_ DDS_EXPORT dds__retcode_t
dds_entity_observer_register_nl(
_In_ dds_entity* observed,
_In_ dds_entity_t observer,
_In_ dds_entity_callback cb);
_Check_return_ dds__retcode_t
_Check_return_ DDS_EXPORT dds__retcode_t
dds_entity_observer_register(
_In_ dds_entity_t observed,
_In_ dds_entity_t observer,
_In_ dds_entity_callback cb);
dds__retcode_t
DDS_EXPORT dds__retcode_t
dds_entity_observer_unregister_nl(
_In_ dds_entity* observed,
_In_ dds_entity_t observer);
dds__retcode_t
DDS_EXPORT dds__retcode_t
dds_entity_observer_unregister(
_In_ dds_entity_t observed,
_In_ dds_entity_t observer);
_Pre_satisfies_(entity & DDS_ENTITY_KIND_MASK)
dds_return_t
DDS_EXPORT dds_return_t
dds_delete_impl(
_In_ dds_entity_t entity,
_In_ bool keep_if_explicit);
const char *
DDS_EXPORT const char *
dds__entity_kind_str(
_In_ dds_entity_t e);
dds_domain *
DDS_EXPORT dds_domain *
dds__entity_domain(
_In_ dds_entity* e);

View file

@ -27,21 +27,17 @@ struct ddsi_serdata;
struct ddsi_tkmap_instance;
struct proxy_writer_info;
struct rhc * dds_rhc_new (dds_reader * reader, const struct ddsi_sertopic * topic);
void dds_rhc_free (struct rhc * rhc);
void dds_rhc_fini (struct rhc * rhc);
DDS_EXPORT struct rhc *dds_rhc_new (dds_reader *reader, const struct ddsi_sertopic *topic);
DDS_EXPORT void dds_rhc_free (struct rhc *rhc);
DDS_EXPORT void dds_rhc_fini (struct rhc *rhc);
uint32_t dds_rhc_lock_samples (struct rhc * rhc);
DDS_EXPORT uint32_t dds_rhc_lock_samples (struct rhc *rhc);
DDS_EXPORT bool dds_rhc_store
(
struct rhc * __restrict rhc, const struct proxy_writer_info * __restrict pwr_info,
struct ddsi_serdata * __restrict sample, struct ddsi_tkmap_instance * __restrict tk
);
void dds_rhc_unregister_wr (struct rhc * __restrict rhc, const struct proxy_writer_info * __restrict pwr_info);
void dds_rhc_relinquish_ownership (struct rhc * __restrict rhc, const uint64_t wr_iid);
DDS_EXPORT bool dds_rhc_store (struct rhc * __restrict rhc, const struct proxy_writer_info * __restrict pwr_info, struct ddsi_serdata * __restrict sample, struct ddsi_tkmap_instance * __restrict tk);
DDS_EXPORT void dds_rhc_unregister_wr (struct rhc * __restrict rhc, const struct proxy_writer_info * __restrict pwr_info);
DDS_EXPORT void dds_rhc_relinquish_ownership (struct rhc * __restrict rhc, const uint64_t wr_iid);
int
DDS_EXPORT int
dds_rhc_read(
struct rhc *rhc,
bool lock,
@ -51,7 +47,7 @@ dds_rhc_read(
uint32_t mask,
dds_instance_handle_t handle,
dds_readcond *cond);
int
DDS_EXPORT int
dds_rhc_take(
struct rhc *rhc,
bool lock,
@ -62,15 +58,12 @@ dds_rhc_take(
dds_instance_handle_t handle,
dds_readcond *cond);
void dds_rhc_set_qos (struct rhc * rhc, const struct nn_xqos * qos);
DDS_EXPORT void dds_rhc_set_qos (struct rhc * rhc, const struct nn_xqos * qos);
bool dds_rhc_add_readcondition (dds_readcond * cond);
void dds_rhc_remove_readcondition (dds_readcond * cond);
DDS_EXPORT bool dds_rhc_add_readcondition (dds_readcond * cond);
DDS_EXPORT void dds_rhc_remove_readcondition (dds_readcond * cond);
bool dds_rhc_add_waitset (dds_readcond * cond, dds_waitset * waitset, dds_attach_t x);
int dds_rhc_remove_waitset (dds_readcond * cond, dds_waitset * waitset);
int dds_rhc_takecdr
DDS_EXPORT int dds_rhc_takecdr
(
struct rhc *rhc, bool lock, struct ddsi_serdata **values, dds_sample_info_t *info_seq,
uint32_t max_samples, unsigned sample_states,

View file

@ -21,8 +21,8 @@ extern "C" {
DEFINE_ENTITY_LOCK_UNLOCK(inline, dds_topic, DDS_KIND_TOPIC)
extern struct ddsi_sertopic * dds_topic_lookup (dds_domain * domain, const char * name);
extern void dds_topic_free (dds_domainid_t domainid, struct ddsi_sertopic * st);
DDS_EXPORT struct ddsi_sertopic * dds_topic_lookup (dds_domain * domain, const char * name);
DDS_EXPORT void dds_topic_free (dds_domainid_t domainid, struct ddsi_sertopic * st);
#ifndef DDS_TOPIC_INTERN_FILTER_FN_DEFINED
#define DDS_TOPIC_INTERN_FILTER_FN_DEFINED

View file

@ -303,7 +303,7 @@ char * dds_stream_reuse_string
}
else
{
if ((str == NULL) || (strlen (str) < length))
if ((str == NULL) || (strlen (str) + 1 < length))
{
str = dds_realloc (str, length);
}

View file

@ -50,8 +50,9 @@ set(ddsc_test_sources
"writer.c")
add_cunit_executable(cunit_ddsc ${ddsc_test_sources})
target_include_directories(cunit_ddsc PRIVATE
"$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/src/include/>")
target_include_directories(
cunit_ddsc PRIVATE
"$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/src/include/>")
target_link_libraries(cunit_ddsc RoundTrip Space TypesArrayKey ddsc OSAPI)
# Setup environment for config-tests