X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/e26d84ebd86c18af7d79d4afd659e53fd62ac9eb..0f5aaf299f85e9347fa65abc98fd03d0555cc254:/teshsuite/msg/host_on_off/host_on_off_recv.c diff --git a/teshsuite/msg/host_on_off/host_on_off_recv.c b/teshsuite/msg/host_on_off/host_on_off_recv.c index 9fb3bde0d3..73adf38c50 100644 --- a/teshsuite/msg/host_on_off/host_on_off_recv.c +++ b/teshsuite/msg/host_on_off/host_on_off_recv.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2010-2014. The SimGrid Team. +/* Copyright (c) 2010-2015. The SimGrid Team. * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it @@ -25,26 +25,25 @@ int master(int argc, char *argv[]) { xbt_ex_t e; TRY { - msg_host_t jupiter = MSG_get_host_by_name("Jupiter"); + msg_host_t jupiter = MSG_host_by_name("Jupiter"); XBT_INFO("Master starting"); MSG_process_sleep(0.5); msg_comm_t comm = NULL; - if (1) { + { msg_task_t task = MSG_task_create("COMM", 0, 100000000, NULL); comm = MSG_task_isend(task, mailbox); } - if(MSG_process_sleep(0.5)) { - XBT_ERROR("Unexpected error while sleeping"); - return 1; - } + MSG_process_sleep(0.5); + XBT_INFO("Turning off the slave host"); MSG_host_off(jupiter); if (comm) { MSG_comm_wait(comm, -1); + MSG_comm_destroy(comm); } XBT_INFO("Master has finished"); } @@ -86,29 +85,23 @@ int main(int argc, char *argv[]) const char *application_file; MSG_init(&argc, argv); - if (argc != 3) { - printf("Usage: %s platform_file deployment_file\n", argv[0]); - printf("example: %s msg_platform.xml msg_deployment.xml\n", argv[0]); - exit(1); - } + xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n" + "\tExample: %s msg_platform.xml msg_deployment.xml\n", argv[0], argv[0]); + platform_file = argv[1]; application_file = argv[2]; - { /* Simulation setting */ - MSG_create_environment(platform_file); - } - { /* Application deployment */ - MSG_function_register("master", master); - MSG_function_register("slave", slave); + /* Simulation setting */ + MSG_create_environment(platform_file); + + /* Application deployment */ + MSG_function_register("master", master); + MSG_function_register("slave", slave); + MSG_launch_application(application_file); - MSG_launch_application(application_file); - } res = MSG_main(); XBT_INFO("Simulation time %g", MSG_get_clock()); - if (res == MSG_OK) - return 0; - else - return 1; + return res != MSG_OK; } /* end_of_main */