From 3bd1f7386ddad36c4ad2a12e131e224afe2551a6 Mon Sep 17 00:00:00 2001 From: mquinson Date: Tue, 20 May 2008 17:29:46 +0000 Subject: [PATCH] Rework all examples and test cases of the properties git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@5452 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- examples/gras/properties/Makefile.am | 13 +- examples/gras/properties/Makefile.in | 52 ++++---- examples/gras/properties/properties.c | 92 ++++++------- examples/gras/properties/properties.xml | 14 +- examples/gras/properties/test_rl | 21 ++- examples/gras/properties/test_sg | 22 +++ examples/gras/properties/test_sg_32 | 12 -- examples/gras/properties/test_sg_64 | 12 -- .../msg/properties/deployment_properties.xml | 13 +- examples/msg/properties/msg_prop.c | 125 ++++++------------ examples/msg/properties/msg_prop.tesh | 20 +-- examples/platforms/prop.xml | 29 ++-- examples/simdag/properties/Makefile | 30 ----- examples/simdag/properties/prop.xml | 19 --- examples/simdag/properties/sd_prop.c | 97 +------------- examples/simdag/properties/test_prop.tesh | 33 ++--- 16 files changed, 218 insertions(+), 386 deletions(-) create mode 100755 examples/gras/properties/test_sg delete mode 100755 examples/gras/properties/test_sg_32 delete mode 100755 examples/gras/properties/test_sg_64 delete mode 100644 examples/simdag/properties/Makefile delete mode 100755 examples/simdag/properties/prop.xml diff --git a/examples/gras/properties/Makefile.am b/examples/gras/properties/Makefile.am index 5d9568b766..cd3f13e3c9 100644 --- a/examples/gras/properties/Makefile.am +++ b/examples/gras/properties/Makefile.am @@ -11,20 +11,21 @@ EXTRA_DIST=properties.xml 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 diff --git a/examples/gras/properties/Makefile.in b/examples/gras/properties/Makefile.in index ebd44be617..9f4efed8e9 100644 --- a/examples/gras/properties/Makefile.in +++ b/examples/gras/properties/Makefile.in @@ -61,7 +61,7 @@ DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ $(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 @@ -79,18 +79,18 @@ mkinstalldirs = $(install_sh) -d 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 @@ -103,10 +103,10 @@ CCLD = $(CC) 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) @@ -251,17 +251,17 @@ INCLUDES = -I$(top_srcdir)/include 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) @@ -306,15 +306,15 @@ clean-noinstPROGRAMS: 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) @@ -322,9 +322,9 @@ mostlyclean-compile: 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: diff --git a/examples/gras/properties/properties.c b/examples/gras/properties/properties.c index 231524051f..732d0cc4c0 100644 --- a/examples/gras/properties/properties.c +++ b/examples/gras/properties/properties.c @@ -4,73 +4,75 @@ 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; } diff --git a/examples/gras/properties/properties.xml b/examples/gras/properties/properties.xml index 2f8cf2e16a..9fc11656fc 100644 --- a/examples/gras/properties/properties.xml +++ b/examples/gras/properties/properties.xml @@ -1,15 +1,9 @@ - - - - - - - - - - + + + + diff --git a/examples/gras/properties/test_rl b/examples/gras/properties/test_rl index 3abcda835f..ce27387e4d 100755 --- a/examples/gras/properties/test_rl +++ b/examples/gras/properties/test_rl @@ -1,6 +1,19 @@ -! 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 diff --git a/examples/gras/properties/test_sg b/examples/gras/properties/test_sg new file mode 100755 index 0000000000..696652fc22 --- /dev/null +++ b/examples/gras/properties/test_sg @@ -0,0 +1,22 @@ +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 diff --git a/examples/gras/properties/test_sg_32 b/examples/gras/properties/test_sg_32 deleted file mode 100755 index 4f2f9524fa..0000000000 --- a/examples/gras/properties/test_sg_32 +++ /dev/null @@ -1,12 +0,0 @@ -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 diff --git a/examples/gras/properties/test_sg_64 b/examples/gras/properties/test_sg_64 deleted file mode 100755 index eb68d63fe7..0000000000 --- a/examples/gras/properties/test_sg_64 +++ /dev/null @@ -1,12 +0,0 @@ -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 diff --git a/examples/msg/properties/deployment_properties.xml b/examples/msg/properties/deployment_properties.xml index 2f8cf2e16a..3cd9eb8af1 100644 --- a/examples/msg/properties/deployment_properties.xml +++ b/examples/msg/properties/deployment_properties.xml @@ -1,15 +1,10 @@ - - - - - - - - - + + + + diff --git a/examples/msg/properties/msg_prop.c b/examples/msg/properties/msg_prop.c index 152fd7f9c5..ca19687633 100644 --- a/examples/msg/properties/msg_prop.c +++ b/examples/msg/properties/msg_prop.c @@ -17,116 +17,79 @@ 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 */ diff --git a/examples/msg/properties/msg_prop.tesh b/examples/msg/properties/msg_prop.tesh index 23fc6b002c..07f9070cf3 100644 --- a/examples/msg/properties/msg_prop.tesh +++ b/examples/msg/properties/msg_prop.tesh @@ -3,12 +3,14 @@ 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 diff --git a/examples/platforms/prop.xml b/examples/platforms/prop.xml index 6046ad98ca..8ba56cc1aa 100644 --- a/examples/platforms/prop.xml +++ b/examples/platforms/prop.xml @@ -1,19 +1,30 @@ + + + + + - - - + + + - - + + - + - + - - + + diff --git a/examples/simdag/properties/Makefile b/examples/simdag/properties/Makefile deleted file mode 100644 index 95aa425733..0000000000 --- a/examples/simdag/properties/Makefile +++ /dev/null @@ -1,30 +0,0 @@ -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 diff --git a/examples/simdag/properties/prop.xml b/examples/simdag/properties/prop.xml deleted file mode 100755 index 6046ad98ca..0000000000 --- a/examples/simdag/properties/prop.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/examples/simdag/properties/sd_prop.c b/examples/simdag/properties/sd_prop.c index 07d8b17a62..0ab21cb207 100755 --- a/examples/simdag/properties/sd_prop.c +++ b/examples/simdag/properties/sd_prop.c @@ -13,7 +13,6 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(test, 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; @@ -24,38 +23,21 @@ int main(int argc, char **argv) { 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]; @@ -140,75 +122,6 @@ int main(int argc, char **argv) { } } - /* 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; diff --git a/examples/simdag/properties/test_prop.tesh b/examples/simdag/properties/test_prop.tesh index ab2bbab52c..49c6225440 100755 --- a/examples/simdag/properties/test_prop.tesh +++ b/examples/simdag/properties/test_prop.tesh @@ -3,31 +3,20 @@ 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 -- 2.20.1