PityTest11 is a very flexible C++11 peer-to-peer test framework supporting hierarchically structured test suites, multi-processing, transport system, logging, IPC, synchronization and more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

125 lines
4.2 KiB

// This file is under GNU General Public License 3.0
// see LICENSE.txt
#include "../src/PityTest.hh"
#include <iostream>
#include <algorithm>
using namespace std;
using namespace pEp::PityTest11;
using TestContext = void;
using TestUnit = PityUnit<>;
//TODO: Add HOME testing
void printHomeDir(TestUnit& myself)
{
// TESTLOG(string(myself.getFQName() + " - PID: " + to_string(getpid())));
// cout << "[" << to_string(getpid()) << "/" << myself.getFQName() << "] - " << endl;
setenv("HOME", myself.getProcessDir().c_str(), 1);
myself.log("HOME=" + string(getenv("HOME")));
}
int main(int argc, char* argv[])
{
PityUnit<>::debug_log_enabled = false;
// Suite
TestUnit suite = TestUnit{ "test_processdirs" };
std::string base = TestUnit::getGlobalRootDir() + "test_processdirs/";
// 1
suite
.addNew<TestUnit>(
"node 1",
[=](TestUnit& pity, TestContext* ctx) {
PITYASSERT(
pity.getProcessDir() == TestUnit::getGlobalRootDir() + "test_processdirs/",
pity.getProcessDir());
return 0;
})
->addNew<TestUnit>("node 1.1", [=](TestUnit& pity, TestContext* ctx) {
PITYASSERT(
pity.getProcessDir() == TestUnit::getGlobalRootDir() + "test_processdirs/",
pity.getProcessDir());
return 0;
});
// 2
suite
.addNew<TestUnit>(
"node 2",
[=](TestUnit& pity, TestContext* ctx) {
PITYASSERT(
pity.getProcessDir() == TestUnit::getGlobalRootDir() + "test_processdirs/",
pity.getProcessDir());
return 0;
})
->addNew<TestUnit>(
"node 2.1",
[=](TestUnit& pity, TestContext* ctx) {
PITYASSERT(
pity.getProcessDir() ==
TestUnit::getGlobalRootDir() + "test_processdirs_node_2_node_2_1/",
pity.getProcessDir());
return 0;
},
nullptr,
PityUnit<>::ExecutionMode::PROCESS_PARALLEL)
->addNew<TestUnit>("node 2.1.1", [=](TestUnit& pity, TestContext* ctx) {
PITYASSERT(
pity.getProcessDir() ==
TestUnit::getGlobalRootDir() + "test_processdirs_node_2_node_2_1/",
pity.getProcessDir());
return 0;
});
//3
suite
.addNew<TestUnit>(
"node 3",
[=](TestUnit& pity, TestContext* ctx) {
PITYASSERT(
pity.getProcessDir() == TestUnit::getGlobalRootDir() + "test_processdirs_node_3/",
pity.getProcessDir());
return 0;
},
nullptr,
PityUnit<>::ExecutionMode::PROCESS_PARALLEL)
->addNew<TestUnit>(
"node 3.1",
[](TestUnit& pity, TestContext* ctx) {
PITYASSERT(
pity.getProcessDir() == TestUnit::getGlobalRootDir() + "test_processdirs_node_3/",
pity.getProcessDir());
return 0;
})
->addNew<TestUnit>(
"node 3.1.1",
[](TestUnit& pity, TestContext* ctx) {
PITYASSERT(
pity.getProcessDir() == TestUnit::getGlobalRootDir() + "test_processdirs_node_3/",
pity.getProcessDir());
return 0;
})
->addNew<TestUnit>(
"node 3.1.1.1",
[](TestUnit& pity, TestContext* ctx) {
PITYASSERT(
pity.getProcessDir() == TestUnit::getGlobalRootDir() + "test_processdirs_node_3_node_3_1_node_3_1_1_node_3_1_1_1/",
pity.getProcessDir());
return 0;
},
nullptr,
PityUnit<>::ExecutionMode::PROCESS_PARALLEL)
->addNew<TestUnit>("node 3.1.1.1.1", [](TestUnit& pity, TestContext* ctx) {
PITYASSERT(
pity.getProcessDir() == TestUnit::getGlobalRootDir() + "test_processdirs_node_3_node_3_1_node_3_1_1_node_3_1_1_1/",
pity.getProcessDir());
return 0;
});
suite.run();
}