Tweak timeouts in secure communication tests

* Increase the matching timeout to 5s (there are some hints the failures
  on Travis are timing related)
* Replace the relative timeout in the waitset by a timestamp so that it
  gives up after the specified timeout regardless of the number of
  events that occur

Signed-off-by: Erik Boasson <eb@ilities.com>
This commit is contained in:
Erik Boasson 2020-05-16 11:13:58 +02:00 committed by eboasson
parent a292e800ac
commit 2aa70548cc
2 changed files with 5 additions and 3 deletions

View file

@ -390,6 +390,7 @@ void handshake_list_fini (struct Handshake *hs_list, int nhs)
void sync_writer_to_readers (dds_entity_t pp_wr, dds_entity_t wr, uint32_t exp_count, dds_duration_t timeout) void sync_writer_to_readers (dds_entity_t pp_wr, dds_entity_t wr, uint32_t exp_count, dds_duration_t timeout)
{ {
dds_time_t abstimeout = dds_time() + timeout;
dds_attach_t triggered; dds_attach_t triggered;
dds_entity_t ws = dds_create_waitset (pp_wr); dds_entity_t ws = dds_create_waitset (pp_wr);
CU_ASSERT_FATAL (ws > 0); CU_ASSERT_FATAL (ws > 0);
@ -399,7 +400,7 @@ void sync_writer_to_readers (dds_entity_t pp_wr, dds_entity_t wr, uint32_t exp_c
CU_ASSERT_EQUAL_FATAL (ret, DDS_RETCODE_OK); CU_ASSERT_EQUAL_FATAL (ret, DDS_RETCODE_OK);
while (true) while (true)
{ {
ret = dds_waitset_wait (ws, &triggered, 1, timeout); ret = dds_waitset_wait_until (ws, &triggered, 1, abstimeout);
CU_ASSERT_EQUAL_FATAL (exp_count > 0, ret >= 1); CU_ASSERT_EQUAL_FATAL (exp_count > 0, ret >= 1);
if (exp_count > 0) if (exp_count > 0)
CU_ASSERT_EQUAL_FATAL (wr, (dds_entity_t)(intptr_t) triggered); CU_ASSERT_EQUAL_FATAL (wr, (dds_entity_t)(intptr_t) triggered);
@ -414,6 +415,7 @@ void sync_writer_to_readers (dds_entity_t pp_wr, dds_entity_t wr, uint32_t exp_c
void sync_reader_to_writers (dds_entity_t pp_rd, dds_entity_t rd, uint32_t exp_count, dds_duration_t timeout) void sync_reader_to_writers (dds_entity_t pp_rd, dds_entity_t rd, uint32_t exp_count, dds_duration_t timeout)
{ {
dds_time_t abstimeout = dds_time() + timeout;
dds_attach_t triggered; dds_attach_t triggered;
dds_entity_t ws = dds_create_waitset (pp_rd); dds_entity_t ws = dds_create_waitset (pp_rd);
CU_ASSERT_FATAL (ws > 0); CU_ASSERT_FATAL (ws > 0);
@ -423,7 +425,7 @@ void sync_reader_to_writers (dds_entity_t pp_rd, dds_entity_t rd, uint32_t exp_c
CU_ASSERT_EQUAL_FATAL (ret, DDS_RETCODE_OK); CU_ASSERT_EQUAL_FATAL (ret, DDS_RETCODE_OK);
while (true) while (true)
{ {
ret = dds_waitset_wait (ws, &triggered, 1, timeout); ret = dds_waitset_wait_until (ws, &triggered, 1, abstimeout);
CU_ASSERT_EQUAL_FATAL (exp_count > 0, ret >= 1); CU_ASSERT_EQUAL_FATAL (exp_count > 0, ret >= 1);
if (exp_count > 0) if (exp_count > 0)
CU_ASSERT_EQUAL_FATAL (rd, (dds_entity_t)(intptr_t) triggered); CU_ASSERT_EQUAL_FATAL (rd, (dds_entity_t)(intptr_t) triggered);

View file

@ -254,7 +254,7 @@ static void test_write_read(struct domain_sec_config *domain_config,
for (size_t w = 0; w < n_writers; w++) for (size_t w = 0; w < n_writers; w++)
{ {
size_t wr_index = pp_index * n_writers + w; size_t wr_index = pp_index * n_writers + w;
sync_writer_to_readers (g_pub_participants[pp_index], writers[wr_index], (uint32_t)(n_sub_domains * n_sub_participants * n_readers), DDS_SECS(2)); sync_writer_to_readers (g_pub_participants[pp_index], writers[wr_index], (uint32_t)(n_sub_domains * n_sub_participants * n_readers), DDS_SECS(5));
sample.id = (int32_t) wr_index; sample.id = (int32_t) wr_index;
printf("writer %"PRId32" writing sample %d\n", writers[wr_index], sample.id); printf("writer %"PRId32" writing sample %d\n", writers[wr_index], sample.id);
ret = dds_write (writers[wr_index], &sample); ret = dds_write (writers[wr_index], &sample);