From ff5c5d1e18fcaea7f732c9f28b58fa4365e23cd4 Mon Sep 17 00:00:00 2001 From: Frederic Suter Date: Tue, 5 Dec 2017 10:53:59 +0100 Subject: [PATCH] move last MSG io example to teshsuite rename s4u-io to s4u-io-file-system update doc --- .gitignore | 4 +- examples/msg/CMakeLists.txt | 4 +- examples/msg/README.doc | 13 ---- examples/s4u/CMakeLists.txt | 4 +- examples/s4u/README.doc | 5 ++ .../s4u/{io => io-file-system}/.gitignore | 0 .../s4u-io-file-system.cpp} | 9 ++- .../s4u-io-file-system.tesh} | 2 +- teshsuite/msg/CMakeLists.txt | 4 +- {examples => teshsuite}/msg/io-file/io-file.c | 77 +++++++++---------- .../msg/io-file/io-file.tesh | 0 11 files changed, 57 insertions(+), 65 deletions(-) rename examples/s4u/{io => io-file-system}/.gitignore (100%) rename examples/s4u/{io/s4u-io.cpp => io-file-system/s4u-io-file-system.cpp} (94%) rename examples/s4u/{io/s4u-io.tesh => io-file-system/s4u-io-file-system.tesh} (95%) rename {examples => teshsuite}/msg/io-file/io-file.c (57%) rename {examples => teshsuite}/msg/io-file/io-file.tesh (100%) diff --git a/.gitignore b/.gitignore index d985817440..dcce047e29 100644 --- a/.gitignore +++ b/.gitignore @@ -135,7 +135,6 @@ examples/msg/energy-consumption/energy-consumption examples/msg/energy-onoff/energy-onoff examples/msg/energy-pstate/energy-pstate examples/msg/energy-vm/energy-vm -examples/msg/io-file/io-file examples/msg/io-file-unlink/io-file-unlink examples/msg/io-remote/io-remote examples/msg/io-storage/io-storage @@ -206,7 +205,7 @@ examples/s4u/energy-link/s4u-energy-link examples/s4u/energy-ptask/s4u-energy-ptask examples/s4u/energy-pstate/s4u-energy-pstate examples/s4u/energy-vm/s4u-energy-vm -examples/s4u/io/s4u-io +examples/s4u/io-file-system/s4u-io-file-system examples/s4u/io-file-remote/s4u-io-file-remote examples/s4u/io-storage-raw/s4u-io-storage-raw examples/s4u/mutex/s4u-mutex @@ -274,6 +273,7 @@ teshsuite/msg/host_on_off/host_on_off teshsuite/msg/host_on_off_processes/host_on_off_processes teshsuite/msg/host_on_off_recv/host_on_off_recv teshsuite/msg/host_on_off_wait/host_on_off_wait +teshsuite/msg/io-file/io-file teshsuite/msg/io-file-remote/io-file-remote teshsuite/msg/io-raw-storage/io-raw-storage teshsuite/msg/listen_async/listen_async diff --git a/examples/msg/CMakeLists.txt b/examples/msg/CMakeLists.txt index d0764e1d96..d630d38f4f 100644 --- a/examples/msg/CMakeLists.txt +++ b/examples/msg/CMakeLists.txt @@ -2,7 +2,7 @@ foreach(x app-masterworker app-pingpong app-token-ring cloud-capping cloud-masterworker cloud-migration cloud-simple cloud-two-tasks dht-pastry energy-consumption energy-onoff energy-vm platform-failures - io-file task-priority + task-priority plugin-hostload process-create process-join synchro-semaphore trace-categories @@ -73,7 +73,7 @@ set(xml_files ${xml_files} ${CMAKE_CURRENT_SOURCE_DIR}/app-masterworker/a foreach(x app-chainsend app-masterworker app-pingpong app-token-ring cloud-capping cloud-masterworker cloud-migration cloud-simple - cloud-two-tasks dht-pastry dht-kademlia platform-failures io-file task-priority + cloud-two-tasks dht-pastry dht-kademlia platform-failures task-priority energy-consumption energy-onoff energy-vm plugin-hostload process-create process-join diff --git a/examples/msg/README.doc b/examples/msg/README.doc index 5a772cf4b7..0cd0792078 100644 --- a/examples/msg/README.doc +++ b/examples/msg/README.doc @@ -12,7 +12,6 @@ documentation, but it should remain readable directly. - @ref msg_ex_tracing_user_variables - @ref msg_ex_models - @ref msg_ex_ns3 - - @ref msg_ex_io - @ref msg_ex_apps - @ref msg_ex_misc @@ -133,16 +132,6 @@ TODO: merge the C files TODO: show the XML files instead if it's what is interesting. On a "XML example files" page that does not exist yet. -@subsection msg_ex_io Simulating disks and files - -The examples of this section demonstrate how to interact with the -simulated storages. - - - File Management. @ref examples/msg/io-file/io-file.c \n - This example illustrates the use of operations on file - (@ref MSG_file_open, @ref MSG_file_read, @ref MSG_file_write, - or @ref MSG_file_close). - @section msg_ex_misc Miscellaneous - Task priorities. @@ -178,8 +167,6 @@ top of the example file). @example examples/msg/network-ns3/network-ns3.c -@example examples/msg/io-file/io-file.c - @example examples/msg/task-priority/task-priority.c */ diff --git a/examples/s4u/CMakeLists.txt b/examples/s4u/CMakeLists.txt index d20f005f21..251e1c48eb 100644 --- a/examples/s4u/CMakeLists.txt +++ b/examples/s4u/CMakeLists.txt @@ -3,7 +3,7 @@ foreach (example actions-comm actions-storage app-masterworker app-pingpong app-token-ring async-wait async-waitany async-waitall energy-link energy-pstate energy-ptask energy-vm - io io-file-remote io-storage-raw + io-file-system io-file-remote io-storage-raw platform-properties plugin-hostload mutex) add_executable (s4u-${example} ${example}/s4u-${example}.cpp) target_link_libraries(s4u-${example} simgrid) @@ -70,7 +70,7 @@ foreach(example actions-comm actions-storage dht-chord energy-link energy-pstate energy-ptask energy-vm platform-properties plugin-hostload mutex - io io-file-remote io-storage-raw) + io-file-system io-file-remote io-storage-raw) ADD_TESH_FACTORIES(s4u-${example} "thread;ucontext;raw;boost" --setenv bindir=${CMAKE_CURRENT_BINARY_DIR}/${example} --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms diff --git a/examples/s4u/README.doc b/examples/s4u/README.doc index 4fa7b4b857..efcefaa105 100644 --- a/examples/s4u/README.doc +++ b/examples/s4u/README.doc @@ -169,6 +169,10 @@ also the tesh files in the example directories for details. The examples of this section demonstrate how to interact with the simulated storages. + - File Management. @ref examples/s4u/io-file-system/s4u-io-file-system.cpp \n + This example illustrates the use of operations on files + (read, write, seek, tell, unlink, ...). + - Access to raw storage devices . @ref examples/s4u/io-storage-raw/s4u-io-storage-raw.cpp \n This example illustrates how to simply read and write data on a @@ -211,6 +215,7 @@ simulated storages. @example examples/s4u/async-waitall/s4u-async-waitall.cpp @example examples/s4u/async-waitany/s4u-async-waitany.cpp @example examples/s4u/energy-pstate/s4u-energy-pstate.cpp +@example examples/s4u/io-file-system/s4u-io-file-system.cpp @example examples/s4u/io-file-remote/s4u-io-file-remote.cpp @example examples/s4u/io-storage-raw/s4u-io-storage-raw.cpp \n @example examples/s4u/mutex/s4u-mutex.cpp diff --git a/examples/s4u/io/.gitignore b/examples/s4u/io-file-system/.gitignore similarity index 100% rename from examples/s4u/io/.gitignore rename to examples/s4u/io-file-system/.gitignore diff --git a/examples/s4u/io/s4u-io.cpp b/examples/s4u/io-file-system/s4u-io-file-system.cpp similarity index 94% rename from examples/s4u/io/s4u-io.cpp rename to examples/s4u/io-file-system/s4u-io-file-system.cpp index 7e6c110323..269cab94ba 100644 --- a/examples/s4u/io/s4u-io.cpp +++ b/examples/s4u/io-file-system/s4u-io-file-system.cpp @@ -27,7 +27,8 @@ public: } } - void operator()() { + void operator()() + { std::unordered_map const& mounts = simgrid::s4u::Host::current()->getMountedStorages(); @@ -37,7 +38,7 @@ public: std::string filename = "/home/tmp/data.txt"; simgrid::s4u::File* file = new simgrid::s4u::File(filename, nullptr); - sg_size_t write = file->write(200000); // Write 200,000 bytes + sg_size_t write = file->write(200000); // Write 200,000 bytes XBT_INFO("Create a %llu bytes file named '%s' on /sd1", write, filename.c_str()); // check that sizes have changed @@ -50,7 +51,7 @@ public: XBT_INFO("Read %llu bytes on %s", read, filename.c_str()); // Now write 100,000 bytes in tmp/data.txt - write = file->write(100000); // Write 100,000 bytes + write = file->write(100000); // Write 100,000 bytes XBT_INFO("Write %llu bytes on %s", write, filename.c_str()); simgrid::s4u::Storage* storage = simgrid::s4u::Storage::byName("Disk4"); @@ -88,7 +89,7 @@ public: } }; -int main(int argc, char **argv) +int main(int argc, char** argv) { simgrid::s4u::Engine e(&argc, argv); sg_storage_file_system_init(); diff --git a/examples/s4u/io/s4u-io.tesh b/examples/s4u/io-file-system/s4u-io-file-system.tesh similarity index 95% rename from examples/s4u/io/s4u-io.tesh rename to examples/s4u/io-file-system/s4u-io-file-system.tesh index 1c3ae8bd5c..e89c8e1f46 100644 --- a/examples/s4u/io/s4u-io.tesh +++ b/examples/s4u/io-file-system/s4u-io-file-system.tesh @@ -1,6 +1,6 @@ #! ./tesh -$ $SG_TEST_EXENV ${bindir:=.}/s4u-io ${platfdir}/storage/storage.xml +$ $SG_TEST_EXENV ${bindir:=.}/s4u-io-file-system ${platfdir}/storage/storage.xml > [denise:host:(1) 0.000000] [s4u_test/INFO] Storage info on denise: > [denise:host:(1) 0.000000] [s4u_test/INFO] Disk2 (c:) Used: 2391537133; Free: 534479374867; Total: 536870912000. > [denise:host:(1) 0.000000] [s4u_test/INFO] Disk4 (/home) Used: 13221994; Free: 536857690006; Total: 536870912000. diff --git a/teshsuite/msg/CMakeLists.txt b/teshsuite/msg/CMakeLists.txt index 92d30420c1..513493db69 100644 --- a/teshsuite/msg/CMakeLists.txt +++ b/teshsuite/msg/CMakeLists.txt @@ -4,7 +4,7 @@ foreach(x actions-comm actions-storage cloud-sharing get_sender host_on_off host_on_off_recv host_on_off_processes process-daemon process-kill process-lifetime process-migration process-suspend process-yield energy-ptask energy-pstate platform-properties - io-raw-storage io-file-remote + io-file io-raw-storage io-file-remote trace_integration) add_executable (${x} ${x}/${x}.c) target_link_libraries(${x} simgrid) @@ -79,7 +79,7 @@ foreach(x task_destroy_cancel task_listen_from task_progress process-daemon process-kill process-lifetime process-migration process-suspend process-yield energy-ptask - io-raw-storage io-file-remote + io-file io-raw-storage io-file-remote platform-properties trace_integration) ADD_TESH_FACTORIES(tesh-msg-${x} "thread;ucontext;raw;boost" diff --git a/examples/msg/io-file/io-file.c b/teshsuite/msg/io-file/io-file.c similarity index 57% rename from examples/msg/io-file/io-file.c rename to teshsuite/msg/io-file/io-file.c index ec150573c7..2c22834a82 100644 --- a/examples/msg/io-file/io-file.c +++ b/teshsuite/msg/io-file/io-file.c @@ -8,7 +8,7 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(io_file, "Messages specific for this io example"); -static int host(int argc, char *argv[]) +static int host(int argc, char* argv[]) { msg_file_t file = NULL; sg_size_t read; @@ -16,46 +16,45 @@ static int host(int argc, char *argv[]) msg_storage_t st; const char* st_name; - switch(MSG_process_self_PID()){ - case 1: - file = MSG_file_open("c:\\Windows\\setupact.log", NULL); - st_name = "Disk2"; - break; - case 2: - file = MSG_file_open("/home/doc/simgrid/examples/platforms/nancy.xml", NULL); - st_name = "Disk1"; - break; - case 3: - file = MSG_file_open("/home/doc/simgrid/examples/platforms/g5k_cabinets.xml", NULL); - st_name = "Disk3"; - break; - case 4: - file = MSG_file_open("/home/doc/simgrid/examples/platforms/g5k.xml", NULL); - MSG_file_dump(file); - st_name = "Disk4"; - break; - default: - xbt_die("FILENAME NOT DEFINED %s",MSG_process_get_name(MSG_process_self())); + switch (MSG_process_self_PID()) { + case 1: + file = MSG_file_open("c:\\Windows\\setupact.log", NULL); + st_name = "Disk2"; + break; + case 2: + file = MSG_file_open("/home/doc/simgrid/examples/platforms/nancy.xml", NULL); + st_name = "Disk1"; + break; + case 3: + file = MSG_file_open("/home/doc/simgrid/examples/platforms/g5k_cabinets.xml", NULL); + st_name = "Disk3"; + break; + case 4: + file = MSG_file_open("/home/doc/simgrid/examples/platforms/g5k.xml", NULL); + MSG_file_dump(file); + st_name = "Disk4"; + break; + default: + xbt_die("FILENAME NOT DEFINED %s", MSG_process_get_name(MSG_process_self())); } const char* filename = MSG_file_get_name(file); - XBT_INFO("\tOpen file '%s'",filename); + XBT_INFO("\tOpen file '%s'", filename); st = MSG_storage_get_by_name(st_name); - XBT_INFO("\tCapacity of the storage element '%s' is stored on: %llu / %llu", - filename, MSG_storage_get_used_size(st), MSG_storage_get_size(st)); + XBT_INFO("\tCapacity of the storage element '%s' is stored on: %llu / %llu", filename, MSG_storage_get_used_size(st), + MSG_storage_get_size(st)); /* Try to read for 10MB */ read = MSG_file_read(file, 10000000); - XBT_INFO("\tHave read %llu from '%s'",read,filename); + XBT_INFO("\tHave read %llu from '%s'", read, filename); /* Write 100KB in file from the current position, i.e, end of file or 10MB */ write = MSG_file_write(file, 100000); - XBT_INFO("\tHave written %llu in '%s'. Size now is: %llu",write,filename, MSG_file_get_size(file)); + XBT_INFO("\tHave written %llu in '%s'. Size now is: %llu", write, filename, MSG_file_get_size(file)); - - XBT_INFO("\tCapacity of the storage element '%s' is stored on: %llu / %llu", - filename, MSG_storage_get_used_size(st), MSG_storage_get_size(st)); + XBT_INFO("\tCapacity of the storage element '%s' is stored on: %llu / %llu", filename, MSG_storage_get_used_size(st), + MSG_storage_get_size(st)); /* rewind to the beginning of the file */ XBT_INFO("\tComing back to the beginning of the stream for file '%s'", filename); @@ -63,7 +62,7 @@ static int host(int argc, char *argv[]) /* Try to read 110KB */ read = MSG_file_read(file, 110000); - XBT_INFO("\tHave read %llu from '%s' (of size %llu)",read,filename, MSG_file_get_size(file)); + XBT_INFO("\tHave read %llu from '%s' (of size %llu)", read, filename, MSG_file_get_size(file)); /* rewind once again to the beginning of the file */ XBT_INFO("\tComing back to the beginning of the stream for file '%s'", filename); @@ -71,12 +70,12 @@ static int host(int argc, char *argv[]) /* Write 110KB in file from the current position, i.e, end of file or 10MB */ write = MSG_file_write(file, 110000); - XBT_INFO("\tHave written %llu in '%s'. Size now is: %llu", write,filename, MSG_file_get_size(file)); + XBT_INFO("\tHave written %llu in '%s'. Size now is: %llu", write, filename, MSG_file_get_size(file)); - XBT_INFO("\tCapacity of the storage element '%s' is stored on: %llu / %llu", - filename, MSG_storage_get_used_size(st), MSG_storage_get_size(st)); + XBT_INFO("\tCapacity of the storage element '%s' is stored on: %llu / %llu", filename, MSG_storage_get_used_size(st), + MSG_storage_get_size(st)); - if (MSG_process_self_PID() == 1){ + if (MSG_process_self_PID() == 1) { XBT_INFO("\tUnlink file '%s'", MSG_file_get_name(file)); MSG_file_unlink(file); } else { @@ -86,18 +85,18 @@ static int host(int argc, char *argv[]) return 0; } -int main(int argc, char **argv) +int main(int argc, char** argv) { MSG_init(&argc, argv); MSG_storage_file_system_init(); MSG_create_environment(argv[1]); - xbt_dynar_t hosts = MSG_hosts_as_dynar(); + xbt_dynar_t hosts = MSG_hosts_as_dynar(); MSG_function_register("host", host); unsigned long nb_hosts = xbt_dynar_length(hosts); - XBT_INFO("Number of host '%lu'",nb_hosts); - for(int i = 0 ; i < nb_hosts; i++){ - MSG_process_create("host", host, NULL, xbt_dynar_get_as(hosts,i,msg_host_t)); + XBT_INFO("Number of host '%lu'", nb_hosts); + for (int i = 0; i < nb_hosts; i++) { + MSG_process_create("host", host, NULL, xbt_dynar_get_as(hosts, i, msg_host_t)); } xbt_dynar_free(&hosts); diff --git a/examples/msg/io-file/io-file.tesh b/teshsuite/msg/io-file/io-file.tesh similarity index 100% rename from examples/msg/io-file/io-file.tesh rename to teshsuite/msg/io-file/io-file.tesh -- 2.20.1