include teshsuite/msg/cloud-two-tasks/cloud-two-tasks.tesh
include teshsuite/msg/get_sender/get_sender.c
include teshsuite/msg/get_sender/get_sender.tesh
-include teshsuite/msg/host_on_off_processes/host_on_off_processes.cpp
-include teshsuite/msg/host_on_off_processes/host_on_off_processes.tesh
include teshsuite/msg/io-file/io-file.c
include teshsuite/msg/io-file/io-file.tesh
include teshsuite/msg/platform-properties/platform-properties.c
include teshsuite/s4u/concurrent_rw/concurrent_rw.tesh
include teshsuite/s4u/evaluate-get-route-time/evaluate-get-route-time.cpp
include teshsuite/s4u/evaluate-parse-time/evaluate-parse-time.cpp
+include teshsuite/s4u/host-on-off-actors/host-on-off-actors.cpp
+include teshsuite/s4u/host-on-off-actors/host-on-off-actors.tesh
include teshsuite/s4u/host-on-off-recv/host-on-off-recv.cpp
include teshsuite/s4u/host-on-off-recv/host-on-off-recv.tesh
include teshsuite/s4u/host-on-off/host-on-off.cpp
set(teshsuite_src ${teshsuite_src} ${CMAKE_CURRENT_SOURCE_DIR}/${x}/${x}.c)
endforeach()
-# CPP examples
-foreach(x host_on_off_processes)
- if(enable_msg)
- add_executable (${x} EXCLUDE_FROM_ALL ${x}/${x}.cpp)
- target_link_libraries(${x} simgrid)
- set_target_properties(${x} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${x})
- add_dependencies(tests ${x})
- endif()
-
- set(tesh_files ${tesh_files} ${CMAKE_CURRENT_SOURCE_DIR}/${x}/${x}.tesh)
- set(teshsuite_src ${teshsuite_src} ${CMAKE_CURRENT_SOURCE_DIR}/${x}/${x}.cpp)
-endforeach()
-
if(enable_msg)
add_executable (bittorrent EXCLUDE_FROM_ALL app-bittorrent/bittorrent.c app-bittorrent/bittorrent-messages.c app-bittorrent/bittorrent-peer.c app-bittorrent/tracker.c app-bittorrent/connection.c)
target_link_libraries(bittorrent simgrid)
PARENT_SCOPE)
if(enable_msg)
- foreach(x app-bittorrent cloud-two-tasks host_on_off_processes get_sender task_destroy_cancel task_listen_from
+ foreach(x app-bittorrent cloud-two-tasks get_sender task_destroy_cancel task_listen_from
io-file platform-properties)
ADD_TESH_FACTORIES(tesh-msg-${x} "raw" --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
+++ /dev/null
-/* Copyright (c) 2010-2020. 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 <stdio.h> /* sscanf */
-
-XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example");
-
-xbt_dynar_t tests;
-int tasks_done = 0;
-
-static void task_cleanup_handler(void* task)
-{
- MSG_task_destroy(static_cast<msg_task_t>(task));
-}
-
-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()));
- for (;;) {
- msg_task_t task = MSG_task_create("daemon", MSG_host_get_speed(MSG_host_self()), 0, NULL);
- MSG_process_set_data(self, task);
- XBT_INFO(" Execute daemon");
- MSG_task_execute(task);
- MSG_task_destroy(task);
- tasks_done++;
- }
- XBT_INFO(" daemon done. See you!");
- return 0;
-}
-
-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).
- 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*/)
-{
- 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", 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: TRANSFER_FAILURE");
- } else {
- XBT_INFO(" Receive message: %u", static_cast<unsigned int>(error));
- }
- XBT_INFO(" RX Done");
- return 0;
-}
-
-static int test_launcher(int /*argc*/, char** /*argv*/)
-{
- int test = 0;
- char** argvF;
- msg_host_t jupiter = MSG_host_by_name("Jupiter");
-
- test = 1;
- // Create a process running a simple task 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 1:");
- XBT_INFO(" Create a process on Jupiter");
- argvF = xbt_new(char*, 2);
- argvF[0] = xbt_strdup("process_daemon");
- MSG_process_create_with_arguments("process_daemon", process_daemon, NULL, jupiter, 1, argvF);
- MSG_process_sleep(3);
- XBT_INFO(" Turn off Jupiter");
- MSG_host_off(jupiter);
- MSG_process_sleep(10);
- XBT_INFO("Test 1 seems ok, cool !(#Processes: %d, it should be 1; #tasks: %d)", MSG_process_get_number(),
- tasks_done);
- }
-
- test = 2;
- // 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");
- // adsein: Jupiter is already, hence nothing should happen
- // adsein: This can be one additional test, to check that you cannot shutdown twice a host
- MSG_host_off(jupiter);
- argvF = xbt_new(char*, 2);
- 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 crash as it should. This message will not be displayed.");
- }
-
- test = 3;
- // 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_die("Test 3 is superseeded by activity-lifecycle");
- }
-
- test = 4;
- if (xbt_dynar_search_or_negative(tests, &test) != -1) {
- XBT_INFO("Test 4 (turn off src during a communication) : Create a Process/task to make a communication between "
- "Jupiter and Tremblay and turn off Jupiter during the communication");
- MSG_host_on(jupiter);
- MSG_process_sleep(10);
- argvF = xbt_new(char*, 2);
- argvF[0] = xbt_strdup("commRX");
- MSG_process_create_with_arguments("commRX", commRX, NULL, MSG_host_by_name("Tremblay"), 1, argvF);
- argvF = xbt_new(char*, 2);
- argvF[0] = xbt_strdup("commTX");
- MSG_process_create_with_arguments("commTX", commTX, NULL, jupiter, 1, argvF);
- XBT_INFO(" number of processes: %d", MSG_process_get_number());
- MSG_process_sleep(10);
- XBT_INFO(" Turn Jupiter off");
- MSG_host_off(jupiter);
- XBT_INFO("Test 4 is ok. (number of Process : %d, it should be 1 or 2 if RX has not been satisfied)."
- " An exception is raised when we turn off a node that has a process sleeping",
- MSG_process_get_number());
- }
-
- test = 5;
- if (xbt_dynar_search_or_negative(tests, &test) != -1) {
- XBT_INFO("Test 5 (turn off dest during a communication : Create a Process/task to make a communication between "
- "Tremblay and Jupiter and turn off Jupiter during the communication");
- MSG_host_on(jupiter);
- MSG_process_sleep(10);
- argvF = xbt_new(char*, 2);
- argvF[0] = xbt_strdup("commRX");
- MSG_process_create_with_arguments("commRX", commRX, NULL, jupiter, 1, argvF);
- argvF = xbt_new(char*, 2);
- argvF[0] = xbt_strdup("commTX");
- MSG_process_create_with_arguments("commTX", commTX, NULL, MSG_host_by_name("Tremblay"), 1, argvF);
- XBT_INFO(" number of processes: %d", MSG_process_get_number());
- MSG_process_sleep(10);
- XBT_INFO(" Turn Jupiter off");
- MSG_host_off(jupiter);
- XBT_INFO("Test 5 seems ok (number of Process: %d, it should be 2)", MSG_process_get_number());
- }
-
- 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");
-
- // Create VM0
- msg_vm_t vm0 = MSG_vm_create_core(jupiter, "vm0");
- MSG_vm_start(vm0);
-
- argvF = xbt_new(char*, 2);
- argvF[0] = xbt_strdup("process_daemon");
- msg_process_t daemon =
- MSG_process_create_with_arguments("process_daemon", process_daemon, NULL, (msg_host_t)vm0, 1, argvF);
-
- argvF = xbt_new(char*, 2);
- argvF[0] = xbt_strdup("process_daemonJUPI");
- MSG_process_create_with_arguments("process_daemonJUPI", process_daemon, NULL, jupiter, 1, argvF);
-
- MSG_process_suspend(daemon);
- MSG_vm_set_bound(vm0, 90);
- MSG_process_resume(daemon);
-
- MSG_process_sleep(10);
-
- XBT_INFO(" Turn Jupiter off");
- MSG_host_off(jupiter);
- XBT_INFO(" Shutdown vm0");
- MSG_vm_shutdown(vm0);
- XBT_INFO(" Destroy vm0");
- MSG_vm_destroy(vm0);
- XBT_INFO("Test 6 is also weird: when the node Jupiter is turned off once again, the VM and its daemon are not "
- "killed. However, the issue regarding the shutdown of hosted VMs can be seen a feature not a bug ;)");
- }
-
- XBT_INFO(" Test done. See you!");
- return 0;
-}
-
-int main(int argc, char* argv[])
-{
- msg_error_t res;
-
- MSG_init(&argc, argv);
- xbt_assert(argc == 3, "Usage: %s platform_file test_number\n\tExample: %s msg_platform.xml 1\n", argv[0], argv[0]);
-
- unsigned int iter;
- char* groups;
- xbt_dynar_t s_tests = xbt_str_split(argv[2], ",");
- int tmp_test = 0;
- tests = xbt_dynar_new(sizeof(int), NULL);
- xbt_dynar_foreach (s_tests, iter, groups) {
- sscanf(xbt_dynar_get_as(s_tests, iter, char*), "%d", &tmp_test);
- xbt_dynar_set_as(tests, iter, int, tmp_test);
- }
- xbt_dynar_free(&s_tests);
-
- 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();
-
- XBT_INFO("Simulation time %g", MSG_get_clock());
- xbt_dynar_free(&tests);
-
- return res != MSG_OK;
-}
+++ /dev/null
-
-$ ${bindir}/host_on_off_processes ${platfdir}/small_platform.xml 1 --log=no_loc
-> [Tremblay:test_launcher:(1) 0.000000] [msg_test/INFO] Test 1:
-> [Tremblay:test_launcher:(1) 0.000000] [msg_test/INFO] Create a process on Jupiter
-> [Jupiter:process_daemon:(2) 0.000000] [msg_test/INFO] Start daemon on Jupiter (76296000.000000)
-> [Jupiter:process_daemon:(2) 0.000000] [msg_test/INFO] Execute daemon
-> [Jupiter:process_daemon:(2) 1.000000] [msg_test/INFO] Execute daemon
-> [Jupiter:process_daemon:(2) 2.000000] [msg_test/INFO] Execute daemon
-> [Tremblay:test_launcher:(1) 3.000000] [msg_test/INFO] Turn off Jupiter
-> [Jupiter:process_daemon:(2) 3.000000] [msg_test/INFO] Execute daemon
-> [Tremblay:test_launcher:(1) 13.000000] [msg_test/INFO] Test 1 seems ok, cool !(#Processes: 1, it should be 1; #tasks: 3)
-> [Tremblay:test_launcher:(1) 13.000000] [msg_test/INFO] Test done. See you!
-> [13.000000] [msg_test/INFO] Simulation time 13
-
-! expect signal SIGIOT
-$ $VALGRIND_NO_LEAK_CHECK ${bindir}/host_on_off_processes ${platfdir}/small_platform.xml 2 --log=no_loc
-> [Tremblay:test_launcher:(1) 0.000000] [msg_test/INFO] Test 2:
-> [Tremblay:test_launcher:(1) 0.000000] [msg_test/INFO] Turn off Jupiter
-> [0.000000] [simix_process/WARNING] Cannot launch actor 'process_daemon' on failed host 'Jupiter'
-> [Tremblay:test_launcher:(1) 0.000000] [xbt/CRITICAL] Could not launch a new process on failed host Jupiter.
-
-$ ${bindir}/host_on_off_processes ${platfdir}/small_platform.xml 4 --log=no_loc
-> [Tremblay:test_launcher:(1) 0.000000] [msg_test/INFO] Test 4 (turn off src during a communication) : Create a Process/task to make a communication between Jupiter and Tremblay and turn off Jupiter during the communication
-> [Tremblay:commRX:(2) 10.000000] [msg_test/INFO] Start RX
-> [Jupiter:commTX:(3) 10.000000] [msg_test/INFO] Start TX
-> [Tremblay:test_launcher:(1) 10.000000] [msg_test/INFO] number of processes: 3
-> [Tremblay:test_launcher:(1) 20.000000] [msg_test/INFO] Turn Jupiter off
-> [Tremblay:test_launcher:(1) 20.000000] [msg_test/INFO] Test 4 is ok. (number of Process : 2, it should be 1 or 2 if RX has not been satisfied). An exception is raised when we turn off a node that has a process sleeping
-> [Tremblay:test_launcher:(1) 20.000000] [msg_test/INFO] Test done. See you!
-> [Tremblay:commRX:(2) 25.033047] [msg_test/INFO] Receive message: COMM
-> [Tremblay:commRX:(2) 25.033047] [msg_test/INFO] RX Done
-> [25.033047] [msg_test/INFO] Simulation time 25.033
-
-$ ${bindir}/host_on_off_processes ${platfdir}/small_platform.xml 5 --log=no_loc
-> [Tremblay:test_launcher:(1) 0.000000] [msg_test/INFO] Test 5 (turn off dest during a communication : Create a Process/task to make a communication between Tremblay and Jupiter and turn off Jupiter during the communication
-> [Jupiter:commRX:(2) 10.000000] [msg_test/INFO] Start RX
-> [Tremblay:commTX:(3) 10.000000] [msg_test/INFO] Start TX
-> [Tremblay:test_launcher:(1) 10.000000] [msg_test/INFO] number of processes: 3
-> [Tremblay:test_launcher:(1) 20.000000] [msg_test/INFO] Turn Jupiter off
-> [Tremblay:test_launcher:(1) 20.000000] [msg_test/INFO] Test 5 seems ok (number of Process: 2, it should be 2)
-> [Tremblay:test_launcher:(1) 20.000000] [msg_test/INFO] Test done. See you!
-> [Tremblay:commTX:(3) 40.000000] [msg_test/INFO] TX done
-> [40.000000] [msg_test/INFO] Simulation time 40
-
-$ ${bindir}/host_on_off_processes ${platfdir}/small_platform.xml 6 --log=no_loc
-> [Tremblay:test_launcher:(1) 0.000000] [msg_test/INFO] Test 6: Turn on Jupiter, assign a VM on Jupiter, launch a process inside the VM, and turn off the node
-> [vm0:process_daemon:(2) 0.000000] [msg_test/INFO] Start daemon on vm0 (76296000.000000)
-> [vm0:process_daemon:(2) 0.000000] [msg_test/INFO] Execute daemon
-> [Jupiter:process_daemonJUPI:(3) 0.000000] [msg_test/INFO] Start daemon on Jupiter (76296000.000000)
-> [Jupiter:process_daemonJUPI:(3) 0.000000] [msg_test/INFO] Execute daemon
-> [Jupiter:process_daemonJUPI:(3) 1.000001] [msg_test/INFO] Execute daemon
-> [Jupiter:process_daemonJUPI:(3) 2.000002] [msg_test/INFO] Execute daemon
-> [Jupiter:process_daemonJUPI:(3) 3.000004] [msg_test/INFO] Execute daemon
-> [Jupiter:process_daemonJUPI:(3) 4.000005] [msg_test/INFO] Execute daemon
-> [Jupiter:process_daemonJUPI:(3) 5.000006] [msg_test/INFO] Execute daemon
-> [Jupiter:process_daemonJUPI:(3) 6.000007] [msg_test/INFO] Execute daemon
-> [Jupiter:process_daemonJUPI:(3) 7.000008] [msg_test/INFO] Execute daemon
-> [Jupiter:process_daemonJUPI:(3) 8.000009] [msg_test/INFO] Execute daemon
-> [Jupiter:process_daemonJUPI:(3) 9.000011] [msg_test/INFO] Execute daemon
-> [Tremblay:test_launcher:(1) 10.000000] [msg_test/INFO] Turn Jupiter off
-> [Tremblay:test_launcher:(1) 10.000000] [msg_test/INFO] Shutdown vm0
-> [Tremblay:test_launcher:(1) 10.000000] [msg_test/INFO] Destroy vm0
-> [Tremblay:test_launcher:(1) 10.000000] [msg_test/INFO] Test 6 is also weird: when the node Jupiter is turned off once again, the VM and its daemon are not killed. However, the issue regarding the shutdown of hosted VMs can be seen a feature not a bug ;)
-> [Tremblay:test_launcher:(1) 10.000000] [msg_test/INFO] Test done. See you!
-> [10.000000] [msg_test/INFO] Simulation time 10
comm-pt2pt wait-any-for
cloud-interrupt-migration cloud-sharing
concurrent_rw
- host-on-off host-on-off-recv
+ host-on-off host-on-off-actors host-on-off-recv
basic-link-test evaluate-get-route-time evaluate-parse-time is-router
storage_client_server listen_async pid
trace-integration)
ADD_TESH_FACTORIES(tesh-s4u-${x} "thread;ucontext;raw;boost" --setenv bindir=${CMAKE_BINARY_DIR}/teshsuite/s4u/${x} --setenv srcdir=${CMAKE_HOME_DIRECTORY}/teshsuite/s4u/${x} --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms --cd ${CMAKE_BINARY_DIR}/teshsuite/s4u/${x} ${CMAKE_HOME_DIRECTORY}/teshsuite/s4u/${x}/${x}.tesh)
endforeach()
-foreach(x basic-link-test host-on-off host-on-off-recv is-router listen_async pid storage_client_server cloud-sharing trace-integration)
+foreach(x basic-link-test host-on-off host-on-off-actors host-on-off-recv is-router listen_async pid storage_client_server cloud-sharing trace-integration)
set(tesh_files ${tesh_files} ${CMAKE_CURRENT_SOURCE_DIR}/${x}/${x}.tesh)
ADD_TESH(tesh-s4u-${x} --setenv srcdir=${CMAKE_HOME_DIRECTORY}/teshsuite/s4u/${x} --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms --cd ${CMAKE_BINARY_DIR}/teshsuite/s4u/${x} ${CMAKE_HOME_DIRECTORY}/teshsuite/s4u/${x}/${x}.tesh)
endforeach()
--- /dev/null
+/* Copyright (c) 2010-2020. 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/s4u.hpp"
+
+XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this s4u example");
+
+int tasks_done = 0;
+
+static void actor_daemon()
+{
+ simgrid::s4u::Host* host = simgrid::s4u::Host::current();
+ XBT_INFO(" Start daemon on %s (%f)", host->get_cname(), host->get_speed());
+ for (;;) {
+ XBT_INFO(" Execute daemon");
+ simgrid::s4u::this_actor::execute(host->get_speed());
+ tasks_done++;
+ }
+ XBT_INFO(" daemon done. See you!");
+}
+
+static void commTX()
+{
+ XBT_INFO(" Start TX");
+ simgrid::s4u::Mailbox::by_name("comm")->put_init(xbt_strdup("COMM"), 100000000)->detach();
+ // We should wait a bit (if not the process will end before the communication, hence an exception on the other side).
+ try {
+ simgrid::s4u::this_actor::sleep_for(30);
+ } catch (const simgrid::HostFailureException&) {
+ XBT_INFO("The host has died ... as expected.");
+ }
+ XBT_INFO(" TX done");
+}
+
+static void commRX()
+{
+ char* payload = nullptr;
+ XBT_INFO(" Start RX");
+ try {
+ payload = static_cast<char*>(simgrid::s4u::Mailbox::by_name("comm")->get());
+ XBT_INFO(" Receive message: %s", payload);
+ } catch (const simgrid::HostFailureException&) {
+ XBT_INFO(" Receive message: HOST_FAILURE");
+ } catch (const simgrid::NetworkFailureException&) {
+ XBT_INFO(" Receive message: TRANSFER_FAILURE");
+ }
+
+ xbt_free(payload);
+ XBT_INFO(" RX Done");
+}
+
+static void test_launcher(int test_number)
+{
+ simgrid::s4u::Host* jupiter = simgrid::s4u::Host::by_name("Jupiter");
+ simgrid::s4u::ActorPtr daemon;
+ simgrid::s4u::VirtualMachine* vm0 = nullptr;
+
+ switch (test_number) {
+ case 1:
+ // Create a process running a simple task on a host and turn the host off during the execution of the actor.
+ XBT_INFO("Test 1:");
+ XBT_INFO(" Create an actor on Jupiter");
+ simgrid::s4u::Actor::create("actor_daemon", jupiter, actor_daemon);
+ simgrid::s4u::this_actor::sleep_for(3);
+ XBT_INFO(" Turn off Jupiter");
+ jupiter->turn_off();
+ simgrid::s4u::this_actor::sleep_for(10);
+ XBT_INFO("Test 1 seems ok, cool !(#Actors: %zu, it should be 1; #tasks: %d)",
+ simgrid::s4u::Engine::get_instance()->get_actor_count(), tasks_done);
+ break;
+ case 2:
+ // Create an actorthat on a host that is turned off (this is not allowed)
+ XBT_INFO("Test 2:");
+ XBT_INFO(" Turn off Jupiter");
+ // adsein: Jupiter is already off, hence nothing should happen
+ // adsein: This can be one additional test, to check that you cannot shutdown twice a host
+ jupiter->turn_off();
+ try {
+ simgrid::s4u::Actor::create("actor_daemon", jupiter, actor_daemon);
+ simgrid::s4u::this_actor::sleep_for(10);
+ XBT_INFO(" Test 2 does crash as it should. This message will not be displayed.");
+ } catch (const simgrid::HostFailureException&) {
+ xbt_die("Could not launch a new actor on failed host %s.", jupiter->get_cname());
+ }
+ break;
+ case 3:
+ // Create an actor running successive sleeps on a host and turn the host off during the execution of the actor.
+ xbt_die("Test 3 is superseded by activity-lifecycle");
+ break;
+ case 4:
+ XBT_INFO("Test 4 (turn off src during a communication) : Create an actor/task to make a communication between "
+ "Jupiter and Tremblay and turn off Jupiter during the communication");
+ jupiter->turn_on();
+ simgrid::s4u::this_actor::sleep_for(10);
+ simgrid::s4u::Actor::create("commRX", simgrid::s4u::Host::by_name("Tremblay"), commRX);
+ simgrid::s4u::Actor::create("commTX", jupiter, commTX);
+ XBT_INFO(" number of actors: %zu", simgrid::s4u::Engine::get_instance()->get_actor_count());
+ simgrid::s4u::this_actor::sleep_for(10);
+ XBT_INFO(" Turn Jupiter off");
+ jupiter->turn_off();
+ XBT_INFO("Test 4 is ok. (number of actors : %zu, it should be 1 or 2 if RX has not been satisfied)."
+ " An exception is raised when we turn off a node that has an actor sleeping",
+ simgrid::s4u::Engine::get_instance()->get_actor_count());
+ break;
+ case 5:
+ XBT_INFO("Test 5 (turn off dest during a communication : Create an actor/task to make a communication between "
+ "Tremblay and Jupiter and turn off Jupiter during the communication");
+ jupiter->turn_on();
+ simgrid::s4u::this_actor::sleep_for(10);
+ simgrid::s4u::Actor::create("commRX", jupiter, commRX);
+ simgrid::s4u::Actor::create("commTX", simgrid::s4u::Host::by_name("Tremblay"), commTX);
+ XBT_INFO(" number of actors: %zu", simgrid::s4u::Engine::get_instance()->get_actor_count());
+ simgrid::s4u::this_actor::sleep_for(10);
+ XBT_INFO(" Turn Jupiter off");
+ jupiter->turn_off();
+ XBT_INFO("Test 5 seems ok (number of actors: %zu, it should be 2)",
+ simgrid::s4u::Engine::get_instance()->get_actor_count());
+ break;
+ case 6:
+ XBT_INFO("Test 6: Turn on Jupiter, assign a VM on Jupiter, launch an actor inside the VM, and turn off the node");
+
+ // Create VM0
+ vm0 = new simgrid::s4u::VirtualMachine("vm0", jupiter, 1);
+ vm0->start();
+
+ daemon = simgrid::s4u::Actor::create("actor_daemon", vm0, actor_daemon);
+ simgrid::s4u::Actor::create("actor_daemonJUPI", jupiter, actor_daemon);
+
+ daemon->suspend();
+ vm0->set_bound(90);
+ daemon->resume();
+
+ simgrid::s4u::this_actor::sleep_for(10);
+
+ XBT_INFO(" Turn Jupiter off");
+ jupiter->turn_off();
+ XBT_INFO(" Shutdown vm0");
+ vm0->shutdown();
+ XBT_INFO(" Destroy vm0");
+ vm0->destroy();
+ XBT_INFO("Test 6 is also weird: when the node Jupiter is turned off once again, the VM and its daemon are not "
+ "killed. However, the issue regarding the shutdown of hosted VMs can be seen a feature not a bug ;)");
+ break;
+ default:
+ xbt_die("Unknown test case.");
+ }
+
+ XBT_INFO(" Test done. See you!");
+}
+
+int main(int argc, char* argv[])
+{
+ simgrid::s4u::Engine e(&argc, argv);
+ xbt_assert(argc == 3, "Usage: %s platform_file test_number\n\tExample: %s msg_platform.xml 1\n", argv[0], argv[0]);
+
+ e.load_platform(argv[1]);
+
+ simgrid::s4u::Actor::create("test_launcher", simgrid::s4u::Host::by_name("Tremblay"), test_launcher,
+ std::stoi(argv[2]));
+
+ e.run();
+
+ XBT_INFO("Simulation time %g", e.get_clock());
+
+ return 0;
+}
--- /dev/null
+
+$ ./host-on-off-actors ${platfdir}/small_platform.xml 1 --log=no_loc
+> [Tremblay:test_launcher:(1) 0.000000] [s4u_test/INFO] Test 1:
+> [Tremblay:test_launcher:(1) 0.000000] [s4u_test/INFO] Create an actor on Jupiter
+> [Jupiter:actor_daemon:(2) 0.000000] [s4u_test/INFO] Start daemon on Jupiter (76296000.000000)
+> [Jupiter:actor_daemon:(2) 0.000000] [s4u_test/INFO] Execute daemon
+> [Jupiter:actor_daemon:(2) 1.000000] [s4u_test/INFO] Execute daemon
+> [Jupiter:actor_daemon:(2) 2.000000] [s4u_test/INFO] Execute daemon
+> [Tremblay:test_launcher:(1) 3.000000] [s4u_test/INFO] Turn off Jupiter
+> [Jupiter:actor_daemon:(2) 3.000000] [s4u_test/INFO] Execute daemon
+> [Tremblay:test_launcher:(1) 13.000000] [s4u_test/INFO] Test 1 seems ok, cool !(#Actors: 1, it should be 1; #tasks: 3)
+> [Tremblay:test_launcher:(1) 13.000000] [s4u_test/INFO] Test done. See you!
+> [13.000000] [s4u_test/INFO] Simulation time 13
+
+! expect signal SIGIOT
+$ $VALGRIND_NO_LEAK_CHECK ./host-on-off-actors ${platfdir}/small_platform.xml 2 --log=no_loc
+> [Tremblay:test_launcher:(1) 0.000000] [s4u_test/INFO] Test 2:
+> [Tremblay:test_launcher:(1) 0.000000] [s4u_test/INFO] Turn off Jupiter
+> [0.000000] [simix_process/WARNING] Cannot launch actor 'actor_daemon' on failed host 'Jupiter'
+> [Tremblay:test_launcher:(1) 0.000000] [xbt/CRITICAL] Could not launch a new actor on failed host Jupiter.
+
+$ ./host-on-off-actors ${platfdir}/small_platform.xml 4 --log=no_loc
+> [Tremblay:test_launcher:(1) 0.000000] [s4u_test/INFO] Test 4 (turn off src during a communication) : Create an actor/task to make a communication between Jupiter and Tremblay and turn off Jupiter during the communication
+> [Tremblay:commRX:(2) 10.000000] [s4u_test/INFO] Start RX
+> [Jupiter:commTX:(3) 10.000000] [s4u_test/INFO] Start TX
+> [Tremblay:test_launcher:(1) 10.000000] [s4u_test/INFO] number of actors: 3
+> [Tremblay:test_launcher:(1) 20.000000] [s4u_test/INFO] Turn Jupiter off
+> [Tremblay:test_launcher:(1) 20.000000] [s4u_test/INFO] Test 4 is ok. (number of actors : 2, it should be 1 or 2 if RX has not been satisfied). An exception is raised when we turn off a node that has an actor sleeping
+> [Tremblay:test_launcher:(1) 20.000000] [s4u_test/INFO] Test done. See you!
+> [Tremblay:commRX:(2) 25.033047] [s4u_test/INFO] Receive message: COMM
+> [Tremblay:commRX:(2) 25.033047] [s4u_test/INFO] RX Done
+> [25.033047] [s4u_test/INFO] Simulation time 25.033
+
+$ ./host-on-off-actors ${platfdir}/small_platform.xml 5 --log=no_loc
+> [Tremblay:test_launcher:(1) 0.000000] [s4u_test/INFO] Test 5 (turn off dest during a communication : Create an actor/task to make a communication between Tremblay and Jupiter and turn off Jupiter during the communication
+> [Jupiter:commRX:(2) 10.000000] [s4u_test/INFO] Start RX
+> [Tremblay:commTX:(3) 10.000000] [s4u_test/INFO] Start TX
+> [Tremblay:test_launcher:(1) 10.000000] [s4u_test/INFO] number of actors: 3
+> [Tremblay:test_launcher:(1) 20.000000] [s4u_test/INFO] Turn Jupiter off
+> [Tremblay:test_launcher:(1) 20.000000] [s4u_test/INFO] Test 5 seems ok (number of actors: 2, it should be 2)
+> [Tremblay:test_launcher:(1) 20.000000] [s4u_test/INFO] Test done. See you!
+> [Tremblay:commTX:(3) 40.000000] [s4u_test/INFO] TX done
+> [40.000000] [s4u_test/INFO] Simulation time 40
+
+$ ./host-on-off-actors ${platfdir}/small_platform.xml 6 --log=no_loc
+> [Tremblay:test_launcher:(1) 0.000000] [s4u_test/INFO] Test 6: Turn on Jupiter, assign a VM on Jupiter, launch an actor inside the VM, and turn off the node
+> [vm0:actor_daemon:(2) 0.000000] [s4u_test/INFO] Start daemon on vm0 (76296000.000000)
+> [vm0:actor_daemon:(2) 0.000000] [s4u_test/INFO] Execute daemon
+> [Jupiter:actor_daemonJUPI:(3) 0.000000] [s4u_test/INFO] Start daemon on Jupiter (76296000.000000)
+> [Jupiter:actor_daemonJUPI:(3) 0.000000] [s4u_test/INFO] Execute daemon
+> [Jupiter:actor_daemonJUPI:(3) 1.000001] [s4u_test/INFO] Execute daemon
+> [Jupiter:actor_daemonJUPI:(3) 2.000002] [s4u_test/INFO] Execute daemon
+> [Jupiter:actor_daemonJUPI:(3) 3.000004] [s4u_test/INFO] Execute daemon
+> [Jupiter:actor_daemonJUPI:(3) 4.000005] [s4u_test/INFO] Execute daemon
+> [Jupiter:actor_daemonJUPI:(3) 5.000006] [s4u_test/INFO] Execute daemon
+> [Jupiter:actor_daemonJUPI:(3) 6.000007] [s4u_test/INFO] Execute daemon
+> [Jupiter:actor_daemonJUPI:(3) 7.000008] [s4u_test/INFO] Execute daemon
+> [Jupiter:actor_daemonJUPI:(3) 8.000009] [s4u_test/INFO] Execute daemon
+> [Jupiter:actor_daemonJUPI:(3) 9.000011] [s4u_test/INFO] Execute daemon
+> [Tremblay:test_launcher:(1) 10.000000] [s4u_test/INFO] Turn Jupiter off
+> [Tremblay:test_launcher:(1) 10.000000] [s4u_test/INFO] Shutdown vm0
+> [Tremblay:test_launcher:(1) 10.000000] [s4u_test/INFO] Destroy vm0
+> [Tremblay:test_launcher:(1) 10.000000] [s4u_test/INFO] Test 6 is also weird: when the node Jupiter is turned off once again, the VM and its daemon are not killed. However, the issue regarding the shutdown of hosted VMs can be seen a feature not a bug ;)
+> [Tremblay:test_launcher:(1) 10.000000] [s4u_test/INFO] Test done. See you!
+> [10.000000] [s4u_test/INFO] Simulation time 10