From: Pierre Veyre Date: Sat, 28 Sep 2013 07:29:51 +0000 (+0200) Subject: Prepare test suite for msg-storage "ctest -R msg-storage" X-Git-Tag: v3_9_90~70 X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/f6890feee4b0c49caf9026977053d8ada82dfcad?hp=b08c515d1ded5726d50e3e9e11c03260e3e1546d Prepare test suite for msg-storage "ctest -R msg-storage" --- diff --git a/buildtools/Cmake/AddTests.cmake b/buildtools/Cmake/AddTests.cmake index 9e20f9f351..668798b517 100644 --- a/buildtools/Cmake/AddTests.cmake +++ b/buildtools/Cmake/AddTests.cmake @@ -139,8 +139,8 @@ if(NOT enable_memcheck) ADD_TEST(msg-energy-pstates ${CMAKE_BINARY_DIR}/bin/tesh ${TESH_OPTION} --cfg contexts/factory:thread --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/msg --cd ${CMAKE_BINARY_DIR}/examples/msg ${CMAKE_HOME_DIRECTORY}/examples/msg/energy/e1/pstate.tesh) ADD_TEST(msg-energy-consumption ${CMAKE_BINARY_DIR}/bin/tesh ${TESH_OPTION} --cfg contexts/factory:thread --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/msg --cd ${CMAKE_BINARY_DIR}/examples/msg ${CMAKE_HOME_DIRECTORY}/examples/msg/energy/e2/energy_consumption.tesh) ADD_TEST(msg-energy-concurrent-tasks ${CMAKE_BINARY_DIR}/bin/tesh ${TESH_OPTION} --cfg contexts/factory:thread --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/msg --cd ${CMAKE_BINARY_DIR}/examples/msg ${CMAKE_HOME_DIRECTORY}/examples/msg/energy/e3/concurrent_tasks.tesh) - - + ADD_TEST(msg-storage ${CMAKE_BINARY_DIR}/bin/tesh ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY}/teshsuite --cd ${CMAKE_BINARY_DIR}/teshsuite ${CMAKE_HOME_DIRECTORY}/teshsuite/msg/storage/storage.tesh) + if(CONTEXT_UCONTEXT) ADD_TEST(msg-sendrecv-CLM03-ucontext ${CMAKE_BINARY_DIR}/bin/tesh ${TESH_OPTION} --cfg contexts/factory:ucontext --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/msg --cd ${CMAKE_BINARY_DIR}/examples/msg ${CMAKE_HOME_DIRECTORY}/examples/msg/sendrecv/sendrecv_CLM03.tesh) ADD_TEST(msg-sendrecv-Vegas-ucontext ${CMAKE_BINARY_DIR}/bin/tesh ${TESH_OPTION} --cfg contexts/factory:ucontext --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/msg --cd ${CMAKE_BINARY_DIR}/examples/msg ${CMAKE_HOME_DIRECTORY}/examples/msg/sendrecv/sendrecv_Vegas.tesh) diff --git a/buildtools/Cmake/MakeExe.cmake b/buildtools/Cmake/MakeExe.cmake index 11deec72e3..8248638b2c 100644 --- a/buildtools/Cmake/MakeExe.cmake +++ b/buildtools/Cmake/MakeExe.cmake @@ -78,6 +78,7 @@ add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/smpi/MM) add_subdirectory(${CMAKE_HOME_DIRECTORY}/teshsuite/msg) add_subdirectory(${CMAKE_HOME_DIRECTORY}/teshsuite/msg/trace) +add_subdirectory(${CMAKE_HOME_DIRECTORY}/teshsuite/msg/storage) add_subdirectory(${CMAKE_HOME_DIRECTORY}/teshsuite/simdag) add_subdirectory(${CMAKE_HOME_DIRECTORY}/teshsuite/simdag/availability) add_subdirectory(${CMAKE_HOME_DIRECTORY}/teshsuite/simdag/network) diff --git a/include/msg/msg.h b/include/msg/msg.h index a595340310..d907f6a1ae 100644 --- a/include/msg/msg.h +++ b/include/msg/msg.h @@ -143,7 +143,7 @@ XBT_PUBLIC(msg_host_t) MSG_get_host_by_name(const char *name); XBT_PUBLIC(xbt_dynar_t) MSG_hosts_as_dynar(void); XBT_PUBLIC(int) MSG_get_host_number(void); XBT_PUBLIC(xbt_dict_t) MSG_host_get_storage_list(msg_host_t host); -XBT_PUBLIC(xbt_dynar_t) MSG_host_get_storage_content(msg_host_t host); +XBT_PUBLIC(xbt_dict_t) MSG_host_get_storage_content(msg_host_t host); /************************** Process handling *********************************/ XBT_PUBLIC(msg_process_t) MSG_process_create(const char *name, xbt_main_func_t code, diff --git a/src/msg/msg_host.c b/src/msg/msg_host.c index f6e96e2ae9..cb9dd4883b 100644 --- a/src/msg/msg_host.c +++ b/src/msg/msg_host.c @@ -354,20 +354,31 @@ xbt_dict_t MSG_host_get_storage_list(msg_host_t host) * \param host a host * \return a dynar containing content (as a dict) of all storages mounted on the host */ -xbt_dynar_t MSG_host_get_storage_content(msg_host_t host) +xbt_dict_t MSG_host_get_storage_content(msg_host_t host) { xbt_assert((host != NULL), "Invalid parameters"); - xbt_dynar_t contents = xbt_dynar_new(sizeof(void *),NULL); -// msg_storage_t storage; -// char* storage_name; -// unsigned int i; -// xbt_dynar_t storage_list = simcall_host_get_storage_list(host); -// xbt_dynar_foreach(storage_list, i, storage_name){ -// storage = xbt_lib_get_elm_or_null(storage_lib,storage_name); -// -// XBT_INFO("STORAGE NAME: %s", storage_name); -// xbt_dict_t content = simcall_storage_get_content(storage); -// xbt_dynar_push(contents, &content); -// } + xbt_dict_t contents = xbt_dict_new(); + + msg_storage_t storage; + char* storage_name; + char* mount_name; + xbt_dict_cursor_t cursor = NULL; + xbt_dict_cursor_t cursor2 = NULL; + char* file; + size_t size; + + xbt_dict_t storage_list = simcall_host_get_storage_list(host); + + xbt_dict_foreach(storage_list,cursor,mount_name,storage_name){ + storage = (msg_storage_t)xbt_lib_get_elm_or_null(storage_lib,storage_name); + + XBT_INFO("mount name => %s", mount_name); + xbt_dict_t content = simcall_storage_get_content(storage); + xbt_dict_foreach(content,cursor2,file,size){ + XBT_INFO("\t\t%s size: %zu bytes", file, size); + } + + xbt_dict_set(contents,mount_name,(void *)content,NULL); + } return contents; } diff --git a/src/surf/storage.c b/src/surf/storage.c index 416cadfc5c..17ed2b164c 100644 --- a/src/surf/storage.c +++ b/src/surf/storage.c @@ -206,9 +206,9 @@ static xbt_dict_t storage_get_content(void *storage) xbt_dict_t content_dict = xbt_dict_new(); xbt_dict_cursor_t cursor = NULL; char *file; - size_t size; + char *size; xbt_dict_foreach(((storage_t)st)->content, cursor, file, size){ - xbt_dict_set(content_dict,file,&size,NULL); + xbt_dict_set(content_dict,file,(void*)size,NULL); } return content_dict; } diff --git a/teshsuite/msg/storage/CMakeLists.txt b/teshsuite/msg/storage/CMakeLists.txt new file mode 100644 index 0000000000..5e143104b8 --- /dev/null +++ b/teshsuite/msg/storage/CMakeLists.txt @@ -0,0 +1,37 @@ +cmake_minimum_required(VERSION 2.6) + +set(EXECUTABLE_OUTPUT_PATH "${CMAKE_CURRENT_BINARY_DIR}") + +add_executable(storage storage.c) + +### Add definitions for compile +if(NOT WIN32) + target_link_libraries(storage simgrid m pthread ) +else() + target_link_libraries(storage simgrid) +endif() + +set(tesh_files + ${tesh_files} + ${CMAKE_CURRENT_SOURCE_DIR}/storage.tesh + PARENT_SCOPE + ) +set(xml_files + ${xml_files} + ${CMAKE_CURRENT_SOURCE_DIR}/platform.xml + ${CMAKE_CURRENT_SOURCE_DIR}/deployment.xml + PARENT_SCOPE + ) +set(teshsuite_src + ${teshsuite_src} + ${CMAKE_CURRENT_SOURCE_DIR}/storage.c + PARENT_SCOPE + ) +set(bin_files + ${bin_files} + PARENT_SCOPE + ) +set(txt_files + ${txt_files} + PARENT_SCOPE + ) diff --git a/teshsuite/msg/storage/deployment.xml b/teshsuite/msg/storage/deployment.xml new file mode 100644 index 0000000000..4ff8c10ded --- /dev/null +++ b/teshsuite/msg/storage/deployment.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/teshsuite/msg/storage/plateform.xml b/teshsuite/msg/storage/plateform.xml new file mode 100644 index 0000000000..c288fb51fd --- /dev/null +++ b/teshsuite/msg/storage/plateform.xml @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/teshsuite/msg/storage/storage b/teshsuite/msg/storage/storage new file mode 100755 index 0000000000..bf8fa10a89 Binary files /dev/null and b/teshsuite/msg/storage/storage differ diff --git a/teshsuite/msg/storage/storage.c b/teshsuite/msg/storage/storage.c new file mode 100644 index 0000000000..8512d6ef8a --- /dev/null +++ b/teshsuite/msg/storage/storage.c @@ -0,0 +1,89 @@ +#include "msg/msg.h" +#include "xbt/log.h" + +XBT_LOG_NEW_DEFAULT_CATEGORY(storage,"Messages specific for this simulation"); + +void storage_info(msg_host_t host); +void display_storage_properties(msg_storage_t storage); +int client(int argc, char *argv[]); +int server(int argc, char *argv[]); + + +int client(int argc, char *argv[]) +{ + storage_info(MSG_host_self()); + return 1; +} + +int server(int argc, char *argv[]) +{ + //display_storage_info(); + return 1; +} + +void storage_info(msg_host_t host){ + + const char* host_name = MSG_host_get_name(host); + XBT_INFO("** Storage info on %s:", host_name); + + xbt_dict_cursor_t cursor = NULL; + char* mount_name; + char* storage_name; + msg_storage_t storage; + + xbt_dict_t storage_list = MSG_host_get_storage_list(MSG_host_self()); + + xbt_dict_foreach(storage_list,cursor,mount_name,storage_name) + { + XBT_INFO("\tStorage mount name: %s", mount_name); + + size_t free_size = MSG_storage_get_free_size(mount_name); + size_t used_size = MSG_storage_get_used_size(mount_name); + + XBT_INFO("\t\tFree size: %zu octets", free_size); + XBT_INFO("\t\tUsed size: %zu octets", used_size); + + storage = MSG_storage_get_by_name(storage_name); + display_storage_properties(storage); + } +} + +void display_storage_properties(msg_storage_t storage){ + xbt_dict_cursor_t cursor = NULL; + char *key, *data; + xbt_dict_t props = MSG_storage_get_properties(storage); + if (props){ + XBT_INFO("\tProperties of mounted storage: %s", MSG_storage_get_name(storage)); + xbt_dict_foreach(props, cursor, key, data) + XBT_INFO("\t\t'%s' -> '%s'", key, data); + }else{ + XBT_INFO("\t\tNo property attached."); + } +} + +int main(int argc, char *argv[]) +{ + MSG_init(&argc, argv); + + /* Check the arguments */ + if (argc < 3) { + printf("Usage: %s platform_file deployment_file \n", argv[0]); + return -1; + } + + const char *platform_file = argv[1]; + const char *deployment_file = argv[2]; + + MSG_create_environment(platform_file); + + MSG_function_register("client", client); + MSG_function_register("server", server); + MSG_launch_application(deployment_file); + + msg_error_t res = MSG_main(); + + if (res == MSG_OK) + return 0; + else + return 1; +} diff --git a/teshsuite/msg/storage/storage.tesh b/teshsuite/msg/storage/storage.tesh new file mode 100644 index 0000000000..a2f24d7198 --- /dev/null +++ b/teshsuite/msg/storage/storage.tesh @@ -0,0 +1,8 @@ +$ msg/storage/storage ${srcdir:=.}/msg/storage/plateform.xml ${srcdir:=.}/msg/storage/deployment.xml 0 "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" +> [ 0.000000] (1:client@client) ** Storage info on client: +> [ 0.000000] (1:client@client) Storage mount name: /sd1 +> [ 0.000000] (1:client@client) Free size: 536774599000 octets +> [ 0.000000] (1:client@client) Used size: 96313000 octets +> [ 0.000000] (1:client@client) Properties of mounted storage: cdisk +> [ 0.000000] (1:client@client) 'date' -> '31-08-13' +> [ 0.000000] (1:client@client) 'usage' -> 'scratch' \ No newline at end of file diff --git a/teshsuite/msg/storage/storage_content_c.txt b/teshsuite/msg/storage/storage_content_c.txt new file mode 100644 index 0000000000..d461c10821 --- /dev/null +++ b/teshsuite/msg/storage/storage_content_c.txt @@ -0,0 +1,5 @@ +./doc/simgrid/examples/cxx/autoDestination/FinalizeTask.cxx 71000 +./doc/simgrid/examples/cxx/autoDestination/autoDestination_deployment.xml 1262000 +./doc/simgrid/examples/cxx/autoDestination/Main.cxx 1480000 +./doc/simgrid/examples/cxx/autoDestination/Slave.cxx 87000000 +./doc/simgrid/examples/cxx/autoDestination/BasicTask.cxx 6500000 diff --git a/teshsuite/msg/storage/storage_content_s1.txt b/teshsuite/msg/storage/storage_content_s1.txt new file mode 100644 index 0000000000..004f34bd65 --- /dev/null +++ b/teshsuite/msg/storage/storage_content_s1.txt @@ -0,0 +1,4 @@ +./doc/simgrid/examples/cxx/autoDestination/Master.cxx 18910000 +./doc/simgrid/examples/cxx/autoDestination/autoDestination_platform.xml 21339320000 +./doc/simgrid/examples/cxx/autoDestination/Forwarder.cxx 113700000 +./doc/simgrid/examples/cxx/basic/FinalizeTask.cxx 710000000 diff --git a/teshsuite/msg/storage/storage_content_s2.txt b/teshsuite/msg/storage/storage_content_s2.txt new file mode 100644 index 0000000000..98d37e0103 --- /dev/null +++ b/teshsuite/msg/storage/storage_content_s2.txt @@ -0,0 +1,2 @@ +./doc/simgrid/examples/cxx/basic/Main.cxx 14800000 +./doc/simgrid/examples/cxx/basic/Slave.cxx 69300000 \ No newline at end of file