Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
fix MSG_task_listen_from() and add a test
authorMartin Quinson <martin.quinson@loria.fr>
Tue, 30 May 2017 20:10:14 +0000 (22:10 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Tue, 30 May 2017 20:10:18 +0000 (22:10 +0200)
(fix #121) sorry for the delay.

.gitignore
src/msg/msg_gos.cpp
teshsuite/msg/CMakeLists.txt
teshsuite/msg/task_listen_from/task_listen_from.cpp [new file with mode: 0644]
teshsuite/msg/task_listen_from/task_listen_from.tesh [new file with mode: 0644]

index c5eea27..e00a0d0 100644 (file)
@@ -122,7 +122,6 @@ doc/msg-tuto-src/masterworker3
 doc/msg-tuto-src/masterworker4
 examples/msg/actions-comm/actions-comm
 examples/msg/actions-storage/actions-storage
-examples/msg/async-yield/async-yield
 examples/msg/async-wait/async-wait
 examples/msg/async-waitall/async-waitall
 examples/msg/async-waitany/async-waitany
@@ -155,6 +154,7 @@ examples/msg/process-join/process-join
 examples/msg/process-migration/process-migration
 examples/msg/process-startkilltime/process-startkilltime
 examples/msg/process-suspend/process-suspend
+examples/msg/process-yield/process-yield
 examples/msg/app-masterworker/app-masterworker
 examples/msg/mc/bugged1
 examples/msg/mc/bugged1_liveness
@@ -259,6 +259,7 @@ teshsuite/msg/pid/pid
 teshsuite/msg/process/process
 teshsuite/msg/storage_client_server/storage_client_server
 teshsuite/msg/task_destroy_cancel/task_destroy_cancel
+teshsuite/msg/task_listen_from/task_listen_from
 teshsuite/msg/trace_integration/trace_integration
 teshsuite/simdag/availability/availability
 teshsuite/simdag/basic-link-test/basic-link-test
index 306af43..3e2eda2 100644 (file)
@@ -873,7 +873,7 @@ int MSG_task_listen_from(const char *alias)
   if (not comm)
     return -1;
 
-  return MSG_process_get_PID( static_cast<msg_task_t>(comm->src_data)->simdata->sender );
+  return MSG_process_get_PID(static_cast<msg_task_t>(comm->src_buff)->simdata->sender);
 }
 
 /** \ingroup msg_task_usage
index 780d908..f3d64d7 100644 (file)
@@ -9,7 +9,7 @@ foreach(x get_sender host_on_off host_on_off_recv host_on_off_processes trace_in
 endforeach()
 
 # CPP examples
-foreach(x task_destroy_cancel)
+foreach(x task_destroy_cancel task_listen_from)
   add_executable       (${x}  ${x}/${x}.cpp)
   target_link_libraries(${x}  simgrid)
   set_target_properties(${x}  PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${x})
@@ -33,6 +33,6 @@ set(xml_files     ${xml_files}     ${CMAKE_CURRENT_SOURCE_DIR}/trace_integration
                                    ${CMAKE_CURRENT_SOURCE_DIR}/trace_integration/test-hbp1-c1s1-c3s2.xml
                                    ${CMAKE_CURRENT_SOURCE_DIR}/trace_integration/test-hbp2.5-hbp1.5.xml    PARENT_SCOPE)
 
-foreach(x get_sender host_on_off host_on_off_processes host_on_off_recv task_destroy_cancel trace_integration)
+foreach(x get_sender host_on_off host_on_off_processes host_on_off_recv task_destroy_cancel task_listen_from trace_integration)
   ADD_TESH_FACTORIES(tesh-msg-${x} "thread;boost;ucontext;raw" --setenv srcdir=${CMAKE_HOME_DIRECTORY}/teshsuite/msg/${x} --cd ${CMAKE_BINARY_DIR}/teshsuite/msg/${x} ${CMAKE_HOME_DIRECTORY}/teshsuite/msg/${x}/${x}.tesh)
 endforeach()
diff --git a/teshsuite/msg/task_listen_from/task_listen_from.cpp b/teshsuite/msg/task_listen_from/task_listen_from.cpp
new file mode 100644 (file)
index 0000000..128b046
--- /dev/null
@@ -0,0 +1,36 @@
+/* Copyright (c) 2017. 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. */
+
+/* This is the test case of GitHub's #121 */
+
+#include "simgrid/msg.h"
+
+XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example");
+
+static int tester(int argc, char* argv[])
+{
+  msg_task_t task = MSG_task_create("name", 0, 10, NULL);
+  msg_comm_t comm = MSG_task_isend(task, "mailbox");
+
+  XBT_INFO("MSG_task_listen_from returns() %d (should return my pid, which is %d)", MSG_task_listen_from("mailbox"),
+           MSG_process_get_PID(MSG_process_self()));
+  XBT_INFO("MSG_task_listen returns()      %d (should return true, i.e. 1)", MSG_task_listen("mailbox"));
+
+  MSG_comm_destroy(comm);
+  MSG_task_destroy(task);
+
+  return 0;
+}
+
+int main(int argc, char* argv[])
+{
+  MSG_init(&argc, argv);
+  xbt_assert(argc == 2, "Usage: %s platform_file\n\tExample: %s msg_platform.xml\n", argv[0], argv[0]);
+  MSG_create_environment(argv[1]);
+
+  MSG_process_create("tester", tester, NULL, MSG_get_host_by_name("Tremblay"));
+
+  return MSG_main();
+}
diff --git a/teshsuite/msg/task_listen_from/task_listen_from.tesh b/teshsuite/msg/task_listen_from/task_listen_from.tesh
new file mode 100644 (file)
index 0000000..32db934
--- /dev/null
@@ -0,0 +1,3 @@
+$ ./task_listen_from ${srcdir:=.}/../../../examples/platforms/small_platform.xml
+> [Tremblay:tester:(1) 0.000000] [msg_test/INFO] MSG_task_listen_from returns() 1 (should return my pid, which is 1)
+> [Tremblay:tester:(1) 0.000000] [msg_test/INFO] MSG_task_listen returns()      1 (should return true, i.e. 1)