Skip to content

Commit

Permalink
* ADD [rap & rh test] add test log.
Browse files Browse the repository at this point in the history
Signed-off-by: Hermann0222 <yukang.wei@emqx.io>
  • Loading branch information
OdyWayne committed Sep 19, 2023
1 parent 2343005 commit ba1420c
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions nanomq/tests/bridge_rap_rh_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,24 +70,28 @@ main()
// TODO: better check the retain flag
assert(read(outfp_nmq_rap0, buf_rap0, buf_size) > 0);
assert(strncmp(buf_rap0, "message-to-nmq", 14) == 0);
printf("rap0 got the msg\n");
assert(read(outfp_nmq_rh0, buf_rh0, buf_size) > 0);
assert(strncmp(buf_rh0, "message-to-nmq", 14) == 0);
printf("rh0 got the msg\n");
assert(read(outfp_nmq_rh1, buf_rh1, buf_size) > 0);
assert(strncmp(buf_rh1, "message-to-nmq", 14) == 0);
printf("rh1 got the msg\n");

// resub to trigger rh1.
popen(cmd_resub, "r");
// popen(cmd_resub, "r"); // rest api for bridge client to resub is not available now.
nng_msleep(1000);
pid_sub_nmq_rh1_re = popen_sub_with_cmd_nonblock(&outfp_nmq_rh1, cmd_sub_nmq_rh1);
pid_sub_nmq_rh2 = popen_sub_with_cmd_nonblock(&outfp_nmq_rh2, cmd_sub_nmq_rh2);
// consider the msg is not recvieved after 2s.
nng_msleep(2000);
int a = read(outfp_nmq_rh1, buf_rh1, buf_size);
int b = read(outfp_nmq_rh2, buf_rh2, buf_size);
printf("a=%d, b=%d\n", a, b);
int rh1_buf = read(outfp_nmq_rh1, buf_rh1, buf_size);
int rh2_buf = read(outfp_nmq_rh2, buf_rh2, buf_size);
printf("rh1_buf size=%d, rh2_buf size=%d\n", rh1_buf, rh2_buf);
// assert(read(outfp_nmq_rh1, buf_rh1, buf_size) == 0);
// read is supposed to return 0, may need further check.
assert(read(outfp_nmq_rh2, buf_rh2, buf_size) == -1);
printf("rap2 got no msg\n");

kill(pid_sub_nmq_rap0, SIGKILL);
kill(pid_sub_nmq_rh0, SIGKILL);
Expand Down

0 comments on commit ba1420c

Please sign in to comment.