diff options
author | Michał Łyszczek <michal.lyszczek@bofc.pl> | 2021-05-23 19:26:02 +0200 |
---|---|---|
committer | Michał Łyszczek <michal.lyszczek@bofc.pl> | 2021-05-23 19:27:05 +0200 |
commit | d5889b437b4d7a5bc170af6052f861678ed5a5b3 (patch) | |
tree | bae93dc6af8950ef5e502d9981418cc4a950f335 | |
parent | 6dc89a9e26a382a7f9011cfa46901ee3ae2837c8 (diff) | |
download | psmq-d5889b437b4d7a5bc170af6052f861678ed5a5b3.tar.gz psmq-d5889b437b4d7a5bc170af6052f861678ed5a5b3.tar.bz2 psmq-d5889b437b4d7a5bc170af6052f861678ed5a5b3.zip |
src/psmq-sub.c: print log with info about subscribed topic
fix a regression where psmq-sub did not print "subscribed to %s"
string anymore.
Signed-off-by: Michał Łyszczek <michal.lyszczek@bofc.pl>
-rw-r--r-- | src/psmq-sub.c | 9 | ||||
-rwxr-xr-x | tst/psmq-progs.sh | 14 |
2 files changed, 13 insertions, 10 deletions
diff --git a/src/psmq-sub.c b/src/psmq-sub.c index 807d5cb..d63b4bf 100644 --- a/src/psmq-sub.c +++ b/src/psmq-sub.c @@ -158,14 +158,6 @@ static int on_receive switch (msg->ctrl.cmd) { - case PSMQ_CTRL_CMD_SUBSCRIBE: - errno = msg->ctrl.data; - if (msg->ctrl.data == 0) - el_oprint(OELN, "subscribed to %s", topic); - else - el_oprint(OELN, "subscribe error: %s", strerror(errno)); - return msg->ctrl.data; - case PSMQ_CTRL_CMD_CLOSE: el_oprint(OELN, "broker has closed the connection"); errno = msg->ctrl.data; @@ -356,6 +348,7 @@ int psmq_sub_main return 1; } + el_oprint(OELN, "subscribed to: %s", msg.data); break; case 'o': diff --git a/tst/psmq-progs.sh b/tst/psmq-progs.sh index 6982118..dec7980 100755 --- a/tst/psmq-progs.sh +++ b/tst/psmq-progs.sh @@ -125,7 +125,7 @@ start_psmqd() start_psmqs() { echo -n > "${psmqs_stdout}" - ${psmqs_bin} -n${psmqs_name} -b${broker_name} -t/1 -t/2 -o${psmqs_stdout} \ + ${psmqs_bin} -n${psmqs_name} -b${broker_name} -t/1 -t/2 -t/3 -o${psmqs_stdout} \ 2> ${psmqs_stderr} & psmqs_pid=${!} @@ -274,6 +274,7 @@ psmq_sub_invalid_topic() mt_fail "psmq_grep \"subscribe failed, topic / is invalid\" \ \"${psmqs_stderr}\"" } + psmq_sub_missing_argument() { ${psmqs_bin} -b 2> ${psmqs_stderr} @@ -304,6 +305,7 @@ psmq_sub_broker_go_down_before_client() # restart psmqd start_psmqd } + psmq_pub_print_help() { ${psmqp_bin} -h > ${psmqp_stdout} @@ -587,7 +589,14 @@ psmq_progs_simple_pub_sub() mt_fail "psmq_grep $(echo ${msg} | cut -c-16) \"${psmqs_stdout}\"" stop_psmqs } - +psmq_sub_subscribe_message() +{ + start_psmqs + mt_fail "psmq_grep \"n/subscribed to: /1\" \"${psmqs_stderr}\"" + mt_fail "psmq_grep \"n/subscribed to: /2\" \"${psmqs_stderr}\"" + mt_fail "psmq_grep \"n/subscribed to: /3\" \"${psmqs_stderr}\"" + stop_psmqs +} ## ========================================================================== # _ @@ -615,6 +624,7 @@ mt_run psmq_sub_unknown_argument mt_run psmq_sub_no_arguments mt_run psmq_sub_invalid_topic mt_run psmq_sub_broker_go_down_before_client +mt_run psmq_sub_subscribe_message mt_run psmq_pub_print_help mt_run psmq_pub_print_version mt_run psmq_pub_broker_doesnt_exist |