From 7b8116162d1b83d56a3190cc193caed45d49454e Mon Sep 17 00:00:00 2001 From: heck Date: Thu, 10 Jun 2021 22:58:13 +0200 Subject: [PATCH] Tests: PityTest - HACK for transport peers problem --- src/PityTransport.cc | 10 ++++++++-- src/PityUnit.hh | 5 ++--- src/PityUnit.hxx | 3 ++- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/PityTransport.cc b/src/PityTransport.cc index 5bf5b75..2985cb0 100644 --- a/src/PityTransport.cc +++ b/src/PityTransport.cc @@ -1,4 +1,5 @@ #include "PityTransport.hh" +#include "PityUnit.hh" #include "iostream" #include "../../../src/std_utils.hh" #include @@ -6,6 +7,7 @@ #include #include + namespace pEp { namespace PityTest11 { bool PityTransport::debug_log_enabled = false; @@ -18,12 +20,16 @@ namespace pEp { void PityTransport::sendMsg(const std::string nodename, const std::string& msg) const { pEpLogClass("Address: " + nodename + " msg: " + msg); + + // HACK TODO + std::string nodename_normalize = PityUnit<>::_normalizeName(nodename); + bool found = false; std::string dir; try { - dir = _endpoints.at(nodename); + dir = _endpoints.at(nodename_normalize); } catch (std::out_of_range&) { - throw std::runtime_error("no such nodename: " + nodename); + throw std::runtime_error("no such nodename: " + nodename_normalize); } Utils::dir_ensure(dir); std::stringstream filename; diff --git a/src/PityUnit.hh b/src/PityUnit.hh index 8351bbb..bda4e28 100644 --- a/src/PityUnit.hh +++ b/src/PityUnit.hh @@ -63,6 +63,7 @@ namespace pEp { // Util void recreateDirsRecursively(); + static std::string _normalizeName(std::string name); //TODO HACK in PityTransport this should be private //Transport PityTransport* transport() const; @@ -102,9 +103,7 @@ namespace pEp { std::string _rootUnitDir(); - // Util - std::string _normalizeName(std::string name) const; std::string _status_string(const std::string& msg) const; Utils::Color _colForProcUnitNr(int procUnitNr) const; Utils::Color _termColor() const; @@ -113,7 +112,7 @@ namespace pEp { // Fields const std::string _name; PityUnit* _parent; //nullptr if RootUnit - TestContext* _perspective; //nullptr if inherited + TestContext* _perspective; //nullptr if inherited TestFunction _test_func; ExecutionMode _exec_mode; static std::string _global_root_dir; diff --git a/src/PityUnit.hxx b/src/PityUnit.hxx index 778747d..f4bfecf 100644 --- a/src/PityUnit.hxx +++ b/src/PityUnit.hxx @@ -478,8 +478,9 @@ namespace pEp { } // name is alphanumeric only (everything else will be replaced by an underscore) + // static template - std::string PityUnit::_normalizeName(std::string name) const + std::string PityUnit::_normalizeName(std::string name) { replace_if( name.begin(),