X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/937f2eb5b429c3c03fc989a25fbc26fabd0cf529..c25a26b26202c93dc2bfa44d214b8f804b78b8b3:/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 8f0b5b2d36..eb6b46359e 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 */ @@ -31,7 +31,7 @@ static int process_daemon(int /*argc*/, char** /*argv*/) MSG_task_destroy(task); tasks_done++; if (res == MSG_HOST_FAILURE) { - XBT_INFO("Host as died as expected, do nothing else"); + XBT_INFO("Host has died as expected, do nothing else"); return 0; } } @@ -39,16 +39,6 @@ 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*/) { const char* mailbox = "comm"; @@ -56,15 +46,9 @@ static int commTX(int /*argc*/, char** /*argv*/) 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; @@ -77,7 +61,7 @@ static int commRX(int /*argc*/, char** /*argv*/) 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"); @@ -140,17 +124,7 @@ static int test_launcher(int /*argc*/, char** /*argv*/) test = 3; // Create a process running sucessive 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; @@ -196,6 +170,7 @@ static int test_launcher(int /*argc*/, char** /*argv*/) test = 6; if (xbt_dynar_search_or_negative(tests, &test) != -1) { XBT_INFO("Test 6: Turn on Jupiter, assign a VM on Jupiter, launch a process inside the VM, and turn off the node"); + MSG_process_set_data_cleanup(nullptr); // If set for test 6, cleanup handler gives double-free errors. // Create VM0 msg_vm_t vm0 = MSG_vm_create_core(jupiter, "vm0"); @@ -250,6 +225,7 @@ int main(int argc, char* argv[]) MSG_create_environment(argv[1]); + MSG_process_set_data_cleanup(task_cleanup_handler); MSG_process_create("test_launcher", test_launcher, NULL, MSG_get_host_by_name("Tremblay")); res = MSG_main();