From 72d62a5fb842f783cc6824be0eb5f9f2c336391d Mon Sep 17 00:00:00 2001 From: Volker Birk Date: Thu, 13 Aug 2020 12:19:35 +0200 Subject: [PATCH] ... --- test/framework.cc | 8 ++++++++ test/framework.hh | 3 +++ test/test_leave_device_group.cc | 27 +++++++++++++-------------- 3 files changed, 24 insertions(+), 14 deletions(-) diff --git a/test/framework.cc b/test/framework.cc index 22731da..5946aaf 100644 --- a/test/framework.cc +++ b/test/framework.cc @@ -5,6 +5,8 @@ #include #include #include +#include + #include #include #include @@ -20,6 +22,7 @@ pEp::Test::Transport pEp::Test::transport; std::string pEp::Test::path; +extern std::thread *pEp::Adapter::_sync_thread; namespace pEp { namespace Test { @@ -148,6 +151,11 @@ namespace pEp { return text; } + void join_sync_thread() + { + _sync_thread->join(); + } + Message Transport::recv() { mkdir(inbox_path.c_str(), 0770); diff --git a/test/framework.hh b/test/framework.hh index a7e2a0a..f0b28f7 100644 --- a/test/framework.hh +++ b/test/framework.hh @@ -38,6 +38,9 @@ namespace pEp { // Sync and Distribution decoder string make_pEp_msg(Message msg); + // wait until Sync has shut down + void join_sync_thread(); + struct Transport { string inbox_path = "inbox"; string outbox_path = "outbox"; diff --git a/test/test_leave_device_group.cc b/test/test_leave_device_group.cc index 9f11f97..a3a1dc8 100644 --- a/test/test_leave_device_group.cc +++ b/test/test_leave_device_group.cc @@ -29,6 +29,7 @@ PEP_STATUS test_notifyHandshake(pEp_identity *_me, pEp_identity *_partner, sync_ int main(int argc, char **argv) { Test::setup(argc, argv); + session(); // set up two own identites for sync @@ -44,39 +45,37 @@ int main(int argc, char **argv) Test::import_key_from_file(bob_filename); Test::import_key_from_file(erwin_filename); - pEp_identity* bob = ::new_identity("bob@example.org", bob_fpr, "BOB", "Bob Dog"); - PEP_STATUS status = ::set_own_key(session(), bob, bob_fpr); + Test::Identity bob = Test::make_identity(::new_identity("bob@example.org", bob_fpr, "BOB", "Bob Dog")); + PEP_STATUS status = ::set_own_key(session(), bob.get(), bob_fpr); assert(status == PEP_STATUS_OK); - status = ::enable_identity_for_sync(session(), bob); + status = ::enable_identity_for_sync(session(), bob.get()); assert(status == PEP_STATUS_OK); - pEp_identity* erwin = ::new_identity("erwin@example.org", erwin_fpr, "BOB", "Bob is Erwin"); - status = ::set_own_key(session(), erwin, erwin_fpr); + Test::Identity erwin = Test::make_identity(::new_identity("erwin@example.org", erwin_fpr, "BOB", "Bob is Erwin")); + status = ::set_own_key(session(), erwin.get(), erwin_fpr); assert(status == PEP_STATUS_OK); - status = ::enable_identity_for_sync(session(), erwin); + status = ::enable_identity_for_sync(session(), erwin.get()); assert(status == PEP_STATUS_OK); // simulate a device group by setting the identities to in sync - status = set_identity_flags(session(), bob, PEP_idf_devicegroup); - status = set_identity_flags(session(), erwin, PEP_idf_devicegroup); + status = set_identity_flags(session(), bob.get(), PEP_idf_devicegroup); + status = set_identity_flags(session(), erwin.get(), PEP_idf_devicegroup); // register at callback_dispatcher and start sync callback_dispatcher.add(test_messageToSend, test_notifyHandshake); CallbackDispatcher::start_sync(); + // leave device group - // stop sync - CallbackDispatcher::stop_sync(); + status = ::leave_device_group(session()); - // free own identities and release session and release session - - ::free_identity(bob); - ::free_identity(erwin); + // wait for sync shutdown and release first session + Test::join_sync_thread(); session(Adapter::release); return 0;