Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
use listen_from in s4u test and kill the MSG one
[simgrid.git] / teshsuite / s4u / listen_async / listen_async.cpp
index c1c5e0a..e277a3d 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2017-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2017-2020. 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. */
@@ -6,7 +6,7 @@
 /* Bug report: https://github.com/simgrid/simgrid/issues/40
  *
  * Task.listen used to be on async mailboxes as it always returned false.
- * This occures in Java and C, but is only tested here in C.
+ * This occurs in Java and C, but is only tested here in C.
  */
 
 #include "simgrid/s4u.hpp"
@@ -15,20 +15,23 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this s4u example")
 
 static void server()
 {
-  simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::by_name("mailbox");
+  simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name("mailbox");
 
   simgrid::s4u::CommPtr sendComm = mailbox->put_async(new std::string("Some data"), 0);
 
   xbt_assert(mailbox->listen()); // True (1)
   XBT_INFO("Task listen works on regular mailboxes");
-  std::string* res = static_cast<std::string*>(mailbox->get());
+  XBT_INFO("Mailbox::listen_from() returns %ld (should return my pid, which is %ld)", mailbox->listen_from(),
+           simgrid::s4u::this_actor::get_pid());
+
+  const std::string* res = static_cast<std::string*>(mailbox->get());
 
   xbt_assert(*res == "Some data", "Data received: %s", res->c_str());
   XBT_INFO("Data successfully received from regular mailbox");
   delete res;
   sendComm->wait();
 
-  simgrid::s4u::MailboxPtr mailbox2 = simgrid::s4u::Mailbox::by_name("mailbox2");
+  simgrid::s4u::Mailbox* mailbox2 = simgrid::s4u::Mailbox::by_name("mailbox2");
   mailbox2->set_receiver(simgrid::s4u::Actor::self());
 
   mailbox2->put_init(new std::string("More data"), 0)->detach();