diff --git a/test/pitytest11/src/PityUnit.hh b/test/pitytest11/src/PityUnit.hh index 5d39714..8351bbb 100644 --- a/test/pitytest11/src/PityUnit.hh +++ b/test/pitytest11/src/PityUnit.hh @@ -19,7 +19,7 @@ namespace pEp { namespace PityTest11 { - template + template class PityUnit { public: using TestFunction = const std::function&, TestContext*)>; diff --git a/test/pitytest11/test/test_execmodes.cc b/test/pitytest11/test/test_execmodes.cc index 6de72a9..b66865f 100644 --- a/test/pitytest11/test/test_execmodes.cc +++ b/test/pitytest11/test/test_execmodes.cc @@ -29,46 +29,36 @@ int main(int argc, char* argv[]) // Subprocess 1 PityUnit<> test1 = PityUnit<>{ &root, "node1", - [](PityUnit<>& unit, - PityModel* model, - PityPerspective* psp) { do_some_work(unit, 200, 10); }, - nullptr, + [](PityUnit<>& unit, void* ctx) { + do_some_work(unit, 200, 10); + }, nullptr, pEp::PityTest11::PityUnit<>::ExecutionMode::PROCESS_PARALLEL }; - PityUnit<> test1_1 = PityUnit<>{ &test1, - "test1.1", - [](PityUnit<>& unit, - PityModel* model, - PityPerspective* psp) { do_some_work(unit, 200, 10); } }; + PityUnit<> test1_1 = PityUnit<>{ &test1, "test1.1", [](PityUnit<>& unit, void* ctx) { + do_some_work(unit, 200, 10); + } }; - PityUnit<> test1_2 = PityUnit<>{ &test1, - "test1.2", - [](PityUnit<>& unit, - PityModel* model, - PityPerspective* psp) { do_some_work(unit, 200, 10); } }; + PityUnit<> test1_2 = PityUnit<>{ &test1, "test1.2", [](PityUnit<>& unit, void* ctx) { + do_some_work(unit, 200, 10); + } }; // Subprocess 2 PityUnit<> test2 = PityUnit<>{ &root, "node2", - [](PityUnit<>& unit, - PityModel* model, - PityPerspective* psp) { do_some_work(unit, 200, 10); }, - nullptr, + [](PityUnit<>& unit, void* ctx) { + do_some_work(unit, 200, 10); + }, nullptr, pEp::PityTest11::PityUnit<>::ExecutionMode::PROCESS_PARALLEL }; - PityUnit<> test2_1 = PityUnit<>{ &test2, - "test2.1", - [](PityUnit<>& unit, - PityModel* model, - PityPerspective* psp) { do_some_work(unit, 200, 10); } }; + PityUnit<> test2_1 = PityUnit<>{ &test2, "test2.1", [](PityUnit<>& unit, void* ctx) { + do_some_work(unit, 200, 10); + } }; - PityUnit<> test2_2 = PityUnit<>{ &test2, - "test2.2", - [](PityUnit<>& unit, - PityModel* model, - PityPerspective* psp) { do_some_work(unit, 200, 10); } }; + PityUnit<> test2_2 = PityUnit<>{ &test2, "test2.2", [](PityUnit<>& unit, void* ctx) { + do_some_work(unit, 200, 10); + } }; root.run(); } diff --git a/test/pitytest11/test/test_linear.cc b/test/pitytest11/test/test_linear.cc index 3a8f880..27208e6 100644 --- a/test/pitytest11/test/test_linear.cc +++ b/test/pitytest11/test/test_linear.cc @@ -35,16 +35,16 @@ public: Car car; }; -void test_setGear(const PityUnit& node) +void test_setGear(PityUnit& node, CarTestModel* ctx) { int gear = 1; node.log("Setting gear to: " + to_string(gear)); - node.getModel()->car.setGear(gear); + ctx->car.setGear(gear); } -void test_drive(const PityUnit& node) +void test_drive(PityUnit& node, CarTestModel* ctx) { - node.getModel()->car.drive(); + ctx->car.drive(); } int main(int argc, char* argv[]) diff --git a/test/pitytest11/test/test_processdirs.cc b/test/pitytest11/test/test_processdirs.cc index 70fe215..ad823d3 100644 --- a/test/pitytest11/test/test_processdirs.cc +++ b/test/pitytest11/test/test_processdirs.cc @@ -19,95 +19,78 @@ int main(int argc, char* argv[]) PityUnit<> root = PityUnit<>{ nullptr, "test_processdirs" }; // 1 - PityUnit<> test1 = PityUnit<>{ - &root, - "node 1", - [](PityUnit<>& mynode, PityModel* model, PityPerspective* psp) { - PTASSERT(mynode.processDir() == "./pitytest_data/test_processdirs/"); - } - }; + PityUnit<> test1 = PityUnit<>{ &root, "node 1", [](PityUnit<>& mynode, void* ctx) { + PTASSERT( + mynode.processDir() == "./pitytest_data/test_processdirs/"); + } }; - PityUnit<> test1_1 = PityUnit<>{ - &test1, - "node 1.1", - []( PityUnit<>& mynode, PityModel* model, PityPerspective* psp) { - PTASSERT(mynode.processDir() == "./pitytest_data/test_processdirs/"); - } - }; + PityUnit<> test1_1 = PityUnit<>{ &test1, "node 1.1", [](PityUnit<>& mynode, void* ctx) { + PTASSERT( + mynode.processDir() == + "./pitytest_data/test_processdirs/"); + } }; // 2 - PityUnit<> test2 = PityUnit<>{ - &root, - "node 2", - []( PityUnit<>& mynode, PityModel* model, PityPerspective* psp) { - PTASSERT(mynode.processDir() == "./pitytest_data/test_processdirs/"); - } - }; + PityUnit<> test2 = PityUnit<>{ &root, "node 2", [](PityUnit<>& mynode, void* ctx) { + PTASSERT( + mynode.processDir() == "./pitytest_data/test_processdirs/"); + } }; PityUnit<> test2_1 = PityUnit<>{ &test2, "node 2.1", - []( PityUnit<>& mynode, PityModel* model, PityPerspective* psp) { + [](PityUnit<>& mynode, void* ctx) { PTASSERT(mynode.processDir() == "./pitytest_data/test_processdirs/node_2_1/"); }, nullptr, - nullptr, pEp::PityTest11::PityUnit<>::ExecutionMode::PROCESS_PARALLEL }; - PityUnit<> test2_1_1 = PityUnit<>{ - &test2_1, - "node 2.1.1", - [](PityUnit<> mynode, PityModel* model, PityPerspective* psp) { - PTASSERT(mynode.processDir() == "./pitytest_data/test_processdirs/node_2_1/"); - } - }; + PityUnit<> test2_1_1 = PityUnit<>{ &test2_1, "node 2.1.1", [](PityUnit<> mynode, void* ctx) { + PTASSERT( + mynode.processDir() == + "./pitytest_data/test_processdirs/node_2_1/"); + } }; // 3 PityUnit<> test3 = PityUnit<>{ &root, "node 3", - []( PityUnit<>& mynode, PityModel* model, PityPerspective* psp) { + [](PityUnit<>& mynode, void* ctx) { PTASSERT(mynode.processDir() == "./pitytest_data/test_processdirs/node_3/"); }, nullptr, - nullptr, PityUnit<>::ExecutionMode::PROCESS_PARALLEL }; - PityUnit<> test3_1 = PityUnit<>{ - &test3, - "node 3.1", - []( PityUnit<>& mynode, PityModel* model, PityPerspective* psp) { - PTASSERT(mynode.processDir() == "./pitytest_data/test_processdirs/node_3/"); - } - }; + PityUnit<> test3_1 = PityUnit<>{ &test3, "node 3.1", [](PityUnit<>& mynode, void* ctx) { + PTASSERT( + mynode.processDir() == + "./pitytest_data/test_processdirs/node_3/"); + } }; - PityUnit<> test3_1_1 = PityUnit<>{ - &test3_1, - "node 3.1.1", - []( PityUnit<>& mynode, PityModel* model, PityPerspective* psp) { - PTASSERT(mynode.processDir() == "./pitytest_data/test_processdirs/node_3/"); - } - }; + PityUnit<> test3_1_1 = PityUnit<>{ &test3_1, "node 3.1.1", [](PityUnit<>& mynode, void* ctx) { + PTASSERT( + mynode.processDir() == + "./pitytest_data/test_processdirs/node_3/"); + } }; PityUnit<> test3_1_1_1 = PityUnit<>{ &test3_1_1, "node 3.1.1", - []( PityUnit<>& mynode, PityModel* model, PityPerspective* psp) { + [](PityUnit<>& mynode, void* ctx) { PTASSERT(mynode.processDir() == "./pitytest_data/test_processdirs/node_3_1_1/"); }, nullptr, - nullptr, PityUnit<>::ExecutionMode::PROCESS_PARALLEL }; PityUnit<> test3_1_1_1_1 = PityUnit<>{ &test3_1_1_1, "node 3.1.1.1", - []( PityUnit<>& mynode, PityModel* model, PityPerspective* psp) { + [](PityUnit<>& mynode, void* ctx) { PTASSERT(mynode.processDir() == "./pitytest_data/test_processdirs/node_3_1_1/"); } }; diff --git a/test/pitytest11/test/test_swarm.cc b/test/pitytest11/test/test_swarm.cc index eb6ebe5..8a5b2a5 100644 --- a/test/pitytest11/test/test_swarm.cc +++ b/test/pitytest11/test/test_swarm.cc @@ -29,7 +29,7 @@ void test_node1(PityUnit& unit, PityPerspective* psp) int main(int argc, char* argv[]) { - int nodesCount = 3; + int nodesCount = 23; PityModel model{ "test_swarm", nodesCount }; PitySwarm swarm{model}; diff --git a/test/test_group.cc b/test/test_group.cc index 9e0684e..4277753 100644 --- a/test/test_group.cc +++ b/test/test_group.cc @@ -8,6 +8,7 @@ #include "../src/Adapter.hh" #include "../src/utils.hh" +#include "../src/std_utils.hh" #include "../src/grp_manager_interface.hh" #include "../src/grp_driver_engine.hh" @@ -59,7 +60,8 @@ GroupQueryInterface* gq = nullptr; log("called"); log("me: " + pEp::Utils::to_string(_me, false)); log("partner: " + pEp::Utils::to_string(_partner, false)); - log("Signal: " + string{ ::sync_handshake_signal_to_string(signal) }); + log("Signal: " + to_string(signal)); + // log("Signal: " + string{ ::sync_handshake_signal_to_string(signal) }); return PEP_STATUS_OK; } @@ -87,8 +89,9 @@ void test_create_bob_partner() logH2("test_create_bob_partner"); bob = ::new_identity("bob@peptest.ch", NULL, PEP_OWN_USERID, "Bob"); assert(bob); - bob->lang[0] = 'c'; - bob->lang[1] = 'r'; +// bob->lang[0] = 'c'; +// bob->lang[1] = 'r'; +// status = ::myself(Adapter::session(), bob); status = ::update_identity(Adapter::session(), bob); log("STATUS: " + status_to_string(status)); assert(!status); @@ -103,6 +106,7 @@ void test_create_carol_partner() carol->lang[0] = 'f'; carol->lang[1] = 'n'; status = ::update_identity(Adapter::session(), carol); +// status = ::myself(Adapter::session(), carol); log("STATUS: " + status_to_string(status)); assert(!status); log("Carol:" + pEp::Utils::to_string(carol, debug_info_full)); @@ -126,8 +130,13 @@ void test_group_create() assert(grp_ident); log("grp_ident:" + pEp::Utils::to_string(grp_ident, debug_info_full)); +// PEP_STATUS stat = ::myself(Adapter::session(), grp_ident); +// log("STATUS: " + status_to_string(status)); +// assert(stat == PEP_STATUS_OK); +// log("grp_ident:" + pEp::Utils::to_string(grp_ident, debug_info_full)); + log("adapter_group_create()"); - status = gu->adapter_group_create(Adapter::session(), grp_ident, alice, initial_memberlist); + status = gu->adapter_group_create(Adapter::session(), grp_ident, alice, nullptr); log("STATUS: " + status_to_string(status)); assert(!status); } @@ -203,14 +212,14 @@ int main(int argc, char** argv) GroupDriverReplicator gdr{}; -// gu = &gde; -// gq = nullptr; + gu = &gde; + gq = nullptr; -// gu = &gdd; -// gq = &gdd; + // gu = &gdd; + // gq = &gdd; - gu = &gdr; - gq = &gdr; + // gu = &gdr; + // gq = &gdr; // Setup Test Context @@ -224,9 +233,9 @@ int main(int argc, char** argv) test_group_create(); logH1("2. Add Bob"); - // test_group_invite_member(*bob); // Fails + test_group_invite_member(*bob); // Fails logH1("3. Add Carol"); - // test_group_invite_member(*carol); + test_group_invite_member(*carol); logH1("4. Remove Carol"); test_group_remove_member(*carol);