Skip to content

Commit

Permalink
added shutdown handshake to test_remote_actor
Browse files Browse the repository at this point in the history
the added shutdown handshake fixes a possible unit test failure
(remote actor calls `shutdown` before final message was sent)
  • Loading branch information
Neverlord committed Feb 20, 2013
1 parent c436fa3 commit e896953
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions unit_testing/test_remote_actor.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -213,8 +213,9 @@ int client_part(const vector<string_pair>& args) {
forward_to(fwd); forward_to(fwd);
} }
); );

// shutdown handshake
send(server, atom("farewell")); send(server, atom("farewell"));
receive(on(atom("cu")) >> [] { });
shutdown(); shutdown();
return CPPA_TEST_RESULT(); return CPPA_TEST_RESULT();
} }
Expand Down Expand Up @@ -329,11 +330,7 @@ int main(int argc, char** argv) {
CPPA_PRINT("test group communication via network (inverted setup)"); CPPA_PRINT("test group communication via network (inverted setup)");
spawn5_server(remote_client, true); spawn5_server(remote_client, true);


self->on_sync_failure([&] { self->on_sync_failure(CPPA_UNEXPECTED_MSG_CB());
CPPA_ERROR("unexpected message: "
<< to_string(self->last_dequeued())
<< endl);
});


// test forward_to "over network and back" // test forward_to "over network and back"
CPPA_PRINT("test forwarding over network 'and back'"); CPPA_PRINT("test forwarding over network 'and back'");
Expand All @@ -348,9 +345,10 @@ int main(int argc, char** argv) {
); );


CPPA_PRINT("wait for a last goodbye"); CPPA_PRINT("wait for a last goodbye");
receive ( receive(on(atom("farewell")) >> [&] {
on(atom("farewell")) >> [] { } send(remote_client, atom("cu"));
); CPPA_CHECKPOINT();
});
// wait until separate process (in sep. thread) finished execution // wait until separate process (in sep. thread) finished execution
if (run_remote_actor) child.join(); if (run_remote_actor) child.join();
shutdown(); shutdown();
Expand Down

0 comments on commit e896953

Please sign in to comment.