-/* $Id: mmrpc.c 3399 2007-04-11 19:34:43Z cherierm $ */
-
/* msg_handle - ensures the semantic of gras_msg_handle(i) for i<0,=0 or >0 */
/* Copyright (c) 2007, 2008, 2009, 2010. The SimGrid Team.
int server(int argc, char *argv[])
{
- gras_socket_t me = NULL, pal = NULL;
+ volatile xbt_socket_t me = NULL, pal = NULL;
int myport;
char *palstr;
xbt_ex_t e;
- int got_expected;
- double now;
+ _XBT_GNUC_UNUSED int got_expected;
+ _XBT_GNUC_UNUSED double now;
gras_init(&argc, argv);
- xbt_assert0(argc == 3, "Usage: server <myport> <client>");
+ xbt_assert(argc == 3, "Usage: server <myport> <client>");
myport = atoi(argv[1]);
palstr = argv[2];
XBT_INFO("Launch server (port=%d)", myport);
TRY {
me = gras_socket_server(myport);
- } CATCH(e) {
- RETHROW0("Unable to establish a server socket: %s");
+ }
+ CATCH_ANONYMOUS {
+ RETHROWF("Unable to establish a server socket: %s");
}
gras_os_sleep(1); /* Wait for pal to startup */
TRY {
pal = gras_socket_client_from_string(palstr);
- } CATCH(e) {
- RETHROW1("Unable to establish a socket to %s: %s", palstr);
+ }
+ CATCH_ANONYMOUS {
+ RETHROWF("Unable to establish a socket to %s: %s", palstr);
}
XBT_INFO("Initialization done.");
now = gras_os_time();
got_expected = 0;
TRY {
gras_msg_handle(0);
- } CATCH(e) {
+ }
+ CATCH(e) {
if (e.category == timeout_error) {
got_expected = 1;
xbt_ex_free(e);
} else {
- RETHROW0("Didn't got the expected timeout: %s");
+ RETHROWF("Didn't got the expected timeout: %s");
}
}
- xbt_assert0(got_expected,
+ xbt_assert(got_expected,
"gras_msg_handle(0) do not lead to any timeout exception");
- xbt_assert1(gras_os_time() - now < 0.01,
+ xbt_assert(gras_os_time() - now < 0.01,
"gras_msg_handle(0) do not anwser immediately (%.4fsec)",
gras_os_time() - now);
XBT_INFO("gras_msg_handle(0) works as expected (immediate timeout)");
got_expected = 1;
xbt_ex_free(e);
} else {
- RETHROW0("Didn't got the expected timeout: %s");
+ RETHROWF("Didn't got the expected timeout: %s");
}
}
- xbt_assert0(got_expected,
+ xbt_assert(got_expected,
"gras_msg_handle(1) do not lead to any timeout exception");
- xbt_assert1(gras_os_time() - now < 1.5,
+ xbt_assert(gras_os_time() - now < 1.5,
"gras_msg_handle(1) needs more than 1.5 sec to answer (%.4fsec)",
gras_os_time() - now);
- xbt_assert1(gras_os_time() - now >= 1.0,
+ xbt_assert(gras_os_time() - now >= 1.0,
"gras_msg_handle(1) answers in less than one second (%.4fsec)",
gras_os_time() - now);
XBT_INFO("gras_msg_handle(1) works as expected (delayed timeout)");
int client(int argc, char *argv[])
{
- gras_socket_t me = NULL, pal = NULL;
+ volatile xbt_socket_t me = NULL, pal = NULL;
int myport;
char *palstr;
- xbt_ex_t e;
- int got_expected;
-
-
gras_init(&argc, argv);
- xbt_assert0(argc == 3, "Usage: client <myport> <server>");
+ xbt_assert(argc == 3, "Usage: client <myport> <server>");
myport = atoi(argv[1]);
palstr = argv[2];
XBT_INFO("Launch client (port=%d)", myport);
TRY {
me = gras_socket_server(myport);
- } CATCH(e) {
- RETHROW0("Unable to establish a server socket: %s");
+ }
+ CATCH_ANONYMOUS {
+ RETHROWF("Unable to establish a server socket: %s");
}
gras_os_sleep(1); /* Wait for pal to startup */
TRY {
pal = gras_socket_client_from_string(palstr);
- } CATCH(e) {
- RETHROW1("Unable to establish a socket to %s: %s", palstr);
+ }
+ CATCH_ANONYMOUS {
+ RETHROWF("Unable to establish a socket to %s: %s", palstr);
}
XBT_INFO("Initialization done.");
/* Launch handle(-1). Lock until message from server expected */
- got_expected = 0;
TRY {
gras_msg_handle(-1);
- } CATCH(e) {
- RETHROW0("No exception expected during handle(-1), but got %s");
+ }
+ CATCH_ANONYMOUS {
+ RETHROWF("No exception expected during handle(-1), but got %s");
}
XBT_INFO("gras_msg_handle(-1) works as expected (locked)");