From 7d9fc15bec106c4b83df25c4f21ae89810652db5 Mon Sep 17 00:00:00 2001 From: Bill Williams Date: Mon, 28 Jan 2019 14:19:24 -0800 Subject: [PATCH 1/3] Add option k to test app cmd line, to specify keepalive timeout --- CHANGELOG.md | 1 + tests/libpd_test.c | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2e6c0af..527c66f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Re-enabled the temporarily commented out setting that prevented cyclic building - Switched from nanomsg (Release 1.1.2) to NNG (Release v1.0.1) - Revert from NNG +- Change test app (libpd_test). Add 'k' cmd line option to specify keepalive timeout ## [1.0.0] - 2018-06-19 ### Added diff --git a/tests/libpd_test.c b/tests/libpd_test.c index fd9ce58..06a5cf0 100644 --- a/tests/libpd_test.c +++ b/tests/libpd_test.c @@ -104,6 +104,7 @@ static bool do_multiple_rcv_test = false; static bool connect_on_every_send = false; static bool do_multiple_inits_test = false; static bool switch_service_names = false; +static int keep_alive_test_timeout = 0; static libpd_instance_t test_instance1; static libpd_instance_t test_instance2; @@ -939,6 +940,9 @@ void test_1(void) if (using_mock) { cfg1.keepalive_timeout_secs = 20; } + else if (keep_alive_test_timeout > 0) { + cfg1.keepalive_timeout_secs = keep_alive_test_timeout; + } if (switch_service_names) { const char *tmp = cfg1.service_name; cfg1.service_name = cfg2.service_name; @@ -1104,7 +1108,7 @@ int main( int argc, char **argv __attribute__((unused)) ) if (argc <= 1) using_mock = true; else { - const char *arg = argv[1]; + char *arg = argv[1]; if ((arg[0] == 's') || (arg[0] == 'S')) no_mock_send_only_test = true; if ((arg[0] == 'r') || (arg[0] == 'R')) @@ -1130,6 +1134,10 @@ int main( int argc, char **argv __attribute__((unused)) ) if (arg[0] == '2') { switch_service_names = true; } + if (arg[0] == 'k') { + arg[0] = '#'; + keep_alive_test_timeout = get_msg_num (arg); + } } From fd990aa43fb1d0fac7437a2e270104138a4b3a26 Mon Sep 17 00:00:00 2001 From: Bill Williams Date: Mon, 18 Feb 2019 15:39:51 -0800 Subject: [PATCH 2/3] add re-registration test --- src/libparodus.c | 9 +++++++++ tests/libpd_test.c | 15 ++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/libparodus.c b/src/libparodus.c index 532eb89..c93bb1c 100644 --- a/src/libparodus.c +++ b/src/libparodus.c @@ -1116,3 +1116,12 @@ void test_get_counts (libpd_instance_t instance, *reconnect_count = inst->reconnect_count; } +int test_send_registration_msg (libpd_instance_t instance, int *oserr) +{ + int rtn; + extra_err_info_t err_info; + __instance_t *inst = (__instance_t *) instance; + rtn = send_registration_msg (inst, &err_info); + *oserr = err_info.oserr; + return rtn; +} diff --git a/tests/libpd_test.c b/tests/libpd_test.c index 06a5cf0..d6b29d2 100644 --- a/tests/libpd_test.c +++ b/tests/libpd_test.c @@ -105,6 +105,7 @@ static bool connect_on_every_send = false; static bool do_multiple_inits_test = false; static bool switch_service_names = false; static int keep_alive_test_timeout = 0; +static bool do_reregister_test = false; static libpd_instance_t test_instance1; static libpd_instance_t test_instance2; @@ -133,6 +134,8 @@ extern int test_close_receiver (libpd_instance_t instance, int *oserr); extern void test_send_wrp_queue_ok (libpd_mq_t wrp_queue, int *oserr); extern void test_get_counts (libpd_instance_t instance, int *keep_alive_count, int *reconnect_count); +extern int test_send_registration_msg + (libpd_instance_t instance, int *oserr); #if TEST_ENVIRONMENT==2 @@ -1021,6 +1024,12 @@ void test_1(void) if (send_event_msgs (&msg_num, &event_num, 5, false) != 0) break; } + if (do_reregister_test) { + if (msgs_received_count == 5) { + rtn = test_send_registration_msg (test_instance1, &oserr); + libpd_log (LEVEL_INFO, ("LIBPD_TEST: libparodus_reregister rtn = %d\n", rtn)); + } + } } CU_ASSERT (reply_error_count == 0); if (reply_error_count != 0) { @@ -1111,8 +1120,12 @@ int main( int argc, char **argv __attribute__((unused)) ) char *arg = argv[1]; if ((arg[0] == 's') || (arg[0] == 'S')) no_mock_send_only_test = true; - if ((arg[0] == 'r') || (arg[0] == 'R')) + if ((arg[0] == 'r') || (arg[0] == 'R')) { + if ((arg[1] == 'r') || (arg[1] == 'R')) + do_reregister_test = true; + else do_multiple_rcv_test = true; + } if ((arg[0] == 'm') || (arg[0] == 'M')) do_multiple_inst_test = true; if ((arg[0] == 'b') || (arg[0] == 'B')) { From e3f632c7627fcac876ccf93a516dbb4ff38671f1 Mon Sep 17 00:00:00 2001 From: Bill Williams Date: Thu, 23 Jan 2020 16:23:20 -0800 Subject: [PATCH 3/3] set queue len to 2 for testing --- src/libparodus.c | 3 ++- src/libparodus_log.h | 2 +- tests/libpd_test.c | 22 +++++++++++++++++----- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/libparodus.c b/src/libparodus.c index c93bb1c..e01e43e 100644 --- a/src/libparodus.c +++ b/src/libparodus.c @@ -80,7 +80,8 @@ typedef struct { #define WRP_QUEUE_SEND_TIMEOUT_MS 2000 #define WRP_QNAME_HDR "/LIBPD_WRP_QUEUE" -#define WRP_QUEUE_SIZE 50 +/*#define WRP_QUEUE_SIZE 50*/ +#define WRP_QUEUE_SIZE 2 const char *wrp_qname_hdr = WRP_QNAME_HDR; diff --git a/src/libparodus_log.h b/src/libparodus_log.h index ec1e9dd..d2f82d3 100644 --- a/src/libparodus_log.h +++ b/src/libparodus_log.h @@ -25,7 +25,7 @@ // if TEST_ENVIRONMENT is not defined, then the macros libpd_log and libpd_log_err // generate nothing -//#define TEST_ENVIRONMENT 1 +#define TEST_ENVIRONMENT 1 #ifndef TEST_ENVIRONMENT #define libpd_log(level,msg) diff --git a/tests/libpd_test.c b/tests/libpd_test.c index d6b29d2..3d3d1d0 100644 --- a/tests/libpd_test.c +++ b/tests/libpd_test.c @@ -323,6 +323,15 @@ int send_reply (libpd_instance_t instance, wrp_msg_t *wrp_msg) return libparodus_send (instance, wrp_msg); } +int test_send_svc_alive (libpd_instance_t instance) +{ + wrp_msg_t svc_alive_msg; + + svc_alive_msg.msg_type = WRP_MSG_TYPE__SVC_ALIVE; + return libparodus_send (instance, (wrp_msg_t *) &svc_alive_msg); +} + + char *new_str (const char *str) { char *buf = malloc (strlen(str) + 1); @@ -404,12 +413,14 @@ int send_event_msgs (unsigned *msg_num, unsigned *event_num, int count, return 0; } if (both) - send_flag = 1; + send_flag = 1; for (i=0; i