include $(top_srcdir)/examples/gras/tests.mk
# AUTOMAKE variable definition
-noinst_PROGRAMS=properties_slave properties_master properties_simulator
+noinst_PROGRAMS=properties_alice properties_bob properties_simulator
properties_simulator_SOURCES= _properties_simulator.c properties.c
properties_simulator_LDADD= $(top_builddir)/src/libsimgrid.la
-properties_slave_SOURCES= _properties_slave.c properties.c
-properties_slave_LDADD= $(top_builddir)/src/libgras.la
+properties_alice_SOURCES= _properties_alice.c properties.c
+properties_alice_LDADD= $(top_builddir)/src/libgras.la
-properties_master_SOURCES= _properties_master.c properties.c
-properties_master_LDADD= $(top_builddir)/src/libgras.la
+properties_bob_SOURCES= _properties_bob.c properties.c
+properties_bob_LDADD= $(top_builddir)/src/libgras.la
+TESTS=test_sg test_rl
# Take care of generatated sources
NAME=properties
-PROCESSES= slave master
+PROCESSES= alice bob
include $(top_srcdir)/examples/temps-gras-stub.mk
# Cruft
$(top_srcdir)/acmacro/dist-files.mk \
$(top_srcdir)/examples/gras/tests.mk \
$(top_srcdir)/examples/temps-gras-stub.mk
-noinst_PROGRAMS = properties_slave$(EXEEXT) properties_master$(EXEEXT) \
+noinst_PROGRAMS = properties_alice$(EXEEXT) properties_bob$(EXEEXT) \
properties_simulator$(EXEEXT)
subdir = examples/gras/properties
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
CONFIG_HEADER = $(top_builddir)/src/gras_config.h
CONFIG_CLEAN_FILES =
PROGRAMS = $(noinst_PROGRAMS)
-am_properties_master_OBJECTS = _properties_master.$(OBJEXT) \
+am_properties_alice_OBJECTS = _properties_alice.$(OBJEXT) \
properties.$(OBJEXT)
-properties_master_OBJECTS = $(am_properties_master_OBJECTS)
-properties_master_DEPENDENCIES = $(top_builddir)/src/libgras.la
+properties_alice_OBJECTS = $(am_properties_alice_OBJECTS)
+properties_alice_DEPENDENCIES = $(top_builddir)/src/libgras.la
+am_properties_bob_OBJECTS = _properties_bob.$(OBJEXT) \
+ properties.$(OBJEXT)
+properties_bob_OBJECTS = $(am_properties_bob_OBJECTS)
+properties_bob_DEPENDENCIES = $(top_builddir)/src/libgras.la
am_properties_simulator_OBJECTS = _properties_simulator.$(OBJEXT) \
properties.$(OBJEXT)
properties_simulator_OBJECTS = $(am_properties_simulator_OBJECTS)
properties_simulator_DEPENDENCIES = $(top_builddir)/src/libsimgrid.la
-am_properties_slave_OBJECTS = _properties_slave.$(OBJEXT) \
- properties.$(OBJEXT)
-properties_slave_OBJECTS = $(am_properties_slave_OBJECTS)
-properties_slave_DEPENDENCIES = $(top_builddir)/src/libgras.la
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
$(LDFLAGS) -o $@
-SOURCES = $(properties_master_SOURCES) $(properties_simulator_SOURCES) \
- $(properties_slave_SOURCES)
-DIST_SOURCES = $(properties_master_SOURCES) \
- $(properties_simulator_SOURCES) $(properties_slave_SOURCES)
+SOURCES = $(properties_alice_SOURCES) $(properties_bob_SOURCES) \
+ $(properties_simulator_SOURCES)
+DIST_SOURCES = $(properties_alice_SOURCES) $(properties_bob_SOURCES) \
+ $(properties_simulator_SOURCES)
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
EXTRA_DIST = properties.xml test_rl test_sg_32 test_sg_64
@GRAS_ARCH_32_BITS_FALSE@TESTS = test_sg_64 test_rl
@GRAS_ARCH_32_BITS_TRUE@TESTS = test_sg_32 test_rl
+TESTS = test_sg test_rl
TESTS_ENVIRONMENT = srcdir=$(srcdir) EXEEXT=$(EXEEXT) @top_builddir@/tools/tesh/tesh
properties_simulator_SOURCES = _properties_simulator.c properties.c
properties_simulator_LDADD = $(top_builddir)/src/libsimgrid.la
-properties_slave_SOURCES = _properties_slave.c properties.c
-properties_slave_LDADD = $(top_builddir)/src/libgras.la
-properties_master_SOURCES = _properties_master.c properties.c
-properties_master_LDADD = $(top_builddir)/src/libgras.la
-
+properties_alice_SOURCES = _properties_alice.c properties.c
+properties_alice_LDADD = $(top_builddir)/src/libgras.la
+properties_bob_SOURCES = _properties_bob.c properties.c
+properties_bob_LDADD = $(top_builddir)/src/libgras.la
# Take care of generatated sources
NAME = properties
-PROCESSES = slave master
+PROCESSES = alice bob
CLEANFILES = _$(NAME)_simulator.c $(NAME).mk $(NAME).Makefile.local $(NAME).Makefile.remote $(NAME).deploy.sh \
$(foreach proc, $(PROCESSES), _$(NAME)_$(proc).c)
echo " rm -f $$p $$f"; \
rm -f $$p $$f ; \
done
-properties_master$(EXEEXT): $(properties_master_OBJECTS) $(properties_master_DEPENDENCIES)
- @rm -f properties_master$(EXEEXT)
- $(LINK) $(properties_master_OBJECTS) $(properties_master_LDADD) $(LIBS)
+properties_alice$(EXEEXT): $(properties_alice_OBJECTS) $(properties_alice_DEPENDENCIES)
+ @rm -f properties_alice$(EXEEXT)
+ $(LINK) $(properties_alice_OBJECTS) $(properties_alice_LDADD) $(LIBS)
+properties_bob$(EXEEXT): $(properties_bob_OBJECTS) $(properties_bob_DEPENDENCIES)
+ @rm -f properties_bob$(EXEEXT)
+ $(LINK) $(properties_bob_OBJECTS) $(properties_bob_LDADD) $(LIBS)
properties_simulator$(EXEEXT): $(properties_simulator_OBJECTS) $(properties_simulator_DEPENDENCIES)
@rm -f properties_simulator$(EXEEXT)
$(LINK) $(properties_simulator_OBJECTS) $(properties_simulator_LDADD) $(LIBS)
-properties_slave$(EXEEXT): $(properties_slave_OBJECTS) $(properties_slave_DEPENDENCIES)
- @rm -f properties_slave$(EXEEXT)
- $(LINK) $(properties_slave_OBJECTS) $(properties_slave_LDADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/_properties_master.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/_properties_alice.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/_properties_bob.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/_properties_simulator.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/_properties_slave.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/properties.Po@am__quote@
.c.o:
XBT_LOG_NEW_DEFAULT_CATEGORY(test,"Simple Property example");
-int master(int argc, char *argv[]);
-int slave(int argc, char *argv[]);
+int alice(int argc, char *argv[]);
+int bob(int argc, char *argv[]);
-
-int slave(int argc, char *argv[]) {
+int alice(int argc, char *argv[]) {
gras_init(&argc,argv);
/* Get the properties */
- xbt_dict_t props = gras_process_properties();
+ xbt_dict_t process_props = gras_process_properties();
+ xbt_dict_t host_props = gras_os_host_properties();
+
xbt_dict_cursor_t cursor = NULL;
char *key,*data;
+ const char *value;
+
+ /* Let the other process change the host props */
+ gras_os_sleep(1);
+
+ INFO0("== Dump all the properties of current host");
+ xbt_dict_foreach(host_props,cursor,key,data)
+ INFO2(" Host property: '%s' has value: '%s'",key,data);
- /* Print the properties of the workstation 1 */
- xbt_dict_foreach(props,cursor,key,data) {
- INFO2("Process property: %s has value: %s",key,data);
- }
+ INFO0("== Dump all the properties of alice");
+ xbt_dict_foreach(process_props,cursor,key,data)
+ if (!strncmp(key,"SG_TEST_",8))
+ INFO2(" Process property: '%s' has value: '%s'",key,data);
- /* Try to get a property that does not exist */
- const char *noexist="Nonexisting";
- const char *value = gras_process_property_value(noexist);
- if ( value == NULL)
- INFO1("Process property: %s is undefined", noexist);
- else
- INFO2("Process property: %s has value: %s", noexist, value);
+ INFO0("== Try to get a process property that does not exist");
+ value = gras_process_property_value("Nonexisting");
+ xbt_assert0(!value, "nonexisting property exists!!");
- /* Modify an existing property. First check it exists */
- INFO0("Trying to modify a process property");
- const char *exist="otherprop";
- value = gras_process_property_value(exist);
- if (value == NULL)
- INFO1("\tProperty: %s is undefined", exist);
- else {
- INFO2("\tProperty: %s old value: %s", exist, value);
- xbt_dict_set(props, exist, xbt_strdup("newValue"), free);
- }
+ /* Modify an existing property. First check it exists */
+ INFO0("== Trying to modify a process property");
+ value = gras_process_property_value("new prop");
+ xbt_assert0(!value,"Property 'new prop' exists before I add it!");
+ xbt_dict_set(process_props, "new prop", xbt_strdup("new value"), xbt_free_f);
- /* Test if we have changed the value */
- value = gras_process_property_value(exist);
- if (value == NULL)
- INFO1("\tProperty: %s is undefined", exist);
- else
- INFO2("\tProperty: %s new value: %s", exist, value);
+ /* Test if we have changed the value */
+ value = gras_process_property_value("new prop");
+ xbt_assert1(!strcmp(value,"new value"), "New property does have the value I've set ('%s' != 'new value')",value);
- gras_os_sleep(1);
gras_exit();
return 0;
}
-int master(int argc, char *argv[]) {
+int bob(int argc, char *argv[]) {
gras_init(&argc,argv);
/* Get the properties */
- xbt_dict_t props = gras_os_host_properties();
+ xbt_dict_t host_props = gras_os_host_properties();
xbt_dict_cursor_t cursor = NULL;
char *key,*data;
+ const char *value;
- /* Print the properties of the workstation 1 */
- xbt_dict_foreach(props,cursor,key,data) {
- INFO2("Host property: %s has value: %s",key,data);
- }
+ INFO0("== Dump all the properties of host1");
+ xbt_dict_foreach(host_props,cursor,key,data)
+ INFO2(" Host property: '%s' has value: '%s'",key,data);
- /* Try to get a property that does not exist */
- const char *noexist="Nonexisting";
- const char *value = gras_os_host_property_value(noexist);
- xbt_assert2(value == NULL, "Host property: %s has value: %s", noexist, value);
-
- gras_os_sleep(1);
+ INFO0("== Try to get a property that does not exist");
+ value = gras_os_host_property_value("non existing key");
+ xbt_assert1(value == NULL, "The key 'non existing key' exists (with value '%s')!!",value);
+
+ INFO0("== Set a host property that alice will try to retrieve in SG (from bob->hello)");
+ xbt_dict_set(host_props,"from bob",xbt_strdup("hello"), xbt_free_f);
+
+ INFO0("== Dump all the properties of host1 again to check the addition");
+ xbt_dict_foreach(host_props,cursor,key,data)
+ INFO2(" Host property: '%s' has value: '%s'",key,data);
+
+ gras_os_sleep(1); /* KILLME once bug on empty main is solved */
gras_exit();
return 0;
}
<?xml version='1.0'?>
<!DOCTYPE platform SYSTEM "simgrid.dtd">
<platform version="2">
- <!-- The master process (with some arguments) -->
- <process host="C1-01" function="master">
- <argument value="1"/> <!-- Number of tasks -->
- <argument value="50000000"/> <!-- Computation size of tasks -->
- <argument value="1000000"/> <!-- Communication size of tasks -->
- <argument value="C1-00"/> <!-- First slave -->
- </process>
- <!-- The slave process (with no argument) -->
- <process host="C1-00" function="slave">
- <prop id="SomeProp" value="SomeValue"/>
+ <process host="host1" function="alice">
+ <prop id="SG_TEST_blah" value="blah"/>
</process>
+
+ <process host="host1" function="bob" />
</platform>
-! timeout 20
-& $SG_TEST_ENV ./properties_master$EXEEXT 4002 --log=root.fmt=%P:%t%e%m%n $ARGS
+! setenv SG_TEST_blah=blah
+$ $SG_TEST_ENV ./properties_alice --log=root.fmt=%P:%t%e%m%n $ARGS
+> alice:main == Dump all the properties of current host
+> alice:main == Dump all the properties of alice
+> alice:main Process property: 'SG_TEST_blah' has value: 'blah'
+> alice:main == Try to get a process property that does not exist
+> alice:main == Trying to modify a process property
+> alice:main Exiting GRAS
+
+! setenv SG_TEST_blah=blah
+$ $SG_TEST_ENV ./properties_bob --log=root.fmt=%P:%t%e%m%n $ARGS
+> bob:main == Dump all the properties of host1
+> bob:main == Try to get a property that does not exist
+> bob:main == Set a host property that alice will try to retrieve in SG (from bob->hello)
+> bob:main == Dump all the properties of host1 again to check the addition
+> bob:main Host property: 'from bob' has value: 'hello'
+> bob:main Exiting GRAS
-! timeout 20
-& $SG_TEST_ENV ./properties_slave$EXEEXT 127.0.0.1 4002 --log=root.fmt=%P:%t%e%m%n $ARGS
--- /dev/null
+p Runs the 'properties' test within the simulator (simulation times valid for 32bits architectures)
+
+$ $SG_TEST_EXENV ./properties_simulator${EXEEXT:=} ${srcdir:=.}/../../platforms/prop.xml ${srcdir:=.}/properties.xml
+> [host1:bob:(2) 0.000000] [test/INFO] == Dump all the properties of host1
+> [host1:bob:(2) 0.000000] [test/INFO] Host property: 'SG_TEST_Hdd' has value: '180'
+> [host1:bob:(2) 0.000000] [test/INFO] Host property: 'SG_TEST_mem' has value: '4'
+> [host1:bob:(2) 0.000000] [test/INFO] == Try to get a property that does not exist
+> [host1:bob:(2) 0.000000] [test/INFO] == Set a host property that alice will try to retrieve in SG (from bob->hello)
+> [host1:bob:(2) 0.000000] [test/INFO] == Dump all the properties of host1 again to check the addition
+> [host1:bob:(2) 0.000000] [test/INFO] Host property: 'from bob' has value: 'hello'
+> [host1:bob:(2) 0.000000] [test/INFO] Host property: 'SG_TEST_Hdd' has value: '180'
+> [host1:bob:(2) 0.000000] [test/INFO] Host property: 'SG_TEST_mem' has value: '4'
+> [host1:bob:(2) 1.000000] [gras/INFO] Exiting GRAS
+> [host1:alice:(1) 1.000000] [test/INFO] == Dump all the properties of current host
+> [host1:alice:(1) 1.000000] [test/INFO] Host property: 'from bob' has value: 'hello'
+> [host1:alice:(1) 1.000000] [test/INFO] Host property: 'SG_TEST_Hdd' has value: '180'
+> [host1:alice:(1) 1.000000] [test/INFO] Host property: 'SG_TEST_mem' has value: '4'
+> [host1:alice:(1) 1.000000] [test/INFO] == Dump all the properties of alice
+> [host1:alice:(1) 1.000000] [test/INFO] Process property: 'SG_TEST_blah' has value: 'blah'
+> [host1:alice:(1) 1.000000] [test/INFO] == Try to get a process property that does not exist
+> [host1:alice:(1) 1.000000] [test/INFO] == Trying to modify a process property
+> [host1:alice:(1) 1.000000] [gras/INFO] Exiting GRAS
+++ /dev/null
-p Runs the 'properties' test within the simulator (simulation times valid for 32bits architectures)
-
-$ $SG_TEST_EXENV ./properties_simulator${EXEEXT:=} ${srcdir:=.}/../../platforms/prop.xml ${srcdir:=.}/properties.xml
-> [C1-01:master:(1) 0.000000] [test/INFO] Host property: mem has value: 4
-> [C1-01:master:(1) 0.000000] [test/INFO] Host property: Hdd has value: 180
-> [C1-00:slave:(2) 0.000000] [test/INFO] Process property: SomeProp has value: SomeValue
-> [C1-00:slave:(2) 0.000000] [test/INFO] Process property: Nonexisting is undefined
-> [C1-00:slave:(2) 0.000000] [test/INFO] Trying to modify a process property
-> [C1-00:slave:(2) 0.000000] [test/INFO] Property: otherprop is undefined
-> [C1-00:slave:(2) 0.000000] [test/INFO] Property: otherprop is undefined
-> [C1-01:master:(1) 1.000000] [gras/INFO] Exiting GRAS
-> [C1-00:slave:(2) 1.000000] [gras/INFO] Exiting GRAS
+++ /dev/null
-p Runs the 'properties' test within the simulator (simulation times valid for 64bits architectures)
-
-$ $SG_TEST_EXENV ./properties_simulator${EXEEXT:=} ${srcdir:=.}/../../platforms/prop.xml ${srcdir:=.}/properties.xml
-> [C1-01:master:(1) 0.000000] [test/INFO] Host property: mem has value: 4
-> [C1-01:master:(1) 0.000000] [test/INFO] Host property: Hdd has value: 180
-> [C1-00:slave:(2) 0.000000] [test/INFO] Process property: SomeProp has value: SomeValue
-> [C1-00:slave:(2) 0.000000] [test/INFO] Process property: Nonexisting is undefined
-> [C1-00:slave:(2) 0.000000] [test/INFO] Trying to modify a process property
-> [C1-00:slave:(2) 0.000000] [test/INFO] Property: otherprop is undefined
-> [C1-00:slave:(2) 0.000000] [test/INFO] Property: otherprop is undefined
-> [C1-01:master:(1) 1.000000] [gras/INFO] Exiting GRAS
-> [C1-00:slave:(2) 1.000000] [gras/INFO] Exiting GRAS
<?xml version='1.0'?>
<!DOCTYPE platform SYSTEM "simgrid.dtd">
<platform version="2">
- <!-- The master process (with some arguments) -->
- <process host="C1-01" function="master">
- <argument value="1"/> <!-- Number of tasks -->
- <argument value="50000000"/> <!-- Computation size of tasks -->
- <argument value="1000000"/> <!-- Communication size of tasks -->
- <argument value="C1-00"/> <!-- First slave -->
- </process>
- <!-- The slave process (with no argument) -->
- <process host="C1-00" function="slave">
+
+ <process host="host1" function="alice" />
+
+ <process host="host1" function="bob">
<prop id="SomeProp" value="SomeValue"/>
</process>
</platform>
XBT_LOG_NEW_DEFAULT_CATEGORY(test,"Property test");
-int master(int argc, char *argv[]);
-int slave(int argc, char *argv[]);
+int alice(int argc, char *argv[]);
+int bob(int argc, char *argv[]);
int forwarder(int argc, char *argv[]);
MSG_error_t test_all(const char *platform_file, const char *application_file);
-/** Emitter function */
-int master(int argc, char *argv[])
+int alice(int argc, char *argv[])
{
- int slaves_count = 0;
- m_host_t *slaves = NULL;
- xbt_dict_t props;
+ m_host_t host1 = MSG_get_host_by_name("host1");
+ xbt_dict_t props = MSG_host_get_properties(host1);
xbt_dict_cursor_t cursor=NULL;
- int i;
char *key,*data;
const char *noexist="Unknown";
const char*value;
- char exist[]="Hdd";
-
- { /* Process organisation */
- slaves_count = argc - 4;
- slaves = xbt_new(m_host_t, sizeof(m_host_t) * slaves_count);
-
- for (i = 4; i < argc; i++) {
- slaves[i-4] = MSG_get_host_by_name(argv[i]);
- xbt_assert1(slaves[i-4]!=NULL, "Unknown host %s. Stopping Now! ", argv[i]);
-
- /* Get the property list of the host */
- props = MSG_host_get_properties(slaves[i-4]);
-
-
-
- /* 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 */
-
- 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",(char*) noexist, argv[i], value);
-
- /* Modify an existing property test. First check it exists */\
- INFO0("Trying to modify a host property");
-
- value = MSG_host_get_property_value(slaves[i-4],exist);
- xbt_assert1(value,"\tProperty %s is undefined", exist);
- INFO2("\tProperty: %s old value: %s", exist, value);
- xbt_dict_set(props, exist, xbt_strdup("250"), free);
-
- /* Test if we have changed the value */
- value = MSG_host_get_property_value(slaves[i-4],exist);
- xbt_assert1(value,"\tProperty %s is undefined", exist);
- INFO2("\tProperty: %s new value: %s", exist, value);
- }
- }
+ char exist[]="SG_TEST_Hdd";
+
+ INFO0("== Print the properties of the host");
+ xbt_dict_foreach(props,cursor,key,data)
+ INFO2(" Host property: '%s' -> '%s'",key,data);
+
+ INFO0("== Try to get a host property that does not exist");
+ value = MSG_host_get_property_value(host1, noexist);
+ xbt_assert0(!value, "The key exists (it's not supposed to)");
+
+ INFO0("== Try to get a host property that does exist");
+ value = MSG_host_get_property_value(host1,exist);
+ xbt_assert1(value,"\tProperty %s is undefined (where it should)", exist);
+ xbt_assert2(!strcmp(value,"180"),"\tValue of property %s is defined to %s (where it should be 180)", exist, value);
+ INFO2(" Property: %s old value: %s", exist, value);
+
+ INFO0("== Trying to modify a host property");
+ xbt_dict_set(props, exist, xbt_strdup("250"), xbt_free_f);
- free(slaves);
+ /* Test if we have changed the value */
+ value = MSG_host_get_property_value(host1,exist);
+ xbt_assert1(value,"Property %s is undefined (where it should)", exist);
+ xbt_assert2(!strcmp(value,"250"),"Value of property %s is defined to %s (where it should be 250)", exist, value);
+ INFO2(" Property: %s old value: %s", exist, value);
+
return 0;
-} /* end_of_master */
+}
-/** Receiver function */
-int slave(int argc, char *argv[])
+int bob(int argc, char *argv[])
{
- /* Get the property list of current slave process */
+ /* Get the property list of current bob process */
xbt_dict_t props = MSG_process_get_properties(MSG_process_self());
xbt_dict_cursor_t cursor=NULL;
char *key,*data;
const char *noexist="UnknownProcessProp";
const char *value;
- /* 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);
- }
+ INFO0("== Print the properties of the process");
+ xbt_dict_foreach(props,cursor,key,data)
+ INFO2(" Process property: %s -> %s",key,data);
- /* Try to get a property that does not exist */
+ INFO0("== Try to get a process property that does not exist");
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);
+ xbt_assert0(!value,"The property is defined (it shouldnt)");
return 0;
-} /* end_of_slave */
+}
/** Test function */
MSG_error_t test_all(const char *platform_file,
const char *application_file)
{
- MSG_error_t res = MSG_OK;
+ MSG_function_register("alice", alice);
+ MSG_function_register("bob", bob);
+
+ MSG_create_environment(platform_file);
+ MSG_launch_application(application_file);
- /* 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_launch_application(application_file);
- }
- res = MSG_main();
-
- INFO1("Simulation time %g",MSG_get_clock());
- return res;
+ return MSG_main();
} /* end_of_test_all */
p Testing a MSG application with properties in the XML for Hosts, Links and Processes
$ $SG_TEST_EXENV properties/msg_prop$EXEEXT ${srcdir:=.}/../platforms/prop.xml ${srcdir:=.}/properties/deployment_properties.xml
-> [C1-01:master:(1) 0.000000] [test/INFO] Property: Hdd for host: C1-00 has value: 120
-> [C1-01:master:(1) 0.000000] [test/INFO] Property: Unknown for host C1-00 is undefined
-> [C1-01:master:(1) 0.000000] [test/INFO] Trying to modify a host property
-> [C1-01:master:(1) 0.000000] [test/INFO] Property: Hdd old value: 120
-> [C1-01:master:(1) 0.000000] [test/INFO] Property: Hdd new value: 250
-> [C1-00:slave:(2) 0.000000] [test/INFO] Property: SomeProp for process slave has value: SomeValue
-> [C1-00:slave:(2) 0.000000] [test/INFO] Property: UnknownProcessProp for process slave is undefined
-> [0.000000] [test/INFO] Simulation time 0
-
+> [host1:alice:(1) 0.000000] [test/INFO] == Print the properties of the host
+> [host1:alice:(1) 0.000000] [test/INFO] Host property: 'SG_TEST_Hdd' -> '180'
+> [host1:alice:(1) 0.000000] [test/INFO] Host property: 'SG_TEST_mem' -> '4'
+> [host1:alice:(1) 0.000000] [test/INFO] == Try to get a host property that does not exist
+> [host1:alice:(1) 0.000000] [test/INFO] == Try to get a host property that does exist
+> [host1:alice:(1) 0.000000] [test/INFO] Property: SG_TEST_Hdd old value: 180
+> [host1:alice:(1) 0.000000] [test/INFO] == Trying to modify a host property
+> [host1:alice:(1) 0.000000] [test/INFO] Property: SG_TEST_Hdd old value: 250
+> [host1:bob:(2) 0.000000] [test/INFO] == Print the properties of the process
+> [host1:bob:(2) 0.000000] [test/INFO] Process property: SomeProp -> SomeValue
+> [host1:bob:(2) 0.000000] [test/INFO] == Try to get a process property that does not exist
<?xml version='1.0'?>
<!DOCTYPE platform SYSTEM "simgrid.dtd">
+
+<!-- This file describe a super simple platform which main interest is
+ to define some properties on hosts, processes and links.
+ It is used in several regression cases on properties -->
+
+<!-- Some properties' name is prefixed by SG_TEST_ only to simplify
+ the test of GRAS on real life: we don't want to display the whole
+ user's environment here, only the ones related to the test.
+
+ Of course, this restriction is not needed in your own platforms. -->
+
<platform version="2">
- <host id="C1-01" power="1000000000">
- <prop id="Hdd" value="180"/>
- <prop id="mem" value="4"/>
+ <host id="host1" power="1000000000">
+ <prop id="SG_TEST_Hdd" value="180"/>
+ <prop id="SG_TEST_mem" value="4"/>
</host>
- <host id="C1-00" power="1000000000">
- <prop id="Hdd" value="120"/>
+ <host id="host2" power="1000000000">
+ <prop id="SG_TEST_Hdd" value="120"/>
</host>
- <link id="6" bandwidth="125000000" latency="0.000100">
+ <link id="l1" bandwidth="125000000" latency="0.000100">
<prop id="type" value="Ethernet"/>
</link>
- <link id="0" bandwidth="125000000" latency="0.000100">
+ <link id="l2" bandwidth="125000000" latency="0.000100">
<prop id="type" value="ethernet"/>
</link>
- <route src="C1-00" dst="C1-01"><link:ctn id="6"/><link:ctn id="0"/></route>
- <route src="C1-01" dst="C1-00"><link:ctn id="0"/><link:ctn id="6"/></route>
+ <route src="host1" dst="host2"><link:ctn id="l1"/><link:ctn id="l2"/></route>
+ <route src="host2" dst="host1"><link:ctn id="l2"/><link:ctn id="l1"/></route>
</platform>
+++ /dev/null
-all: sd_prop
-masterslave: sd_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
+++ /dev/null
-<?xml version='1.0'?>
-<!DOCTYPE platform SYSTEM "simgrid.dtd">
-<platform version="2">
- <host id="C1-01" power="1000000000">
- <prop id="Hdd" value="180"/>
- <prop id="mem" value="4"/>
- </host>
- <host id="C1-00" power="1000000000">
- <prop id="Hdd" value="120"/>
- </host>
- <link id="6" bandwidth="125000000" latency="0.000100">
- <prop id="type" value="Ethernet"/>
- </link>
- <link id="0" bandwidth="125000000" latency="0.000100">
- <prop id="type" value="ethernet"/>
- </link>
- <route src="C1-00" dst="C1-01"><link:ctn id="6"/><link:ctn id="0"/></route>
- <route src="C1-01" dst="C1-00"><link:ctn id="0"/><link:ctn id="6"/></route>
-</platform>
int main(int argc, char **argv) {
int i;
- const char * platform_file;
const SD_workstation_t *workstations;
SD_workstation_t w1;
SD_workstation_t w2;
char *key,*data;
char noexist[]="NoProp";
const char *value;
- char exist[]="Hdd";
- const double computation_amount1 = 2000000;
- const double computation_amount2 = 1000000;
- const double communication_amount12 = 2000000;
- const double communication_amount21 = 3000000;
+ char exist[]="SG_TEST_Hdd";
+
const SD_link_t *route;
int route_size;
- SD_task_t taskA, taskB, taskC, taskD, task;
- const int workstation_number = 2;
- SD_workstation_t workstation_list[2];
- double computation_amount[2];
- double communication_amount[4] = {0};
- double rate = -1.0;
- SD_task_t *changed_tasks;
/* initialisation of SD */
- SD_init(&argc, argv);
-
- platform_file = argv[1];
-
- /* xbt_log_control_set("sd.thres=debug"); */
-
+ SD_init(&argc, argv);
if (argc < 2) {
INFO1("Usage: %s platform_file", argv[0]);
INFO1("example: %s sd_platform.xml", argv[0]);
exit(1);
}
+ SD_create_environment(argv[1]);
- /* creation of the environment */
- SD_create_environment(platform_file);
-
- /* test the estimation functions */
+ /* init of platform elements */
workstations = SD_workstation_get_list();
w1 = workstations[0];
w2 = workstations[1];
}
}
- /* creation of the tasks and their dependencies */
- taskA = SD_task_create("Task A", NULL, 10.0);
- taskB = SD_task_create("Task B", NULL, 40.0);
- taskC = SD_task_create("Task C", NULL, 30.0);
- taskD = SD_task_create("Task D", NULL, 60.0);
-
-
- SD_task_dependency_add(NULL, NULL, taskB, taskA);
- SD_task_dependency_add(NULL, NULL, taskC, taskA);
- SD_task_dependency_add(NULL, NULL, taskD, taskB);
- SD_task_dependency_add(NULL, NULL, taskD, taskC);
-
- /* watch points */
- SD_task_watch(taskD, SD_DONE);
- SD_task_watch(taskB, SD_DONE);
- SD_task_unwatch(taskD, SD_DONE);
-
-
- /* scheduling parameters */
- workstation_list[0] = w1;
- workstation_list[1] = w2;
- computation_amount[0] = computation_amount1;
- computation_amount[1] = computation_amount2;
-
- communication_amount[1] = communication_amount12;
- communication_amount[2] = communication_amount21;
-
-
-
- /* estimated time */
- task = taskD;
- INFO2("Estimated time for '%s': %f", SD_task_get_name(task),
- SD_task_get_execution_time(task, workstation_number, workstation_list,
- computation_amount, communication_amount, rate));
-
- /* let's launch the simulation! */
-
- SD_task_schedule(taskA, workstation_number, workstation_list,
- computation_amount, communication_amount, rate);
- SD_task_schedule(taskB, workstation_number, workstation_list,
- computation_amount, communication_amount, rate);
- SD_task_schedule(taskC, workstation_number, workstation_list,
- computation_amount, communication_amount, rate);
- SD_task_schedule(taskD, workstation_number, workstation_list,
- computation_amount, communication_amount, rate);
-
- changed_tasks = SD_simulate(-1.0);
- for (i = 0; changed_tasks[i] != NULL; i++) {
- INFO3("Task '%s' start time: %f, finish time: %f",
- SD_task_get_name(changed_tasks[i]),
- SD_task_get_start_time(changed_tasks[i]),
- SD_task_get_finish_time(changed_tasks[i]));
- }
-
- xbt_assert0(changed_tasks[0] == taskD &&
- changed_tasks[1] == taskB &&
- changed_tasks[2] == NULL,
- "Unexpected simulation results");
-
- xbt_free(changed_tasks);
-
- DEBUG0("Destroying tasks...");
-
- SD_task_destroy(taskA);
- SD_task_destroy(taskB);
- SD_task_destroy(taskC);
- SD_task_destroy(taskD);
-
- DEBUG0("Tasks destroyed. Exiting SimDag...");
SD_exit();
return 0;
p Simple test of simdag with properties
$ $SG_TEST_EXENV properties/sd_prop ${srcdir:=.}/../platforms/prop.xml
-> [0.000000] [test/INFO] Property list for workstation C1-00
+> [0.000000] [test/INFO] Property list for workstation host1
> [0.000000] [test/INFO] Property: NewProp has value: newValue
-> [0.000000] [test/INFO] Property: Hdd has value: 120
+> [0.000000] [test/INFO] Property: SG_TEST_Hdd has value: 180
+> [0.000000] [test/INFO] Property: SG_TEST_mem has value: 4
> [0.000000] [test/INFO] Property: NoProp is undefined
-> [0.000000] [test/INFO] Property list for workstation C1-01
-> [0.000000] [test/INFO] Property: mem on host: 4
-> [0.000000] [test/INFO] Property: Hdd on host: 180
+> [0.000000] [test/INFO] Property list for workstation host2
+> [0.000000] [test/INFO] Property: SG_TEST_Hdd on host: 120
> [0.000000] [test/INFO] Modify an existing property
-> [0.000000] [test/INFO] Property: Hdd old value: 180
-> [0.000000] [test/INFO] Property: Hdd new value: 250
-> [0.000000] [test/INFO] Link 6 property: type has value: Ethernet
-> [0.000000] [test/INFO] Property: NoProp for link 6 is undefined
-> [0.000000] [test/INFO] Link 0 property: type has value: ethernet
-> [0.000000] [test/INFO] Property: NoProp for link 0 is undefined
-> [0.000000] [test/INFO] Estimated time for 'Task D': 1.512000
-> [0.000000] [sd_kernel/INFO] Starting simulation...
-> [0.000000] [sd_kernel/INFO] Executing task 'Task D'
-> [3.600200] [sd_kernel/INFO] Task 'Task D' done
-> [3.600200] [sd_kernel/INFO] Executing task 'Task B'
-> [3.600200] [sd_kernel/INFO] Executing task 'Task C'
-> [6.000400] [sd_kernel/INFO] Task 'Task B' done
-> [6.000400] [sd_task/INFO] Watch point reached with task 'Task B'!
-> [6.000400] [sd_kernel/INFO] Simulation finished
-> [6.000400] [test/INFO] Task 'Task D' start time: 0.000000, finish time: 3.600200
-> [6.000400] [test/INFO] Task 'Task B' start time: 3.600200, finish time: 6.000400
+> [0.000000] [test/INFO] Property: SG_TEST_Hdd old value: 120
+> [0.000000] [test/INFO] Property: SG_TEST_Hdd new value: 250
+> [0.000000] [test/INFO] Link l1 property: type has value: Ethernet
+> [0.000000] [test/INFO] Property: NoProp for link l1 is undefined
+> [0.000000] [test/INFO] Link l2 property: type has value: ethernet
+> [0.000000] [test/INFO] Property: NoProp for link l2 is undefined