From cce9bf321c240cca55882e769e8871e814c5af07 Mon Sep 17 00:00:00 2001 From: Pierre Veyre Date: Thu, 13 Mar 2014 12:19:35 +0100 Subject: [PATCH 1/1] Implement a disk attachment check and add a tesh test to detect invalid platform description --- buildtools/Cmake/AddTests.cmake | 1 + src/surf/surf_routing.cpp | 19 ++++++++++++++ teshsuite/simdag/platforms/CMakeLists.txt | 2 ++ .../platforms/bogus_disk_attachment.tesh | 4 +++ .../platforms/bogus_disk_attachment.xml | 26 +++++++++++++++++++ 5 files changed, 52 insertions(+) create mode 100644 teshsuite/simdag/platforms/bogus_disk_attachment.tesh create mode 100644 teshsuite/simdag/platforms/bogus_disk_attachment.xml diff --git a/buildtools/Cmake/AddTests.cmake b/buildtools/Cmake/AddTests.cmake index 1d6641a11a..4d8363e58c 100644 --- a/buildtools/Cmake/AddTests.cmake +++ b/buildtools/Cmake/AddTests.cmake @@ -140,6 +140,7 @@ if(NOT enable_memcheck) IF(enable_debug AND NOT enable_memcheck) ADD_TEST(tesh-parser-bogus-symmetric ${TESH_COMMAND} ${TESH_OPTION} --setenv bindir=${CMAKE_BINARY_DIR}/teshsuite/simdag/platforms --cd ${CMAKE_HOME_DIRECTORY}/teshsuite/simdag/platforms bogus_two_hosts_asymetric.tesh) ADD_TEST(tesh-parser-bogus-missing-gw ${TESH_COMMAND} ${TESH_OPTION} --setenv bindir=${CMAKE_BINARY_DIR}/teshsuite/simdag/platforms --cd ${CMAKE_HOME_DIRECTORY}/teshsuite/simdag/platforms bogus_missing_gateway.tesh) + ADD_TEST(tesh-disk-attachment ${TESH_COMMAND} ${TESH_OPTION} --setenv bindir=${CMAKE_BINARY_DIR}/teshsuite/simdag/platforms --cd ${CMAKE_HOME_DIRECTORY}/teshsuite/simdag/platforms bogus_disk_attachment.tesh) ENDIF() ADD_TEST(tesh-simdag-bypass ${TESH_COMMAND} ${TESH_OPTION} --setenv bindir=${CMAKE_BINARY_DIR}/teshsuite/simdag/platforms --setenv srcdir=${CMAKE_HOME_DIRECTORY} --cd ${CMAKE_HOME_DIRECTORY}/teshsuite/simdag/platforms basic_parsing_test_bypass.tesh) diff --git a/src/surf/surf_routing.cpp b/src/surf/surf_routing.cpp index 455f3e8134..93a3ca0fcd 100644 --- a/src/surf/surf_routing.cpp +++ b/src/surf/surf_routing.cpp @@ -12,9 +12,11 @@ #include "simgrid/platf_interface.h" // platform creation API internal interface #include "simgrid/sg_config.h" +#include "storage_interface.hpp" #include "surf/surfxml_parse_values.h" + /** * @ingroup SURF_build_api * @brief A library containing all known workstations @@ -1239,6 +1241,22 @@ static void routing_parse_peer(sg_platf_peer_cbarg_t peer) // } // } +static void check_disk_attachment() +{ + xbt_lib_cursor_t cursor; + char *key; + void **data; + RoutingEdgePtr host_elm; + xbt_lib_foreach(storage_lib, cursor, key, data) { + if(xbt_lib_get_level(xbt_lib_get_elm_or_null(storage_lib, key), SURF_STORAGE_LEVEL) != NULL) { + StoragePtr storage = static_cast(xbt_lib_get_level(xbt_lib_get_elm_or_null(storage_lib, key), SURF_STORAGE_LEVEL)); + host_elm = sg_routing_edge_by_name_or_null(storage->p_attach); + if(!host_elm) + surf_parse_error("Enable to attach storage %s: host %s doesn't exist.", storage->getName(), storage->p_attach); + } + } +} + void routing_register_callbacks() { sg_platf_host_add_cb(parse_S_host); @@ -1254,6 +1272,7 @@ void routing_register_callbacks() sg_platf_peer_add_cb(routing_parse_peer); sg_platf_postparse_add_cb(routing_parse_postparse); + sg_platf_postparse_add_cb(check_disk_attachment); /* we care about the ASes while parsing the platf. Incredible, isnt it? */ sg_platf_AS_end_add_cb(routing_AS_end); diff --git a/teshsuite/simdag/platforms/CMakeLists.txt b/teshsuite/simdag/platforms/CMakeLists.txt index 320a0c146a..5fe5c14a33 100644 --- a/teshsuite/simdag/platforms/CMakeLists.txt +++ b/teshsuite/simdag/platforms/CMakeLists.txt @@ -38,6 +38,7 @@ set(tesh_files ${CMAKE_CURRENT_SOURCE_DIR}/get_full_link.tesh ${CMAKE_CURRENT_SOURCE_DIR}/bogus_two_hosts_asymetric.tesh ${CMAKE_CURRENT_SOURCE_DIR}/bogus_missing_gateway.tesh + ${CMAKE_CURRENT_SOURCE_DIR}/bogus_disk_attachment.tesh PARENT_SCOPE ) set(xml_files @@ -88,6 +89,7 @@ set(xml_files ${CMAKE_CURRENT_SOURCE_DIR}/clusterA.xml ${CMAKE_CURRENT_SOURCE_DIR}/clusterB.xml ${CMAKE_CURRENT_SOURCE_DIR}/Dijkstra.xml + ${CMAKE_CURRENT_SOURCE_DIR}/bogus_disk_attachment.xml PARENT_SCOPE ) set(teshsuite_src diff --git a/teshsuite/simdag/platforms/bogus_disk_attachment.tesh b/teshsuite/simdag/platforms/bogus_disk_attachment.tesh new file mode 100644 index 0000000000..534cd7fcea --- /dev/null +++ b/teshsuite/simdag/platforms/bogus_disk_attachment.tesh @@ -0,0 +1,4 @@ +! expect signal SIGABRT +$ ${bindir:=.}/flatifier bogus_disk_attachment.xml "--log=root.fmt:[%10.6r]%e[%i:%P@%h]%e%m%n" +> [ 0.000000] [0:@] surf_workstation_model_init_ptask_L07 +> [ 0.000000] [0:@] Parse error at bogus_disk_attachment.xml:26: Enable to attach storage cdisk: host plouf doesn't exist. diff --git a/teshsuite/simdag/platforms/bogus_disk_attachment.xml b/teshsuite/simdag/platforms/bogus_disk_attachment.xml new file mode 100644 index 0000000000..c5ca5dc192 --- /dev/null +++ b/teshsuite/simdag/platforms/bogus_disk_attachment.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file -- 2.20.1