diff --git a/.gitignore b/.gitignore index db014cb..35c1e34 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,6 @@ test_pEpLog_basic *.db +/test/PityTest11/test/test_pEpTest_basic +/test/PityTest11/test/test_transport +/test/PityTest11/test/test_processdirs diff --git a/test/pEpTest/Makefile b/test/PityTest11/Makefile similarity index 100% rename from test/pEpTest/Makefile rename to test/PityTest11/Makefile diff --git a/test/PityTest11/src/PityModel.cc b/test/PityTest11/src/PityModel.cc new file mode 100644 index 0000000..1fcb546 --- /dev/null +++ b/test/PityTest11/src/PityModel.cc @@ -0,0 +1,16 @@ +#include "PityModel.hh" +#include "iostream" + +using namespace std; +namespace pEp { + namespace PityTest11 { + bool PityModel::log_enabled = true; + + PityModel::PityModel(const string& name) : name(name) {} + + const std::string& PityModel::getName() const + { + return name; + } + } // namespace Test +} // namespace pEp diff --git a/test/pEpTest/src/pEpTestModel.hh b/test/PityTest11/src/PityModel.hh similarity index 81% rename from test/pEpTest/src/pEpTestModel.hh rename to test/PityTest11/src/PityModel.hh index dfe1b4c..720a6ce 100644 --- a/test/pEpTest/src/pEpTestModel.hh +++ b/test/PityTest11/src/PityModel.hh @@ -7,11 +7,11 @@ #include "../../../src/pEpLog.hh" namespace pEp { - namespace Test { - class pEpTestModel { + namespace PityTest11 { + class PityModel { public: - pEpTestModel() = delete; - pEpTestModel(const std::string& name); + PityModel() = delete; + PityModel(const std::string& name); virtual const std::string& getName() const; private: diff --git a/test/pEpTest/src/pEpTestTree.hh b/test/PityTest11/src/PityUnit.hh similarity index 78% rename from test/pEpTest/src/pEpTestTree.hh rename to test/PityTest11/src/PityUnit.hh index b340d5b..e4f2397 100644 --- a/test/pEpTest/src/pEpTestTree.hh +++ b/test/PityTest11/src/PityUnit.hh @@ -1,8 +1,8 @@ // This file is under GNU General Public License 3.0 // see LICENSE.txt -#ifndef LIBPEPADAPTER_PEPTEST_PEPTESTTREE_HH -#define LIBPEPADAPTER_PEPTEST_PEPTESTTREE_HH +#ifndef PITYTEST_PITYUNIT_HH +#define PITYTEST_PITYUNIT_HH #include #include @@ -12,11 +12,11 @@ // Yes, the mem mgmt is purely static on purpose (so far) namespace pEp { - namespace Test { + namespace PityTest11 { template - class pEpTestTree { + class PityUnit { public: - using NodeFunc = std::function; + using NodeFunc = std::function; enum class ExecutionMode { @@ -29,9 +29,9 @@ namespace pEp { }; // Constructors are private - pEpTestTree() = delete; - explicit pEpTestTree( - pEpTestTree* parent, + PityUnit() = delete; + explicit PityUnit( + PityUnit* parent, const std::string& name, const NodeFunc test_func = nullptr, T* model = nullptr, @@ -76,13 +76,13 @@ namespace pEp { void _waitChildProcesses() const; // Modify - void _addChildNode(pEpTestTree& node); + void _addChildNode(PityUnit& node); // Query bool _isProcessNode() const; bool _isRootNode() const; - const pEpTestTree& _rootNode() const; - const pEpTestTree& _parentingProcessNode() const; + const PityUnit& _rootNode() const; + const PityUnit& _parentingProcessNode() const; // Util std::string _normalizeName(std::string name) const; @@ -94,13 +94,13 @@ namespace pEp { // Fields const std::string _name; - const pEpTestTree* _parent; //nullptr if RootUnit - T* _model; //nullptr if inherited + const PityUnit* _parent; //nullptr if RootUnit + T* _model; //nullptr if inherited const NodeFunc _test_func; ExecutionMode _exec_mode; static std::string _global_root_dir; - std::map _children; // map to guarantee uniqueness of sibling-names + std::map _children; // map to guarantee uniqueness of sibling-names // internal logging Adapter::pEpLog::pEpLogger& m4gic_logger_n4me = logger_debug; @@ -108,6 +108,6 @@ namespace pEp { }; // namespace Test }; // namespace pEp -#include "pEpTestTree.hxx" +#include "PityUnit.hxx" -#endif // LIBPEPADAPTER_PEPTEST_PEPTESTTREE_HH +#endif // PITYTEST_PITYUNIT_HH diff --git a/test/pEpTest/src/pEpTestTree.hxx b/test/PityTest11/src/PityUnit.hxx similarity index 62% rename from test/pEpTest/src/pEpTestTree.hxx rename to test/PityTest11/src/PityUnit.hxx index 18f77fd..cbae9e6 100644 --- a/test/pEpTest/src/pEpTestTree.hxx +++ b/test/PityTest11/src/PityUnit.hxx @@ -1,8 +1,8 @@ // This file is under GNU General Public License 3.0 // see LICENSE.txt -#ifndef LIBPEPADAPTER_PEPTEST_PEPTESTTREE_HXX -#define LIBPEPADAPTER_PEPTEST_PEPTESTTREE_HXX +#ifndef LIBPEPADAPTER_PEPTEST_PityUnit_HXX +#define LIBPEPADAPTER_PEPTEST_PityUnit_HXX #include "../../../src/std_utils.hh" #include "../../framework/utils.hh" @@ -15,22 +15,20 @@ #include -using namespace std; -using namespace pEp::Adapter; -using namespace pEp::Utils; +using namespace pEp::Adapter::pEpLog; namespace pEp { - namespace Test { + namespace PityTest11 { template - string pEpTestTree::_global_root_dir = "./peptest"; + std::string PityUnit::_global_root_dir = "./peptest"; template - bool pEpTestTree::debug_log_enabled = false; + bool PityUnit::debug_log_enabled = false; // PUBLIC CONCSTRUCTORS / FACTORY ----------------------------------------------------------- template - pEpTestTree::pEpTestTree( - pEpTestTree* const parent, - const string& name, + PityUnit::PityUnit( + PityUnit* const parent, + const std::string& name, const NodeFunc test_func, T* model, ExecutionMode exec_mode) : @@ -44,16 +42,15 @@ namespace pEp { } template - string pEpTestTree::getNodeName() const + std::string PityUnit::getNodeName() const { return _name; } template - string pEpTestTree::getNodePath() const + std::string PityUnit::getNodePath() const { - pEpLogClass("called"); - string ret; + std::string ret; if (!_isRootNode()) { ret = _parent->getNodePath() + "/" + getNodeName(); @@ -69,9 +66,9 @@ namespace pEp { // When Process as dir. parent - "...//name" // When no process as dir. parent - "...//.../name" template - std::string pEpTestTree::getNodePathShort() const + std::string PityUnit::getNodePathShort() const { - string ret; + std::string ret; if (_isRootNode()) { ret = getNodeName(); } else { @@ -90,7 +87,7 @@ namespace pEp { // Inherited (if null see parent recursively) template - T* pEpTestTree::getModel() const + T* PityUnit::getModel() const { pEpLogClass("called"); T* ret = nullptr; @@ -105,114 +102,100 @@ namespace pEp { return ret; } - // RootNodes have their own data_dir - // ProcessNodes have their own data_dir inside their RootNote dir (nameclash prossible) - // All other nodes inherit data_dir from their Root/ProcessNode - // string pEpTestTree::dataDir() const - // { - // pEpLogClass("called"); - // string ret; - // if(!_isRootNode()) { - // ret = getRootNodesDir() + _getRootNode().getNodeName() + "/" + _getParentingProcessNode().getNodeName() + "/"; - // } else { - // ret = getRootNodesDir() + _getRootNode().getNodeName() + "/"; - // } - // return ret; - // } - // - // Every RootNode has its own dir template - string pEpTestTree::rootNodeDir() const + std::string PityUnit::rootNodeDir() const { return getGlobalRootDir() + _rootNode().getNodeName() + "/"; } // Every process has its own dir inside its rootNodeDir - // The Root node has its own processDir for future use + // All other nodes inherit processDir from their Root/ProcessNode template - string pEpTestTree::processDir() const + std::string PityUnit::processDir() const { if (_isRootNode()) { - return rootNodeDir() + "rootnode_data"; + return rootNodeDir(); } else { - if (&_parentingProcessNode() == &_rootNode()) { + if (_isProcessNode()) { return rootNodeDir() + getNodeName() + "/"; - } else { - return rootNodeDir() + _parentingProcessNode().getNodeName() + "/"; - }; + } else{ + return _parent->processDir(); + } } } template - void pEpTestTree::setExecutionMode(ExecutionMode mode) + void PityUnit::setExecutionMode(ExecutionMode mode) { _exec_mode = mode; } // static template<> - void pEpTestTree::setGlobalRootDir(const string& dir) + void PityUnit::setGlobalRootDir(const std::string& dir) { - pEpTestTree::_global_root_dir = dir; + PityUnit::_global_root_dir = dir; } // static template - string pEpTestTree::getGlobalRootDir() + std::string PityUnit::getGlobalRootDir() { - return pEpTestTree::_global_root_dir + "/"; + return PityUnit::_global_root_dir; } template - void pEpTestTree::run() const + void PityUnit::run() const { pEpLogClass("called"); - // caller is never nullptr if called by another pEpTestTree + // caller is never nullptr if called by another PityUnit if (_isRootNode()) { - pEpLog::logH1("Starting pEpTestTree from node: " + getNodePathShort()); - pEpLog::log(to_string()); + logH1("Starting PityUnit from node: " + getNodePathShort()); + log(to_string()); } // Execute in fork and wait here until process ends if (_exec_mode == ExecutionMode::PROCESS_SEQUENTIAL) { // fork - pEpLog::logH2("[ " + to_string(_exec_mode) + " / " + getNodePathShort() + "]"); - _executeInFork(bind(&pEpTestTree::_run, this), true); + logH2("[ " + to_string(_exec_mode) + " / " + getNodePathShort() + " ]"); + _executeInFork(std::bind(&PityUnit::_run, this), true); // Execute in fork and go on, wait for process execution in the end } else if (_exec_mode == ExecutionMode::PROCESS_PARALLEL) { - pEpLog::logH2("[ " + to_string(_exec_mode) + " / " + getNodePathShort() + "]"); - _executeInFork(bind(&pEpTestTree::_run, this), false); + logH2("[ " + to_string(_exec_mode) + " / " + getNodePathShort() + " ]"); + _executeInFork(std::bind(&PityUnit::_run, this), false); // Execute as normal funciton } else if (_exec_mode == ExecutionMode::FUNCTION) { - pEpLog::logH3("[ " + to_string(_exec_mode) + " / " + getNodePathShort() + "]"); + logH3("[ " + to_string(_exec_mode) + " / " + getNodePathShort() + " ]"); _run(); } else if (_exec_mode == ExecutionMode::THREAD_PARALLEL) { - throw invalid_argument(to_string(_exec_mode) + " - not implemented"); + throw std::invalid_argument(to_string(_exec_mode) + " - not implemented"); } else if (_exec_mode == ExecutionMode::THREAD_SEQUENTIAL) { - throw invalid_argument(to_string(_exec_mode) + " - not implemented"); + throw std::invalid_argument(to_string(_exec_mode) + " - not implemented"); } - _waitChildProcesses(); + if(_isRootNode()) { + _waitChildProcesses(); + } } template - string pEpTestTree::to_string(bool recursive, int indent) const + std::string PityUnit::to_string(bool recursive, int indent) const { - string ret; - stringstream builder; - builder << string(indent * 4, ' '); + std::string ret; + std::stringstream builder; + builder << std::string(indent * 4, ' '); builder << getNodeName(); builder << " [ "; builder << to_string(_exec_mode) << " - "; builder << "\"" << processDir() << "\""; builder << " ]"; - builder << endl; + builder << std::endl; ret = builder.str(); if (recursive) { indent++; - for (const pair child : _children) { + for (const std::pair child : _children) { ret += child.second.to_string(true, indent); } indent--; @@ -221,7 +204,7 @@ namespace pEp { } template - string pEpTestTree::to_string(const ExecutionMode& emode) + std::string PityUnit::to_string(const ExecutionMode& emode) { switch (emode) { case ExecutionMode::FUNCTION: @@ -243,50 +226,50 @@ namespace pEp { //Well, ok, lets just add some little convenience logging service in here, too template - void pEpTestTree::log(const string& msg) const + void PityUnit::log(const std::string& msg) const { - stringstream builder; + std::stringstream builder; builder << "["; builder << std::to_string(getpid()); builder << " - "; builder << getNodePathShort(); builder << "] - "; builder << msg; - builder << endl; - cout << builder.str(); + builder << std::endl; + std::cout << builder.str(); } // PRIVATE --------------------------------------------------------------------------------- template - void pEpTestTree::_run() const + void PityUnit::_run() const { _runSelf(); _runChildren(); } template - void pEpTestTree::_runSelf() const + void PityUnit::_runSelf() const { if (_test_func != nullptr) { _test_func(*this); } else { - pEpLog::log("No function to execute"); + log("No function to execute"); } } template - void pEpTestTree::_runChildren() const + void PityUnit::_runChildren() const { if (!_children.empty()) { - for (const pair child : _children) { + for (const std::pair child : _children) { child.second.run(); } } } template - void pEpTestTree::_executeInFork(function func, bool wait_child) const + void PityUnit::_executeInFork(std::function func, bool wait_child) const { pid_t pid; pid = fork(); @@ -294,7 +277,7 @@ namespace pEp { func(); exit(0); } else if (pid < pid_t(0)) { - throw runtime_error("Error forking"); + throw std::runtime_error("Error forking"); } if (wait_child) { _waitChildProcesses(); @@ -302,25 +285,25 @@ namespace pEp { } template - void pEpTestTree::_waitChildProcesses() const + void PityUnit::_waitChildProcesses() const { int status; pid_t pid; while ((pid = wait(&status)) > 0) { - pEpLog::log( + log( "process[" + std::to_string((int)pid) + "] terminated with status: " + std::to_string(status)); } } template - void pEpTestTree::_addChildNode(pEpTestTree& node) + void PityUnit::_addChildNode(PityUnit& node) { - _children.insert(pair(node.getNodeName(), node)); + _children.insert(std::pair(node.getNodeName(), node)); } template - bool pEpTestTree::_isProcessNode() const + bool PityUnit::_isProcessNode() const { bool ret = false; if (_exec_mode == ExecutionMode::PROCESS_SEQUENTIAL || @@ -331,7 +314,7 @@ namespace pEp { } template - bool pEpTestTree::_isRootNode() const + bool PityUnit::_isRootNode() const { if (_parent == nullptr) { return true; @@ -341,9 +324,9 @@ namespace pEp { } template - const pEpTestTree& pEpTestTree::_rootNode() const + const PityUnit& PityUnit::_rootNode() const { - const pEpTestTree* ret = nullptr; + const PityUnit* ret = nullptr; if (!_isRootNode()) { ret = &(_parent->_rootNode()); } else { @@ -356,7 +339,7 @@ namespace pEp { } template - const pEpTestTree& pEpTestTree::_parentingProcessNode() const + const PityUnit& PityUnit::_parentingProcessNode() const { if (_isRootNode() || _isProcessNode()) { return *this; @@ -367,7 +350,7 @@ namespace pEp { // name is alphanumeric only (everything else will be replaced by an underscore) template - string pEpTestTree::_normalizeName(string name) const + std::string PityUnit::_normalizeName(std::string name) const { replace_if( name.begin(), @@ -379,24 +362,24 @@ namespace pEp { } template - void pEpTestTree::_data_dir_create() + void PityUnit::_data_dir_create() { // Utils::dir_create(dataDir()); - pEpLog::log("creating dir:" + getGlobalRootDir()); + log("creating dir:" + getGlobalRootDir()); } template - void pEpTestTree::_data_dir_delete() + void PityUnit::_data_dir_delete() { try { Utils::path_delete_all(getGlobalRootDir()); - } catch (const exception& e) { - pEpLog::log("DistTest: - could not delete data dir: " + getGlobalRootDir()); + } catch (const std::exception& e) { + log("DistTest: - could not delete data dir: " + getGlobalRootDir()); } } template - void pEpTestTree::_data_dir_recreate() + void PityUnit::_data_dir_recreate() { _data_dir_delete(); _data_dir_create(); @@ -404,4 +387,4 @@ namespace pEp { } // namespace Test } // namespace pEp -#endif // LIBPEPADAPTER_PEPTEST_PEPTESTTREE_HXX \ No newline at end of file +#endif // LIBPEPADAPTER_PEPTEST_PityUnit_HXX \ No newline at end of file diff --git a/test/PityTest11/test/test_execmodes.cc b/test/PityTest11/test/test_execmodes.cc new file mode 100644 index 0000000..ab063de --- /dev/null +++ b/test/PityTest11/test/test_execmodes.cc @@ -0,0 +1,65 @@ +#include "../src/PityUnit.hh" +#include + +using namespace std; +using namespace pEp::PityTest11; + +void printHomeDir(const PityUnit<>& myself, int sleepmilis, int rep_count) +{ + int i = 0; + while (i < rep_count) { + myself.log(myself.getNodeName() + " - " + to_string(i)); + sleep_millis(sleepmilis); + i++; + } +} + +int main(int argc, char* argv[]) +{ + { + // DEBUG Logging of pEpTestTree itself + PityUnit<>::debug_log_enabled = false; + + // Configure DataRoot for all TestNodes + PityUnit<>::setGlobalRootDir("./basic_data_root"); + + // The RootNode is the + PityUnit<> root = PityUnit<>{ nullptr, "Test Execution Model" }; + + // Subprocess 1 + PityUnit<> test1 = PityUnit<>{ &root, + "node1", + [](const PityUnit<>& mynode) { + printHomeDir(mynode, 200, 10); + }, + nullptr, + pEp::PityTest11::PityUnit<>::ExecutionMode::PROCESS_PARALLEL }; + + PityUnit<> test1_1 = PityUnit<>{ &test1, "test1.1", [](const PityUnit<>& mynode) { + printHomeDir(mynode, 200, 10); + } }; + + PityUnit<> test1_2 = PityUnit<>{ &test1, "test1.2", [](const PityUnit<>& mynode) { + printHomeDir(mynode, 200, 10); + } }; + + // Subprocess 2 + PityUnit<> test2 = PityUnit<>{ &root, + "node2", + [](const PityUnit<>& mynode) { + printHomeDir(mynode, 200, 10); + }, + nullptr, + pEp::PityTest11::PityUnit<>::ExecutionMode::PROCESS_PARALLEL }; + + PityUnit<> test2_1 = PityUnit<>{ &test2, "test2.1", [](const PityUnit<>& mynode) { + printHomeDir(mynode, 200, 10); + } }; + + PityUnit<> test2_2 = PityUnit<>{ &test2, "test2.2", [](const PityUnit<>& mynode) { + printHomeDir(mynode, 200, 10); + } }; + + test1.run(); + } +} \ No newline at end of file diff --git a/test/PityTest11/test/test_processdirs.cc b/test/PityTest11/test/test_processdirs.cc new file mode 100644 index 0000000..2abade1 --- /dev/null +++ b/test/PityTest11/test/test_processdirs.cc @@ -0,0 +1,50 @@ +#include "../src/PityUnit.hh" +#include "../../framework/utils.hh" +#include +#include + +using namespace std; +using namespace pEp::PityTest11; + +void printHomeDir(const PityUnit<>& myself) +{ + // TESTLOG(string(myself.getFQName() + " - PID: " + to_string(getpid()))); + // cout << "[" << to_string(getpid()) << "/" << myself.getFQName() << "] - " << endl; + setenv("HOME", myself.processDir().c_str(), 1); + myself.log("HOME=" + string(getenv("HOME"))); +} + + +int main(int argc, char* argv[]) +{ + PityUnit<>::debug_log_enabled = false; + PityUnit<>::setGlobalRootDir("./"); + PityUnit<> root = PityUnit<>{ nullptr, "rootnode" }; + + PityUnit<> test1 = PityUnit<>{ &root, "node 1", [](const PityUnit<>& mynode) { + assert(mynode.processDir() == "./rootnode/"); + } }; + + PityUnit<> test1_1 = PityUnit<>{ &test1, "node 1.1", [](const PityUnit<>& mynode) { + assert(mynode.processDir() == "./rootnode/"); + } }; + + PityUnit<> test2 = PityUnit<>{ &root, "node 2", [](const PityUnit<>& mynode) { + assert(mynode.processDir() == "./rootnode/"); + } }; + + PityUnit<> test2_1 = PityUnit<>{ &test2, + "node 2.1", + [](const PityUnit<>& mynode) { + assert(mynode.processDir() == "./rootnode/"); + }, + nullptr, + pEp::PityTest11::PityUnit<>::ExecutionMode::PROCESS_PARALLEL }; + + + PityUnit<> test2_1_1 = PityUnit<>{ &test2_1, "node 2.1.1", [](PityUnit<> mynode) { + assert(mynode.processDir() == "./rootnode/"); + } }; + + root.run(); +} \ No newline at end of file diff --git a/test/pEpTest/src/pEpTestModel.cc b/test/pEpTest/src/pEpTestModel.cc deleted file mode 100644 index 880d992..0000000 --- a/test/pEpTest/src/pEpTestModel.cc +++ /dev/null @@ -1,16 +0,0 @@ -#include "pEpTestModel.hh" -#include "iostream" - -using namespace std; -namespace pEp { - namespace Test { - bool pEpTestModel::log_enabled = true; - - pEpTestModel::pEpTestModel(const string& name) : name(name) {} - - const std::string& pEpTestModel::getName() const - { - return name; - } - } // namespace Test -} // namespace pEp diff --git a/test/pEpTest/test/test_pEpTest_basic.cc b/test/pEpTest/test/test_pEpTest_basic.cc deleted file mode 100644 index f33638e..0000000 --- a/test/pEpTest/test/test_pEpTest_basic.cc +++ /dev/null @@ -1,72 +0,0 @@ -#include "../src/pEpTestTree.hh" -#include "../../framework/utils.hh" -#include -#include - -using namespace std; -using namespace pEp; -using namespace pEp::Test; - - -void printHomeDir(const pEpTestTree<>& myself, int sleepmilis, int rep_count) -{ - // TESTLOGH1("HYA FROM:" + myself.getFQName()); - int i = 0; - while (i < rep_count) { - myself.log(myself.getNodeName() + " - " + to_string(i)); - // TESTLOG(string(myself.getFQName() + " - PID: " + to_string(getpid()) + " - " + to_string(i))); - sleep_millis(sleepmilis); - i++; - } -} - -int main(int argc, char* argv[]) -{ - string dummy; - { - // DEBUG Logging of pEpTestTree itself - pEpTestTree<>::debug_log_enabled = false; - - // Configure DataRoot for all TestNodes - pEpTestTree<>::setGlobalRootDir("./basic_data_root"); - - // The RootNode is the - pEpTestTree<> root = pEpTestTree<>{ nullptr, "Test Execution Model"}; - - // Subprocess 1 - pEpTestTree<> test1 = pEpTestTree<>{ - &root, - "node1", - [](const pEpTestTree<>& mynode) { printHomeDir(mynode, 200, 10); }, - nullptr, - pEp::Test::pEpTestTree<>::ExecutionMode::PROCESS_PARALLEL - }; - - pEpTestTree<> test1_1 = pEpTestTree<>{ &test1, "test1.1", [](const pEpTestTree<>& mynode) { - printHomeDir(mynode, 200, 10); - } }; - - pEpTestTree<> test1_2 = pEpTestTree<>{ &test1, "test1.2", [](const pEpTestTree<>& mynode) { - printHomeDir(mynode, 200, 10); - } }; - - // Subprocess 2 - pEpTestTree<> test2 = pEpTestTree<>{ - &root, - "node2", - [](const pEpTestTree<>& mynode) { printHomeDir(mynode, 200, 10); }, - nullptr, - pEp::Test::pEpTestTree<>::ExecutionMode::PROCESS_PARALLEL - }; - - pEpTestTree<> test2_1 = pEpTestTree<>{ &test2, "test2.1", [](const pEpTestTree<>& mynode) { - printHomeDir(mynode, 200, 10); - } }; - - pEpTestTree<> test2_2 = pEpTestTree<>{ &test2, "test2.2", [](const pEpTestTree<>& mynode) { - printHomeDir(mynode, 200, 10); - } }; - - root.run(); - } -} \ No newline at end of file diff --git a/test/pEpTest/test/test_transport.cc b/test/pEpTest/test/test_transport.cc deleted file mode 100644 index 053869a..0000000 --- a/test/pEpTest/test/test_transport.cc +++ /dev/null @@ -1,53 +0,0 @@ -#include "../src/pEpTestTree.hh" -#include "../../framework/utils.hh" -#include -#include -#include -#include -//#include - -using namespace std; -using namespace pEp; -using namespace pEp::Test; - - -void printHomeDir(const pEpTestTree<>& myself) -{ - // TESTLOG(string(myself.getFQName() + " - PID: " + to_string(getpid()))); - // cout << "[" << to_string(getpid()) << "/" << myself.getFQName() << "] - " << endl; - setenv("HOME", myself.processDir().c_str(), 1); - myself.log("HOME=" + string(getenv("HOME"))); -} - - -int main(int argc, char* argv[]) -{ - pEpTestTree<>::debug_log_enabled = true; - pEpTestTree<>::setGlobalRootDir("./testdata"); - pEpTestTree<> root = pEpTestTree<>{ nullptr, "rootnode"}; - - pEpTestTree<> test1 = pEpTestTree<>{ &root, "node 1", [](const pEpTestTree<>& mynode) { - printHomeDir(mynode); - } }; - - pEpTestTree<> test1_1 = pEpTestTree<>{ &test1, "node 1.1", [](const pEpTestTree<>& mynode) { - printHomeDir(mynode); - } }; - - pEpTestTree<> test2 = pEpTestTree<>{ &root, "node 2", [](const pEpTestTree<>& mynode) { - printHomeDir(mynode); - } }; - - pEpTestTree<> test2_1 = pEpTestTree<>{ &test2, - "node 2.1", - [](const pEpTestTree<>& mynode) { printHomeDir(mynode); }, - nullptr, - pEp::Test::pEpTestTree<>::ExecutionMode::PROCESS_PARALLEL }; - - - pEpTestTree<> test2_1_1 = pEpTestTree<>{ &test2_1, "node 2.1.1", [](pEpTestTree<> mynode) { - printHomeDir(mynode); - } }; - - root.run(); -} \ No newline at end of file