Browse Source

Test: update swarm templates

LIB-11
heck 11 months ago
parent
commit
97e1286f5b
2 changed files with 23 additions and 21 deletions
  1. +17
    -16
      test/test_template_swarm_multi.cc
  2. +6
    -5
      test/test_template_swarm_single.cc

+ 17
- 16
test/test_template_swarm_multi.cc View File

@ -17,20 +17,21 @@ using namespace pEp::Test::Utils;
using namespace pEp::PityTest11;
// Test template for 3 nodes (processes) running the same 2 tests each in their own environment in parallel
using TestUnit = PityUnit<PityPerspective>;
// This is the 1st test unit
int test_func1(PityUnit<PityPerspective> &pity, PityPerspective *ctx)
{
pity.log(ctx->own_name);
pity.log("getName: " + pity.getName());
pity.log("getPath: " +pity.getPath());
pity.log("getPathShort: " +pity.getPathShort());
pity.log("transportDir: " +pity.transportDir());
pity.log("processDir: " +pity.processDir());
pity.log("getGlobalRootDir: " +pity.getGlobalRootDir());
pity.log("to_string: " +pity.to_string());
pity.log("getPath: " + pity.getPath());
pity.log("getPathShort: " + pity.getPathShort());
pity.log("transportDir: " + pity.transportDir());
pity.log("processDir: " + pity.processDir());
pity.log("getGlobalRootDir: " + pity.getGlobalRootDir());
pity.log("to_string: " + pity.to_string());
PITYASSERT(true,"");
PITYASSERT(true, "");
return 0;
}
@ -38,7 +39,7 @@ int test_func1(PityUnit<PityPerspective> &pity, PityPerspective *ctx)
int test_func2(PityUnit<PityPerspective> &pity, PityPerspective *ctx)
{
pity.log(ctx->own_name);
PITYASSERT(false,"");
PITYASSERT(false, "");
return 0;
}
@ -47,18 +48,18 @@ int main(int argc, char *argv[])
{
int nodecount = 3;
PityModel model{ "templ_swarm_multi", nodecount };
PitySwarm swarm{ model };
PitySwarm swarm{ "swarm_multi", model };
// 1. Create the swarm process TestUnit
// 2. Append a PityUnit to process 1 unit
auto unit1 = swarm.addTestUnit(0, "unit1", test_func1);
auto unit1_1 = PityUnit<PityPerspective>(*unit1,"unit1_1", test_func2);
auto unit2 = swarm.addTestUnit(1, "unit2", test_func1);
auto unit2_1 = PityUnit<PityPerspective>(*unit2,"unit2_1", test_func2);
swarm.addTestUnit(0, TestUnit("unit1", test_func1));
swarm.addTestUnit(0, TestUnit("unit1_1", test_func2));
auto unit3 = swarm.addTestUnit(2, "unit3", test_func1);
auto unit3_1 = PityUnit<PityPerspective>(*unit3,"unit3_1", test_func2);
swarm.addTestUnit(1, TestUnit("unit2", test_func1));
swarm.addTestUnit(1, TestUnit("unit2_1", test_func2));
swarm.addTestUnit(2, TestUnit("unit3", test_func1));
swarm.addTestUnit(2, TestUnit("unit3_1", test_func2));
swarm.run();
}

+ 6
- 5
test/test_template_swarm_single.cc View File

@ -16,6 +16,7 @@ using namespace pEp::Adapter;
using namespace pEp::Test::Utils;
using namespace pEp::PityTest11;
using TestUnit = PityUnit<PityPerspective>;
// Test template for a single process with 2 test units that run in sequence
// This is the 1st test unit
@ -29,7 +30,7 @@ int test_func1(PityUnit<PityPerspective> &pity, PityPerspective *ctx)
pity.log("processDir: " + pity.processDir());
pity.log("getGlobalRootDir: " + pity.getGlobalRootDir());
pity.log("to_string: " + pity.to_string(false));
PITYASSERT(true,"");
PITYASSERT(true, "");
return 0;
}
@ -37,7 +38,7 @@ int test_func1(PityUnit<PityPerspective> &pity, PityPerspective *ctx)
int test_func2(PityUnit<PityPerspective> &pity, PityPerspective *ctx)
{
pity.log(ctx->own_name);
PITYASSERT(false,"");
PITYASSERT(false, "");
return 0;
}
@ -45,10 +46,10 @@ int test_func2(PityUnit<PityPerspective> &pity, PityPerspective *ctx)
int main(int argc, char *argv[])
{
PityModel model{ "templ_swarm_single", 1 };
PitySwarm swarm{ model };
PitySwarm swarm{ "swarm_single", model };
auto unit1 = swarm.addTestUnit(0, "unit1", test_func1);
auto unit1_1 = PityUnit<PityPerspective>(*unit1, "unit1_1", test_func2);
swarm.addTestUnit(0, TestUnit("unit1", test_func1));
swarm.addTestUnit(0, TestUnit("unit1_1", test_func2));
swarm.run();
}

Loading…
Cancel
Save