1 /* Bug report: https://github.com/mquinson/simgrid/issues/40
3 * Task.listen used to be on async mailboxes as it always returned false.
4 * This occures in Java and C, but is only tested here in C.
8 #include "simgrid/msg.h"
10 XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example");
12 static int server(int argc, char *argv[])
14 msg_task_t task = MSG_task_create("a", 0, 0, (char*)"Some data");
15 MSG_task_isend(task, "mailbox");
17 xbt_assert(MSG_task_listen("mailbox")); // True (1)
18 XBT_INFO("Task listen works on regular mailboxes");
20 MSG_task_receive(&task, "mailbox");
21 xbt_assert(!strcmp("Some data", MSG_task_get_data(task)), "Data received: %s", (char*)MSG_task_get_data(task));
22 MSG_task_destroy(task);
23 XBT_INFO("Data successfully received from regular mailbox");
25 MSG_mailbox_set_async("mailbox2");
26 task = MSG_task_create("b", 0, 0, (char*)"More data");
27 MSG_task_isend(task, "mailbox2");
29 xbt_assert(MSG_task_listen("mailbox2")); // used to break.
30 XBT_INFO("Task listen works on asynchronous mailboxes");
32 MSG_task_receive(&task, "mailbox2");
33 xbt_assert(!strcmp("More data", MSG_task_get_data(task)));
34 MSG_task_destroy(task);
35 XBT_INFO("Data successfully received from asynchronous mailbox");
41 int main(int argc, char *argv[])
43 MSG_init(&argc, argv);
45 MSG_create_environment(argv[1]);
46 MSG_process_create("test", server, NULL, MSG_host_by_name("Tremblay"));