diff --git a/test/test_transport.cc b/test/test_transport.cc new file mode 100644 index 0000000..bf03383 --- /dev/null +++ b/test/test_transport.cc @@ -0,0 +1,60 @@ +#include "../src/PityUnit.hh" +#include "../../framework/utils.hh" +#include "../../../src/std_utils.hh" +#include +#include +#include + +using namespace std; +using namespace pEp; +using namespace pEp::PityTest11; + +void send(const PityUnit<>& myself) +{ + setenv("HOME", myself.processDir().c_str(), 1); + myself.log("HOME=" + string(getenv("HOME"))); + ofstream msgfile = Utils::file_create(myself.processDir() + "/transport.msg"); + msgfile << "G4rbage" << endl; + msgfile.close(); + sleep_millis(400000); +} + +void receive(const PityUnit<>& myself) +{ + setenv("HOME", myself.processDir().c_str(), 1); + myself.log("HOME=" + string(getenv("HOME"))); +// Utils::dir_list_files() + sleep_millis(400000); +} + +int main(int argc, char* argv[]) +{ + PityUnit<>::debug_log_enabled = false; + PityUnit<> root = PityUnit<>{ nullptr, "test_transport" }; + + // 1 + PityUnit<> node1 = PityUnit<>{ &root, + "node 1", + [](const PityUnit<>& mynode) { + + }, + nullptr, + pEp::PityTest11::PityUnit<>::ExecutionMode::PROCESS_PARALLEL }; + + PityUnit<> node1_send = PityUnit<>{ &node1, "send", &send }; + + + // 2 + PityUnit<> node2 = PityUnit<>{ &root, + "node 2", + [](const PityUnit<>& mynode) { + + }, + nullptr, + pEp::PityTest11::PityUnit<>::ExecutionMode::PROCESS_PARALLEL }; + + PityUnit<> node2_receive = PityUnit<>{ &node2, "receive", &receive }; + + // root._init(); + root.run(); +} \ No newline at end of file