Dedup function to create unique topic names in tests

Signed-off-by: Erik Boasson <eb@ilities.com>
This commit is contained in:
Erik Boasson 2020-03-24 18:50:09 +01:00 committed by eboasson
parent 63f67ae965
commit d089ce946c
28 changed files with 133 additions and 347 deletions

View file

@ -55,7 +55,9 @@ set(ddsc_test_sources
"whc.c"
"write.c"
"write_various_types.c"
"writer.c")
"writer.c"
"test_common.c"
"test_common.h")
if(ENABLE_LIFESPAN)
list(APPEND ddsc_test_sources "lifespan.c")

View file

@ -10,7 +10,7 @@
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
#include "dds/dds.h"
#include "CUnit/Test.h"
#include "test_common.h"
CU_Test(ddsc_basic, test)
{

View file

@ -10,10 +10,7 @@
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
#include "dds/dds.h"
#include "RoundTrip.h"
#include "Space.h"
#include "test-common.h"
#include "CUnit/Test.h"
#include "test_common.h"
static dds_entity_t g_participant = 0;
static dds_entity_t g_subscriber = 0;

View file

@ -12,7 +12,6 @@
#include <stdlib.h>
#include "dds/dds.h"
#include "CUnit/Test.h"
#include "config_env.h"
#include "dds/version.h"
@ -20,6 +19,8 @@
#include "dds/ddsrt/environ.h"
#include "dds/ddsrt/heap.h"
#include "test_common.h"
#define FORCE_ENV
#define URI_VARIABLE DDS_PROJECT_NAME_NOSPACE_CAPS"_URI"

View file

@ -13,9 +13,6 @@
#include <limits.h>
#include "dds/dds.h"
#include "CUnit/Theory.h"
#include "Space.h"
#include "dds/ddsrt/process.h"
#include "dds/ddsrt/threads.h"
#include "dds/ddsrt/environ.h"
@ -24,6 +21,8 @@
#include "dds/ddsi/q_whc.h"
#include "dds__entity.h"
#include "test_common.h"
#define MAX_RUNS 4
#define WRITER_DEADLINE DDS_MSECS(50)
@ -42,15 +41,6 @@ static dds_entity_t g_remote_participant = 0;
static dds_entity_t g_remote_subscriber = 0;
static dds_entity_t g_remote_topic = 0;
static char * create_topic_name(const char *prefix, char *name, size_t size)
{
ddsrt_pid_t pid = ddsrt_getpid();
ddsrt_tid_t tid = ddsrt_gettid();
(void) snprintf(name, size, "%s_pid%"PRIdPID"_tid%"PRIdTID"", prefix, pid, tid);
return name;
}
static void sync_reader_writer(dds_entity_t participant, dds_entity_t reader, dds_entity_t writer)
{
dds_attach_t triggered;
@ -126,7 +116,7 @@ static void deadline_init(void)
g_publisher = dds_create_publisher(g_participant, NULL, NULL);
CU_ASSERT_FATAL(g_publisher > 0);
create_topic_name("ddsc_qos_deadline_test", name, sizeof name);
create_unique_topic_name("ddsc_qos_deadline_test", name, sizeof name);
g_topic = dds_create_topic(g_participant, &Space_Type1_desc, name, NULL, NULL);
CU_ASSERT_FATAL(g_topic > 0);
g_remote_topic = dds_create_topic(g_remote_participant, &Space_Type1_desc, name, NULL, NULL);

View file

@ -12,13 +12,12 @@
#include <limits.h>
#include "dds/dds.h"
#include "CUnit/Theory.h"
#include "Space.h"
#include "dds/ddsrt/misc.h"
#include "dds/ddsrt/process.h"
#include "dds/ddsrt/threads.h"
#include "test_common.h"
/**************************************************************************************************
*
* Test fixtures
@ -41,16 +40,6 @@ static void* g_samples[MAX_SAMPLES];
static Space_Type1 g_data[MAX_SAMPLES];
static dds_sample_info_t g_info[MAX_SAMPLES];
static char*
create_topic_name(const char *prefix, char *name, size_t size)
{
/* Get semi random g_topic name. */
ddsrt_pid_t pid = ddsrt_getpid();
ddsrt_tid_t tid = ddsrt_gettid();
(void) snprintf(name, size, "%s_pid%"PRIdPID"_tid%"PRIdTID"", prefix, pid, tid);
return name;
}
static void
disposing_init(void)
{
@ -69,7 +58,7 @@ disposing_init(void)
g_waitset = dds_create_waitset(g_participant);
CU_ASSERT_FATAL(g_waitset > 0);
g_topic = dds_create_topic(g_participant, &Space_Type1_desc, create_topic_name("ddsc_disposing_test", name, sizeof name), qos, NULL);
g_topic = dds_create_topic(g_participant, &Space_Type1_desc, create_unique_topic_name("ddsc_disposing_test", name, sizeof name), qos, NULL);
CU_ASSERT_FATAL(g_topic > 0);
/* Create a reader that keeps one sample on three instances. */

View file

@ -12,14 +12,12 @@
#include <limits.h>
#include "dds/dds.h"
#include "CUnit/Test.h"
#include "CUnit/Theory.h"
#include "RoundTrip.h"
#include "dds/ddsrt/misc.h"
#include "dds/ddsrt/process.h"
#include "dds/ddsrt/threads.h"
#include "test_common.h"
/**************************************************************************************************
*
* Test fixtures
@ -44,16 +42,6 @@ accept_all(const void * sample)
return true;
}
static char*
create_topic_name(const char *prefix, char *name, size_t size)
{
/* Get semi random g_topic name. */
ddsrt_pid_t pid = ddsrt_getpid();
ddsrt_tid_t tid = ddsrt_gettid();
(void) snprintf(name, size, "%s_pid%"PRIdPID"_tid%"PRIdTID"", prefix, pid, tid);
return name;
}
static void
hierarchy_init(void)
{
@ -63,7 +51,7 @@ hierarchy_init(void)
g_participant = dds_create_participant(DDS_DOMAIN_DEFAULT, NULL, NULL);
CU_ASSERT_FATAL(g_participant > 0 );
g_topic = dds_create_topic(g_participant, &RoundTripModule_DataType_desc, create_topic_name("ddsc_hierarchy_test", name, sizeof name), NULL, NULL);
g_topic = dds_create_topic(g_participant, &RoundTripModule_DataType_desc, create_unique_topic_name("ddsc_hierarchy_test", name, sizeof name), NULL, NULL);
CU_ASSERT_FATAL(g_topic > 0);
g_publisher = dds_create_publisher(g_participant, NULL, NULL);
@ -179,7 +167,7 @@ CU_Test(ddsc_entity_delete, recursive_with_deleted_topic)
/* First, create a topic and a writer with that topic. */
g_participant = dds_create_participant(DDS_DOMAIN_DEFAULT, NULL, NULL);
CU_ASSERT_FATAL(g_participant > 0);
g_topic = dds_create_topic(g_participant, &RoundTripModule_DataType_desc, create_topic_name("ddsc_hierarchy_test", name, 100), NULL, NULL);
g_topic = dds_create_topic(g_participant, &RoundTripModule_DataType_desc, create_unique_topic_name("ddsc_hierarchy_test", name, 100), NULL, NULL);
CU_ASSERT_FATAL(g_topic > 0);
g_writer = dds_create_writer(g_participant, g_topic, NULL, NULL);
CU_ASSERT_FATAL(g_writer> 0);
@ -747,7 +735,7 @@ CU_Test(ddsc_entity_implicit_publisher, deleted)
participant = dds_create_participant(DDS_DOMAIN_DEFAULT, NULL, NULL);
CU_ASSERT_FATAL(participant > 0);
topic = dds_create_topic(participant, &RoundTripModule_DataType_desc, create_topic_name("ddsc_entity_implicit_publisher_test", name, 100), NULL, NULL);
topic = dds_create_topic(participant, &RoundTripModule_DataType_desc, create_unique_topic_name("ddsc_entity_implicit_publisher_test", name, 100), NULL, NULL);
CU_ASSERT_FATAL(topic > 0);
writer = dds_create_writer(participant, topic, NULL, NULL);
@ -799,7 +787,7 @@ CU_Test(ddsc_entity_implicit_subscriber, deleted)
participant = dds_create_participant(DDS_DOMAIN_DEFAULT, NULL, NULL);
CU_ASSERT_FATAL(participant > 0);
topic = dds_create_topic(participant, &RoundTripModule_DataType_desc, create_topic_name("ddsc_entity_implicit_subscriber_test", name, 100), NULL, NULL);
topic = dds_create_topic(participant, &RoundTripModule_DataType_desc, create_unique_topic_name("ddsc_entity_implicit_subscriber_test", name, 100), NULL, NULL);
CU_ASSERT_FATAL(topic > 0);
reader = dds_create_reader(participant, topic, NULL, NULL);
@ -854,7 +842,7 @@ CU_Test(ddsc_entity_get_children, implicit_publisher)
participant = dds_create_participant(DDS_DOMAIN_DEFAULT, NULL, NULL);
CU_ASSERT_FATAL(participant > 0);
topic = dds_create_topic(participant, &RoundTripModule_DataType_desc, create_topic_name("ddsc_entity_implicit_publisher_test", name, 100), NULL, NULL);
topic = dds_create_topic(participant, &RoundTripModule_DataType_desc, create_unique_topic_name("ddsc_entity_implicit_publisher_test", name, 100), NULL, NULL);
CU_ASSERT_FATAL(topic > 0);
writer = dds_create_writer(participant, topic, NULL, NULL);
@ -898,7 +886,7 @@ CU_Test(ddsc_entity_get_children, implicit_subscriber)
participant = dds_create_participant(DDS_DOMAIN_DEFAULT, NULL, NULL);
CU_ASSERT_FATAL(participant > 0);
topic = dds_create_topic(participant, &RoundTripModule_DataType_desc, create_topic_name("ddsc_entity_implicit_subscriber_test", name, 100), NULL, NULL);
topic = dds_create_topic(participant, &RoundTripModule_DataType_desc, create_unique_topic_name("ddsc_entity_implicit_subscriber_test", name, 100), NULL, NULL);
CU_ASSERT_FATAL(topic > 0);
reader = dds_create_reader(participant, topic, NULL, NULL);
@ -942,7 +930,7 @@ CU_Test(ddsc_entity_get_parent, implicit_publisher)
participant = dds_create_participant(DDS_DOMAIN_DEFAULT, NULL, NULL);
CU_ASSERT_FATAL(participant > 0);
topic = dds_create_topic(participant, &RoundTripModule_DataType_desc, create_topic_name("ddsc_entity_implicit_publisher_promotion_test", name, 100), NULL, NULL);
topic = dds_create_topic(participant, &RoundTripModule_DataType_desc, create_unique_topic_name("ddsc_entity_implicit_publisher_promotion_test", name, 100), NULL, NULL);
CU_ASSERT_FATAL(topic > 0);
writer = dds_create_writer(participant, topic, NULL, NULL);
@ -973,7 +961,7 @@ CU_Test(ddsc_entity_get_parent, implicit_subscriber)
participant = dds_create_participant(DDS_DOMAIN_DEFAULT, NULL, NULL);
CU_ASSERT_FATAL(participant > 0);
topic = dds_create_topic(participant, &RoundTripModule_DataType_desc, create_topic_name("ddsc_entity_implicit_subscriber_promotion_test", name, 100), NULL, NULL);
topic = dds_create_topic(participant, &RoundTripModule_DataType_desc, create_unique_topic_name("ddsc_entity_implicit_subscriber_promotion_test", name, 100), NULL, NULL);
CU_ASSERT_FATAL(topic > 0);
reader = dds_create_reader(participant, topic, NULL, NULL);
@ -1005,7 +993,7 @@ CU_Test(ddsc_entity_implicit, delete_publisher)
participant = dds_create_participant(DDS_DOMAIN_DEFAULT, NULL, NULL);
CU_ASSERT_FATAL(participant > 0);
topic = dds_create_topic(participant, &RoundTripModule_DataType_desc, create_topic_name("ddsc_entity_implicit_delete_publisher", name, 100), NULL, NULL);
topic = dds_create_topic(participant, &RoundTripModule_DataType_desc, create_unique_topic_name("ddsc_entity_implicit_delete_publisher", name, 100), NULL, NULL);
CU_ASSERT_FATAL(topic > 0);
writer = dds_create_writer(participant, topic, NULL, NULL);
@ -1037,7 +1025,7 @@ CU_Test(ddsc_entity_implicit, delete_subscriber)
participant = dds_create_participant(DDS_DOMAIN_DEFAULT, NULL, NULL);
CU_ASSERT_FATAL(participant > 0);
topic = dds_create_topic(participant, &RoundTripModule_DataType_desc, create_topic_name("ddsc_entity_implicit_delete_subscriber", name, 100), NULL, NULL);
topic = dds_create_topic(participant, &RoundTripModule_DataType_desc, create_unique_topic_name("ddsc_entity_implicit_delete_subscriber", name, 100), NULL, NULL);
CU_ASSERT_FATAL(topic > 0);
reader = dds_create_reader(participant, topic, NULL, NULL);

View file

@ -11,13 +11,13 @@
*/
#include <limits.h>
#include <stdlib.h>
#include "CUnit/Theory.h"
#include "dds/dds.h"
#include "RoundTrip.h"
#include "dds/dds.h"
#include "dds/ddsrt/process.h"
#include "dds/ddsrt/threads.h"
#include "test_common.h"
/****************************************************************************
* Test globals.
****************************************************************************/
@ -56,15 +56,6 @@ static dds_instance_handle_t writer_i_hdl = 0;
/****************************************************************************
* Test initializations and teardowns.
****************************************************************************/
static char*
create_topic_name(const char *prefix, char *name, size_t size)
{
/* Get semi random g_topic name. */
ddsrt_pid_t pid = ddsrt_getpid();
ddsrt_tid_t tid = ddsrt_gettid();
(void) snprintf(name, size, "%s_pid%"PRIdPID"_tid%"PRIdTID"", prefix, pid, tid);
return name;
}
static void
init_entity_status(void)
@ -74,7 +65,7 @@ init_entity_status(void)
participant = dds_create_participant(DDS_DOMAIN_DEFAULT, NULL, NULL);
CU_ASSERT(participant > 0);
top = dds_create_topic(participant, &RoundTripModule_DataType_desc, create_topic_name("ddsc_status_test", topicName, 100), NULL, NULL);
top = dds_create_topic(participant, &RoundTripModule_DataType_desc, create_unique_topic_name("ddsc_status_test", topicName, 100), NULL, NULL);
CU_ASSERT(top > 0);
qos = dds_create_qos();

View file

@ -13,9 +13,6 @@
#include <limits.h>
#include "dds/dds.h"
#include "CUnit/Theory.h"
#include "Space.h"
#include "dds/ddsrt/process.h"
#include "dds/ddsrt/threads.h"
#include "dds/ddsi/ddsi_entity_index.h"
@ -23,6 +20,8 @@
#include "dds/ddsi/q_whc.h"
#include "dds__entity.h"
#include "test_common.h"
static dds_entity_t g_participant = 0;
static dds_entity_t g_subscriber = 0;
static dds_entity_t g_publisher = 0;
@ -33,16 +32,6 @@ static dds_entity_t g_waitset = 0;
static dds_entity_t g_rcond = 0;
static dds_entity_t g_qcond = 0;
static char*
create_topic_name(const char *prefix, char *name, size_t size)
{
/* Get semi random g_topic name. */
ddsrt_pid_t pid = ddsrt_getpid();
ddsrt_tid_t tid = ddsrt_gettid();
(void) snprintf(name, size, "%s_pid%"PRIdPID"_tid%"PRIdTID"", prefix, pid, tid);
return name;
}
static void lifespan_init(void)
{
dds_attach_t triggered;
@ -65,7 +54,7 @@ static void lifespan_init(void)
g_waitset = dds_create_waitset(g_participant);
CU_ASSERT_FATAL(g_waitset > 0);
g_topic = dds_create_topic(g_participant, &Space_Type1_desc, create_topic_name("ddsc_qos_lifespan_test", name, sizeof name), NULL, NULL);
g_topic = dds_create_topic(g_participant, &Space_Type1_desc, create_unique_topic_name("ddsc_qos_lifespan_test", name, sizeof name), NULL, NULL);
CU_ASSERT_FATAL(g_topic > 0);
dds_qset_history(qos, DDS_HISTORY_KEEP_ALL, DDS_LENGTH_UNLIMITED);

View file

@ -10,8 +10,6 @@
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
#include "dds/dds.h"
#include "RoundTrip.h"
#include "CUnit/Test.h"
#include "dds/ddsrt/cdtors.h"
#include "dds/ddsrt/misc.h"
@ -19,6 +17,8 @@
#include "dds/ddsrt/sync.h"
#include "dds/ddsrt/threads.h"
#include "test_common.h"
/****************************************************************************
* TODO: Add DDS_INCONSISTENT_TOPIC_STATUS test
* TODO: Add DDS_OFFERED/REQUESTED_DEADLINE_MISSED_STATUS test
@ -311,15 +311,6 @@ waitfor_cb(uint32_t expected)
/****************************************************************************
* Test initializations and teardowns.
****************************************************************************/
static char*
create_topic_name(const char *prefix, char *name, size_t size)
{
/* Get semi random g_topic name. */
ddsrt_pid_t pid = ddsrt_getpid();
ddsrt_tid_t tid = ddsrt_gettid();
(void) snprintf(name, size, "%s_pid%"PRIdPID"_tid%"PRIdTID"", prefix, pid, tid);
return name;
}
static void
init_triggering_base(void)
@ -340,7 +331,7 @@ init_triggering_base(void)
g_publisher = dds_create_publisher(g_participant, NULL, NULL);
CU_ASSERT_FATAL(g_publisher > 0);
g_topic = dds_create_topic(g_participant, &RoundTripModule_DataType_desc, create_topic_name("ddsc_listener_test", name, 100), NULL, NULL);
g_topic = dds_create_topic(g_participant, &RoundTripModule_DataType_desc, create_unique_topic_name("ddsc_listener_test", name, 100), NULL, NULL);
CU_ASSERT_FATAL(g_topic > 0);
g_listener = dds_create_listener(NULL);

View file

@ -13,8 +13,6 @@
#include <limits.h>
#include "dds/dds.h"
#include "CUnit/Theory.h"
#include "Space.h"
#include "config_env.h"
#include "dds/version.h"
@ -29,12 +27,13 @@
#include "dds/ddsrt/atomics.h"
#include "dds/ddsrt/time.h"
#include "test_common.h"
#define DDS_DOMAINID_PUB 0
#define DDS_DOMAINID_SUB 1
#define DDS_CONFIG_NO_PORT_GAIN "${CYCLONEDDS_URI}${CYCLONEDDS_URI:+,}<Discovery><ExternalDomainId>0</ExternalDomainId></Discovery>"
#define DDS_CONFIG_NO_PORT_GAIN_LOG "${CYCLONEDDS_URI}${CYCLONEDDS_URI:+,}<Tracing><OutputFile>cyclonedds_liveliness_tests.${CYCLONEDDS_DOMAIN_ID}.${CYCLONEDDS_PID}.log</OutputFile><Verbosity>finest</Verbosity></Tracing><Discovery><ExternalDomainId>0</ExternalDomainId></Discovery>"
uint32_t g_topic_nr = 0;
static dds_entity_t g_pub_domain = 0;
static dds_entity_t g_pub_participant = 0;
static dds_entity_t g_pub_publisher = 0;
@ -43,15 +42,6 @@ static dds_entity_t g_sub_domain = 0;
static dds_entity_t g_sub_participant = 0;
static dds_entity_t g_sub_subscriber = 0;
static char *create_topic_name(const char *prefix, uint32_t nr, char *name, size_t size)
{
/* Get unique g_topic name. */
ddsrt_pid_t pid = ddsrt_getpid();
ddsrt_tid_t tid = ddsrt_gettid();
(void)snprintf(name, size, "%s%d_pid%" PRIdPID "_tid%" PRIdTID "", prefix, nr, pid, tid);
return name;
}
static void liveliness_init(void)
{
/* Domains for pub and sub use a different domain id, but the portgain setting
@ -179,7 +169,7 @@ static void test_pmd_count(dds_liveliness_kind_t kind, uint32_t ldur, double mul
dds_sleepfor(DDS_MSECS(50));
/* topics */
create_topic_name("ddsc_liveliness_pmd_count", g_topic_nr++, name, sizeof name);
create_unique_topic_name("ddsc_liveliness_pmd_count", name, sizeof name);
CU_ASSERT_FATAL((pub_topic = dds_create_topic(g_pub_participant, &Space_Type1_desc, name, NULL, NULL)) > 0);
if (remote_reader)
CU_ASSERT_FATAL((sub_topic = dds_create_topic(g_sub_participant, &Space_Type1_desc, name, NULL, NULL)) > 0);
@ -272,7 +262,7 @@ static void test_expire_liveliness_kinds(uint32_t ldur, double mult, uint32_t wr
ldur, mult, wr_cnt_auto, wr_cnt_man_pp, wr_cnt_man_tp, remote_reader ? "remote" : "local");
/* topics */
create_topic_name("ddsc_liveliness_expire_kinds", g_topic_nr++, name, sizeof name);
create_unique_topic_name("ddsc_liveliness_expire_kinds", name, sizeof name);
CU_ASSERT_FATAL((pub_topic = dds_create_topic(g_pub_participant, &Space_Type1_desc, name, NULL, NULL)) > 0);
if (remote_reader)
CU_ASSERT_FATAL((sub_topic = dds_create_topic(g_sub_participant, &Space_Type1_desc, name, NULL, NULL)) > 0);
@ -428,7 +418,7 @@ CU_Test(ddsc_liveliness, lease_duration, .init = liveliness_init, .fini = liveli
uint32_t n;
/* topics */
create_topic_name("ddsc_liveliness_ldur", g_topic_nr++, name, sizeof name);
create_unique_topic_name("ddsc_liveliness_ldur", name, sizeof name);
CU_ASSERT_FATAL((pub_topic = dds_create_topic(g_pub_participant, &Space_Type1_desc, name, NULL, NULL)) > 0);
CU_ASSERT_FATAL((sub_topic = dds_create_topic(g_sub_participant, &Space_Type1_desc, name, NULL, NULL)) > 0);
@ -489,7 +479,7 @@ static void test_lease_duration_pwr(bool remote_reader)
printf("running test lease_duration_pwr: %s reader\n", remote_reader ? "remote" : "local");
/* topics */
create_topic_name("ddsc_liveliness_ldurpwr", g_topic_nr++, name, sizeof name);
create_unique_topic_name("ddsc_liveliness_ldurpwr", name, sizeof name);
CU_ASSERT_FATAL((pub_topic = dds_create_topic(g_pub_participant, &Space_Type1_desc, name, NULL, NULL)) > 0);
if (remote_reader)
CU_ASSERT_FATAL((sub_topic = dds_create_topic(g_sub_participant, &Space_Type1_desc, name, NULL, NULL)) > 0);
@ -571,7 +561,7 @@ static void test_create_delete_writer_stress(bool remote_reader)
printf("running test create_delete_writer_stress: %s reader\n", remote_reader ? "remote" : "local");
/* topics */
create_topic_name("ddsc_liveliness_wr_stress", g_topic_nr++, name, sizeof name);
create_unique_topic_name("ddsc_liveliness_wr_stress", name, sizeof name);
CU_ASSERT_FATAL((pub_topic = dds_create_topic(g_pub_participant, &Space_Type1_desc, name, NULL, NULL)) > 0);
if (remote_reader)
CU_ASSERT_FATAL((sub_topic = dds_create_topic(g_sub_participant, &Space_Type1_desc, name, NULL, NULL)) > 0);
@ -672,7 +662,7 @@ static void test_status_counts(bool remote_reader)
printf("running test status_counts: %s reader\n", remote_reader ? "remote" : "local");
/* topics */
create_topic_name("ddsc_liveliness_status_counts", g_topic_nr++, name, sizeof name);
create_unique_topic_name("ddsc_liveliness_status_counts", name, sizeof name);
CU_ASSERT_FATAL((pub_topic = dds_create_topic(g_pub_participant, &Space_Type1_desc, name, NULL, NULL)) > 0);
if (remote_reader)
CU_ASSERT_FATAL((sub_topic = dds_create_topic(g_sub_participant, &Space_Type1_desc, name, NULL, NULL)) > 0);
@ -772,7 +762,7 @@ static void test_assert_liveliness(uint32_t wr_cnt_auto, uint32_t wr_cnt_man_pp,
wr_cnt_auto, wr_cnt_man_pp, wr_cnt_man_tp, ldur, remote_reader ? "remote" : "local");
/* topics */
create_topic_name("ddsc_liveliness_assert", g_topic_nr++, name, sizeof name);
create_unique_topic_name("ddsc_liveliness_assert", name, sizeof name);
CU_ASSERT_FATAL((pub_topic = dds_create_topic(g_pub_participant, &Space_Type1_desc, name, NULL, NULL)) > 0);
if (remote_reader)
CU_ASSERT_FATAL((sub_topic = dds_create_topic(g_sub_participant, &Space_Type1_desc, name, NULL, NULL)) > 0);
@ -1018,7 +1008,7 @@ static void lease_duration_zero_or_one_impl (dds_duration_t sleep, dds_livelines
dds_qset_reliability(qos, DDS_RELIABILITY_RELIABLE, DDS_INFINITY);
dds_qset_history(qos, DDS_HISTORY_KEEP_ALL, 0);
create_topic_name("ddsc_liveliness_lease_duration_zero", g_topic_nr++, name, sizeof name);
create_unique_topic_name("ddsc_liveliness_lease_duration_zero", name, sizeof name);
pub_topic = dds_create_topic(g_pub_participant, &Space_Type1_desc, name, qos, NULL);
CU_ASSERT_FATAL(pub_topic > 0);
if (remote_reader)

View file

@ -13,8 +13,6 @@
#include <limits.h>
#include "dds/dds.h"
#include "CUnit/Theory.h"
#include "Space.h"
#include "config_env.h"
#include "dds/version.h"
@ -30,6 +28,8 @@
#include "dds/ddsrt/atomics.h"
#include "dds/ddsrt/time.h"
#include "test_common.h"
#define DDS_DOMAINID_PUB 0
#define DDS_DOMAINID_SUB 1
#define DDS_CONFIG_NO_PORT_GAIN "${CYCLONEDDS_URI}${CYCLONEDDS_URI:+,}<Discovery><ExternalDomainId>0</ExternalDomainId></Discovery>"
@ -167,7 +167,6 @@ static const dds_topic_descriptor_t type_ary2_desc =
.m_meta = "" /* this is on its way out anyway */
};
static uint32_t g_topic_nr = 0;
static dds_entity_t g_pub_domain = 0;
static dds_entity_t g_pub_participant = 0;
static dds_entity_t g_pub_publisher = 0;
@ -176,15 +175,6 @@ static dds_entity_t g_sub_domain = 0;
static dds_entity_t g_sub_participant = 0;
static dds_entity_t g_sub_subscriber = 0;
static char *create_topic_name (const char *prefix, uint32_t nr, char *name, size_t size)
{
/* Get unique g_topic name. */
ddsrt_pid_t pid = ddsrt_getpid();
ddsrt_tid_t tid = ddsrt_gettid();
(void) snprintf (name, size, "%s%d_pid%" PRIdPID "_tid%" PRIdTID "", prefix, nr, pid, tid);
return name;
}
static void multi_sertopic_init (void)
{
/* Domains for pub and sub use a different domain id, but the portgain setting
@ -366,7 +356,7 @@ static void ddsc_multi_sertopic_impl (dds_entity_t pp_pub, dds_entity_t pp_sub,
dds_qset_destination_order (qos, DDS_DESTINATIONORDER_BY_SOURCE_TIMESTAMP);
dds_qset_history (qos, DDS_HISTORY_KEEP_ALL, 0);
create_topic_name ("ddsc_multi_sertopic_lease_duration_zero", g_topic_nr++, name, sizeof name);
create_unique_topic_name ("ddsc_multi_sertopic_lease_duration_zero", name, sizeof name);
for (size_t i = 0; i < sizeof (pub_topics) / sizeof (pub_topics[0]); i++)
{

View file

@ -12,13 +12,12 @@
#include <limits.h>
#include "dds/dds.h"
#include "CUnit/Theory.h"
#include "Space.h"
#include "dds/ddsrt/misc.h"
#include "dds/ddsrt/process.h"
#include "dds/ddsrt/threads.h"
#include "test_common.h"
/**************************************************************************************************
*
* Test fixtures
@ -68,16 +67,6 @@ filter_mod2(const void * sample)
return (s->long_1 % 2 == 0);
}
static char*
create_topic_name(const char *prefix, char *name, size_t size)
{
/* Get semi random g_topic name. */
ddsrt_pid_t pid = ddsrt_getpid();
ddsrt_tid_t tid = ddsrt_gettid();
(void) snprintf(name, size, "%s_pid%"PRIdPID"_tid%"PRIdTID"", prefix, pid, tid);
return name;
}
static void
querycondition_init_hdepth(int hdepth)
{
@ -93,7 +82,7 @@ querycondition_init_hdepth(int hdepth)
g_waitset = dds_create_waitset(g_participant);
CU_ASSERT_FATAL(g_waitset > 0);
g_topic = dds_create_topic(g_participant, &Space_Type1_desc, create_topic_name("ddsc_querycondition_test", name, sizeof name), NULL, NULL);
g_topic = dds_create_topic(g_participant, &Space_Type1_desc, create_unique_topic_name("ddsc_querycondition_test", name, sizeof name), NULL, NULL);
CU_ASSERT_FATAL(g_topic > 0);
/* Create a reader that keeps last sample of all instances. */

View file

@ -13,13 +13,11 @@
#include <limits.h>
#include "dds/dds.h"
#include "Space.h"
#include "RoundTrip.h"
#include "CUnit/Theory.h"
#include "dds/ddsrt/process.h"
#include "dds/ddsrt/threads.h"
#include "test_common.h"
/**************************************************************************************************
*
* Test fixtures
@ -67,16 +65,6 @@ filter_mod2(const void * sample)
return (s->long_2 % 2 == 0);
}
static char*
create_topic_name(const char *prefix, char *name, size_t size)
{
/* Get semi random g_topic name. */
ddsrt_pid_t pid = ddsrt_getpid();
ddsrt_tid_t tid = ddsrt_gettid();
(void) snprintf(name, size, "%s_pid%"PRIdPID"_tid%"PRIdTID"", prefix, pid, tid);
return name;
}
static void
read_instance_init(void)
{
@ -101,7 +89,7 @@ read_instance_init(void)
g_waitset = dds_create_waitset(g_participant);
CU_ASSERT_FATAL(g_waitset > 0);
g_topic = dds_create_topic(g_participant, &Space_Type1_desc, create_topic_name("ddsc_read_instance_test", name, sizeof name), NULL, NULL);
g_topic = dds_create_topic(g_participant, &Space_Type1_desc, create_unique_topic_name("ddsc_read_instance_test", name, sizeof name), NULL, NULL);
CU_ASSERT_FATAL(g_topic > 0);
/* Create a writer that will not automatically dispose unregistered samples. */

View file

@ -10,14 +10,12 @@
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
#include "dds/dds.h"
#include "CUnit/Test.h"
#include "CUnit/Theory.h"
#include "Space.h"
#include "dds/ddsrt/misc.h"
#include "dds/ddsrt/process.h"
#include "dds/ddsrt/threads.h"
#include "test_common.h"
/**************************************************************************************************
*
* Test fixtures
@ -60,16 +58,6 @@ static void* g_samples[MAX_SAMPLES];
static Space_Type1 g_data[MAX_SAMPLES];
static dds_sample_info_t g_info[MAX_SAMPLES];
static char*
create_topic_name(const char *prefix, char *name, size_t size)
{
/* Get semi random g_topic name. */
ddsrt_pid_t pid = ddsrt_getpid();
ddsrt_tid_t tid = ddsrt_gettid();
(void) snprintf(name, size, "%s_pid%"PRIdPID"_tid%"PRIdTID"", prefix, pid, tid);
return name;
}
static void
readcondition_init(void)
{
@ -85,7 +73,7 @@ readcondition_init(void)
g_waitset = dds_create_waitset(g_participant);
CU_ASSERT_FATAL(g_waitset > 0);
g_topic = dds_create_topic(g_participant, &Space_Type1_desc, create_topic_name("ddsc_readcondition_test", name, 100), NULL, NULL);
g_topic = dds_create_topic(g_participant, &Space_Type1_desc, create_unique_topic_name("ddsc_readcondition_test", name, 100), NULL, NULL);
CU_ASSERT_FATAL(g_topic > 0);
/* Create a reader that keeps last sample of all instances. */

View file

@ -13,14 +13,12 @@
#include <limits.h>
#include "dds/dds.h"
#include "Space.h"
#include "RoundTrip.h"
#include "CUnit/Theory.h"
#include "dds/ddsrt/misc.h"
#include "dds/ddsrt/process.h"
#include "dds/ddsrt/threads.h"
#include "test_common.h"
/**************************************************************************************************
*
* Test fixtures
@ -64,16 +62,6 @@ static void* g_samples[MAX_SAMPLES];
static Space_Type1 g_data[MAX_SAMPLES];
static dds_sample_info_t g_info[MAX_SAMPLES];
static char*
create_topic_name(const char *prefix, char *name, size_t size)
{
/* Get semi random g_topic name. */
ddsrt_pid_t pid = ddsrt_getpid();
ddsrt_tid_t tid = ddsrt_gettid();
(void) snprintf(name, size, "%s_pid%"PRIdPID"_tid%"PRIdTID"", prefix, pid, tid);
return name;
}
static void
reader_init(void)
{
@ -94,7 +82,7 @@ reader_init(void)
g_waitset = dds_create_waitset(g_participant);
CU_ASSERT_FATAL(g_waitset > 0);
g_topic = dds_create_topic(g_participant, &Space_Type1_desc, create_topic_name("ddsc_reader_test", name, sizeof name), NULL, NULL);
g_topic = dds_create_topic(g_participant, &Space_Type1_desc, create_unique_topic_name("ddsc_reader_test", name, sizeof name), NULL, NULL);
CU_ASSERT_FATAL(g_topic > 0);
/* Create a reader that keeps last sample of all instances. */
@ -306,7 +294,7 @@ CU_Test(ddsc_reader_create, participant_mismatch)
sub1 = dds_create_subscriber(par1, NULL, NULL);
CU_ASSERT_FATAL(sub1 > 0);
top2 = dds_create_topic(par2, &Space_Type1_desc, create_topic_name("ddsc_reader_participant_mismatch", name, sizeof name), NULL, NULL);
top2 = dds_create_topic(par2, &Space_Type1_desc, create_unique_topic_name("ddsc_reader_participant_mismatch", name, sizeof name), NULL, NULL);
CU_ASSERT_FATAL(top2 > 0);
/* Create reader with participant mismatch. */
@ -2512,7 +2500,7 @@ CU_Test(ddsc_take_mask, take_instance_last_sample)
CU_ASSERT_FATAL(g_participant > 0);
g_waitset = dds_create_waitset(g_participant);
CU_ASSERT_FATAL(g_waitset > 0);
g_topic = dds_create_topic(g_participant, &Space_Type1_desc, create_topic_name("ddsc_reader_test", name, 100), NULL, NULL);
g_topic = dds_create_topic(g_participant, &Space_Type1_desc, create_unique_topic_name("ddsc_reader_test", name, 100), NULL, NULL);
CU_ASSERT_FATAL(g_topic > 0);
g_reader = dds_create_reader(g_participant, g_topic, g_qos, NULL);
CU_ASSERT_FATAL(g_reader > 0);

View file

@ -13,13 +13,11 @@
#include <limits.h>
#include "dds/dds.h"
#include "Space.h"
#include "RoundTrip.h"
#include "CUnit/Theory.h"
#include "dds/ddsrt/process.h"
#include "dds/ddsrt/threads.h"
#include "test_common.h"
/**************************************************************************************************
*
* Test fixtures
@ -83,16 +81,6 @@ static void* g_samples[MAX_SAMPLES];
static Space_Type1 g_data[MAX_SAMPLES];
static dds_sample_info_t g_info[MAX_SAMPLES];
static char*
create_topic_name(const char *prefix, char *name, size_t size)
{
/* Get semi random g_topic name. */
ddsrt_pid_t pid = ddsrt_getpid();
ddsrt_tid_t tid = ddsrt_gettid();
(void) snprintf(name, size, "%s_pid%"PRIdPID"_tid%"PRIdTID"", prefix, pid, tid);
return name;
}
static bool
filter_init(const void * sample)
{
@ -140,7 +128,7 @@ reader_iterator_init(void)
g_waitset = dds_create_waitset(g_participant);
CU_ASSERT_FATAL(g_waitset > 0);
g_topic = dds_create_topic(g_participant, &Space_Type1_desc, create_topic_name("ddsc_read_iterator_test", name, sizeof name), NULL, NULL);
g_topic = dds_create_topic(g_participant, &Space_Type1_desc, create_unique_topic_name("ddsc_read_iterator_test", name, sizeof name), NULL, NULL);
CU_ASSERT_FATAL(g_topic > 0);
/* Create a writer that will not automatically dispose unregistered samples. */
@ -459,7 +447,8 @@ CU_Test(ddsc_read_next_wl, reader, .init=reader_iterator_init, .fini=reader_iter
CU_ASSERT_EQUAL_FATAL(cnt, RDR_NOT_READ_CNT);
CU_ASSERT_EQUAL_FATAL(cntinv, RDR_INV_READ_CNT);
ret = dds_return_loan(g_reader, g_loans, ret);
/* return_loan 3rd arg should be in [highest count ever returned, read limit] */
ret = dds_return_loan(g_reader, g_loans, 1);
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
/* All samples should still be available. */
@ -683,7 +672,8 @@ CU_Test(ddsc_take_next_wl, reader, .init=reader_iterator_init, .fini=reader_iter
CU_ASSERT_EQUAL_FATAL(cnt, RDR_NOT_READ_CNT);
CU_ASSERT_EQUAL_FATAL(cntinv, RDR_INV_READ_CNT);
ret = dds_return_loan(g_reader, g_loans, ret);
/* return_loan 3rd arg should be in [highest count ever returned, read limit] */
ret = dds_return_loan(g_reader, g_loans, 1);
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_OK);
/* All samples should still be available. */

View file

@ -12,14 +12,12 @@
#include <assert.h>
#include "dds/dds.h"
#include "CUnit/Test.h"
#include "CUnit/Theory.h"
#include "Space.h"
#include "dds/ddsrt/misc.h"
#include "dds/ddsrt/process.h"
#include "dds/ddsrt/threads.h"
#include "test_common.h"
/**************************************************************************************************
*
* Test fixtures
@ -41,16 +39,6 @@ static dds_time_t g_present = 0;
static void* g_samples[MAX_SAMPLES];
static Space_Type1 g_data[MAX_SAMPLES];
static char*
create_topic_name(const char *prefix, char *name, size_t size)
{
/* Get semi random g_topic name. */
ddsrt_pid_t pid = ddsrt_getpid();
ddsrt_tid_t tid = ddsrt_gettid();
(void) snprintf(name, size, "%s_pid%"PRIdPID"_tid%"PRIdTID"", prefix, pid, tid);
return name;
}
static void
registering_init(void)
{
@ -69,7 +57,7 @@ registering_init(void)
g_waitset = dds_create_waitset(g_participant);
CU_ASSERT_FATAL(g_waitset > 0);
g_topic = dds_create_topic(g_participant, &Space_Type1_desc, create_topic_name("ddsc_registering_test", name, sizeof name), qos, NULL);
g_topic = dds_create_topic(g_participant, &Space_Type1_desc, create_unique_topic_name("ddsc_registering_test", name, sizeof name), qos, NULL);
CU_ASSERT_FATAL(g_topic > 0);
/* Create a reader that keeps one sample on three instances. */

View file

@ -13,13 +13,11 @@
#include <limits.h>
#include "dds/dds.h"
#include "Space.h"
#include "RoundTrip.h"
#include "CUnit/Theory.h"
#include "dds/ddsrt/process.h"
#include "dds/ddsrt/threads.h"
#include "test_common.h"
/**************************************************************************************************
*
* Test fixtures
@ -67,16 +65,6 @@ filter_mod2(const void * sample)
return (s->long_2 % 2 == 0);
}
static char*
create_topic_name(const char *prefix, char *name, size_t size)
{
/* Get semi random g_topic name. */
ddsrt_pid_t pid = ddsrt_getpid();
ddsrt_tid_t tid = ddsrt_gettid();
(void) snprintf(name, size, "%s_pid%"PRIdPID"_tid%"PRIdTID"", prefix, pid, tid);
return name;
}
static void
take_instance_init(void)
{
@ -101,7 +89,7 @@ take_instance_init(void)
g_waitset = dds_create_waitset(g_participant);
CU_ASSERT_FATAL(g_waitset > 0);
g_topic = dds_create_topic(g_participant, &Space_Type1_desc, create_topic_name("ddsc_take_instance_test", name, sizeof name), NULL, NULL);
g_topic = dds_create_topic(g_participant, &Space_Type1_desc, create_unique_topic_name("ddsc_take_instance_test", name, sizeof name), NULL, NULL);
CU_ASSERT_FATAL(g_topic > 0);
/* Create a writer that will not automatically dispose unregistered samples. */

View file

@ -1,31 +0,0 @@
/*
* Copyright(c) 2006 to 2018 ADLINK Technology Limited 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 "dds/dds.h"
const char*
entity_kind_str(dds_entity_t ent) {
if(ent <= 0) {
return "(ERROR)";
}
switch(ent & DDS_ENTITY_KIND_MASK) {
case DDS_KIND_TOPIC: return "Topic";
case DDS_KIND_PARTICIPANT: return "Participant";
case DDS_KIND_READER: return "Reader";
case DDS_KIND_WRITER: return "Writer";
case DDS_KIND_SUBSCRIBER: return "Subscriber";
case DDS_KIND_PUBLISHER: return "Publisher";
case DDS_KIND_COND_READ: return "ReadCondition";
case DDS_KIND_COND_QUERY: return "QueryCondition";
case DDS_KIND_WAITSET: return "WaitSet";
default: return "(INVALID_ENTITY)";
}
}

View file

@ -0,0 +1,26 @@
/*
* Copyright(c) 2006 to 2018 ADLINK Technology Limited 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 "dds/dds.h"
#include "dds/ddsrt/atomics.h"
#include "dds/ddsrt/process.h"
#include "dds/ddsrt/threads.h"
#include "test_common.h"
char *create_unique_topic_name (const char *prefix, char *name, size_t size)
{
static ddsrt_atomic_uint32_t count = DDSRT_ATOMIC_UINT64_INIT (0);
const ddsrt_pid_t pid = ddsrt_getpid();
const ddsrt_tid_t tid = ddsrt_gettid();
const uint32_t nr = ddsrt_atomic_inc32_nv (&count);
(void) snprintf (name, size, "%s%"PRIu32"_pid%" PRIdPID "_tid%" PRIdTID "", prefix, nr, pid, tid);
return name;
}

View file

@ -1,5 +1,5 @@
/*
* Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
* Copyright(c) 2006 to 2020 ADLINK Technology Limited 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
@ -12,6 +12,16 @@
#ifndef _TEST_COMMON_H_
#define _TEST_COMMON_H_
const char *entity_kind_str(dds_entity_t ent);
#include <stdint.h>
#include <stddef.h>
#include "CUnit/Test.h"
#include "CUnit/Theory.h"
#include "Space.h"
#include "RoundTrip.h"
/* Get unique g_topic name on each invocation. */
char *create_unique_topic_name (const char *prefix, char *name, size_t size);
#endif /* _TEST_COMMON_H_ */

View file

@ -10,13 +10,12 @@
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
#include "dds/dds.h"
#include "RoundTrip.h"
#include "CUnit/Theory.h"
#include "dds/ddsrt/misc.h"
#include "dds/ddsrt/process.h"
#include "dds/ddsrt/threads.h"
#include "test_common.h"
/**************************************************************************************************
*
* Test fixtures
@ -36,21 +35,11 @@ char g_topicRtmAddressName[MAX_NAME_SIZE];
char g_topicRtmDataTypeName[MAX_NAME_SIZE];
char g_nameBuffer[MAX_NAME_SIZE];
static char*
create_topic_name(const char *prefix, char *name, size_t size)
{
/* Get semi random g_topic name. */
ddsrt_pid_t pid = ddsrt_getpid();
ddsrt_tid_t tid = ddsrt_gettid();
(void) snprintf(name, size, "%s_pid%"PRIdPID"_tid%"PRIdTID"", prefix, pid, tid);
return name;
}
static void
ddsc_topic_init(void)
{
create_topic_name("ddsc_topic_test_rtm_address", g_topicRtmAddressName, MAX_NAME_SIZE);
create_topic_name("ddsc_topic_test_rtm_datatype", g_topicRtmDataTypeName, MAX_NAME_SIZE);
create_unique_topic_name("ddsc_topic_test_rtm_address", g_topicRtmAddressName, MAX_NAME_SIZE);
create_unique_topic_name("ddsc_topic_test_rtm_datatype", g_topicRtmDataTypeName, MAX_NAME_SIZE);
g_participant = dds_create_participant(DDS_DOMAIN_DEFAULT, NULL, NULL);
CU_ASSERT_FATAL(g_participant > 0);

View file

@ -13,13 +13,11 @@
#include <limits.h>
#include "dds/dds.h"
#include "CUnit/Test.h"
#include "CUnit/Theory.h"
#include "Space.h"
#include "dds/ddsrt/process.h"
#include "dds/ddsrt/threads.h"
#include "test_common.h"
/**************************************************************************************************
*
* Test fixtures
@ -41,16 +39,6 @@ static void* g_samples[MAX_SAMPLES];
static Space_Type1 g_data[MAX_SAMPLES];
static dds_sample_info_t g_info[MAX_SAMPLES];
static char*
create_topic_name(const char *prefix, char *name, size_t size)
{
/* Get semi random g_topic name. */
ddsrt_pid_t pid = ddsrt_getpid();
ddsrt_tid_t tid = ddsrt_gettid();
(void) snprintf(name, size, "%s_pid%"PRIdPID"_tid%"PRIdTID"", prefix, pid, tid);
return name;
}
static void
unregistering_init(void)
{
@ -69,7 +57,7 @@ unregistering_init(void)
g_waitset = dds_create_waitset(g_participant);
CU_ASSERT_FATAL(g_waitset > 0);
g_topic = dds_create_topic(g_participant, &Space_Type1_desc, create_topic_name("ddsc_unregistering_test", name, 100), qos, NULL);
g_topic = dds_create_topic(g_participant, &Space_Type1_desc, create_unique_topic_name("ddsc_unregistering_test", name, 100), qos, NULL);
CU_ASSERT_FATAL(g_topic > 0);
/* Create a reader that keeps one sample on three instances. */
@ -616,7 +604,7 @@ CU_Test(ddsc_unregister_instance_ih_ts, unregistering_instance)
/* Create a writer that WILL automatically dispose unregistered samples. */
g_participant = dds_create_participant(DDS_DOMAIN_DEFAULT, NULL, NULL);
CU_ASSERT_FATAL(g_participant > 0);
g_topic = dds_create_topic(g_participant, &Space_Type1_desc, create_topic_name("ddsc_unregistering_instance_test", name, 100), NULL, NULL);
g_topic = dds_create_topic(g_participant, &Space_Type1_desc, create_unique_topic_name("ddsc_unregistering_instance_test", name, 100), NULL, NULL);
CU_ASSERT_FATAL(g_topic > 0);
g_writer = dds_create_writer(g_participant, g_topic, NULL, NULL);
CU_ASSERT_FATAL(g_writer > 0);

View file

@ -15,7 +15,7 @@
#include "dds/dds.h"
#include "RoundTrip.h"
#include "test-common.h"
#include "test_common.h"
static dds_entity_t e[8];

View file

@ -13,9 +13,6 @@
#include <limits.h>
#include "dds/dds.h"
#include "CUnit/Theory.h"
#include "RoundTrip.h"
#include "dds/ddsrt/cdtors.h"
#include "dds/ddsrt/misc.h"
#include "dds/ddsrt/process.h"
@ -23,6 +20,8 @@
#include "dds/ddsrt/atomics.h"
#include "dds/ddsrt/time.h"
#include "test_common.h"
/**************************************************************************************************
*
* Some thread related convenience stuff.
@ -63,17 +62,6 @@ static dds_entity_t subscriber = 0;
static dds_entity_t readcond = 0;
static char*
create_topic_name(const char *prefix, char *name, size_t size)
{
/* Get semi random g_topic name. */
ddsrt_pid_t pid = ddsrt_getpid();
ddsrt_tid_t tid = ddsrt_gettid();
(void) snprintf(name, size, "%s_pid%"PRIdPID"_tid%"PRIdTID"", prefix, pid, tid);
return name;
}
static void
ddsc_waitset_basic_init(void)
{
@ -109,7 +97,7 @@ ddsc_waitset_init(void)
subscriber = dds_create_subscriber(participant, NULL, NULL);
CU_ASSERT_FATAL(subscriber > 0);
topic = dds_create_topic(participant, &RoundTripModule_DataType_desc, create_topic_name("ddsc_waitset_test", name, sizeof name), NULL, NULL);
topic = dds_create_topic(participant, &RoundTripModule_DataType_desc, create_unique_topic_name("ddsc_waitset_test", name, sizeof name), NULL, NULL);
CU_ASSERT_FATAL(topic > 0);
reader = dds_create_reader(subscriber, topic, NULL, NULL);

View file

@ -13,9 +13,6 @@
#include <limits.h>
#include "dds/dds.h"
#include "CUnit/Theory.h"
#include "Space.h"
#include "dds/ddsrt/process.h"
#include "dds/ddsrt/threads.h"
#include "dds/ddsrt/environ.h"
@ -24,6 +21,8 @@
#include "dds/ddsi/q_whc.h"
#include "dds__entity.h"
#include "test_common.h"
#define DDS_DOMAINID_PUB 0
#define DDS_DOMAINID_SUB 1
#define DDS_CONFIG_NO_PORT_GAIN "${CYCLONEDDS_URI}${CYCLONEDDS_URI:+,}<Discovery><ExternalDomainId>0</ExternalDomainId></Discovery>"
@ -32,7 +31,6 @@
#define SAMPLE_COUNT 5
#define DEADLINE_DURATION DDS_MSECS(1)
static uint32_t g_topic_nr = 0;
static dds_entity_t g_domain = 0;
static dds_entity_t g_participant = 0;
static dds_entity_t g_subscriber = 0;
@ -42,15 +40,6 @@ static dds_entity_t g_remote_domain = 0;
static dds_entity_t g_remote_participant = 0;
static dds_entity_t g_remote_subscriber = 0;
static char *create_topic_name (const char *prefix, uint32_t nr, char *name, size_t size)
{
/* Get unique g_topic name. */
ddsrt_pid_t pid = ddsrt_getpid ();
ddsrt_tid_t tid = ddsrt_gettid ();
(void) snprintf (name, size, "%s%d_pid%" PRIdPID "_tid%" PRIdTID "", prefix, nr, pid, tid);
return name;
}
static void whc_init(void)
{
/* Domains for pub and sub use a different domain id, but the portgain setting
@ -177,7 +166,7 @@ static void test_whc_end_state(dds_durability_kind_t d, dds_reliability_kind_t r
dds_qset_deadline (g_qos, dl ? DEADLINE_DURATION : DDS_INFINITY);
dds_qset_durability_service (g_qos, 0, dh, dh == KA ? 0 : dhd, DDS_LENGTH_UNLIMITED, DDS_LENGTH_UNLIMITED, DDS_LENGTH_UNLIMITED);
create_topic_name ("ddsc_whc_end_state_test", g_topic_nr++, name, sizeof name);
create_unique_topic_name ("ddsc_whc_end_state_test", name, sizeof name);
topic = dds_create_topic (g_participant, k ? &Space_Type1_desc : &Space_Type3_desc, name, NULL, NULL);
CU_ASSERT_FATAL(topic > 0);
remote_topic = dds_create_topic (g_remote_participant, k ? &Space_Type1_desc : &Space_Type3_desc, name, NULL, NULL);

View file

@ -13,19 +13,18 @@
#include <limits.h>
#include "dds/dds.h"
#include "CUnit/Theory.h"
#include "WriteTypes.h"
#include "dds/ddsrt/process.h"
#include "dds/ddsrt/threads.h"
#include "dds/ddsrt/environ.h"
#include "test_common.h"
#include "WriteTypes.h"
#define DDS_DOMAINID_PUB 0
#define DDS_DOMAINID_SUB 1
#define DDS_CONFIG_NO_PORT_GAIN "${CYCLONEDDS_URI}${CYCLONEDDS_URI:+,}<Discovery><ExternalDomainId>0</ExternalDomainId></Discovery>"
#define DDS_CONFIG_NO_PORT_GAIN_LOG "${CYCLONEDDS_URI}${CYCLONEDDS_URI:+,}<Tracing><OutputFile>cyclonedds_writetypes_various.${CYCLONEDDS_DOMAIN_ID}.${CYCLONEDDS_PID}.log</OutputFile><Verbosity>finest</Verbosity></Tracing><Discovery><ExternalDomainId>0</ExternalDomainId></Discovery>"
static uint32_t g_topic_nr = 0;
static dds_entity_t g_pub_domain = 0;
static dds_entity_t g_pub_participant = 0;
static dds_entity_t g_pub_publisher = 0;
@ -34,15 +33,6 @@ static dds_entity_t g_sub_domain = 0;
static dds_entity_t g_sub_participant = 0;
static dds_entity_t g_sub_subscriber = 0;
static char *create_topic_name (const char *prefix, uint32_t nr, char *name, size_t size)
{
/* Get unique g_topic name. */
ddsrt_pid_t pid = ddsrt_getpid ();
ddsrt_tid_t tid = ddsrt_gettid ();
(void) snprintf (name, size, "%s%d_pid%" PRIdPID "_tid%" PRIdTID "", prefix, nr, pid, tid);
return name;
}
static void writetypes_init(void)
{
/* Domains for pub and sub use a different domain id, but the portgain setting
@ -152,7 +142,7 @@ CU_Theory((const dds_topic_descriptor_t *desc, compare_fn_t cmp, size_t nsamples
CU_ASSERT_FATAL (qos != NULL);
dds_qset_reliability (qos, DDS_RELIABILITY_RELIABLE, DDS_SECS (1));
dds_qset_writer_data_lifecycle (qos, false);
create_topic_name ("ddsc_writetypes_various", g_topic_nr++, name, sizeof name);
create_unique_topic_name ("ddsc_writetypes_various", name, sizeof name);
pub_topic = dds_create_topic (g_pub_participant, desc, name, qos, NULL);
CU_ASSERT_FATAL (pub_topic > 0);
sub_topic = dds_create_topic (g_sub_participant, desc, name, qos, NULL);