X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/8b52a012857a15e9403981d7993a00e7af635d94..16bbb8a8212497d9c44c81333ed2c0e689e0c5af:/teshsuite/msg/storage/storage_basic.c diff --git a/teshsuite/msg/storage/storage_basic.c b/teshsuite/msg/storage/storage_basic.c index d352f27363..400c47ff21 100644 --- a/teshsuite/msg/storage/storage_basic.c +++ b/teshsuite/msg/storage/storage_basic.c @@ -1,10 +1,10 @@ -/* Copyright (c) 2013-2014. The SimGrid Team. +/* Copyright (c) 2013-2015. The SimGrid Team. * 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" +#include "simgrid/msg.h" #include "xbt/log.h" XBT_LOG_NEW_DEFAULT_CATEGORY(storage,"Messages specific for this simulation"); @@ -17,6 +17,7 @@ sg_size_t read_local_file(const char *src); void dump_storage_by_name(char *name); void display_storage_content(msg_storage_t storage); void get_set_storage_data(const char *storage_name); +void dump_platform_storages(void); int client(int argc, char *argv[]); int server(int argc, char *argv[]); @@ -57,9 +58,9 @@ void display_storage_properties(msg_storage_t storage){ if (xbt_dict_length(props) > 0){ 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); + XBT_INFO("\t\t'%s' -> '%s'", key, data); }else{ - XBT_INFO("\tNo property attached."); + XBT_INFO("\tNo property attached."); } } @@ -139,16 +140,27 @@ void get_set_storage_data(const char *storage_name){ xbt_free(data); } +void dump_platform_storages(void){ + unsigned int cursor; + xbt_dynar_t storages = MSG_storages_as_dynar(); + msg_storage_t storage; + xbt_dynar_foreach(storages, cursor, storage){ + XBT_INFO("Storage %s is attached to %s", MSG_storage_get_name(storage), MSG_storage_get_host(storage)); + MSG_storage_set_property_value(storage, "other usage", xbt_strdup("gpfs"), xbt_free_f); + } + xbt_dynar_free(&storages); +} + int client(int argc, char *argv[]) { - hsm_put("server","/sd1/doc/simgrid/examples/cxx/autoDestination/FinalizeTask.cxx","/sd2/scratch/toto.cxx"); - hsm_put("server","/sd1/doc/simgrid/examples/cxx/autoDestination/autoDestination_deployment.xml","/sd2/scratch/titi.xml"); - hsm_put("server","/sd1/doc/simgrid/examples/cxx/autoDestination/Slave.cxx","/sd2/scratch/tata.cxx"); + hsm_put("alice","/home/doc/simgrid/examples/msg/icomms/small_platform.xml","c:\\Windows\\toto.cxx"); + hsm_put("alice","/home/doc/simgrid/examples/msg/parallel_task/test_ptask_deployment.xml","c:\\Windows\\titi.xml"); + hsm_put("alice","/home/doc/simgrid/examples/msg/alias/masterslave_forwarder_with_alias.c","c:\\Windows\\tata.c"); msg_task_t finalize = MSG_task_create("finalize", 0, 0, NULL); - MSG_task_send(finalize, "server"); + MSG_task_send(finalize, "alice"); - get_set_storage_data("cdisk"); + get_set_storage_data("Disk1"); return 1; } @@ -156,7 +168,7 @@ int client(int argc, char *argv[]) int server(int argc, char *argv[]) { msg_task_t to_execute = NULL; - _XBT_GNUC_UNUSED int res; + XBT_ATTRIB_UNUSED int res; storage_info(MSG_host_self()); @@ -175,15 +187,16 @@ int server(int argc, char *argv[]) else if(!strcmp(task_name,"hsm_put")){// Receive file to save // Write file on local disk char *dest = MSG_task_get_data(to_execute); - sg_size_t size_to_write = (sg_size_t)MSG_task_get_data_size(to_execute); + sg_size_t size_to_write = (sg_size_t)MSG_task_get_bytes_amount(to_execute); write_local_file(dest, size_to_write); - } + } MSG_task_destroy(to_execute); to_execute = NULL; } storage_info(MSG_host_self()); + dump_platform_storages(); return 1; } @@ -192,10 +205,7 @@ 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; - } + xbt_assert(argc > 2,"Usage: %s platform_file deployment_file \n", argv[0]); const char *platform_file = argv[1]; const char *deployment_file = argv[2]; @@ -209,8 +219,5 @@ int main(int argc, char *argv[]) msg_error_t res = MSG_main(); XBT_INFO("Simulated time: %g", MSG_get_clock()); - if (res == MSG_OK) - return 0; - else - return 1; + return res != MSG_OK; }