Rearrange and fixup abstraction layer
- Replace os_result by dds_retcode_t and move DDS return code defines down. Eliminates the need to convert between different return code types. - Move dds_time_t down and remove os_time. Eliminates the need to convert between different time representations and reduces code duplication. - Remove use of Microsoft source-code annotation language (SAL). SAL annotations are Microsoft specific and not very well documented. This makes it very difficult for contributers to write. - Rearrange the abstraction layer to be feature-based. The previous layout falsely assumed that the operating system dictates which implementation is best suited. For general purpose operating systems this is mostly true, but embedded targets require a slightly different approach and may not even offer all features. The new layout makes it possible to mix-and-match feature implementations and allows for features to not be implemented at all. - Replace the os prefix by ddsrt to avoid name collisions. - Remove various portions of unused and unwanted code. - Export thread names on all supported platforms. - Return native thread identifier on POSIX compatible platforms. - Add timed wait for condition variables that takes an absolute time. - Remove system abstraction for errno. The os_getErrno and os_setErrno were incorrect. Functions that might fail now simply return a DDS return code instead. - Remove thread-specific memory abstraction. os_threadMemGet and accompanying functions were a mess and their use has been eliminated by other changes in this commit. - Replace attribute (re)defines by ddsrt_ prefixed equivalents to avoid name collisions and problems with faulty __nonnull__ attributes. Signed-off-by: Jeroen Koekkoek <jeroen@koekkoek.nl>
This commit is contained in:
parent
318968f40f
commit
cd6742ee12
439 changed files with 22117 additions and 28782 deletions
|
|
@ -23,7 +23,6 @@ set(ddsc_test_sources
|
|||
"entity_api.c"
|
||||
"entity_hierarchy.c"
|
||||
"entity_status.c"
|
||||
"err.c"
|
||||
"file_id.c"
|
||||
"instance_get_key.c"
|
||||
"listener.c"
|
||||
|
|
@ -53,7 +52,7 @@ add_cunit_executable(cunit_ddsc ${ddsc_test_sources})
|
|||
target_include_directories(
|
||||
cunit_ddsc PRIVATE
|
||||
"$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/src/include/>")
|
||||
target_link_libraries(cunit_ddsc RoundTrip Space TypesArrayKey ddsc OSAPI)
|
||||
target_link_libraries(cunit_ddsc PRIVATE RoundTrip Space TypesArrayKey ddsc)
|
||||
|
||||
# Setup environment for config-tests
|
||||
get_test_property(CUnit_ddsc_config_simple_udp ENVIRONMENT CUnit_ddsc_config_simple_udp_env)
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
*
|
||||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||
*/
|
||||
#include "ddsc/dds.h"
|
||||
#include "dds/dds.h"
|
||||
#include "CUnit/Test.h"
|
||||
|
||||
CU_Test(ddsc_basic, test)
|
||||
|
|
|
|||
|
|
@ -9,13 +9,11 @@
|
|||
*
|
||||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||
*/
|
||||
#include "dds/dds.h"
|
||||
#include "RoundTrip.h"
|
||||
#include "Space.h"
|
||||
#include "ddsc/dds.h"
|
||||
#include "os/os.h"
|
||||
#include "test-common.h"
|
||||
#include "CUnit/Test.h"
|
||||
#include "CUnit/Theory.h"
|
||||
|
||||
static dds_entity_t g_participant = 0;
|
||||
static dds_entity_t g_subscriber = 0;
|
||||
|
|
|
|||
|
|
@ -9,22 +9,28 @@
|
|||
*
|
||||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||
*/
|
||||
#include "ddsc/dds.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "dds/dds.h"
|
||||
#include "CUnit/Test.h"
|
||||
#include "os/os.h"
|
||||
#include "config_env.h"
|
||||
#include "ddsc/ddsc_project.h"
|
||||
|
||||
#include "dds/version.h"
|
||||
#include "dds/ddsrt/cdtors.h"
|
||||
#include "dds/ddsrt/environ.h"
|
||||
#include "dds/ddsrt/heap.h"
|
||||
|
||||
#define FORCE_ENV
|
||||
|
||||
#define URI_VARIABLE DDSC_PROJECT_NAME_NOSPACE_CAPS"_URI"
|
||||
#define URI_VARIABLE DDS_PROJECT_NAME_NOSPACE_CAPS"_URI"
|
||||
#define MAX_PARTICIPANTS_VARIABLE "MAX_PARTICIPANTS"
|
||||
|
||||
static void config__check_env(
|
||||
_In_z_ const char * env_variable,
|
||||
_In_z_ const char * expected_value)
|
||||
const char * env_variable,
|
||||
const char * expected_value)
|
||||
{
|
||||
const char * env_uri = os_getenv(env_variable);
|
||||
char * env_uri = NULL;
|
||||
ddsrt_getenv(env_variable, &env_uri);
|
||||
#if 0
|
||||
const char * const env_not_set = "Environment variable '%s' isn't set. This needs to be set to '%s' for this test to run.";
|
||||
const char * const env_not_as_expected = "Environment variable '%s' has an unexpected value: '%s' (expected: '%s')";
|
||||
|
|
@ -43,17 +49,10 @@ static void config__check_env(
|
|||
}
|
||||
|
||||
if ( !env_ok ) {
|
||||
os_result r;
|
||||
char *envstr;
|
||||
size_t len = strlen(env_variable) + strlen("=") + strlen(expected_value) + 1;
|
||||
dds_retcode_t r;
|
||||
|
||||
envstr = os_malloc(len);
|
||||
(void)snprintf(envstr, len, "%s=%s", env_variable, expected_value);
|
||||
|
||||
r = os_putenv(envstr);
|
||||
CU_ASSERT_EQUAL_FATAL(r, os_resultSuccess);
|
||||
|
||||
os_free(envstr);
|
||||
r = ddsrt_setenv(env_variable, expected_value);
|
||||
CU_ASSERT_EQUAL_FATAL(r, DDS_RETCODE_OK);
|
||||
}
|
||||
}
|
||||
#else
|
||||
|
|
@ -63,7 +62,7 @@ static void config__check_env(
|
|||
|
||||
}
|
||||
|
||||
CU_Test(ddsc_config, simple_udp, .init = os_osInit, .fini = os_osExit) {
|
||||
CU_Test(ddsc_config, simple_udp, .init = ddsrt_init, .fini = ddsrt_fini) {
|
||||
|
||||
dds_entity_t participant;
|
||||
|
||||
|
|
|
|||
|
|
@ -9,12 +9,16 @@
|
|||
*
|
||||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||
*/
|
||||
#include "ddsc/dds.h"
|
||||
#include "os/os.h"
|
||||
#include "CUnit/Test.h"
|
||||
#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"
|
||||
|
||||
/**************************************************************************************************
|
||||
*
|
||||
* Test fixtures
|
||||
|
|
@ -41,9 +45,9 @@ static char*
|
|||
create_topic_name(const char *prefix, char *name, size_t size)
|
||||
{
|
||||
/* Get semi random g_topic name. */
|
||||
os_procId pid = os_getpid();
|
||||
uintmax_t tid = os_threadIdToInteger(os_threadIdSelf());
|
||||
(void) snprintf(name, size, "%s_pid%"PRIprocId"_tid%"PRIuMAX"", prefix, pid, tid);
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
@ -146,9 +150,9 @@ CU_Test(ddsc_writedispose, deleted, .init=disposing_init, .fini=disposing_fini)
|
|||
{
|
||||
dds_return_t ret;
|
||||
dds_delete(g_writer);
|
||||
OS_WARNING_MSVC_OFF(6387); /* Disable SAL warning on intentional misuse of the API */
|
||||
DDSRT_WARNING_MSVC_OFF(6387); /* Disable SAL warning on intentional misuse of the API */
|
||||
ret = dds_writedispose(g_writer, NULL);
|
||||
OS_WARNING_MSVC_ON(6387);
|
||||
DDSRT_WARNING_MSVC_ON(6387);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_ALREADY_DELETED);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
|
@ -157,9 +161,9 @@ CU_Test(ddsc_writedispose, deleted, .init=disposing_init, .fini=disposing_fini)
|
|||
CU_Test(ddsc_writedispose, null, .init=disposing_init, .fini=disposing_fini)
|
||||
{
|
||||
dds_return_t ret;
|
||||
OS_WARNING_MSVC_OFF(6387); /* Disable SAL warning on intentional misuse of the API */
|
||||
DDSRT_WARNING_MSVC_OFF(6387); /* Disable SAL warning on intentional misuse of the API */
|
||||
ret = dds_writedispose(g_writer, NULL);
|
||||
OS_WARNING_MSVC_ON(6387);
|
||||
DDSRT_WARNING_MSVC_ON(6387);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
|
@ -173,9 +177,9 @@ CU_Theory((dds_entity_t writer), ddsc_writedispose, invalid_writers, .init=dispo
|
|||
dds_entity_t exp = DDS_RETCODE_BAD_PARAMETER * -1;
|
||||
dds_return_t ret;
|
||||
|
||||
OS_WARNING_MSVC_OFF(6387); /* Disable SAL warning on intentional misuse of the API */
|
||||
DDSRT_WARNING_MSVC_OFF(6387); /* Disable SAL warning on intentional misuse of the API */
|
||||
ret = dds_writedispose(writer, NULL);
|
||||
OS_WARNING_MSVC_ON(6387);
|
||||
DDSRT_WARNING_MSVC_ON(6387);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), dds_err_nr(exp));
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
|
@ -187,9 +191,9 @@ CU_TheoryDataPoints(ddsc_writedispose, non_writers) = {
|
|||
CU_Theory((dds_entity_t *writer), ddsc_writedispose, non_writers, .init=disposing_init, .fini=disposing_fini)
|
||||
{
|
||||
dds_return_t ret;
|
||||
OS_WARNING_MSVC_OFF(6387); /* Disable SAL warning on intentional misuse of the API */
|
||||
DDSRT_WARNING_MSVC_OFF(6387); /* Disable SAL warning on intentional misuse of the API */
|
||||
ret = dds_writedispose(*writer, NULL);
|
||||
OS_WARNING_MSVC_ON(6387);
|
||||
DDSRT_WARNING_MSVC_ON(6387);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
|
@ -303,9 +307,9 @@ CU_Test(ddsc_writedispose_ts, deleted, .init=disposing_init, .fini=disposing_fin
|
|||
{
|
||||
dds_return_t ret;
|
||||
dds_delete(g_writer);
|
||||
OS_WARNING_MSVC_OFF(6387); /* Disable SAL warning on intentional misuse of the API */
|
||||
DDSRT_WARNING_MSVC_OFF(6387); /* Disable SAL warning on intentional misuse of the API */
|
||||
ret = dds_writedispose_ts(g_writer, NULL, g_present);
|
||||
OS_WARNING_MSVC_ON(6387);
|
||||
DDSRT_WARNING_MSVC_ON(6387);
|
||||
CU_ASSERT_EQUAL(dds_err_nr(ret), DDS_RETCODE_ALREADY_DELETED);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
|
@ -314,9 +318,9 @@ CU_Test(ddsc_writedispose_ts, deleted, .init=disposing_init, .fini=disposing_fin
|
|||
CU_Test(ddsc_writedispose_ts, null, .init=disposing_init, .fini=disposing_fini)
|
||||
{
|
||||
dds_return_t ret;
|
||||
OS_WARNING_MSVC_OFF(6387); /* Disable SAL warning on intentional misuse of the API */
|
||||
DDSRT_WARNING_MSVC_OFF(6387); /* Disable SAL warning on intentional misuse of the API */
|
||||
ret = dds_writedispose_ts(g_writer, NULL, g_present);
|
||||
OS_WARNING_MSVC_ON(6387);
|
||||
DDSRT_WARNING_MSVC_ON(6387);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
|
@ -344,9 +348,9 @@ CU_Theory((dds_entity_t writer), ddsc_writedispose_ts, invalid_writers, .init=di
|
|||
dds_entity_t exp = DDS_RETCODE_BAD_PARAMETER * -1;
|
||||
dds_return_t ret;
|
||||
|
||||
OS_WARNING_MSVC_OFF(6387); /* Disable SAL warning on intentional misuse of the API */
|
||||
DDSRT_WARNING_MSVC_OFF(6387); /* Disable SAL warning on intentional misuse of the API */
|
||||
ret = dds_writedispose_ts(writer, NULL, g_present);
|
||||
OS_WARNING_MSVC_ON(6387);
|
||||
DDSRT_WARNING_MSVC_ON(6387);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), dds_err_nr(exp));
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
|
@ -358,9 +362,9 @@ CU_TheoryDataPoints(ddsc_writedispose_ts, non_writers) = {
|
|||
CU_Theory((dds_entity_t *writer), ddsc_writedispose_ts, non_writers, .init=disposing_init, .fini=disposing_fini)
|
||||
{
|
||||
dds_return_t ret;
|
||||
OS_WARNING_MSVC_OFF(6387); /* Disable SAL warning on intentional misuse of the API */
|
||||
DDSRT_WARNING_MSVC_OFF(6387); /* Disable SAL warning on intentional misuse of the API */
|
||||
ret = dds_writedispose_ts(*writer, NULL, g_present);
|
||||
OS_WARNING_MSVC_ON(6387);
|
||||
DDSRT_WARNING_MSVC_ON(6387);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
|
@ -503,9 +507,9 @@ CU_Test(ddsc_dispose, deleted, .init=disposing_init, .fini=disposing_fini)
|
|||
{
|
||||
dds_return_t ret;
|
||||
dds_delete(g_writer);
|
||||
OS_WARNING_MSVC_OFF(6387); /* Disable SAL warning on intentional misuse of the API */
|
||||
DDSRT_WARNING_MSVC_OFF(6387); /* Disable SAL warning on intentional misuse of the API */
|
||||
ret = dds_dispose(g_writer, NULL);
|
||||
OS_WARNING_MSVC_ON(6387);
|
||||
DDSRT_WARNING_MSVC_ON(6387);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_ALREADY_DELETED);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
|
@ -514,9 +518,9 @@ CU_Test(ddsc_dispose, deleted, .init=disposing_init, .fini=disposing_fini)
|
|||
CU_Test(ddsc_dispose, null, .init=disposing_init, .fini=disposing_fini)
|
||||
{
|
||||
dds_return_t ret;
|
||||
OS_WARNING_MSVC_OFF(6387); /* Disable SAL warning on intentional misuse of the API */
|
||||
DDSRT_WARNING_MSVC_OFF(6387); /* Disable SAL warning on intentional misuse of the API */
|
||||
ret = dds_dispose(g_writer, NULL);
|
||||
OS_WARNING_MSVC_ON(6387);
|
||||
DDSRT_WARNING_MSVC_ON(6387);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
|
@ -544,9 +548,9 @@ CU_Theory((dds_entity_t writer), ddsc_dispose, invalid_writers, .init=disposing_
|
|||
dds_entity_t exp = DDS_RETCODE_BAD_PARAMETER * -1;
|
||||
dds_return_t ret;
|
||||
|
||||
OS_WARNING_MSVC_OFF(6387); /* Disable SAL warning on intentional misuse of the API */
|
||||
DDSRT_WARNING_MSVC_OFF(6387); /* Disable SAL warning on intentional misuse of the API */
|
||||
ret = dds_dispose(writer, NULL);
|
||||
OS_WARNING_MSVC_ON(6387);
|
||||
DDSRT_WARNING_MSVC_ON(6387);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), dds_err_nr(exp));
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
|
@ -558,9 +562,9 @@ CU_TheoryDataPoints(ddsc_dispose, non_writers) = {
|
|||
CU_Theory((dds_entity_t *writer), ddsc_dispose, non_writers, .init=disposing_init, .fini=disposing_fini)
|
||||
{
|
||||
dds_return_t ret;
|
||||
OS_WARNING_MSVC_OFF(6387); /* Disable SAL warning on intentional misuse of the API */
|
||||
DDSRT_WARNING_MSVC_OFF(6387); /* Disable SAL warning on intentional misuse of the API */
|
||||
ret = dds_dispose(*writer, NULL);
|
||||
OS_WARNING_MSVC_ON(6387);
|
||||
DDSRT_WARNING_MSVC_ON(6387);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
|
@ -658,9 +662,9 @@ CU_Test(ddsc_dispose_ts, deleted, .init=disposing_init, .fini=disposing_fini)
|
|||
{
|
||||
dds_return_t ret;
|
||||
dds_delete(g_writer);
|
||||
OS_WARNING_MSVC_OFF(6387); /* Disable SAL warning on intentional misuse of the API */
|
||||
DDSRT_WARNING_MSVC_OFF(6387); /* Disable SAL warning on intentional misuse of the API */
|
||||
ret = dds_dispose_ts(g_writer, NULL, g_present);
|
||||
OS_WARNING_MSVC_ON(6387); /* Disable SAL warning on intentional misuse of the API */
|
||||
DDSRT_WARNING_MSVC_ON(6387); /* Disable SAL warning on intentional misuse of the API */
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_ALREADY_DELETED);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
|
@ -669,9 +673,9 @@ CU_Test(ddsc_dispose_ts, deleted, .init=disposing_init, .fini=disposing_fini)
|
|||
CU_Test(ddsc_dispose_ts, null, .init=disposing_init, .fini=disposing_fini)
|
||||
{
|
||||
dds_return_t ret;
|
||||
OS_WARNING_MSVC_OFF(6387); /* Disable SAL warning on intentional misuse of the API */
|
||||
DDSRT_WARNING_MSVC_OFF(6387); /* Disable SAL warning on intentional misuse of the API */
|
||||
ret = dds_dispose_ts(g_writer, NULL, g_present);
|
||||
OS_WARNING_MSVC_ON(6387);
|
||||
DDSRT_WARNING_MSVC_ON(6387);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
|
@ -699,9 +703,9 @@ CU_Theory((dds_entity_t writer), ddsc_dispose_ts, invalid_writers, .init=disposi
|
|||
dds_entity_t exp = DDS_RETCODE_BAD_PARAMETER * -1;
|
||||
dds_return_t ret;
|
||||
|
||||
OS_WARNING_MSVC_OFF(6387); /* Disable SAL warning on intentional misuse of the API */
|
||||
DDSRT_WARNING_MSVC_OFF(6387); /* Disable SAL warning on intentional misuse of the API */
|
||||
ret = dds_dispose_ts(writer, NULL, g_present);
|
||||
OS_WARNING_MSVC_ON(6387);
|
||||
DDSRT_WARNING_MSVC_ON(6387);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), dds_err_nr(exp));
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
|
@ -713,9 +717,9 @@ CU_TheoryDataPoints(ddsc_dispose_ts, non_writers) = {
|
|||
CU_Theory((dds_entity_t *writer), ddsc_dispose_ts, non_writers, .init=disposing_init, .fini=disposing_fini)
|
||||
{
|
||||
dds_return_t ret;
|
||||
OS_WARNING_MSVC_OFF(6387); /* Disable SAL warning on intentional misuse of the API */
|
||||
DDSRT_WARNING_MSVC_OFF(6387); /* Disable SAL warning on intentional misuse of the API */
|
||||
ret = dds_dispose_ts(*writer, NULL, g_present);
|
||||
OS_WARNING_MSVC_ON(6387);
|
||||
DDSRT_WARNING_MSVC_ON(6387);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_ILLEGAL_OPERATION);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
*
|
||||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||
*/
|
||||
#include "ddsc/dds.h"
|
||||
#include "dds/dds.h"
|
||||
#include "CUnit/Test.h"
|
||||
|
||||
/* We are deliberately testing some bad arguments that SAL will complain about.
|
||||
|
|
@ -338,7 +338,7 @@ CU_Test(ddsc_entity, get_entities, .init = create_entity, .fini = delete_entity)
|
|||
CU_Test(ddsc_entity, get_domainid, .init = create_entity, .fini = delete_entity)
|
||||
{
|
||||
dds_return_t status;
|
||||
dds_domainid_t id;
|
||||
dds_domainid_t id = -1;
|
||||
|
||||
/* Check getting ID with bad parameters. */
|
||||
status = dds_get_domainid (0, NULL);
|
||||
|
|
@ -351,7 +351,7 @@ CU_Test(ddsc_entity, get_domainid, .init = create_entity, .fini = delete_entity)
|
|||
/* Get and check the domain id. */
|
||||
status = dds_get_domainid (entity, &id);
|
||||
cu_assert_status_eq(status, DDS_RETCODE_OK);
|
||||
CU_ASSERT_EQUAL_FATAL(id, 0);
|
||||
CU_ASSERT_FATAL(id != -1);
|
||||
}
|
||||
|
||||
CU_Test(ddsc_entity, delete, .init = create_entity)
|
||||
|
|
|
|||
|
|
@ -9,15 +9,16 @@
|
|||
*
|
||||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||
*/
|
||||
#include "ddsc/dds.h"
|
||||
#include "os/os.h"
|
||||
#include <limits.h>
|
||||
|
||||
#include "dds/dds.h"
|
||||
#include "CUnit/Test.h"
|
||||
#include "CUnit/Theory.h"
|
||||
#include "RoundTrip.h"
|
||||
|
||||
/* Add --verbose command line argument to get the cr_log_info traces (if there are any). */
|
||||
|
||||
|
||||
#include "dds/ddsrt/misc.h"
|
||||
#include "dds/ddsrt/process.h"
|
||||
#include "dds/ddsrt/threads.h"
|
||||
|
||||
/**************************************************************************************************
|
||||
*
|
||||
|
|
@ -47,9 +48,9 @@ static char*
|
|||
create_topic_name(const char *prefix, char *name, size_t size)
|
||||
{
|
||||
/* Get semi random g_topic name. */
|
||||
os_procId pid = os_getpid();
|
||||
uintmax_t tid = os_threadIdToInteger(os_threadIdSelf());
|
||||
(void) snprintf(name, size, "%s_pid%"PRIprocId"_tid%"PRIuMAX"", prefix, pid, tid);
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
@ -772,10 +773,10 @@ CU_Test(ddsc_entity_implicit_publisher, invalid_topic)
|
|||
CU_ASSERT_FATAL(participant > 0);
|
||||
|
||||
/* Disable SAL warning on intentional misuse of the API */
|
||||
OS_WARNING_MSVC_OFF(28020);
|
||||
DDSRT_WARNING_MSVC_OFF(28020);
|
||||
writer = dds_create_writer(participant, 0, NULL, NULL);
|
||||
/* Disable SAL warning on intentional misuse of the API */
|
||||
OS_WARNING_MSVC_ON(28020);
|
||||
DDSRT_WARNING_MSVC_ON(28020);
|
||||
CU_ASSERT_FATAL(writer < 0);
|
||||
|
||||
dds_delete(writer);
|
||||
|
|
@ -826,9 +827,9 @@ CU_Test(ddsc_entity_explicit_subscriber, invalid_topic)
|
|||
|
||||
subscriber = dds_create_subscriber(participant, NULL,NULL);
|
||||
/* Disable SAL warning on intentional misuse of the API */
|
||||
OS_WARNING_MSVC_OFF(28020);
|
||||
DDSRT_WARNING_MSVC_OFF(28020);
|
||||
reader = dds_create_reader(subscriber, 0, NULL, NULL);
|
||||
OS_WARNING_MSVC_ON(28020);
|
||||
DDSRT_WARNING_MSVC_ON(28020);
|
||||
CU_ASSERT_FATAL(reader < 0);
|
||||
|
||||
dds_delete(reader);
|
||||
|
|
|
|||
|
|
@ -9,12 +9,14 @@
|
|||
*
|
||||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||
*/
|
||||
#include <limits.h>
|
||||
#include <stdlib.h>
|
||||
#include "CUnit/Theory.h"
|
||||
#include "ddsc/dds.h"
|
||||
#include "os/os.h"
|
||||
#include "dds/dds.h"
|
||||
#include "RoundTrip.h"
|
||||
|
||||
#include "dds/ddsrt/process.h"
|
||||
#include "dds/ddsrt/threads.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Test globals.
|
||||
|
|
@ -51,9 +53,9 @@ static char*
|
|||
create_topic_name(const char *prefix, char *name, size_t size)
|
||||
{
|
||||
/* Get semi random g_topic name. */
|
||||
os_procId pid = os_getpid();
|
||||
uintmax_t tid = os_threadIdToInteger(os_threadIdSelf());
|
||||
(void) snprintf(name, size, "%s_pid%"PRIprocId"_tid%"PRIuMAX"", prefix, pid, tid);
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,32 +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 "ddsc/dds.h"
|
||||
#include "CUnit/Test.h"
|
||||
|
||||
CU_Test(ddsc_err, str)
|
||||
{
|
||||
CU_ASSERT_STRING_EQUAL(dds_err_str(1 ), "Success");
|
||||
CU_ASSERT_STRING_EQUAL(dds_err_str(-255 ), "Unknown");
|
||||
CU_ASSERT_STRING_EQUAL(dds_err_str(DDS_RETCODE_OK * -1), "Success");
|
||||
CU_ASSERT_STRING_EQUAL(dds_err_str(DDS_RETCODE_ERROR * -1), "Error");
|
||||
CU_ASSERT_STRING_EQUAL(dds_err_str(DDS_RETCODE_UNSUPPORTED * -1), "Unsupported");
|
||||
CU_ASSERT_STRING_EQUAL(dds_err_str(DDS_RETCODE_BAD_PARAMETER * -1), "Bad Parameter");
|
||||
CU_ASSERT_STRING_EQUAL(dds_err_str(DDS_RETCODE_PRECONDITION_NOT_MET * -1), "Precondition Not Met");
|
||||
CU_ASSERT_STRING_EQUAL(dds_err_str(DDS_RETCODE_OUT_OF_RESOURCES * -1), "Out Of Resources");
|
||||
CU_ASSERT_STRING_EQUAL(dds_err_str(DDS_RETCODE_NOT_ENABLED * -1), "Not Enabled");
|
||||
CU_ASSERT_STRING_EQUAL(dds_err_str(DDS_RETCODE_IMMUTABLE_POLICY * -1), "Immutable Policy");
|
||||
CU_ASSERT_STRING_EQUAL(dds_err_str(DDS_RETCODE_INCONSISTENT_POLICY * -1), "Inconsistent Policy");
|
||||
CU_ASSERT_STRING_EQUAL(dds_err_str(DDS_RETCODE_ALREADY_DELETED * -1), "Already Deleted");
|
||||
CU_ASSERT_STRING_EQUAL(dds_err_str(DDS_RETCODE_TIMEOUT * -1), "Timeout");
|
||||
CU_ASSERT_STRING_EQUAL(dds_err_str(DDS_RETCODE_NO_DATA * -1), "No Data");
|
||||
CU_ASSERT_STRING_EQUAL(dds_err_str(DDS_RETCODE_ILLEGAL_OPERATION * -1), "Illegal Operation");
|
||||
}
|
||||
|
|
@ -9,9 +9,10 @@
|
|||
*
|
||||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||
*/
|
||||
#include "ddsc/dds.h"
|
||||
#include "dds/dds.h"
|
||||
#include "CUnit/Test.h"
|
||||
#include "os/os.h"
|
||||
|
||||
#include "dds/ddsrt/misc.h"
|
||||
|
||||
CU_Test(ddsc_err, unique_file_id)
|
||||
{
|
||||
|
|
@ -21,14 +22,14 @@ CU_Test(ddsc_err, unique_file_id)
|
|||
CU_ASSERT_FATAL(participant > 0);
|
||||
|
||||
/* Disable SAL warning on intentional misuse of the API */
|
||||
OS_WARNING_MSVC_OFF(28020);
|
||||
DDSRT_WARNING_MSVC_OFF(28020);
|
||||
reader = dds_create_reader(0, 0, NULL, NULL);
|
||||
CU_ASSERT_FATAL(reader < 0);
|
||||
|
||||
writer = dds_create_writer(0, 0, NULL, NULL);
|
||||
CU_ASSERT_FATAL(writer < 0);
|
||||
|
||||
OS_WARNING_MSVC_ON(28020);
|
||||
DDSRT_WARNING_MSVC_ON(28020);
|
||||
|
||||
CU_ASSERT_NOT_EQUAL_FATAL(dds_err_file_id(reader), dds_err_file_id(writer));
|
||||
|
||||
|
|
|
|||
|
|
@ -12,10 +12,10 @@
|
|||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "CUnit/Test.h"
|
||||
|
||||
#include "os/os.h"
|
||||
#include "ddsc/dds.h"
|
||||
#include "CUnit/Test.h"
|
||||
#include "dds/dds.h"
|
||||
#include "dds/ddsrt/string.h"
|
||||
#include "RoundTrip.h"
|
||||
|
||||
static dds_entity_t participant = DDS_ENTITY_NIL;
|
||||
|
|
@ -42,7 +42,7 @@ static void setup(void)
|
|||
CU_ASSERT_FATAL(writer > 0);
|
||||
|
||||
memset(&data, 0, sizeof(data));
|
||||
data.ip = os_strdup("some data");
|
||||
data.ip = ddsrt_strdup("some data");
|
||||
CU_ASSERT_PTR_NOT_NULL_FATAL(data.ip);
|
||||
data.port = 1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,20 +9,23 @@
|
|||
*
|
||||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||
*/
|
||||
#include "ddsc/dds.h"
|
||||
#include "os/os.h"
|
||||
#include "dds/dds.h"
|
||||
#include "RoundTrip.h"
|
||||
#include "CUnit/Test.h"
|
||||
|
||||
#include "dds/ddsrt/cdtors.h"
|
||||
#include "dds/ddsrt/misc.h"
|
||||
#include "dds/ddsrt/process.h"
|
||||
#include "dds/ddsrt/sync.h"
|
||||
#include "dds/ddsrt/threads.h"
|
||||
|
||||
/****************************************************************************
|
||||
* TODO: (CHAM-279) Add DDS_INCONSISTENT_TOPIC_STATUS test
|
||||
* TODO: (CHAM-277) Add DDS_OFFERED/REQUESTED_DEADLINE_MISSED_STATUS test
|
||||
* TODO: (CHAM-278) Add DDS_LIVELINESS_LOST_STATUS test
|
||||
* TODO: Add DDS_INCONSISTENT_TOPIC_STATUS test
|
||||
* TODO: Add DDS_OFFERED/REQUESTED_DEADLINE_MISSED_STATUS test
|
||||
* TODO: Add DDS_LIVELINESS_LOST_STATUS test
|
||||
* TODO: Check DDS_REQUESTED_INCOMPATIBLE_QOS_STATUS intermittent fail (total_count != 1)
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Convenience test macros.
|
||||
****************************************************************************/
|
||||
|
|
@ -68,8 +71,8 @@ static dds_entity_t g_reader = 0;
|
|||
|
||||
static dds_listener_t *g_listener = NULL;
|
||||
static dds_qos_t *g_qos = NULL;
|
||||
static os_mutex g_mutex;
|
||||
static os_cond g_cond;
|
||||
static ddsrt_mutex_t g_mutex;
|
||||
static ddsrt_cond_t g_cond;
|
||||
|
||||
|
||||
|
||||
|
|
@ -101,12 +104,12 @@ inconsistent_topic_cb(
|
|||
const dds_inconsistent_topic_status_t status, void* arg)
|
||||
{
|
||||
(void)arg;
|
||||
os_mutexLock(&g_mutex);
|
||||
ddsrt_mutex_lock(&g_mutex);
|
||||
cb_topic = topic;
|
||||
cb_inconsistent_topic_status = status;
|
||||
cb_called |= DDS_INCONSISTENT_TOPIC_STATUS;
|
||||
os_condBroadcast(&g_cond);
|
||||
os_mutexUnlock(&g_mutex);
|
||||
ddsrt_cond_broadcast(&g_cond);
|
||||
ddsrt_mutex_unlock(&g_mutex);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -116,12 +119,12 @@ liveliness_lost_cb(
|
|||
void* arg)
|
||||
{
|
||||
(void)arg;
|
||||
os_mutexLock(&g_mutex);
|
||||
ddsrt_mutex_lock(&g_mutex);
|
||||
cb_writer = writer;
|
||||
cb_liveliness_lost_status = status;
|
||||
cb_called |= DDS_LIVELINESS_LOST_STATUS;
|
||||
os_condBroadcast(&g_cond);
|
||||
os_mutexUnlock(&g_mutex);
|
||||
ddsrt_cond_broadcast(&g_cond);
|
||||
ddsrt_mutex_unlock(&g_mutex);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -131,12 +134,12 @@ offered_deadline_missed_cb(
|
|||
void* arg)
|
||||
{
|
||||
(void)arg;
|
||||
os_mutexLock(&g_mutex);
|
||||
ddsrt_mutex_lock(&g_mutex);
|
||||
cb_writer = writer;
|
||||
cb_offered_deadline_missed_status = status;
|
||||
cb_called |= DDS_OFFERED_DEADLINE_MISSED_STATUS;
|
||||
os_condBroadcast(&g_cond);
|
||||
os_mutexUnlock(&g_mutex);
|
||||
ddsrt_cond_broadcast(&g_cond);
|
||||
ddsrt_mutex_unlock(&g_mutex);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -146,12 +149,12 @@ offered_incompatible_qos_cb(
|
|||
void* arg)
|
||||
{
|
||||
(void)arg;
|
||||
os_mutexLock(&g_mutex);
|
||||
ddsrt_mutex_lock(&g_mutex);
|
||||
cb_writer = writer;
|
||||
cb_offered_incompatible_qos_status = status;
|
||||
cb_called |= DDS_OFFERED_INCOMPATIBLE_QOS_STATUS;
|
||||
os_condBroadcast(&g_cond);
|
||||
os_mutexUnlock(&g_mutex);
|
||||
ddsrt_cond_broadcast(&g_cond);
|
||||
ddsrt_mutex_unlock(&g_mutex);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -160,11 +163,11 @@ data_on_readers_cb(
|
|||
void* arg)
|
||||
{
|
||||
(void)arg;
|
||||
os_mutexLock(&g_mutex);
|
||||
ddsrt_mutex_lock(&g_mutex);
|
||||
cb_subscriber = subscriber;
|
||||
cb_called |= DDS_DATA_ON_READERS_STATUS;
|
||||
os_condBroadcast(&g_cond);
|
||||
os_mutexUnlock(&g_mutex);
|
||||
ddsrt_cond_broadcast(&g_cond);
|
||||
ddsrt_mutex_unlock(&g_mutex);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -174,12 +177,12 @@ sample_lost_cb(
|
|||
void* arg)
|
||||
{
|
||||
(void)arg;
|
||||
os_mutexLock(&g_mutex);
|
||||
ddsrt_mutex_lock(&g_mutex);
|
||||
cb_reader = reader;
|
||||
cb_sample_lost_status = status;
|
||||
cb_called |= DDS_SAMPLE_LOST_STATUS;
|
||||
os_condBroadcast(&g_cond);
|
||||
os_mutexUnlock(&g_mutex);
|
||||
ddsrt_cond_broadcast(&g_cond);
|
||||
ddsrt_mutex_unlock(&g_mutex);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -188,11 +191,11 @@ data_available_cb(
|
|||
void* arg)
|
||||
{
|
||||
(void)arg;
|
||||
os_mutexLock(&g_mutex);
|
||||
ddsrt_mutex_lock(&g_mutex);
|
||||
cb_reader = reader;
|
||||
cb_called |= DDS_DATA_AVAILABLE_STATUS;
|
||||
os_condBroadcast(&g_cond);
|
||||
os_mutexUnlock(&g_mutex);
|
||||
ddsrt_cond_broadcast(&g_cond);
|
||||
ddsrt_mutex_unlock(&g_mutex);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -202,12 +205,12 @@ sample_rejected_cb(
|
|||
void* arg)
|
||||
{
|
||||
(void)arg;
|
||||
os_mutexLock(&g_mutex);
|
||||
ddsrt_mutex_lock(&g_mutex);
|
||||
cb_reader = reader;
|
||||
cb_sample_rejected_status = status;
|
||||
cb_called |= DDS_SAMPLE_REJECTED_STATUS;
|
||||
os_condBroadcast(&g_cond);
|
||||
os_mutexUnlock(&g_mutex);
|
||||
ddsrt_cond_broadcast(&g_cond);
|
||||
ddsrt_mutex_unlock(&g_mutex);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -217,12 +220,12 @@ liveliness_changed_cb(
|
|||
void* arg)
|
||||
{
|
||||
(void)arg;
|
||||
os_mutexLock(&g_mutex);
|
||||
ddsrt_mutex_lock(&g_mutex);
|
||||
cb_reader = reader;
|
||||
cb_liveliness_changed_status = status;
|
||||
cb_called |= DDS_LIVELINESS_CHANGED_STATUS;
|
||||
os_condBroadcast(&g_cond);
|
||||
os_mutexUnlock(&g_mutex);
|
||||
ddsrt_cond_broadcast(&g_cond);
|
||||
ddsrt_mutex_unlock(&g_mutex);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -232,12 +235,12 @@ requested_deadline_missed_cb(
|
|||
void* arg)
|
||||
{
|
||||
(void)arg;
|
||||
os_mutexLock(&g_mutex);
|
||||
ddsrt_mutex_lock(&g_mutex);
|
||||
cb_reader = reader;
|
||||
cb_requested_deadline_missed_status = status;
|
||||
cb_called |= DDS_REQUESTED_DEADLINE_MISSED_STATUS;
|
||||
os_condBroadcast(&g_cond);
|
||||
os_mutexUnlock(&g_mutex);
|
||||
ddsrt_cond_broadcast(&g_cond);
|
||||
ddsrt_mutex_unlock(&g_mutex);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -247,12 +250,12 @@ requested_incompatible_qos_cb(
|
|||
void* arg)
|
||||
{
|
||||
(void)arg;
|
||||
os_mutexLock(&g_mutex);
|
||||
ddsrt_mutex_lock(&g_mutex);
|
||||
cb_reader = reader;
|
||||
cb_requested_incompatible_qos_status = status;
|
||||
cb_called |= DDS_REQUESTED_INCOMPATIBLE_QOS_STATUS;
|
||||
os_condBroadcast(&g_cond);
|
||||
os_mutexUnlock(&g_mutex);
|
||||
ddsrt_cond_broadcast(&g_cond);
|
||||
ddsrt_mutex_unlock(&g_mutex);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -262,12 +265,12 @@ publication_matched_cb(
|
|||
void* arg)
|
||||
{
|
||||
(void)arg;
|
||||
os_mutexLock(&g_mutex);
|
||||
ddsrt_mutex_lock(&g_mutex);
|
||||
cb_writer = writer;
|
||||
cb_publication_matched_status = status;
|
||||
cb_called |= DDS_PUBLICATION_MATCHED_STATUS;
|
||||
os_condBroadcast(&g_cond);
|
||||
os_mutexUnlock(&g_mutex);
|
||||
ddsrt_cond_broadcast(&g_cond);
|
||||
ddsrt_mutex_unlock(&g_mutex);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -277,12 +280,12 @@ subscription_matched_cb(
|
|||
void* arg)
|
||||
{
|
||||
(void)arg;
|
||||
os_mutexLock(&g_mutex);
|
||||
ddsrt_mutex_lock(&g_mutex);
|
||||
cb_reader = reader;
|
||||
cb_subscription_matched_status = status;
|
||||
cb_called |= DDS_SUBSCRIPTION_MATCHED_STATUS;
|
||||
os_condBroadcast(&g_cond);
|
||||
os_mutexUnlock(&g_mutex);
|
||||
ddsrt_cond_broadcast(&g_cond);
|
||||
ddsrt_mutex_unlock(&g_mutex);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -293,13 +296,13 @@ callback_dummy(void)
|
|||
static uint32_t
|
||||
waitfor_cb(uint32_t expected)
|
||||
{
|
||||
os_time timeout = { 5, 0 };
|
||||
os_result osr = os_resultSuccess;
|
||||
os_mutexLock(&g_mutex);
|
||||
while (((cb_called & expected) != expected) && (osr == os_resultSuccess)) {
|
||||
osr = os_condTimedWait(&g_cond, &g_mutex, &timeout);
|
||||
dds_time_t timeout = 5 * DDS_NSECS_IN_SEC;
|
||||
bool signalled = true;
|
||||
ddsrt_mutex_lock(&g_mutex);
|
||||
while (((cb_called & expected) != expected) && (signalled)) {
|
||||
signalled = ddsrt_cond_waitfor(&g_cond, &g_mutex, timeout);
|
||||
}
|
||||
os_mutexUnlock(&g_mutex);
|
||||
ddsrt_mutex_unlock(&g_mutex);
|
||||
return cb_called;
|
||||
}
|
||||
|
||||
|
|
@ -312,9 +315,9 @@ static char*
|
|||
create_topic_name(const char *prefix, char *name, size_t size)
|
||||
{
|
||||
/* Get semi random g_topic name. */
|
||||
os_procId pid = os_getpid();
|
||||
uintmax_t tid = os_threadIdToInteger(os_threadIdSelf());
|
||||
(void) snprintf(name, size, "%s_pid%"PRIprocId"_tid%"PRIuMAX"", prefix, pid, tid);
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
@ -323,10 +326,10 @@ init_triggering_base(void)
|
|||
{
|
||||
char name[100];
|
||||
|
||||
os_osInit();
|
||||
ddsrt_init();
|
||||
|
||||
os_mutexInit(&g_mutex);
|
||||
os_condInit(&g_cond, &g_mutex);
|
||||
ddsrt_mutex_init(&g_mutex);
|
||||
ddsrt_cond_init(&g_cond);
|
||||
|
||||
g_participant = dds_create_participant(DDS_DOMAIN_DEFAULT, NULL, NULL);
|
||||
CU_ASSERT_FATAL(g_participant > 0);
|
||||
|
|
@ -347,6 +350,8 @@ init_triggering_base(void)
|
|||
CU_ASSERT_PTR_NOT_NULL_FATAL(g_qos);
|
||||
dds_qset_reliability(g_qos, DDS_RELIABILITY_RELIABLE, DDS_SECS(1));
|
||||
dds_qset_history(g_qos, DDS_HISTORY_KEEP_ALL, 0);
|
||||
|
||||
cb_called = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -386,9 +391,9 @@ fini_triggering_base(void)
|
|||
dds_delete_qos(g_qos);
|
||||
dds_delete_listener(g_listener);
|
||||
dds_delete(g_participant);
|
||||
os_condDestroy(&g_cond);
|
||||
os_mutexDestroy(&g_mutex);
|
||||
os_osExit();
|
||||
ddsrt_cond_destroy(&g_cond);
|
||||
ddsrt_mutex_destroy(&g_mutex);
|
||||
ddsrt_fini();
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -426,9 +431,9 @@ CU_Test(ddsc_listener, create_and_delete)
|
|||
ASSERT_CALLBACK_EQUAL(data_available, listener, DDS_LUNSET);
|
||||
|
||||
dds_delete_listener(listener);
|
||||
OS_WARNING_MSVC_OFF(6387); /* Disable SAL warning on intentional misuse of the API */
|
||||
DDSRT_WARNING_MSVC_OFF(6387); /* Disable SAL warning on intentional misuse of the API */
|
||||
dds_delete_listener(NULL);
|
||||
OS_WARNING_MSVC_ON(6387);
|
||||
DDSRT_WARNING_MSVC_ON(6387);
|
||||
}
|
||||
|
||||
CU_Test(ddsc_listener, reset)
|
||||
|
|
@ -475,11 +480,11 @@ CU_Test(ddsc_listener, copy)
|
|||
ASSERT_CALLBACK_EQUAL(sample_lost, listener2, sample_lost_cb);
|
||||
|
||||
/* Calling copy with NULL should not crash and be noops. */
|
||||
OS_WARNING_MSVC_OFF(6387); /* Disable SAL warning on intentional misuse of the API */
|
||||
DDSRT_WARNING_MSVC_OFF(6387); /* Disable SAL warning on intentional misuse of the API */
|
||||
dds_copy_listener(listener2, NULL);
|
||||
dds_copy_listener(NULL, listener1);
|
||||
dds_copy_listener(NULL, NULL);
|
||||
OS_WARNING_MSVC_ON(6387);
|
||||
DDSRT_WARNING_MSVC_ON(6387);
|
||||
|
||||
dds_delete_listener(listener1);
|
||||
dds_delete_listener(listener2);
|
||||
|
|
@ -568,7 +573,7 @@ CU_Test(ddsc_listener, getters_setters)
|
|||
dds_listener_t *listener = dds_create_listener(NULL);
|
||||
CU_ASSERT_PTR_NOT_NULL_FATAL(listener);
|
||||
|
||||
OS_WARNING_MSVC_OFF(6387); /* Disable SAL warning on intentional misuse of the API */ \
|
||||
DDSRT_WARNING_MSVC_OFF(6387); /* Disable SAL warning on intentional misuse of the API */ \
|
||||
TEST_GET_SET(listener, inconsistent_topic, inconsistent_topic_cb);
|
||||
TEST_GET_SET(listener, liveliness_lost, liveliness_lost_cb);
|
||||
TEST_GET_SET(listener, offered_deadline_missed, offered_deadline_missed_cb);
|
||||
|
|
@ -582,7 +587,7 @@ CU_Test(ddsc_listener, getters_setters)
|
|||
TEST_GET_SET(listener, publication_matched, publication_matched_cb);
|
||||
TEST_GET_SET(listener, subscription_matched, subscription_matched_cb);
|
||||
TEST_GET_SET(listener, data_available, data_available_cb);
|
||||
OS_WARNING_MSVC_ON(6387);
|
||||
DDSRT_WARNING_MSVC_ON(6387);
|
||||
|
||||
dds_delete_listener(listener);
|
||||
}
|
||||
|
|
@ -1013,8 +1018,8 @@ Test(ddsc_listener, inconsistent_topic, .init=init_triggering_base, .fini=fini_t
|
|||
|
||||
os_osInit();
|
||||
|
||||
os_mutexInit(&g_mutex);
|
||||
os_condInit(&g_cond, &g_mutex);
|
||||
ddsrt_mutex_init(&g_mutex);
|
||||
ddsrt_cond_init(&g_cond);
|
||||
|
||||
g_qos = dds_create_qos();
|
||||
cr_assert_not_null(g_qos, "Failed to create prerequisite g_qos");
|
||||
|
|
|
|||
|
|
@ -9,12 +9,13 @@
|
|||
*
|
||||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||
*/
|
||||
#include "ddsc/dds.h"
|
||||
#include "CUnit/Test.h"
|
||||
#include <os/os.h>
|
||||
#include "config_env.h"
|
||||
#include "ddsc/ddsc_project.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "dds/dds.h"
|
||||
#include "CUnit/Test.h"
|
||||
#include "config_env.h"
|
||||
#include "dds/version.h"
|
||||
#include "dds/ddsrt/environ.h"
|
||||
|
||||
#define cu_assert_status_eq(s1, s2) CU_ASSERT_EQUAL_FATAL(dds_err_nr(s1), s2)
|
||||
|
||||
|
|
@ -41,14 +42,14 @@ CU_Test(ddsc_participant, create_and_delete) {
|
|||
|
||||
|
||||
/* Test for creating participant with no configuration file */
|
||||
CU_Test(ddsc_participant, create_with_no_conf_no_env) {
|
||||
CU_Test(ddsc_participant, create_with_no_conf_no_env)
|
||||
{
|
||||
dds_entity_t participant, participant2, participant3;
|
||||
dds_return_t status;
|
||||
dds_domainid_t domain_id;
|
||||
dds_domainid_t valid_domain=3;
|
||||
|
||||
const char * env_uri = os_getenv(DDSC_PROJECT_NAME_NOSPACE_CAPS"_URI");
|
||||
CU_ASSERT_EQUAL_FATAL(env_uri, NULL);
|
||||
ddsrt_unsetenv(DDS_PROJECT_NAME_NOSPACE_CAPS"_URI");
|
||||
|
||||
//invalid domain
|
||||
participant = dds_create_participant (-2, NULL, NULL);
|
||||
|
|
@ -70,8 +71,6 @@ CU_Test(ddsc_participant, create_with_no_conf_no_env) {
|
|||
|
||||
dds_delete(participant2);
|
||||
dds_delete(participant3);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -84,17 +83,12 @@ CU_Test(ddsc_participant, create_with_conf_no_env) {
|
|||
dds_domainid_t domain_id;
|
||||
dds_domainid_t valid_domain=3;
|
||||
|
||||
static char env_uri_str[1000];
|
||||
(void) snprintf(env_uri_str, sizeof(env_uri_str), "%s=%s", DDSC_PROJECT_NAME_NOSPACE_CAPS"_URI", CONFIG_ENV_SIMPLE_UDP);
|
||||
os_putenv(env_uri_str);
|
||||
printf("env_uri_str %s\n", env_uri_str);
|
||||
ddsrt_setenv(DDS_PROJECT_NAME_NOSPACE_CAPS"_URI", CONFIG_ENV_SIMPLE_UDP);
|
||||
ddsrt_setenv("MAX_PARTICIPANTS", CONFIG_ENV_MAX_PARTICIPANTS);
|
||||
|
||||
static char env_mp_str[100];
|
||||
(void) snprintf(env_mp_str, sizeof(env_mp_str), "%s=%s", "MAX_PARTICIPANTS", CONFIG_ENV_MAX_PARTICIPANTS);
|
||||
os_putenv(env_mp_str);
|
||||
|
||||
const char * env_uri = os_getenv(DDSC_PROJECT_NAME_NOSPACE_CAPS"_URI");
|
||||
CU_ASSERT_NOT_EQUAL_FATAL(env_uri, NULL);
|
||||
char * env_uri = NULL;
|
||||
ddsrt_getenv(DDS_PROJECT_NAME_NOSPACE_CAPS"_URI", &env_uri);
|
||||
CU_ASSERT_PTR_NOT_EQUAL_FATAL(env_uri, NULL);
|
||||
|
||||
//invalid domain
|
||||
participant = dds_create_participant (1, NULL, NULL);
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
*
|
||||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||
*/
|
||||
#include "ddsc/dds.h"
|
||||
#include "dds/dds.h"
|
||||
#include "CUnit/Test.h"
|
||||
|
||||
/* We are deliberately testing some bad arguments that SAL will complain about.
|
||||
|
|
|
|||
|
|
@ -10,16 +10,7 @@
|
|||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||
*/
|
||||
#include "CUnit/Test.h"
|
||||
#include "ddsc/dds.h"
|
||||
#include "os/os.h"
|
||||
|
||||
/* We are deliberately testing some bad arguments that SAL will complain about.
|
||||
* So, silence SAL regarding these issues. */
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable: 6387 28020)
|
||||
#endif
|
||||
|
||||
#include "dds/dds.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Convenience global policies
|
||||
|
|
@ -655,6 +646,3 @@ CU_Test(ddsc_qos, durability_service, .init=qos_init, .fini=qos_fini)
|
|||
CU_ASSERT_EQUAL_FATAL(p.max_samples_per_instance, g_pol_durability_service.max_samples_per_instance);
|
||||
}
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -9,12 +9,16 @@
|
|||
*
|
||||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||
*/
|
||||
#include "ddsc/dds.h"
|
||||
#include "os/os.h"
|
||||
#include "CUnit/Test.h"
|
||||
#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"
|
||||
|
||||
/**************************************************************************************************
|
||||
*
|
||||
* Test fixtures
|
||||
|
|
@ -68,9 +72,9 @@ static char*
|
|||
create_topic_name(const char *prefix, char *name, size_t size)
|
||||
{
|
||||
/* Get semi random g_topic name. */
|
||||
os_procId pid = os_getpid();
|
||||
uintmax_t tid = os_threadIdToInteger(os_threadIdSelf());
|
||||
(void) snprintf(name, size, "%s_pid%"PRIprocId"_tid%"PRIuMAX"", prefix, pid, tid);
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
@ -305,9 +309,9 @@ CU_Test(ddsc_querycondition_get_mask, null, .init=querycondition_init, .fini=que
|
|||
dds_return_t ret;
|
||||
condition = dds_create_querycondition(g_reader, mask, filter_mod2);
|
||||
CU_ASSERT_FATAL(condition > 0);
|
||||
OS_WARNING_MSVC_OFF(6387); /* Disable SAL warning on intentional misuse of the API */
|
||||
DDSRT_WARNING_MSVC_OFF(6387); /* Disable SAL warning on intentional misuse of the API */
|
||||
ret = dds_get_mask(condition, NULL);
|
||||
OS_WARNING_MSVC_ON(6387);
|
||||
DDSRT_WARNING_MSVC_ON(6387);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
dds_delete(condition);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,13 +10,16 @@
|
|||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include "ddsc/dds.h"
|
||||
#include "os/os.h"
|
||||
#include <limits.h>
|
||||
|
||||
#include "dds/dds.h"
|
||||
#include "Space.h"
|
||||
#include "RoundTrip.h"
|
||||
#include "CUnit/Test.h"
|
||||
#include "CUnit/Theory.h"
|
||||
|
||||
#include "dds/ddsrt/process.h"
|
||||
#include "dds/ddsrt/threads.h"
|
||||
|
||||
/**************************************************************************************************
|
||||
*
|
||||
* Test fixtures
|
||||
|
|
@ -68,9 +71,9 @@ static char*
|
|||
create_topic_name(const char *prefix, char *name, size_t size)
|
||||
{
|
||||
/* Get semi random g_topic name. */
|
||||
os_procId pid = os_getpid();
|
||||
uintmax_t tid = os_threadIdToInteger(os_threadIdSelf());
|
||||
(void) snprintf(name, size, "%s_pid%"PRIprocId"_tid%"PRIuMAX"", prefix, pid, tid);
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,12 +9,15 @@
|
|||
*
|
||||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||
*/
|
||||
#include "ddsc/dds.h"
|
||||
#include "os/os.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"
|
||||
|
||||
/**************************************************************************************************
|
||||
*
|
||||
* Test fixtures
|
||||
|
|
@ -61,9 +64,9 @@ static char*
|
|||
create_topic_name(const char *prefix, char *name, size_t size)
|
||||
{
|
||||
/* Get semi random g_topic name. */
|
||||
os_procId pid = os_getpid();
|
||||
uintmax_t tid = os_threadIdToInteger(os_threadIdSelf());
|
||||
(void) snprintf(name, size, "%s_pid%"PRIprocId"_tid%"PRIuMAX"", prefix, pid, tid);
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
@ -288,9 +291,9 @@ CU_Test(ddsc_readcondition_get_mask, null, .init=readcondition_init, .fini=readc
|
|||
dds_return_t ret;
|
||||
condition = dds_create_readcondition(g_reader, mask);
|
||||
CU_ASSERT_FATAL(condition > 0);
|
||||
OS_WARNING_MSVC_OFF(6387); /* Disable SAL warning on intentional misuse of the API */
|
||||
DDSRT_WARNING_MSVC_OFF(6387); /* Disable SAL warning on intentional misuse of the API */
|
||||
ret = dds_get_mask(condition, NULL);
|
||||
OS_WARNING_MSVC_ON(6387);
|
||||
DDSRT_WARNING_MSVC_ON(6387);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
dds_delete(condition);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,14 +10,17 @@
|
|||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include "ddsc/dds.h"
|
||||
#include "os/os.h"
|
||||
#include "dds/dds.h"
|
||||
#include "Space.h"
|
||||
#include "RoundTrip.h"
|
||||
#include "CUnit/Test.h"
|
||||
#include "CUnit/Theory.h"
|
||||
|
||||
#include "dds/ddsrt/misc.h"
|
||||
#include "dds/ddsrt/process.h"
|
||||
#include "dds/ddsrt/threads.h"
|
||||
|
||||
/**************************************************************************************************
|
||||
*
|
||||
* Test fixtures
|
||||
|
|
@ -65,9 +68,9 @@ static char*
|
|||
create_topic_name(const char *prefix, char *name, size_t size)
|
||||
{
|
||||
/* Get semi random g_topic name. */
|
||||
os_procId pid = os_getpid();
|
||||
uintmax_t tid = os_threadIdToInteger(os_threadIdSelf());
|
||||
(void) snprintf(name, size, "%s_pid%"PRIprocId"_tid%"PRIuMAX"", prefix, pid, tid);
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
@ -234,9 +237,9 @@ CU_Test(ddsc_reader_create, invalid_qos_participant, .init=reader_init, .fini=re
|
|||
dds_entity_t rdr;
|
||||
dds_qos_t *qos = dds_create_qos();
|
||||
/* Set invalid reader data lifecycle policy */
|
||||
OS_WARNING_MSVC_OFF(28020); /* Disable SAL warning on intentional misuse of the API */
|
||||
DDSRT_WARNING_MSVC_OFF(28020); /* Disable SAL warning on intentional misuse of the API */
|
||||
dds_qset_reader_data_lifecycle(qos, DDS_SECS(-1), DDS_SECS(-1));
|
||||
OS_WARNING_MSVC_ON(28020);
|
||||
DDSRT_WARNING_MSVC_ON(28020);
|
||||
rdr = dds_create_reader(g_participant, g_topic, qos, NULL);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(rdr), DDS_RETCODE_INCONSISTENT_POLICY);
|
||||
dds_delete_qos(qos);
|
||||
|
|
@ -249,9 +252,9 @@ CU_Test(ddsc_reader_create, invalid_qos_subscriber, .init=reader_init, .fini=rea
|
|||
dds_entity_t rdr;
|
||||
dds_qos_t *qos = dds_create_qos();
|
||||
/* Set invalid reader data lifecycle policy */
|
||||
OS_WARNING_MSVC_OFF(28020); /* Disable SAL warning on intentional misuse of the API */
|
||||
DDSRT_WARNING_MSVC_OFF(28020); /* Disable SAL warning on intentional misuse of the API */
|
||||
dds_qset_reader_data_lifecycle(qos, DDS_SECS(-1), DDS_SECS(-1));
|
||||
OS_WARNING_MSVC_ON(28020);
|
||||
DDSRT_WARNING_MSVC_ON(28020);
|
||||
rdr = dds_create_reader(g_subscriber, g_topic, qos, NULL);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(rdr), DDS_RETCODE_INCONSISTENT_POLICY);
|
||||
dds_delete_qos(qos);
|
||||
|
|
|
|||
|
|
@ -10,14 +10,16 @@
|
|||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include "ddsc/dds.h"
|
||||
#include "os/os.h"
|
||||
#include "dds/dds.h"
|
||||
#include "Space.h"
|
||||
#include "RoundTrip.h"
|
||||
#include "CUnit/Test.h"
|
||||
#include "CUnit/Theory.h"
|
||||
|
||||
#include "dds/ddsrt/process.h"
|
||||
#include "dds/ddsrt/threads.h"
|
||||
|
||||
/**************************************************************************************************
|
||||
*
|
||||
* Test fixtures
|
||||
|
|
@ -85,9 +87,9 @@ static char*
|
|||
create_topic_name(const char *prefix, char *name, size_t size)
|
||||
{
|
||||
/* Get semi random g_topic name. */
|
||||
os_procId pid = os_getpid();
|
||||
uintmax_t tid = os_threadIdToInteger(os_threadIdSelf());
|
||||
(void) snprintf(name, size, "%s_pid%"PRIprocId"_tid%"PRIuMAX"", prefix, pid, tid);
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,12 +11,14 @@
|
|||
*/
|
||||
#include <assert.h>
|
||||
|
||||
#include "ddsc/dds.h"
|
||||
#include "os/os.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"
|
||||
|
||||
/**************************************************************************************************
|
||||
*
|
||||
|
|
@ -43,9 +45,9 @@ static char*
|
|||
create_topic_name(const char *prefix, char *name, size_t size)
|
||||
{
|
||||
/* Get semi random g_topic name. */
|
||||
os_procId pid = os_getpid();
|
||||
uintmax_t tid = os_threadIdToInteger(os_threadIdSelf());
|
||||
(void) snprintf(name, size, "%s_pid%"PRIprocId"_tid%"PRIuMAX"", prefix, pid, tid);
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
@ -164,9 +166,9 @@ CU_Theory((dds_instance_handle_t *hndl2, void *datap), ddsc_register_instance, i
|
|||
/* Only test when the combination of parameters is actually invalid.*/
|
||||
CU_ASSERT_FATAL((hndl2 == NULL) || (datap == NULL));
|
||||
|
||||
OS_WARNING_MSVC_OFF(6387); /* Disable SAL warning on intentional misuse of the API */
|
||||
DDSRT_WARNING_MSVC_OFF(6387); /* Disable SAL warning on intentional misuse of the API */
|
||||
ret = dds_register_instance(g_writer, hndl2, datap);
|
||||
OS_WARNING_MSVC_ON(6387);
|
||||
DDSRT_WARNING_MSVC_ON(6387);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,9 +9,8 @@
|
|||
*
|
||||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||
*/
|
||||
#include "ddsc/dds.h"
|
||||
#include "dds/dds.h"
|
||||
#include "RoundTrip.h"
|
||||
#include "os/os.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include "CUnit/Test.h"
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
*
|
||||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||
*/
|
||||
#include "ddsc/dds.h"
|
||||
#include "dds/dds.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include "CUnit/Test.h"
|
||||
|
|
|
|||
|
|
@ -10,14 +10,16 @@
|
|||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include "ddsc/dds.h"
|
||||
#include "os/os.h"
|
||||
#include "dds/dds.h"
|
||||
#include "Space.h"
|
||||
#include "RoundTrip.h"
|
||||
#include "CUnit/Test.h"
|
||||
#include "CUnit/Theory.h"
|
||||
|
||||
#include "dds/ddsrt/process.h"
|
||||
#include "dds/ddsrt/threads.h"
|
||||
|
||||
/**************************************************************************************************
|
||||
*
|
||||
* Test fixtures
|
||||
|
|
@ -69,9 +71,9 @@ static char*
|
|||
create_topic_name(const char *prefix, char *name, size_t size)
|
||||
{
|
||||
/* Get semi random g_topic name. */
|
||||
os_procId pid = os_getpid();
|
||||
uintmax_t tid = os_threadIdToInteger(os_threadIdSelf());
|
||||
(void) snprintf(name, size, "%s_pid%"PRIprocId"_tid%"PRIuMAX"", prefix, pid, tid);
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
*
|
||||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||
*/
|
||||
#include "ddsc/dds.h"
|
||||
#include "dds/dds.h"
|
||||
|
||||
const char*
|
||||
entity_kind_str(dds_entity_t ent) {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||
*/
|
||||
#include "CUnit/Test.h"
|
||||
#include "ddsc/dds.h"
|
||||
#include "dds/dds.h"
|
||||
|
||||
CU_Test(ddsc_time, request_time)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -9,12 +9,14 @@
|
|||
*
|
||||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||
*/
|
||||
#include "ddsc/dds.h"
|
||||
#include "os/os.h"
|
||||
#include "dds/dds.h"
|
||||
#include "RoundTrip.h"
|
||||
#include "CUnit/Test.h"
|
||||
#include "CUnit/Theory.h"
|
||||
|
||||
#include "dds/ddsrt/misc.h"
|
||||
#include "dds/ddsrt/process.h"
|
||||
#include "dds/ddsrt/threads.h"
|
||||
|
||||
/**************************************************************************************************
|
||||
*
|
||||
* Test fixtures
|
||||
|
|
@ -38,9 +40,9 @@ static char*
|
|||
create_topic_name(const char *prefix, char *name, size_t size)
|
||||
{
|
||||
/* Get semi random g_topic name. */
|
||||
os_procId pid = os_getpid();
|
||||
uintmax_t tid = os_threadIdToInteger(os_threadIdSelf());
|
||||
(void) snprintf(name, size, "%s_pid%"PRIprocId"_tid%"PRIuMAX"", prefix, pid, tid);
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
@ -102,9 +104,9 @@ CU_Test(ddsc_topic_create, invalid_qos, .init=ddsc_topic_init, .fini=ddsc_topic_
|
|||
{
|
||||
dds_entity_t topic;
|
||||
dds_qos_t *qos = dds_create_qos();
|
||||
OS_WARNING_MSVC_OFF(28020); /* Disable SAL warning on intentional misuse of the API */
|
||||
DDSRT_WARNING_MSVC_OFF(28020); /* Disable SAL warning on intentional misuse of the API */
|
||||
dds_qset_lifespan(qos, DDS_SECS(-1));
|
||||
OS_WARNING_MSVC_OFF(28020);
|
||||
DDSRT_WARNING_MSVC_OFF(28020);
|
||||
topic = dds_create_topic(g_participant, &RoundTripModule_DataType_desc, "inconsistent", qos, NULL);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(topic), DDS_RETCODE_INCONSISTENT_POLICY);
|
||||
dds_delete_qos(qos);
|
||||
|
|
@ -164,9 +166,9 @@ CU_Test(ddsc_topic_create, recreate, .init=ddsc_topic_init, .fini=ddsc_topic_fin
|
|||
CU_Test(ddsc_topic_create, desc_null, .init=ddsc_topic_init, .fini=ddsc_topic_fini)
|
||||
{
|
||||
dds_entity_t topic;
|
||||
OS_WARNING_MSVC_OFF(6387); /* Disable SAL warning on intentional misuse of the API */
|
||||
DDSRT_WARNING_MSVC_OFF(6387); /* Disable SAL warning on intentional misuse of the API */
|
||||
topic = dds_create_topic (g_participant, NULL, "desc_null", NULL, NULL);
|
||||
OS_WARNING_MSVC_ON(6387);
|
||||
DDSRT_WARNING_MSVC_ON(6387);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(topic), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
|
@ -219,9 +221,9 @@ CU_Test(ddsc_topic_find, non_participants, .init=ddsc_topic_init, .fini=ddsc_top
|
|||
CU_Test(ddsc_topic_find, null, .init=ddsc_topic_init, .fini=ddsc_topic_fini)
|
||||
{
|
||||
dds_entity_t topic;
|
||||
OS_WARNING_MSVC_OFF(6387); /* Disable SAL warning on intentional misuse of the API */
|
||||
DDSRT_WARNING_MSVC_OFF(6387); /* Disable SAL warning on intentional misuse of the API */
|
||||
topic = dds_find_topic(g_participant, NULL);
|
||||
OS_WARNING_MSVC_ON(6387);
|
||||
DDSRT_WARNING_MSVC_ON(6387);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(topic), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
|
@ -411,9 +413,9 @@ CU_Test(ddsc_topic_set_qos, valid, .init=ddsc_topic_init, .fini=ddsc_topic_fini)
|
|||
CU_Test(ddsc_topic_set_qos, inconsistent, .init=ddsc_topic_init, .fini=ddsc_topic_fini)
|
||||
{
|
||||
dds_return_t ret;
|
||||
OS_WARNING_MSVC_OFF(28020); /* Disable SAL warning on intentional misuse of the API */
|
||||
DDSRT_WARNING_MSVC_OFF(28020); /* Disable SAL warning on intentional misuse of the API */
|
||||
dds_qset_lifespan(g_qos, DDS_SECS(-1));
|
||||
OS_WARNING_MSVC_ON(28020);
|
||||
DDSRT_WARNING_MSVC_ON(28020);
|
||||
ret = dds_set_qos(g_topicRtmDataType, g_qos);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_INCONSISTENT_POLICY);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include "ddsc/dds.h"
|
||||
#include "dds/dds.h"
|
||||
#include "Space.h"
|
||||
#include "CUnit/Test.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||
*/
|
||||
#include "CUnit/Test.h"
|
||||
#include "ddsc/dds.h"
|
||||
#include "dds/dds.h"
|
||||
#include "TypesArrayKey.h"
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -10,13 +10,15 @@
|
|||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include "ddsc/dds.h"
|
||||
#include "os/os.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"
|
||||
|
||||
/**************************************************************************************************
|
||||
*
|
||||
|
|
@ -43,9 +45,9 @@ static char*
|
|||
create_topic_name(const char *prefix, char *name, size_t size)
|
||||
{
|
||||
/* Get semi random g_topic name. */
|
||||
os_procId pid = os_getpid();
|
||||
uintmax_t tid = os_threadIdToInteger(os_threadIdSelf());
|
||||
(void) snprintf(name, size, "%s_pid%"PRIprocId"_tid%"PRIuMAX"", prefix, pid, tid);
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
#include <stdio.h>
|
||||
#include "CUnit/Test.h"
|
||||
|
||||
#include "ddsc/dds.h"
|
||||
#include "dds/dds.h"
|
||||
#include "RoundTrip.h"
|
||||
|
||||
#include "test-common.h"
|
||||
|
|
|
|||
|
|
@ -10,13 +10,18 @@
|
|||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include "ddsc/dds.h"
|
||||
#include "os/os.h"
|
||||
#include "CUnit/Test.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"
|
||||
#include "dds/ddsrt/threads.h"
|
||||
#include "dds/ddsrt/time.h"
|
||||
|
||||
/**************************************************************************************************
|
||||
*
|
||||
* Some thread related convenience stuff.
|
||||
|
|
@ -30,7 +35,7 @@ typedef enum thread_state_t {
|
|||
} thread_state_t;
|
||||
|
||||
typedef struct thread_arg_t {
|
||||
os_threadId tid;
|
||||
ddsrt_thread_t tid;
|
||||
thread_state_t state;
|
||||
dds_entity_t expected;
|
||||
} thread_arg_t;
|
||||
|
|
@ -61,9 +66,9 @@ static char*
|
|||
create_topic_name(const char *prefix, char *name, size_t size)
|
||||
{
|
||||
/* Get semi random g_topic name. */
|
||||
os_procId pid = os_getpid();
|
||||
uintmax_t tid = os_threadIdToInteger(os_threadIdSelf());
|
||||
(void) snprintf(name, size, "%s_pid%"PRIprocId"_tid%"PRIuMAX"", prefix, pid, tid);
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
@ -93,7 +98,7 @@ ddsc_waitset_init(void)
|
|||
uint32_t mask = DDS_ANY_SAMPLE_STATE | DDS_ANY_VIEW_STATE | DDS_ANY_INSTANCE_STATE;
|
||||
char name[100];
|
||||
|
||||
os_osInit();
|
||||
ddsrt_init();
|
||||
|
||||
ddsc_waitset_basic_init();
|
||||
|
||||
|
|
@ -128,7 +133,7 @@ ddsc_waitset_fini(void)
|
|||
dds_delete(publisher);
|
||||
dds_delete(subscriber);
|
||||
ddsc_waitset_basic_fini();
|
||||
os_osExit();
|
||||
ddsrt_fini();
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -823,9 +828,9 @@ CU_Theory((size_t size), ddsc_waitset_get_entities, array_sizes, .init=ddsc_wait
|
|||
CU_Test(ddsc_waitset_get_entities, no_array, .init=ddsc_waitset_attached_init, .fini=ddsc_waitset_attached_fini)
|
||||
{
|
||||
dds_return_t ret;
|
||||
OS_WARNING_MSVC_OFF(6387); /* Disable SAL warning on intentional misuse of the API */
|
||||
DDSRT_WARNING_MSVC_OFF(6387); /* Disable SAL warning on intentional misuse of the API */
|
||||
ret = dds_waitset_get_entities(waitset, NULL, 1);
|
||||
OS_WARNING_MSVC_ON(6387);
|
||||
DDSRT_WARNING_MSVC_ON(6387);
|
||||
/* ddsc_waitset_attached_init attached 7 entities. */
|
||||
CU_ASSERT_EQUAL_FATAL(ret, 7);
|
||||
}
|
||||
|
|
@ -1068,41 +1073,41 @@ waiting_thread(void *a)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static os_result
|
||||
static dds_retcode_t
|
||||
thread_reached_state(thread_state_t *actual, thread_state_t expected, int32_t msec)
|
||||
{
|
||||
/* Convenience function. */
|
||||
os_time msec10 = { 0, 10000000 };
|
||||
dds_time_t msec10 = DDS_MSECS(10);
|
||||
while ((msec > 0) && (*actual != expected)) {
|
||||
os_nanoSleep(msec10);
|
||||
dds_sleepfor(msec10);
|
||||
msec -= 10;
|
||||
}
|
||||
return (*actual == expected) ? os_resultSuccess : os_resultTimeout;
|
||||
return (*actual == expected) ? DDS_RETCODE_OK : DDS_RETCODE_TIMEOUT;
|
||||
}
|
||||
|
||||
static void
|
||||
waiting_thread_start(struct thread_arg_t *arg, dds_entity_t expected)
|
||||
{
|
||||
os_threadId thread_id;
|
||||
os_threadAttr thread_attr;
|
||||
os_result osr;
|
||||
ddsrt_thread_t thread_id;
|
||||
ddsrt_threadattr_t thread_attr;
|
||||
dds_retcode_t rc;
|
||||
|
||||
assert(arg);
|
||||
|
||||
/* Create an other thread that will blocking wait on the waitset. */
|
||||
arg->expected = expected;
|
||||
arg->state = STARTING;
|
||||
os_threadAttrInit(&thread_attr);
|
||||
osr = os_threadCreate(&thread_id, "waiting_thread", &thread_attr, waiting_thread, arg);
|
||||
CU_ASSERT_EQUAL_FATAL(osr, os_resultSuccess);
|
||||
ddsrt_threadattr_init(&thread_attr);
|
||||
rc = ddsrt_thread_create(&thread_id, "waiting_thread", &thread_attr, waiting_thread, arg);
|
||||
CU_ASSERT_EQUAL_FATAL(rc, DDS_RETCODE_OK);
|
||||
|
||||
/* The thread should reach 'waiting' state. */
|
||||
osr = thread_reached_state(&(arg->state), WAITING, 1000);
|
||||
CU_ASSERT_EQUAL_FATAL(osr, os_resultSuccess);
|
||||
rc = thread_reached_state(&(arg->state), WAITING, 1000);
|
||||
CU_ASSERT_EQUAL_FATAL(rc, DDS_RETCODE_OK);
|
||||
|
||||
/* But thread should block and thus NOT reach 'stopped' state. */
|
||||
osr = thread_reached_state(&(arg->state), STOPPED, 100);
|
||||
CU_ASSERT_EQUAL_FATAL(osr, os_resultTimeout);
|
||||
rc = thread_reached_state(&(arg->state), STOPPED, 100);
|
||||
CU_ASSERT_EQUAL_FATAL(rc, DDS_RETCODE_TIMEOUT);
|
||||
|
||||
arg->tid = thread_id;
|
||||
}
|
||||
|
|
@ -1110,11 +1115,11 @@ waiting_thread_start(struct thread_arg_t *arg, dds_entity_t expected)
|
|||
static dds_return_t
|
||||
waiting_thread_expect_exit(struct thread_arg_t *arg)
|
||||
{
|
||||
os_result osr;
|
||||
dds_retcode_t rc;
|
||||
assert(arg);
|
||||
osr = thread_reached_state(&(arg->state), STOPPED, 5000);
|
||||
if (osr == os_resultSuccess) {
|
||||
os_threadWaitExit(arg->tid, NULL);
|
||||
rc = thread_reached_state(&(arg->state), STOPPED, 5000);
|
||||
if (rc == DDS_RETCODE_OK) {
|
||||
ddsrt_thread_join(arg->tid, NULL);
|
||||
return DDS_RETCODE_OK;
|
||||
}
|
||||
return DDS_RETCODE_TIMEOUT;
|
||||
|
|
|
|||
|
|
@ -10,12 +10,12 @@
|
|||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include "CUnit/Test.h"
|
||||
|
||||
#include "CUnit/Theory.h"
|
||||
#include "ddsc/dds.h"
|
||||
#include "dds/dds.h"
|
||||
#include "RoundTrip.h"
|
||||
#include "Space.h"
|
||||
#include "os/os.h"
|
||||
#include "dds/ddsrt/misc.h"
|
||||
|
||||
/* Tests in this file only concern themselves with very basic api tests of
|
||||
dds_write and dds_write_ts */
|
||||
|
|
@ -73,9 +73,9 @@ CU_Test(ddsc_write, null_writer, .init = setup, .fini = teardown)
|
|||
dds_return_t status;
|
||||
|
||||
/* Disable warning related to improper API usage by passing incompatible parameter. */
|
||||
OS_WARNING_MSVC_OFF(28020);
|
||||
DDSRT_WARNING_MSVC_OFF(28020);
|
||||
status = dds_write(0, &data);
|
||||
OS_WARNING_MSVC_ON(28020);
|
||||
DDSRT_WARNING_MSVC_ON(28020);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(status), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
|
||||
|
|
@ -103,9 +103,9 @@ CU_Test(ddsc_write, null_sample, .init = setup, .fini = teardown)
|
|||
dds_return_t status;
|
||||
|
||||
/* Disable warning related to improper API usage by passing NULL to a non-NULL parameter. */
|
||||
OS_WARNING_MSVC_OFF(6387);
|
||||
DDSRT_WARNING_MSVC_OFF(6387);
|
||||
status = dds_write(writer, NULL);
|
||||
OS_WARNING_MSVC_ON(6387);
|
||||
DDSRT_WARNING_MSVC_ON(6387);
|
||||
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(status), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,10 +10,11 @@
|
|||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||
*/
|
||||
#include <stdio.h>
|
||||
|
||||
#include "CUnit/Test.h"
|
||||
#include "ddsc/dds.h"
|
||||
#include "dds/dds.h"
|
||||
#include "RoundTrip.h"
|
||||
#include "os/os.h"
|
||||
#include "dds/ddsrt/misc.h"
|
||||
|
||||
static dds_entity_t participant = 0;
|
||||
static dds_entity_t topic = 0;
|
||||
|
|
@ -53,9 +54,9 @@ CU_Test(ddsc_create_writer, basic, .init = setup, .fini = teardown)
|
|||
|
||||
CU_Test(ddsc_create_writer, null_parent, .init = setup, .fini = teardown)
|
||||
{
|
||||
OS_WARNING_MSVC_OFF(28020); /* Disable SAL warning on intentional misuse of the API */
|
||||
DDSRT_WARNING_MSVC_OFF(28020); /* Disable SAL warning on intentional misuse of the API */
|
||||
writer = dds_create_writer(0, topic, NULL, NULL);
|
||||
OS_WARNING_MSVC_ON(28020);
|
||||
DDSRT_WARNING_MSVC_ON(28020);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(writer), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
|
||||
|
|
@ -87,9 +88,9 @@ CU_Test(ddsc_create_writer, deleted_publisher, .init = setup, .fini = teardown)
|
|||
|
||||
CU_Test(ddsc_create_writer, null_topic, .init = setup, .fini = teardown)
|
||||
{
|
||||
OS_WARNING_MSVC_OFF(28020); /* Disable SAL warning on intentional misuse of the API */
|
||||
DDSRT_WARNING_MSVC_OFF(28020); /* Disable SAL warning on intentional misuse of the API */
|
||||
writer = dds_create_writer(publisher, 0, NULL, NULL);
|
||||
OS_WARNING_MSVC_ON(28020);
|
||||
DDSRT_WARNING_MSVC_ON(28020);
|
||||
CU_ASSERT_EQUAL_FATAL(dds_err_nr(writer), DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue