X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/1b4f0ecf22879a1152f7b5fbcbf7bcdb416d21da..258864c23d070467ce222d3fa78aeb63e849c47c:/teshsuite/msg/host_on_off_processes/host_on_off_processes.cpp diff --git a/teshsuite/msg/host_on_off_processes/host_on_off_processes.cpp b/teshsuite/msg/host_on_off_processes/host_on_off_processes.cpp index c2ec3201ad..b4a467a306 100644 --- a/teshsuite/msg/host_on_off_processes/host_on_off_processes.cpp +++ b/teshsuite/msg/host_on_off_processes/host_on_off_processes.cpp @@ -1,10 +1,10 @@ -/* Copyright (c) 2010-2018. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ +#include "simgrid/Exception.hpp" #include "simgrid/msg.h" -#include #include /* sscanf */ @@ -15,11 +15,10 @@ int tasks_done = 0; static void task_cleanup_handler(void* task) { - if (task) - MSG_task_destroy(static_cast(task)); + MSG_task_destroy(static_cast(task)); } -static int process_daemon(int argc, char* argv[]) +static int process_daemon(int /*argc*/, char** /*argv*/) { msg_process_t self = MSG_process_self(); XBT_INFO(" Start daemon on %s (%f)", MSG_host_get_name(MSG_host_self()), MSG_host_get_speed(MSG_host_self())); @@ -28,7 +27,6 @@ static int process_daemon(int argc, char* argv[]) MSG_process_set_data(self, task); XBT_INFO(" Execute daemon"); MSG_task_execute(task); - MSG_process_set_data(self, NULL); MSG_task_destroy(task); tasks_done++; } @@ -36,58 +34,42 @@ static int process_daemon(int argc, char* argv[]) return 0; } -static int process_sleep(int argc, char* argv[]) -{ - for (;;) { - XBT_INFO(" I'm alive but I should sleep"); - MSG_process_sleep(10); - } - XBT_INFO(" I'm done. See you!"); - return 0; -} - -static int commTX(int argc, char* argv[]) +static int commTX(int /*argc*/, char** /*argv*/) { const char* mailbox = "comm"; XBT_INFO(" Start TX"); msg_task_t task = MSG_task_create("COMM", 0, 100000000, NULL); MSG_task_dsend(task, mailbox, task_cleanup_handler); // We should wait a bit (if not the process will end before the communication, hence an exception on the other side). - try { - MSG_process_sleep(30); - } catch (xbt_ex& e) { - if (e.category == host_error) { - XBT_INFO("The host has died ... as expected."); - } else { - XBT_ERROR("An unexpected exception has been raised."); - throw; - } + int res = MSG_process_sleep(30); + if (res == MSG_HOST_FAILURE) { + XBT_INFO("The host has died ... as expected."); } XBT_INFO(" TX done"); return 0; } -static int commRX(int argc, char* argv[]) +static int commRX(int /*argc*/, char** /*argv*/) { msg_task_t task = NULL; const char* mailbox = "comm"; XBT_INFO(" Start RX"); msg_error_t error = MSG_task_receive(&(task), mailbox); if (error == MSG_OK) { - XBT_INFO(" Receive message: %s", task->name); + XBT_INFO(" Receive message: %s", MSG_task_get_name(task)); MSG_task_destroy(task); } else if (error == MSG_HOST_FAILURE) { XBT_INFO(" Receive message: HOST_FAILURE"); } else if (error == MSG_TRANSFER_FAILURE) { - XBT_INFO(" Receive message: TRANSFERT_FAILURE"); + XBT_INFO(" Receive message: TRANSFER_FAILURE"); } else { - XBT_INFO(" Receive message: %u", error); + XBT_INFO(" Receive message: %u", static_cast(error)); } XBT_INFO(" RX Done"); return 0; } -static int test_launcher(int argc, char* argv[]) +static int test_launcher(int /*argc*/, char** /*argv*/) { int test = 0; char** argvF; @@ -110,7 +92,7 @@ static int test_launcher(int argc, char* argv[]) } test = 2; - // Create a process that on a host that is turned off (this should not be possible) + // Create a process that on a host that is turned off (this is not allowed) if (xbt_dynar_search_or_negative(tests, &test) != -1) { XBT_INFO("Test 2:"); XBT_INFO(" Turn off Jupiter"); @@ -121,33 +103,13 @@ static int test_launcher(int argc, char* argv[]) argvF[0] = xbt_strdup("process_daemon"); MSG_process_create_with_arguments("process_daemon", process_daemon, NULL, jupiter, 1, argvF); MSG_process_sleep(10); - XBT_INFO(" Test 2 does not crash as it should (number of Process : %d, it should be 1)", MSG_process_get_number()); - XBT_INFO(" Ok so let's turn on/off the node to see whether the process is correctly bound to Jupiter"); - MSG_host_on(jupiter); - XBT_INFO(" Turn off"); - MSG_host_off(jupiter); - XBT_INFO(" sleep"); - MSG_process_sleep(10); - XBT_INFO("number of Process : %d it should be 1. The daemon that has been created for test2 has been correctly " - "destroyed....ok at least it looks rigorous, cool ! You just have to disallow the possibility to create " - "a new process on a node when the node is off.)", - MSG_process_get_number()); + XBT_INFO(" Test 2 does crash as it should. This message will not be displayed."); } test = 3; - // Create a process running sucessive sleeps on a host and turn the host off during the execution of the process. + // Create a process running successive sleeps on a host and turn the host off during the execution of the process. if (xbt_dynar_search_or_negative(tests, &test) != -1) { - XBT_INFO("Test 3:"); - MSG_host_on(jupiter); - argvF = xbt_new(char*, 2); - argvF[0] = xbt_strdup("process_sleep"); - MSG_process_create_with_arguments("process_sleep", process_sleep, NULL, jupiter, 1, argvF); - MSG_process_sleep(100); - XBT_INFO(" Turn off"); - MSG_host_off(jupiter); - XBT_INFO(" sleep for 10 seconds"); - MSG_process_sleep(10000); - XBT_INFO("number of Process : %d it should be 1 (i.e. the Test one))", MSG_process_get_number()); + xbt_die("Test 3 is superseeded by activity-lifecycle"); } test = 4;