Skip to content

Commit b3b7246

Browse files
authored
[OMON-384] Test backends writing to output by redirecting cout (#241)
1 parent 10c9602 commit b3b7246

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

test/testInfluxDb.cxx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ BOOST_AUTO_TEST_CASE(simplySendMetric2)
2929
{
3030
using namespace std::string_literals;
3131
auto monitoring = MonitoringFactory::Get("influxdb-stdout://");
32+
33+
std::stringstream coutRedirect;
34+
std::streambuf* coutBuffer = std::cout.rdbuf(coutRedirect.rdbuf());
35+
3236
monitoring->send(Metric{"card"}
3337
.addValue(40.217773, "temperature")
3438
.addValue(0, "droppedPackets")
@@ -38,6 +42,9 @@ BOOST_AUTO_TEST_CASE(simplySendMetric2)
3842
.addTag(tags::Key::ID, 3)
3943
.addTag(tags::Key::Type, tags::Value::CRU)
4044
);
45+
std::string expected1 = "card,hostname=pcaldadam2.local,id=3,type=CRU temperature=40.2178,droppedPackets=0i,ctpClock=0.76817,localClock=240.471,totalPacketsPerSecond=0i 1618241730312076000\n";
46+
BOOST_CHECK(expected1.compare(coutRedirect.str()));
47+
coutRedirect.str(std::string());
4148

4249
monitoring->send(Metric{"link"}
4350
.addValue("GBT/GBT"s, "gbtMode")
@@ -52,6 +59,10 @@ BOOST_AUTO_TEST_CASE(simplySendMetric2)
5259
.addTag(tags::Key::CRU, 3)
5360
.addTag(tags::Key::ID, 3)
5461
);
62+
std::string expected2 = R"(link,hostname=pcaldadam2.local,CRU=3,id=3 gbtMode="GBT/GBT",loopback="None",gbtMux="TTC:CTP",datapathMode="Continuous",datapath="Disabled",rxFreq=181.371,txFreq=196.25,status=0i,opticalPower=657.4 1618241730312104000)";
63+
BOOST_CHECK(expected2.compare(coutRedirect.str()));
64+
65+
std::cout.rdbuf(coutBuffer);
5566
}
5667

5768
BOOST_AUTO_TEST_CASE(InfluxDbv2)

test/testMonitoringFactory.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include <chrono>
1212
#include <vector>
1313

14-
#define BOOST_TEST_MODULE TestMonitoringFactory
14+
#define BOOST_TEST_MODULE TestMonitoringVerbosityy
1515
#define BOOST_TEST_DYN_LINK
1616
#include <boost/test/unit_test.hpp>
1717
#include <boost/lexical_cast.hpp>

test/testThreads.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace Test
1515

1616
using namespace o2::monitoring;
1717

18-
BOOST_AUTO_TEST_CASE(retrieveOtherParams)
18+
BOOST_AUTO_TEST_CASE(runLibraryInMultipleThreads)
1919
{
2020
std::array<std::thread, 4> threads;
2121
for (auto& thread : threads) {

0 commit comments

Comments
 (0)