Browse Source

Tests: PityTest - update tests

LIB-11
heck 11 months ago
parent
commit
aa286f459f
4 changed files with 51 additions and 24 deletions
  1. +33
    -7
      test/pitytest11/test/test_execmodes.cc
  2. +6
    -4
      test/pitytest11/test/test_linear.cc
  3. +11
    -12
      test/pitytest11/test/test_processdirs.cc
  4. +1
    -1
      test/pitytest11/test/test_swarm.cc

+ 33
- 7
test/pitytest11/test/test_execmodes.cc View File

@ -1,6 +1,7 @@
#include "../src/PityUnit.hh"
#include "../src/PityModel.hh"
#include "../src/PityPerspective.hh"
#include "../../../src/utils.hh"
#include <iostream>
using namespace std;
@ -34,31 +35,56 @@ int main(int argc, char* argv[])
CTXExecmodes ctxe;
ctxe.sleepmilis = 100;
ctxe.rep_count = 3;
// Utils::readKey();
// The RootNode is the
TestUnit root = TestUnit{ nullptr, "Test Execution Model" };
TestUnit root = TestUnit{ "Test Execution Model" };
// Subprocess 1
TestUnit test1 = TestUnit{ &root,
TestUnit test1 = TestUnit{ "node1", do_some_work, &ctxe, TestUnit::ExecutionMode::PROCESS_PARALLEL };
TestUnit test1_1 = TestUnit{ "test1.1", do_some_work };
TestUnit test1_2 = TestUnit{ "test1.2", do_some_work };
root.add(test1);
test1.add(test1_1);
test1.add(test1_2);
// Subprocess 2
TestUnit test2 = TestUnit{ "node2", do_some_work, &ctxe, TestUnit::ExecutionMode::PROCESS_PARALLEL };
TestUnit test2_1 = TestUnit{ "test2.1", do_some_work };
TestUnit test2_2 = TestUnit{ "test2.2", do_some_work };
root.add(test2);
test2.add(test2_1);
test2.add(test2_2);
root.run();
/*
// The RootNode is the
TestUnit root = TestUnit{ "Test Execution Model" };
// Subprocess 1
TestUnit test1 = TestUnit{ root,
"node1",
do_some_work,
&ctxe,
TestUnit::ExecutionMode::PROCESS_PARALLEL };
TestUnit test1_1 = TestUnit{ &test1, "test1.1", do_some_work };
TestUnit test1_1 = TestUnit{ test1, "test1.1", do_some_work };
TestUnit test1_2 = TestUnit{ &test1, "test1.2", do_some_work };
TestUnit test1_2 = TestUnit{ test1, "test1.2", do_some_work };
// Subprocess 2
TestUnit test2 = TestUnit{ &root,
TestUnit test2 = TestUnit{ root,
"node2",
do_some_work,
&ctxe,
TestUnit::ExecutionMode::PROCESS_PARALLEL };
TestUnit test2_1 = TestUnit{ &test2, "test2.1", do_some_work };
TestUnit test2_1 = TestUnit{ test2, "test2.1", do_some_work };
TestUnit test2_2 = TestUnit{ &test2, "test2.2", do_some_work };
TestUnit test2_2 = TestUnit{ test2, "test2.2", do_some_work };
root.run();
*/
}

+ 6
- 4
test/pitytest11/test/test_linear.cc View File

@ -6,6 +6,8 @@ using namespace std;
using namespace pEp;
using namespace pEp::PityTest11;
// eeks_test
// The test framework for geeks without the g
class Car {
private:
@ -53,11 +55,11 @@ int main(int argc, char* argv[])
{
// Linear Test
CarTestModel model{ "CarTestModel" };
PityUnit<CarTestModel> testnode_car{ nullptr, "test car", nullptr, &model };
PityUnit<CarTestModel> testnode_setGear{ &testnode_car, "test car setGear()", test_setGear };
PityUnit<CarTestModel> testnode_driv{ &testnode_setGear, "test car drive()", &test_drive };
PityUnit<CarTestModel> testnode_car{ "test car", nullptr, &model };
PityUnit<CarTestModel> testnode_setGear{ testnode_car, "test car setGear()", test_setGear };
PityUnit<CarTestModel> testnode_driv{ testnode_setGear, "test car drive()", &test_drive };
PityUnit<CarTestModel> testnode_driv_before_gear{ &testnode_car,
PityUnit<CarTestModel> testnode_driv_before_gear{ testnode_car,
"testnode_driv_before_gear",
&test_drive };


+ 11
- 12
test/pitytest11/test/test_processdirs.cc View File

@ -16,17 +16,17 @@ void printHomeDir(PityUnit<>& myself)
int main(int argc, char* argv[])
{
PityUnit<>::debug_log_enabled = false;
PityUnit<> root = PityUnit<>{ nullptr, "test_processdirs" };
PityUnit<> root = PityUnit<>{ "test_processdirs" };
// 1
PityUnit<> test1 = PityUnit<>{ &root, "node 1", [](PityUnit<>& mynode, void* ctx) {
PityUnit<> test1 = PityUnit<>{ root, "node 1", [](PityUnit<>& mynode, void* ctx) {
PTASSERT(
mynode.processDir() == "./pitytest_data/test_processdirs/",
"");
return 0;
} };
PityUnit<> test1_1 = PityUnit<>{ &test1, "node 1.1", [](PityUnit<>& mynode, void* ctx) {
PityUnit<> test1_1 = PityUnit<>{ test1, "node 1.1", [](PityUnit<>& mynode, void* ctx) {
PTASSERT(
mynode.processDir() == "./pitytest_data/test_processdirs/",
"");
@ -34,15 +34,14 @@ int main(int argc, char* argv[])
} };
// 2
PityUnit<> test2 = PityUnit<>{ &root, "node 2", [](PityUnit<>& mynode, void* ctx) {
PityUnit<> test2 = PityUnit<>{ root, "node 2", [](PityUnit<>& mynode, void* ctx) {
PTASSERT(
mynode.processDir() == "./pitytest_data/test_processdirs/",
"");
return 0;
} };
PityUnit<> test2_1 = PityUnit<>{
&test2,
test2,
"node 2.1",
[](PityUnit<>& mynode, void* ctx) {
PTASSERT(mynode.processDir() == "./pitytest_data/test_processdirs/node_2_1/", "");
@ -53,7 +52,7 @@ int main(int argc, char* argv[])
};
PityUnit<> test2_1_1 = PityUnit<>{ &test2_1, "node 2.1.1", [](PityUnit<> mynode, void* ctx) {
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/",
@ -64,7 +63,7 @@ int main(int argc, char* argv[])
// 3
PityUnit<> test3 = PityUnit<>{
&root,
root,
"node 3",
[](PityUnit<>& mynode, void* ctx) {
PTASSERT(mynode.processDir() == "./pitytest_data/test_processdirs/node_3/", "");
@ -74,7 +73,7 @@ int main(int argc, char* argv[])
PityUnit<>::ExecutionMode::PROCESS_PARALLEL
};
PityUnit<> test3_1 = PityUnit<>{ &test3, "node 3.1", [](PityUnit<>& mynode, void* ctx) {
PityUnit<> test3_1 = PityUnit<>{ test3, "node 3.1", [](PityUnit<>& mynode, void* ctx) {
PTASSERT(
mynode.processDir() ==
"./pitytest_data/test_processdirs/node_3/",
@ -82,7 +81,7 @@ int main(int argc, char* argv[])
return 0;
} };
PityUnit<> test3_1_1 = PityUnit<>{ &test3_1, "node 3.1.1", [](PityUnit<>& mynode, void* ctx) {
PityUnit<> test3_1_1 = PityUnit<>{ test3_1, "node 3.1.1", [](PityUnit<>& mynode, void* ctx) {
PTASSERT(
mynode.processDir() ==
"./pitytest_data/test_processdirs/node_3/",
@ -91,7 +90,7 @@ int main(int argc, char* argv[])
} };
PityUnit<> test3_1_1_1 = PityUnit<>{
&test3_1_1,
test3_1_1,
"node 3.1.1",
[](PityUnit<>& mynode, void* ctx) {
PTASSERT(mynode.processDir() == "./pitytest_data/test_processdirs/node_3_1_1/", "");
@ -102,7 +101,7 @@ int main(int argc, char* argv[])
};
PityUnit<> test3_1_1_1_1 = PityUnit<>{
&test3_1_1_1,
test3_1_1_1,
"node 3.1.1.1",
[](PityUnit<>& mynode, void* ctx) {
PTASSERT(mynode.processDir() == "./pitytest_data/test_processdirs/node_3_1_1/", "");


+ 1
- 1
test/pitytest11/test/test_swarm.cc View File

@ -18,7 +18,7 @@ int test_node1(PityUnit<PityPerspective>& unit, PityPerspective* ctx)
int throttle = 1000;
while (true) {
Utils::sleep_millis(throttle);
for (auto peer : ctx->peers) {
for (const auto& peer : ctx->peers) {
unit.transport()->sendMsg(peer, msg);
}


Loading…
Cancel
Save