diff --git a/test/pitytest11/src/PitySwarm.cc b/test/pitytest11/src/PitySwarm.cc index 5983b4e..296b57b 100644 --- a/test/pitytest11/src/PitySwarm.cc +++ b/test/pitytest11/src/PitySwarm.cc @@ -41,11 +41,12 @@ namespace pEp { } } - void PitySwarm::_init_process(PityUnit& unit, PityPerspective* ctx) + int PitySwarm::_init_process(PityUnit& unit, PityPerspective* ctx) { - std::cout << "PROC INIT" << std::endl; + std::cout << "Node init, setting $HOME" << std::endl; std::string home = unit.processDir(); setenv("HOME", home.c_str(), true); + return 0; } PitySwarm::PitySwarm(PityModel& model) : _model{ model } diff --git a/test/pitytest11/src/PitySwarm.hh b/test/pitytest11/src/PitySwarm.hh index 3f1c23c..cff8cb6 100644 --- a/test/pitytest11/src/PitySwarm.hh +++ b/test/pitytest11/src/PitySwarm.hh @@ -34,7 +34,7 @@ namespace pEp { private: // methods void _createPerspective(const PityModel& model, PityPerspective* psp, int node_nr); - void _init_process(PityUnit& unit, PityPerspective* ctx); + int _init_process(PityUnit& unit, PityPerspective* ctx); // fields PityModel& _model; diff --git a/test/pitytest11/test/test_linear.cc b/test/pitytest11/test/test_linear.cc index 27208e6..fe0c7ee 100644 --- a/test/pitytest11/test/test_linear.cc +++ b/test/pitytest11/test/test_linear.cc @@ -35,16 +35,18 @@ public: Car car; }; -void test_setGear(PityUnit& node, CarTestModel* ctx) +int test_setGear(PityUnit& node, CarTestModel* ctx) { int gear = 1; node.log("Setting gear to: " + to_string(gear)); ctx->car.setGear(gear); + return 0; } -void test_drive(PityUnit& node, CarTestModel* ctx) +int test_drive(PityUnit& node, CarTestModel* ctx) { ctx->car.drive(); + return 0; } int main(int argc, char* argv[]) diff --git a/test/pitytest11/test/test_processdirs.cc b/test/pitytest11/test/test_processdirs.cc index 4815a7a..c78837d 100644 --- a/test/pitytest11/test/test_processdirs.cc +++ b/test/pitytest11/test/test_processdirs.cc @@ -21,26 +21,32 @@ int main(int argc, char* argv[]) // 1 PityUnit<> test1 = PityUnit<>{ &root, "node 1", [](PityUnit<>& mynode, void* ctx) { PTASSERT( - mynode.processDir() == "./pitytest_data/test_processdirs/",""); + mynode.processDir() == "./pitytest_data/test_processdirs/", + ""); + return 0; } }; PityUnit<> test1_1 = PityUnit<>{ &test1, "node 1.1", [](PityUnit<>& mynode, void* ctx) { PTASSERT( - mynode.processDir() == - "./pitytest_data/test_processdirs/",""); + mynode.processDir() == "./pitytest_data/test_processdirs/", + ""); + return 0; } }; // 2 PityUnit<> test2 = PityUnit<>{ &root, "node 2", [](PityUnit<>& mynode, void* ctx) { PTASSERT( - mynode.processDir() == "./pitytest_data/test_processdirs/",""); + mynode.processDir() == "./pitytest_data/test_processdirs/", + ""); + return 0; } }; PityUnit<> test2_1 = PityUnit<>{ &test2, "node 2.1", [](PityUnit<>& mynode, void* ctx) { - PTASSERT(mynode.processDir() == "./pitytest_data/test_processdirs/node_2_1/",""); + PTASSERT(mynode.processDir() == "./pitytest_data/test_processdirs/node_2_1/", ""); + return 0; }, nullptr, pEp::PityTest11::PityUnit<>::ExecutionMode::PROCESS_PARALLEL @@ -50,7 +56,9 @@ int main(int argc, char* argv[]) 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/",""); + "./pitytest_data/test_processdirs/node_2_1/", + ""); + return 0; } }; @@ -59,7 +67,8 @@ int main(int argc, char* argv[]) &root, "node 3", [](PityUnit<>& mynode, void* ctx) { - PTASSERT(mynode.processDir() == "./pitytest_data/test_processdirs/node_3/",""); + PTASSERT(mynode.processDir() == "./pitytest_data/test_processdirs/node_3/", ""); + return 0; }, nullptr, PityUnit<>::ExecutionMode::PROCESS_PARALLEL @@ -68,20 +77,25 @@ int main(int argc, char* argv[]) PityUnit<> test3_1 = PityUnit<>{ &test3, "node 3.1", [](PityUnit<>& mynode, void* ctx) { PTASSERT( mynode.processDir() == - "./pitytest_data/test_processdirs/node_3/",""); + "./pitytest_data/test_processdirs/node_3/", + ""); + return 0; } }; PityUnit<> test3_1_1 = PityUnit<>{ &test3_1, "node 3.1.1", [](PityUnit<>& mynode, void* ctx) { PTASSERT( mynode.processDir() == - "./pitytest_data/test_processdirs/node_3/",""); + "./pitytest_data/test_processdirs/node_3/", + ""); + return 0; } }; PityUnit<> test3_1_1_1 = PityUnit<>{ &test3_1_1, "node 3.1.1", [](PityUnit<>& mynode, void* ctx) { - PTASSERT(mynode.processDir() == "./pitytest_data/test_processdirs/node_3_1_1/",""); + PTASSERT(mynode.processDir() == "./pitytest_data/test_processdirs/node_3_1_1/", ""); + return 0; }, nullptr, PityUnit<>::ExecutionMode::PROCESS_PARALLEL @@ -91,7 +105,8 @@ int main(int argc, char* argv[]) &test3_1_1_1, "node 3.1.1.1", [](PityUnit<>& mynode, void* ctx) { - PTASSERT(mynode.processDir() == "./pitytest_data/test_processdirs/node_3_1_1/",""); + PTASSERT(mynode.processDir() == "./pitytest_data/test_processdirs/node_3_1_1/", ""); + return 0; } }; diff --git a/test/pitytest11/test/test_swarm.cc b/test/pitytest11/test/test_swarm.cc index bce3510..2b97c32 100644 --- a/test/pitytest11/test/test_swarm.cc +++ b/test/pitytest11/test/test_swarm.cc @@ -7,7 +7,7 @@ using namespace pEp; using namespace pEp::Adapter; using namespace pEp::PityTest11; -void test_node1(PityUnit& unit, PityPerspective* ctx) +int test_node1(PityUnit& unit, PityPerspective* ctx) { unit.log("ModelName:" + ctx->model.getName()); unit.log("perspective name:" + ctx->own_name); diff --git a/test/test_template_swarm_multi.cc b/test/test_template_swarm_multi.cc index 8e0cddb..63438d0 100644 --- a/test/test_template_swarm_multi.cc +++ b/test/test_template_swarm_multi.cc @@ -22,7 +22,7 @@ using namespace pEp::PityTest11; // Test template for 3 nodes (processes) running the same 2 tests each in their own environment in parallel // This is the 1st test unit -void test_func1(PityUnit &pity, PityPerspective *ctx) +int test_func1(PityUnit &pity, PityPerspective *ctx) { pity.log(ctx->own_name); pity.log("getName: " + pity.getName()); @@ -34,13 +34,15 @@ void test_func1(PityUnit &pity, PityPerspective *ctx) pity.log("to_string: " +pity.to_string()); PTASSERT(true,""); + return 0; } // This is the 2nd test unit -void test_func2(PityUnit &pity, PityPerspective *ctx) +int test_func2(PityUnit &pity, PityPerspective *ctx) { pity.log(ctx->own_name); PTASSERT(false,""); + return 0; } diff --git a/test/test_template_swarm_single.cc b/test/test_template_swarm_single.cc index 46a5a48..b0236d8 100644 --- a/test/test_template_swarm_single.cc +++ b/test/test_template_swarm_single.cc @@ -22,7 +22,7 @@ using namespace pEp::PityTest11; // Test template for a single process with 2 test units that run in sequence // This is the 1st test unit -void test_func1(PityUnit &pity, PityPerspective *ctx) +int test_func1(PityUnit &pity, PityPerspective *ctx) { // here some example values from the PityUnit pity.log("getName: " + pity.getName()); @@ -33,13 +33,15 @@ void test_func1(PityUnit &pity, PityPerspective *ctx) pity.log("getGlobalRootDir: " + pity.getGlobalRootDir()); pity.log("to_string: " + pity.to_string(false)); PTASSERT(true,""); + return 0; } // This is the 2nd test unit -void test_func2(PityUnit &pity, PityPerspective *ctx) +int test_func2(PityUnit &pity, PityPerspective *ctx) { pity.log(ctx->own_name); PTASSERT(false,""); + return 0; } diff --git a/test/test_tofu.cc b/test/test_tofu.cc index df13aed..05fc766 100644 --- a/test/test_tofu.cc +++ b/test/test_tofu.cc @@ -80,6 +80,13 @@ void reply(PityUnit &pity, PityPerspective *ctx, MinMsgRx msg_o // Encrypt pity.log("TX message - BEFORE encrypt: \n" + Utils::to_string(msg.get())); + + // pEpIdent tmp_ident = createRawIdent(addr_orig); + // tmp_ident.get()->user_id = strdup("23"); + // PEP_STATUS status = ::update_identity(Adapter::session(),tmp_ident.get()); + // throw_status(status); + // pity.log("IDENTZZZ:" + Utils::to_string(tmp_ident.get())); + EncryptResult eres = encryptMessage(msg); pEpMessage msg_encrypted = std::get<0>(eres); did_tx_encrypted = std::get<2>(eres); @@ -93,7 +100,7 @@ void reply(PityUnit &pity, PityPerspective *ctx, MinMsgRx msg_o pity.transport()->sendMsg(addr_orig, mime_data_tx); } -void tofu(PityUnit &pity, PityPerspective *ctx, bool init) +int tofu(PityUnit &pity, PityPerspective *ctx, bool init) { pity.log("Model : " + ctx->model.getName()); pity.log("myself : " + ctx->own_name); @@ -111,15 +118,16 @@ void tofu(PityUnit &pity, PityPerspective *ctx, bool init) send(pity, ctx); } - MinMsgRx rx_msg = receive(pity,ctx); - reply(pity,ctx, rx_msg); + MinMsgRx rx_msg = receive(pity, ctx); + reply(pity, ctx, rx_msg); - if(!init) { - receive(pity,ctx); + if (!init) { + receive(pity, ctx); } PTASSERT(did_tx_encrypted, "could never send encrypted"); PTASSERT(did_rx_encrypted, "no encrypted msg received"); + return 0; } @@ -132,10 +140,10 @@ int main(int argc, char *argv[]) PitySwarm swarm{ model }; swarm.addTestUnit(0, "tofu1", [](PityUnit &unit, PityPerspective *ctx) { - tofu(unit, ctx, true); + return tofu(unit, ctx, true); }); swarm.addTestUnit(1, "tofu2", [](PityUnit &unit, PityPerspective *ctx) { - tofu(unit, ctx, false); + return tofu(unit, ctx, false); }); swarm.run();