From a3570625c9460617ccad1803b50bc4f1793b6376 Mon Sep 17 00:00:00 2001 From: schnorr Date: Wed, 21 Apr 2010 08:38:08 +0000 Subject: [PATCH] adding test example to trace process migration using the mask TRACE_PROCESS git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@7625 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- buildtools/Cmake/src/CMakeTest.txt | 1 + examples/msg/tracing/CMakeLists.txt | 2 + examples/msg/tracing/procmig-deploy.xml | 5 ++ examples/msg/tracing/procmig.c | 78 +++++++++++++++++++++++++ examples/msg/tracing/procmig.tesh | 12 ++++ 5 files changed, 98 insertions(+) create mode 100644 examples/msg/tracing/procmig-deploy.xml create mode 100644 examples/msg/tracing/procmig.c create mode 100644 examples/msg/tracing/procmig.tesh diff --git a/buildtools/Cmake/src/CMakeTest.txt b/buildtools/Cmake/src/CMakeTest.txt index 54471516d7..8bfb8f080a 100644 --- a/buildtools/Cmake/src/CMakeTest.txt +++ b/buildtools/Cmake/src/CMakeTest.txt @@ -135,6 +135,7 @@ ADD_TEST(msg-masterslave_cpu_ti ${PROJECT_DIRECTORY}/tools/tesh/tesh --cd ${PROJ IF(HAVE_TRACING) ADD_TEST(tracing-ms ${PROJECT_DIRECTORY}/tools/tesh/tesh --cd ${PROJECT_DIRECTORY}/examples/msg tracing/ms.tesh) ADD_TEST(tracing-categories ${PROJECT_DIRECTORY}/tools/tesh/tesh --cd ${PROJECT_DIRECTORY}/examples/msg tracing/categories.tesh) + ADD_TEST(tracing-process-migration ${PROJECT_DIRECTORY}/tools/tesh/tesh --cd ${PROJECT_DIRECTORY}/examples/msg tracing/procmig.tesh) ENDIF(HAVE_TRACING) diff --git a/examples/msg/tracing/CMakeLists.txt b/examples/msg/tracing/CMakeLists.txt index e5f6d7b295..23663d90cc 100644 --- a/examples/msg/tracing/CMakeLists.txt +++ b/examples/msg/tracing/CMakeLists.txt @@ -5,7 +5,9 @@ set(LIBRARY_OUTPUT_PATH "${PROJECT_DIRECTORY}/lib") add_executable(ms ${PROJECT_DIRECTORY}/examples/msg/tracing/ms.c) add_executable(categories ${PROJECT_DIRECTORY}/examples/msg/tracing/categories.c) +add_executable(procmig ${PROJECT_DIRECTORY}/examples/msg/tracing/procmig.c) ### Add definitions for compile target_link_libraries(ms simgrid m -fprofile-arcs) target_link_libraries(categories simgrid m -fprofile-arcs) +target_link_libraries(procmig simgrid m -fprofile-arcs) diff --git a/examples/msg/tracing/procmig-deploy.xml b/examples/msg/tracing/procmig-deploy.xml new file mode 100644 index 0000000000..ff128dd608 --- /dev/null +++ b/examples/msg/tracing/procmig-deploy.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/examples/msg/tracing/procmig.c b/examples/msg/tracing/procmig.c new file mode 100644 index 0000000000..e72866fb9e --- /dev/null +++ b/examples/msg/tracing/procmig.c @@ -0,0 +1,78 @@ +/* $Id$ */ + +/* Copyright (c) 2009 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 "msg/msg.h" /* core library */ +#include "xbt/sysdep.h" /* calloc */ + +/* Create a log channel to have nice outputs. */ +#include "xbt/log.h" +XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, + "Messages specific for this msg example"); + +/** The guy we will move from host to host. It move alone and then is moved by policeman back */ +static int emigrant(int argc, char *argv[]) +{ + INFO0("Setting process category"); + TRACE_msg_set_process_category (MSG_process_self(), "emigrant"); + MSG_process_sleep (2); + INFO0("Migrating to Tremblay"); + MSG_process_change_host(MSG_get_host_by_name("Tremblay")); + MSG_process_sleep (2); + INFO0("Migrating to Jupiter"); + MSG_process_change_host(MSG_get_host_by_name("Jupiter")); + MSG_process_sleep (2); + INFO0("Migrating to Fafard"); + MSG_process_change_host(MSG_get_host_by_name("Fafard")); + MSG_process_sleep (2); + INFO0("Migrating to Ginette"); + MSG_process_change_host(MSG_get_host_by_name("Ginette")); + MSG_process_sleep (2); + INFO0("Migrating to Bourassa"); + MSG_process_change_host(MSG_get_host_by_name("Bourassa")); + MSG_process_sleep (2); + return 0; +} + +/** Main function */ +int main(int argc, char *argv[]) +{ + MSG_error_t res = MSG_OK; + + //starting the simulation trace + TRACE_start_with_mask ("procmig.trace", TRACE_PROCESS); + TRACE_category ("emigrant"); + + /* Argument checking */ + MSG_global_init(&argc, argv); + if (argc < 3) { + CRITICAL1("Usage: %s platform_file deployment_file\n", argv[0]); + CRITICAL1("example: %s msg_platform.xml msg_deployment_suspend.xml\n", + argv[0]); + exit(1); + } + + /* Simulation setting */ + MSG_create_environment(argv[1]); + + /* Application deployment */ + MSG_function_register("emigrant", emigrant); + MSG_launch_application(argv[2]); + + /* Run the simulation */ + res = MSG_main(); + INFO1("Simulation time %g", MSG_get_clock()); + if (res == MSG_OK) + res = MSG_clean(); + + //ending the simulation trace + TRACE_end(); + + if (res == MSG_OK) + return 0; + else + return 1; +} /* end_of_main */ diff --git a/examples/msg/tracing/procmig.tesh b/examples/msg/tracing/procmig.tesh new file mode 100644 index 0000000000..735cf09789 --- /dev/null +++ b/examples/msg/tracing/procmig.tesh @@ -0,0 +1,12 @@ +#! ./tesh + +p Tracing processes + +$ $SG_TEST_EXENV tracing/procmig$EXEEXT ${srcdir:=.}/tracing/platform.xml ${srcdir:=.}/tracing/procmig-deploy.xml +> [Fafard:emigrant:(1) 0.000000] [msg_test/INFO] Setting process category +> [Fafard:emigrant:(1) 2.000000] [msg_test/INFO] Migrating to Tremblay +> [Tremblay:emigrant:(1) 4.000000] [msg_test/INFO] Migrating to Jupiter +> [Jupiter:emigrant:(1) 6.000000] [msg_test/INFO] Migrating to Fafard +> [Fafard:emigrant:(1) 8.000000] [msg_test/INFO] Migrating to Ginette +> [Ginette:emigrant:(1) 10.000000] [msg_test/INFO] Migrating to Bourassa +> [12.000000] [msg_test/INFO] Simulation time 12 -- 2.20.1