Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 11 additions & 1 deletion src/libparodus.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -1116,3 +1117,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;
}
2 changes: 1 addition & 1 deletion src/libparodus_log.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
47 changes: 40 additions & 7 deletions tests/libpd_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ 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 bool do_reregister_test = false;

static libpd_instance_t test_instance1;
static libpd_instance_t test_instance2;
Expand Down Expand Up @@ -132,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
Expand Down Expand Up @@ -319,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);
Expand Down Expand Up @@ -400,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<count; i++) {
(*event_num)++;
if (send_event_msg ("---LIBPARODUS---", "---ParodusService---",
"---EventMessagePayload####", *event_num, send_flag) != 0)
return -1;
if (0==i)
test_send_svc_alive (test_instance1);
(*event_num)++;
if (send_event_msg ("---LIBPARODUS---", "---ParodusService---",
"---EventMessagePayload####", *event_num, send_flag) != 0)
return -1;
}
return 0;
}
Expand Down Expand Up @@ -939,10 +954,14 @@ 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;
cfg2.service_name = tmp;
cfg1.client_url = GOOD_CLIENT_URL2;
}
rtn = libparodus_init(&test_instance1, &cfg1);
CU_ASSERT_FATAL (rtn == 0);
Expand Down Expand Up @@ -1017,6 +1036,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) {
Expand Down Expand Up @@ -1104,11 +1129,15 @@ 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'))
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')) {
Expand All @@ -1130,6 +1159,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);
}

}

Expand Down