X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/ec16845133f5f1b5262d2d77d8ba22824fa8a446..9d7e857328377861f81e95fbc3138032b51b7da9:/teshsuite/gras/msg_handle/msg_handle.c diff --git a/teshsuite/gras/msg_handle/msg_handle.c b/teshsuite/gras/msg_handle/msg_handle.c index 5c4325a385..675cb00c4d 100644 --- a/teshsuite/gras/msg_handle/msg_handle.c +++ b/teshsuite/gras/msg_handle/msg_handle.c @@ -1,5 +1,3 @@ -/* $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. @@ -25,18 +23,18 @@ static int server_cb_hello_handler(gras_msg_cb_ctx_t ctx, 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 "); + xbt_assert(argc == 3, "Usage: server "); myport = atoi(argv[1]); palstr = argv[2]; @@ -46,13 +44,15 @@ int server(int argc, char *argv[]) XBT_INFO("Launch server (port=%d)", myport); TRY { me = gras_socket_server(myport); - } CATCH(e) { + } + 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) { + } + CATCH_ANONYMOUS { RETHROWF("Unable to establish a socket to %s: %s", palstr); } XBT_INFO("Initialization done."); @@ -62,7 +62,8 @@ int server(int argc, char *argv[]) got_expected = 0; TRY { gras_msg_handle(0); - } CATCH(e) { + } + CATCH(e) { if (e.category == timeout_error) { got_expected = 1; xbt_ex_free(e); @@ -70,9 +71,9 @@ int server(int argc, char *argv[]) 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)"); @@ -89,12 +90,12 @@ int server(int argc, char *argv[]) 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)"); @@ -113,16 +114,12 @@ int server(int argc, char *argv[]) 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 "); + xbt_assert(argc == 3, "Usage: client "); myport = atoi(argv[1]); palstr = argv[2]; @@ -132,22 +129,24 @@ int client(int argc, char *argv[]) XBT_INFO("Launch client (port=%d)", myport); TRY { me = gras_socket_server(myport); - } CATCH(e) { + } + 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) { + } + 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) { + } + CATCH_ANONYMOUS { RETHROWF("No exception expected during handle(-1), but got %s"); } XBT_INFO("gras_msg_handle(-1) works as expected (locked)");