From a300c30846b3dbaf928e15958b4df1d797c73640 Mon Sep 17 00:00:00 2001 From: quasar Date: Thu, 1 Nov 2007 15:59:42 +0000 Subject: [PATCH] msg properties example git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@4952 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- examples/msg/Makefile.am | 17 +- examples/msg/Makefile.in | 50 +++- examples/msg/masterslave/masterslave_bypass.c | 20 +- examples/msg/properties/Makefile | 30 +++ .../msg/properties/deployment_platform.xml | 12 + .../msg/properties/deployment_properties.xml | 15 ++ examples/msg/properties/msg_prop.c | 242 ++++++++++++++++++ examples/msg/properties/msg_test.tesh | 13 + 8 files changed, 377 insertions(+), 22 deletions(-) create mode 100644 examples/msg/properties/Makefile create mode 100644 examples/msg/properties/deployment_platform.xml create mode 100644 examples/msg/properties/deployment_properties.xml create mode 100644 examples/msg/properties/msg_prop.c create mode 100644 examples/msg/properties/msg_test.tesh diff --git a/examples/msg/Makefile.am b/examples/msg/Makefile.am index 2a7d98a1c4..87cb091288 100644 --- a/examples/msg/Makefile.am +++ b/examples/msg/Makefile.am @@ -20,7 +20,9 @@ EXTRA_DIST = msg_platform.xml \ gtnets/onelink-d.xml \ gtnets/r-n200-f50-s4-2-p.xml \ gtnets/dogbone-d.xml \ - gtnets/dogbone-p.xml + gtnets/dogbone-p.xml \ + properties/deployment_platform.xml \ + properties/deployment_properties.xml TESTS_ENVIRONMENT = $(top_builddir)/tools/tesh/tesh @@ -35,7 +37,8 @@ TESTS = sendrecv/sendrecv_KCCFLN05.tesh \ masterslave/masterslave_failure.tesh \ masterslave/masterslave_bypass.tesh \ parallel_task/parallel_task.tesh \ - priority/priority.tesh + priority/priority.tesh \ + properties/msg_test.tesh if HAVE_SDP @@ -53,7 +56,8 @@ CLEANFILES = sendrecv/*~ \ masterslave/masterslave_failure \ masterslave/masterslave_bypass \ parallel_task/parallel_task \ - priority/priority + priority/priority \ + properties/msg_prop if HAVE_GTNETS CLEANFILES += gtnets/gtnets @@ -68,13 +72,18 @@ noinst_PROGRAMS = sendrecv/sendrecv \ masterslave/masterslave_failure \ masterslave/masterslave_bypass \ parallel_task/parallel_task \ - priority/priority + priority/priority \ + properties/msg_prop if HAVE_GTNETS noinst_PROGRAMS += gtnets/gtnets endif +# property handle example +properties_msg_prop_SOURCES = properties/msg_prop.c +properties_msg_prop_LDADD = $(top_builddir)/src/libsimgrid.la + # sendrecv simple example sendrecv_sendrecv_SOURCES = sendrecv/sendrecv.c diff --git a/examples/msg/Makefile.in b/examples/msg/Makefile.in index 3acf3b1c96..d08dcef105 100644 --- a/examples/msg/Makefile.in +++ b/examples/msg/Makefile.in @@ -50,7 +50,8 @@ noinst_PROGRAMS = sendrecv/sendrecv$(EXEEXT) suspend/suspend$(EXEEXT) \ masterslave/masterslave_failure$(EXEEXT) \ masterslave/masterslave_bypass$(EXEEXT) \ parallel_task/parallel_task$(EXEEXT) \ - priority/priority$(EXEEXT) $(am__EXEEXT_1) + priority/priority$(EXEEXT) properties/msg_prop$(EXEEXT) \ + $(am__EXEEXT_1) @HAVE_GTNETS_TRUE@am__append_2 = gtnets/gtnets @HAVE_GTNETS_FALSE@am__append_3 = gtnets/gtnets.c DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ @@ -104,6 +105,9 @@ parallel_task_parallel_task_DEPENDENCIES = \ am_priority_priority_OBJECTS = priority.$(OBJEXT) priority_priority_OBJECTS = $(am_priority_priority_OBJECTS) priority_priority_DEPENDENCIES = $(top_builddir)/src/libsimgrid.la +am_properties_msg_prop_OBJECTS = msg_prop.$(OBJEXT) +properties_msg_prop_OBJECTS = $(am_properties_msg_prop_OBJECTS) +properties_msg_prop_DEPENDENCIES = $(top_builddir)/src/libsimgrid.la am_sendrecv_sendrecv_OBJECTS = sendrecv.$(OBJEXT) sendrecv_sendrecv_OBJECTS = $(am_sendrecv_sendrecv_OBJECTS) sendrecv_sendrecv_DEPENDENCIES = $(top_builddir)/src/libsimgrid.la @@ -127,15 +131,15 @@ SOURCES = $(gtnets_gtnets_SOURCES) \ $(masterslave_masterslave_failure_SOURCES) \ $(masterslave_masterslave_forwarder_SOURCES) \ $(parallel_task_parallel_task_SOURCES) \ - $(priority_priority_SOURCES) $(sendrecv_sendrecv_SOURCES) \ - $(suspend_suspend_SOURCES) + $(priority_priority_SOURCES) $(properties_msg_prop_SOURCES) \ + $(sendrecv_sendrecv_SOURCES) $(suspend_suspend_SOURCES) DIST_SOURCES = $(am__gtnets_gtnets_SOURCES_DIST) \ $(masterslave_masterslave_bypass_SOURCES) \ $(masterslave_masterslave_failure_SOURCES) \ $(masterslave_masterslave_forwarder_SOURCES) \ $(parallel_task_parallel_task_SOURCES) \ - $(priority_priority_SOURCES) $(sendrecv_sendrecv_SOURCES) \ - $(suspend_suspend_SOURCES) + $(priority_priority_SOURCES) $(properties_msg_prop_SOURCES) \ + $(sendrecv_sendrecv_SOURCES) $(suspend_suspend_SOURCES) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) @@ -284,7 +288,9 @@ EXTRA_DIST = msg_platform.xml small_platform.xml \ masterslave/deployment_masterslave.xml \ gtnets/r-n200-f50-s4-2-d.xml gtnets/onelink-p.xml \ gtnets/onelink-d.xml gtnets/r-n200-f50-s4-2-p.xml \ - gtnets/dogbone-d.xml gtnets/dogbone-p.xml $(am__append_3) + gtnets/dogbone-d.xml gtnets/dogbone-p.xml \ + properties/deployment_platform.xml \ + properties/deployment_properties.xml $(am__append_3) TESTS_ENVIRONMENT = $(top_builddir)/tools/tesh/tesh TESTS = sendrecv/sendrecv_KCCFLN05.tesh \ sendrecv/sendrecv_Vegas.tesh \ @@ -295,13 +301,19 @@ TESTS = sendrecv/sendrecv_KCCFLN05.tesh \ masterslave/masterslave_failure.tesh \ masterslave/masterslave_bypass.tesh \ parallel_task/parallel_task.tesh \ - priority/priority.tesh + priority/priority.tesh \ + properties/msg_prop.tesh @HAVE_SDP_TRUE@BROKEN_TESTS = sendrecv/sendrecv_SDP.tesh CLEANFILES = sendrecv/*~ sendrecv/sendrecv suspend/*~ suspend/suspend \ masterslave/*~ masterslave/masterslave_forwarder \ masterslave/masterslave_failure masterslave/masterslave_bypass \ - parallel_task/parallel_task priority/priority $(am__append_1) + parallel_task/parallel_task priority/priority \ + properties/msg_prop $(am__append_1) + +# property handle example +properties_msg_prop_SOURCES = properties/msg_prop.c +properties_msg_prop_LDADD = $(top_builddir)/src/libsimgrid.la # sendrecv simple example sendrecv_sendrecv_SOURCES = sendrecv/sendrecv.c @@ -404,6 +416,12 @@ priority/$(am__dirstamp): priority/priority$(EXEEXT): $(priority_priority_OBJECTS) $(priority_priority_DEPENDENCIES) priority/$(am__dirstamp) @rm -f priority/priority$(EXEEXT) $(LINK) $(priority_priority_OBJECTS) $(priority_priority_LDADD) $(LIBS) +properties/$(am__dirstamp): + @$(MKDIR_P) properties + @: > properties/$(am__dirstamp) +properties/msg_prop$(EXEEXT): $(properties_msg_prop_OBJECTS) $(properties_msg_prop_DEPENDENCIES) properties/$(am__dirstamp) + @rm -f properties/msg_prop$(EXEEXT) + $(LINK) $(properties_msg_prop_OBJECTS) $(properties_msg_prop_LDADD) $(LIBS) sendrecv/$(am__dirstamp): @$(MKDIR_P) sendrecv @: > sendrecv/$(am__dirstamp) @@ -427,6 +445,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/masterslave_bypass.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/masterslave_failure.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/masterslave_forwarder.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/msg_prop.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parallel_task.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/priority.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sendrecv.Po@am__quote@ @@ -537,6 +556,20 @@ priority.obj: priority/priority.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o priority.obj `if test -f 'priority/priority.c'; then $(CYGPATH_W) 'priority/priority.c'; else $(CYGPATH_W) '$(srcdir)/priority/priority.c'; fi` +msg_prop.o: properties/msg_prop.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT msg_prop.o -MD -MP -MF $(DEPDIR)/msg_prop.Tpo -c -o msg_prop.o `test -f 'properties/msg_prop.c' || echo '$(srcdir)/'`properties/msg_prop.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/msg_prop.Tpo $(DEPDIR)/msg_prop.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='properties/msg_prop.c' object='msg_prop.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o msg_prop.o `test -f 'properties/msg_prop.c' || echo '$(srcdir)/'`properties/msg_prop.c + +msg_prop.obj: properties/msg_prop.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT msg_prop.obj -MD -MP -MF $(DEPDIR)/msg_prop.Tpo -c -o msg_prop.obj `if test -f 'properties/msg_prop.c'; then $(CYGPATH_W) 'properties/msg_prop.c'; else $(CYGPATH_W) '$(srcdir)/properties/msg_prop.c'; fi` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/msg_prop.Tpo $(DEPDIR)/msg_prop.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='properties/msg_prop.c' object='msg_prop.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o msg_prop.obj `if test -f 'properties/msg_prop.c'; then $(CYGPATH_W) 'properties/msg_prop.c'; else $(CYGPATH_W) '$(srcdir)/properties/msg_prop.c'; fi` + sendrecv.o: sendrecv/sendrecv.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT sendrecv.o -MD -MP -MF $(DEPDIR)/sendrecv.Tpo -c -o sendrecv.o `test -f 'sendrecv/sendrecv.c' || echo '$(srcdir)/'`sendrecv/sendrecv.c @am__fastdepCC_TRUE@ mv -f $(DEPDIR)/sendrecv.Tpo $(DEPDIR)/sendrecv.Po @@ -748,6 +781,7 @@ distclean-generic: -rm -f masterslave/$(am__dirstamp) -rm -f parallel_task/$(am__dirstamp) -rm -f priority/$(am__dirstamp) + -rm -f properties/$(am__dirstamp) -rm -f sendrecv/$(am__dirstamp) -rm -f suspend/$(am__dirstamp) diff --git a/examples/msg/masterslave/masterslave_bypass.c b/examples/msg/masterslave/masterslave_bypass.c index 3e475fcaa4..10d40ecddc 100644 --- a/examples/msg/masterslave/masterslave_bypass.c +++ b/examples/msg/masterslave/masterslave_bypass.c @@ -23,10 +23,10 @@ static int surf_parse_bypass_platform(void) /* allocating memory for the buffer, I think 2kB should be enough */ surfxml_bufferstack = xbt_new0(char, surfxml_bufferstack_size); - /* */ - SURFXML_BUFFER_SET(platform_description_version,"2"); + /* */ + SURFXML_BUFFER_SET(platform_version,"2"); - SURFXML_START_TAG(platform_description); + SURFXML_START_TAG(platform); /* */ SURFXML_BUFFER_SET(host_id,"host A"); @@ -101,8 +101,8 @@ static int surf_parse_bypass_platform(void) SURFXML_END_TAG(link_c_ctn); SURFXML_END_TAG(route); -/* */ - SURFXML_END_TAG(platform_description); +/* */ + SURFXML_END_TAG(platform); free(surfxml_bufferstack); return 0; @@ -115,10 +115,10 @@ static int surf_parse_bypass_application(void) { /* allocating memory to the buffer, I think 2MB should be enough */ surfxml_bufferstack = xbt_new0(char, surfxml_bufferstack_size); - /* */ - SURFXML_BUFFER_SET(platform_description_version,"2"); + /* */ + SURFXML_BUFFER_SET(platform_version,"2"); - SURFXML_START_TAG(platform_description); + SURFXML_START_TAG(platform); /* */ SURFXML_BUFFER_SET(process_host, "host A"); @@ -158,8 +158,8 @@ static int surf_parse_bypass_application(void) { SURFXML_START_TAG(process); SURFXML_END_TAG(process); -/* */ - SURFXML_END_TAG(platform_description); +/* */ + SURFXML_END_TAG(platform); free(surfxml_bufferstack); return 0; diff --git a/examples/msg/properties/Makefile b/examples/msg/properties/Makefile new file mode 100644 index 0000000000..1d4b6a1058 --- /dev/null +++ b/examples/msg/properties/Makefile @@ -0,0 +1,30 @@ +all: msg_prop +masterslave: msg_prop.o + +INSTALL_PATH = $$HOME +CC = gcc +PEDANTIC_PARANOID_FREAK = -O0 -Wshadow -Wcast-align \ + -Waggregate-return -Wmissing-prototypes -Wmissing-declarations \ + -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations \ + -Wmissing-noreturn -Wredundant-decls -Wnested-externs \ + -Wpointer-arith -Wwrite-strings -finline-functions +REASONABLY_CAREFUL_DUDE = -Wall +NO_PRAYER_FOR_THE_WICKED = -w -O2 +WARNINGS = $(REASONABLY_CAREFUL_DUDE) +CFLAGS = -g $(WARNINGS) + +INCLUDES = -I$(INSTALL_PATH)/include +DEFS = -L$(INSTALL_PATH)/lib/ +LDADD = -lm -lsimgrid +LIBS = + +%: %.o + $(CC) $(INCLUDES) $(DEFS) $(CFLAGS) $^ $(LIBS) $(LDADD) -o $@ + +%.o: %.c + $(CC) $(INCLUDES) $(DEFS) $(CFLAGS) -c -o $@ $< + +clean: + rm -f $(BIN_FILES) *.o *~ +.SUFFIXES: +.PHONY : clean diff --git a/examples/msg/properties/deployment_platform.xml b/examples/msg/properties/deployment_platform.xml new file mode 100644 index 0000000000..44ac5b0c85 --- /dev/null +++ b/examples/msg/properties/deployment_platform.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/examples/msg/properties/deployment_properties.xml b/examples/msg/properties/deployment_properties.xml new file mode 100644 index 0000000000..b3dba6726b --- /dev/null +++ b/examples/msg/properties/deployment_properties.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/examples/msg/properties/msg_prop.c b/examples/msg/properties/msg_prop.c new file mode 100644 index 0000000000..3c6c1765b0 --- /dev/null +++ b/examples/msg/properties/msg_prop.c @@ -0,0 +1,242 @@ +/* $Id: msg_test.c,v 1.24 2007/03/16 13:18:24 cherierm Exp $ */ + +/* Copyright (c) 2002,2003,2004 Arnaud Legrand. 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" /* Yeah! If you want to use msg, you need to include msg/msg.h */ +#include "xbt/sysdep.h" /* calloc, printf */ + +/* Create a log channel to have nice outputs. */ +#include "xbt/log.h" +#include "xbt/asserts.h" + +#include +#include + +XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test,"Messages specific for this msg example"); + +int master(int argc, char *argv[]); +int slave(int argc, char *argv[]); +int forwarder(int argc, char *argv[]); +MSG_error_t test_all(const char *platform_file, const char *application_file); + +typedef enum { + PORT_22 = 0, + MAX_CHANNEL +} channel_t; + +#define FINALIZE ((void*)221297) /* a magic number to tell people to stop working */ + +/** Emitter function */ +int master(int argc, char *argv[]) +{ + int slaves_count = 0; + m_host_t *slaves = NULL; + m_task_t *todo = NULL; + int number_of_tasks = 0; + double task_comp_size = 0; + double task_comm_size = 0; + + + int i; + + xbt_assert1(sscanf(argv[1],"%d", &number_of_tasks), + "Invalid argument %s\n",argv[1]); + xbt_assert1(sscanf(argv[2],"%lg", &task_comp_size), + "Invalid argument %s\n",argv[2]); + xbt_assert1(sscanf(argv[3],"%lg", &task_comm_size), + "Invalid argument %s\n",argv[3]); + + { /* Task creation */ + char sprintf_buffer[64]; + + todo = calloc(number_of_tasks, sizeof(m_task_t)); + + for (i = 0; i < number_of_tasks; i++) { + sprintf(sprintf_buffer, "Task_%d", i); + todo[i] = MSG_task_create(sprintf_buffer, task_comp_size, task_comm_size, NULL); + } + } + + { /* Process organisation */ + slaves_count = argc - 4; + slaves = calloc(slaves_count, sizeof(m_host_t)); + xbt_dict_t props; + for (i = 4; i < argc; i++) { + slaves[i-4] = MSG_get_host_by_name(argv[i]); + /* Get the property list of the host */ + props = MSG_host_get_properties(slaves[i-4]); + xbt_dict_cursor_t cursor=NULL; + char *key,*data; + + /* Print the properties of the host */ + xbt_dict_foreach(props,cursor,key,data) { + INFO3("Property: %s for host: %s has value: %s",key,argv[i],data); + } + + /* Try to get a property that does not exist */ + char *noexist=xbt_strdup("Unknown"); + const char *value = MSG_host_get_property_value(slaves[i-4],noexist); + if ( value == NULL) + INFO2("Property: %s for host %s is undefined", noexist, argv[i]); + else + INFO3("Property: %s for host %s has value: %s", noexist, argv[i], value); + + if(slaves[i-4]==NULL) { + INFO1("Unknown host %s. Stopping Now! ", argv[i]); + abort(); + } + } + } + + for (i = 0; i < number_of_tasks; i++) { + if(MSG_host_self()==slaves[i % slaves_count]) { + } + + MSG_task_put(todo[i], slaves[i % slaves_count], + PORT_22); + } + + for (i = 0; i < slaves_count; i++) + MSG_task_put(MSG_task_create("finalize", 0, 0, FINALIZE), + slaves[i], PORT_22); + + free(slaves); + free(todo); + return 0; +} /* end_of_master */ + +/** Receiver function */ +int slave(int argc, char *argv[]) +{ + while(1) { + m_task_t task = NULL; + int a; + a = MSG_task_get(&(task), PORT_22); + if (a == MSG_OK) { + INFO1("Received \"%s\" ", MSG_task_get_name(task)); + if(MSG_task_get_data(task)==FINALIZE) { + MSG_task_destroy(task); + break; + } + + /* Get the property list of current slave process */ + xbt_dict_t props = MSG_process_get_properties(MSG_process_self()); + xbt_dict_cursor_t cursor=NULL; + char *key,*data; + + /* Print the properties of the process */ + xbt_dict_foreach(props,cursor,key,data) { + INFO3("Property: %s for process %s has value: %s",key,MSG_process_get_name(MSG_process_self()),data); + } + + /* Try to get a property that does not exist */ + char *noexist=xbt_strdup("UnknownProcessProp"); + const char *value = MSG_process_get_property_value(MSG_process_self(),noexist); + if ( value == NULL) + INFO2("Property: %s for process %s is undefined", noexist, MSG_process_get_name(MSG_process_self())); + else + INFO3("Property: %s for process %s has value: %s", noexist, MSG_process_get_name(MSG_process_self()), value); + + MSG_task_execute(task); + MSG_task_destroy(task); + } else { + INFO0("Hey ?! What's up ? "); + xbt_assert0(0,"Unexpected behavior"); + } + } + return 0; +} /* end_of_slave */ + +/** Forwarder function */ +int forwarder(int argc, char *argv[]) +{ + int i; + int slaves_count; + m_host_t *slaves; + + { /* Process organisation */ + slaves_count = argc - 1; + slaves = calloc(slaves_count, sizeof(m_host_t)); + + for (i = 1; i < argc; i++) { + slaves[i-1] = MSG_get_host_by_name(argv[i]); + if(slaves[i-1]==NULL) { + INFO1("Unknown host %s. Stopping Now! ", argv[i]); + abort(); + } + } + } + + i=0; + while(1) { + m_task_t task = NULL; + int a; + a = MSG_task_get(&(task), PORT_22); + if (a == MSG_OK) { + INFO1("Received \"%s\" ", MSG_task_get_name(task)); + if(MSG_task_get_data(task)==FINALIZE) { + INFO0("All tasks have been dispatched. Let's tell everybody the computation is over."); + for (i = 0; i < slaves_count; i++) + MSG_task_put(MSG_task_create("finalize", 0, 0, FINALIZE), + slaves[i], PORT_22); + MSG_task_destroy(task); + break; + } + MSG_task_put(task, slaves[i % slaves_count], + PORT_22); + i++; + } else { + INFO0("Hey ?! What's up ? "); + xbt_assert0(0,"Unexpected behavior"); + } + } + return 0; +} /* end_of_forwarder */ + +/** Test function */ +MSG_error_t test_all(const char *platform_file, + const char *application_file) +{ + MSG_error_t res = MSG_OK; + + /* MSG_config("surf_workstation_model","KCCFLN05"); */ + { /* Simulation setting */ + MSG_set_channel_number(MAX_CHANNEL); + MSG_paje_output("msg_test.trace"); + MSG_create_environment(platform_file); + } + { /* Application deployment */ + MSG_function_register("master", master); + MSG_function_register("slave", slave); + MSG_function_register("forwarder", forwarder); + MSG_launch_application(application_file); + } + res = MSG_main(); + + INFO1("Simulation time %g",MSG_get_clock()); + return res; +} /* end_of_test_all */ + + +/** Main function */ +int main(int argc, char *argv[]) +{ + MSG_error_t res = MSG_OK; + + MSG_global_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); + } + res = test_all(argv[1],argv[2]); + MSG_clean(); + + if(res==MSG_OK) + return 0; + else + return 1; +} /* end_of_main */ diff --git a/examples/msg/properties/msg_test.tesh b/examples/msg/properties/msg_test.tesh new file mode 100644 index 0000000000..918763b2ed --- /dev/null +++ b/examples/msg/properties/msg_test.tesh @@ -0,0 +1,13 @@ +#! ./tesh + +p Testing a MSG application with properties in the XML for Hosts, Links and Processes + +$ $SG_TEST_EXENV ./msg_prop$EXEEXT ${srcdir:=.}/deployment_platform.xml ${srcdir:=.}/deployment_properties.xml +> [Jacquelin:master:(1) 0.000000] [msg_test/INFO] Property: mem for host: Boivin has value: 654321 +> [Jacquelin:master:(1) 0.000000] [msg_test/INFO] Property: disk for host: Boivin has value: 123456 +> [Jacquelin:master:(1) 0.000000] [msg_test/INFO] Property: Unknown for host Boivin is undefined +> [Boivin:slave:(2) 0.303833] [msg_test/INFO] Received "Task_0" +> [Boivin:slave:(2) 0.303833] [msg_test/INFO] Property: SomeProp for process slave has value: SomeValue +> [Boivin:slave:(2) 0.303833] [msg_test/INFO] Property: UnknownProcessProp for process slave is undefined +> [Boivin:slave:(2) 0.814139] [msg_test/INFO] Received "finalize" +> [0.814139] [msg_test/INFO] Simulation time 0.814139 -- 2.20.1