Skip to content

Commit

Permalink
Remove raw uses of std::cout in ecflow/udp tests
Browse files Browse the repository at this point in the history
  • Loading branch information
marcosbento committed Sep 20, 2024
1 parent 72627a5 commit 51f2ff1
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions libs/udp/test/TestSupport.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ class BaseMockServer {
BOOST_REQUIRE_MESSAGE(port_ > 0, "port is be larger than 0");

server_ = SERVER::launch(host_, port_, std::forward<Args>(args)...);
std::cout << " MOCK: " << SERVER::designation << " has been started!" << std::endl;
ECF_TEST_DBG(<< " MOCK: " << SERVER::designation << " has been started!");
}
BaseMockServer(const BaseMockServer&) = delete;
BaseMockServer(BaseMockServer&&) = delete;

~BaseMockServer() {
server_.terminate();
SERVER::cleanup(host_, port_);
std::cout << " MOCK: " << SERVER::designation << " has been terminated!" << std::endl;
ECF_TEST_DBG(<< " MOCK: " << SERVER::designation << " has been terminated!");
}

const hostname_t& host() const { return host_; }
Expand Down Expand Up @@ -86,7 +86,7 @@ class MockServer : public BaseMockServer<MockServer> {
false, "load definitions, without throwing exception (but threw: " + std::string(e.what()) + ")");
}

std::cout << " MOCK: reference ecFlow suite has been loaded" << std::endl;
ECF_TEST_DBG(<< " MOCK: reference ecFlow suite has been loaded");
}

Meter get_meter(const std::string& path, const std::string& name) const {
Expand All @@ -106,7 +106,7 @@ class MockServer : public BaseMockServer<MockServer> {

private:
node_ptr get_node_at(const std::string& path) const {
std::cout << " Creating ecflow_client connected to " << host() << ":" << port() << std::endl;
ECF_TEST_DBG(<< " Creating ecflow_client connected to " << host() << ":" << port());
ClientInvoker client(ecf::Str::LOCALHOST(), port());

// load all definitions
Expand Down Expand Up @@ -144,7 +144,7 @@ class MockServer : public BaseMockServer<MockServer> {
invoke_command += std::to_string(port);
invoke_command += " -d &";

std::cout << "Launching ecflow_server @" << host << ":" << port << ", with: " << invoke_command << std::endl;
ECF_TEST_DBG(<< "Launching ecflow_server @" << host << ":" << port << ", with: " << invoke_command);

bp::child child(invoke_command);

Expand Down Expand Up @@ -195,7 +195,7 @@ class MockUDPServer : public BaseMockServer<MockUDPServer> {
}

void send(const std::string& request) {
std::cout << " MOCK: UDP Client sending request: " << request << std::endl;
ECF_TEST_DBG(<< " MOCK: UDP Client sending request: " << request);
sendRequest(port(), request);
}

Expand All @@ -221,7 +221,7 @@ class MockUDPServer : public BaseMockServer<MockUDPServer> {

static void sendRequest(uint16_t port, const std::string& request) {
const std::string host = "localhost";
std::cout << " Creating ecflow_udp client connected to " << host << ":" << port << std::endl;
ECF_TEST_DBG(<< " Creating ecflow_udp client connected to " << host << ":" << port);
ecf::UDPClient client(host, std::to_string(port));
client.send(request);

Expand All @@ -241,7 +241,7 @@ class MockUDPServer : public BaseMockServer<MockUDPServer> {
invoke_command += std::to_string(ecflow_port);
invoke_command += " --verbose";

std::cout << " Launching ecflow_udp @" << host << ":" << port << ", with: " << invoke_command << std::endl;
ECF_TEST_DBG(<< " Launching ecflow_udp @" << host << ":" << port << ", with: " << invoke_command);

bp::child server(invoke_command);

Expand Down Expand Up @@ -270,13 +270,13 @@ struct EnableServersFixture
private:
static MockServer::port_t get_ecflow_server_port() {
MockServer::port_t selected_port = 3199;
std::cout << " Attempting to use port: " << selected_port << std::endl;
ECF_TEST_DBG(<< " Attempting to use port: " << selected_port);
while (!EcfPortLock::is_free(selected_port)) {
std::cout << " Selected port: " << selected_port << " is not available." << std::endl;
ECF_TEST_DBG(<< " Selected port: " << selected_port << " is not available.");
++selected_port;
std::cout << " Attempting to use port: " << selected_port << std::endl;
ECF_TEST_DBG(<< " Attempting to use port: " << selected_port);
}
std::cout << " Found free port: " << selected_port << "\n";
ECF_TEST_DBG(<< " Found free port: " << selected_port);
return selected_port;
}
static MockServer::port_t get_ecflow_udp_port() { return 3198; }
Expand Down

0 comments on commit 51f2ff1

Please sign in to comment.