Skip to content

Commit

Permalink
test/dispatch: cover flux_dispatch_requeue()
Browse files Browse the repository at this point in the history
  • Loading branch information
garlick committed Jun 9, 2017
1 parent a9236aa commit a7dfa53
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions t/loop/dispatch.c
Expand Up @@ -203,38 +203,44 @@ void test_cloned_dispatch (flux_t *orig)
ok (cb_called == 2,
"no messages handled on third reactor loop");


/* close the clone (requeues event and unmatched response) */
flux_matchtag_free (h, m.matchtag);
flux_matchtag_free (h, m2.matchtag);
flux_msg_handler_destroy (w);
flux_msg_handler_destroy (w2);
flux_close (h);
flux_reactor_destroy (r);
diag ("destroyed reactor, closed clone");
/* requeue event and unmatched responses */
ok (flux_dispatch_requeue (h) == 0,
"requeued unconsumed messages in clone");

msg = flux_recv (orig, FLUX_MATCH_ANY, 0);
ok (msg != NULL,
"received first message on orig handle");
skip (msg == NULL, 2);
rc = flux_msg_get_type (msg, &type);
ok (rc == 0 && type == FLUX_MSGTYPE_EVENT,
"and its the event");
flux_msg_destroy (msg);
end_skip;

msg = flux_recv (orig, FLUX_MATCH_ANY, 0);
ok (msg != NULL,
"received second message on orig handle");
skip (msg == NULL, 2);
rc = flux_msg_get_type (msg, &type);
ok (rc == 0 && type == FLUX_MSGTYPE_RESPONSE,
"and its a response");
rc = flux_msg_get_matchtag (msg, &matchtag);
ok (rc == 0 && matchtag == 2,
"and matchtag=2 (%d)", matchtag);
flux_msg_destroy (msg);
end_skip;

ok (flux_recv (orig, FLUX_MATCH_ANY, 0) == NULL,
"there are no more messages");

/* close the clone */
flux_msg_handler_destroy (w);
flux_msg_handler_destroy (w2);
flux_matchtag_free (h, m.matchtag);
flux_matchtag_free (h, m2.matchtag);
flux_close (h);
flux_reactor_destroy (r);
diag ("destroyed reactor, closed clone");
}

int main (int argc, char *argv[])
Expand Down

0 comments on commit a7dfa53

Please sign in to comment.