Skip to content
Snippets Groups Projects
Commit c1781766 authored by Philipp Spilger's avatar Philipp Spilger
Browse files

Unify test main files

* use logger instead of direct cout in throughputtests

Change-Id: I343e55338499c827e8afab79c7ffd687413e8bdb
parent 92318655
No related branches found
No related tags found
No related merge requests found
File moved
#include <string>
#include <boost/program_options.hpp>
#include <gtest/gtest.h>
// logger include directory structure omits prefix
#include "logging_ctrl.h"
bool hxcomm_verbose;
int main(int argc, char* argv[])
{
testing::InitGoogleTest(&argc, argv);
std::string loglevel;
namespace bpo = boost::program_options;
bpo::options_description desc("Options");
// clang-format off
desc.add_options()("loglevel", bpo::value<std::string>(&loglevel)->default_value("trace"))
("hxcomm-verbose", bpo::bool_switch(&hxcomm_verbose)->default_value(false));
// clang-format on
bpo::variables_map vm;
bpo::store(
bpo::basic_command_line_parser(argc, argv).options(desc).allow_unregistered().run(), vm);
bpo::notify(vm);
if (loglevel == "trace") {
logger_default_config(log4cxx::Level::getTrace());
} else if (loglevel == "debug") {
logger_default_config(log4cxx::Level::getDebug());
} else if (loglevel == "info") {
logger_default_config(log4cxx::Level::getInfo());
} else if (loglevel == "warning") {
logger_default_config(log4cxx::Level::getWarn());
} else if (loglevel == "error") {
logger_default_config(log4cxx::Level::getError());
} else if (loglevel == "fatal") {
logger_default_config(log4cxx::Level::getFatal());
} else {
std::cout << "loglevel option has to be one of {trace,debug,info,warning,error,fatal"
<< std::endl;
exit(EXIT_FAILURE);
}
return RUN_ALL_TESTS();
}
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "hate/timer.h" #include "hate/timer.h"
#include "hxcomm/common/decoder.h" #include "hxcomm/common/decoder.h"
#include "hxcomm/common/encoder.h" #include "hxcomm/common/encoder.h"
#include "hxcomm/common/logger.h"
#include "hxcomm/vx/connection_parameter.h" #include "hxcomm/vx/connection_parameter.h"
#include "hxcomm/vx/utmessage.h" #include "hxcomm/vx/utmessage.h"
#include "hxcomm/vx/utmessage_random.h" #include "hxcomm/vx/utmessage_random.h"
...@@ -14,8 +15,6 @@ using namespace hxcomm::vx::instruction; ...@@ -14,8 +15,6 @@ using namespace hxcomm::vx::instruction;
using send_dict = hxcomm::vx::instruction::ToFPGADictionary; using send_dict = hxcomm::vx::instruction::ToFPGADictionary;
using recv_dict = hxcomm::vx::instruction::FromFPGADictionary; using recv_dict = hxcomm::vx::instruction::FromFPGADictionary;
extern bool hxcomm_verbose;
/** /**
* Queue that stores only one element and blindly overwrites it without memory allocation. * Queue that stores only one element and blindly overwrites it without memory allocation.
* Used for throughput measurement simulating a fast and non-blocking circular buffer. * Used for throughput measurement simulating a fast and non-blocking circular buffer.
...@@ -120,9 +119,8 @@ TEST(Encoder, Throughput) ...@@ -120,9 +119,8 @@ TEST(Encoder, Throughput)
{ {
auto result = throughput_measurement<typename hxcomm::vx::ConnectionParameter::Send>(num); auto result = throughput_measurement<typename hxcomm::vx::ConnectionParameter::Send>(num);
auto encode_mega_rate = result.first; auto encode_mega_rate = result.first;
if (hxcomm_verbose) { auto logger = log4cxx::Logger::getLogger("hxcomm.swtest.Encoder.Throughput");
std::cout << "[ INFO ] Encode rate: " << encode_mega_rate << " MB/s" << std::endl; HXCOMM_LOG_INFO(logger, "Encode rate: " << encode_mega_rate << " MB/s");
}
EXPECT_GT(encode_mega_rate, 125.); // reach minimally 1GBit EXPECT_GT(encode_mega_rate, 125.); // reach minimally 1GBit
} }
...@@ -131,8 +129,7 @@ TEST(Decoder, Throughput) ...@@ -131,8 +129,7 @@ TEST(Decoder, Throughput)
auto result = auto result =
throughput_measurement<typename hxcomm::vx::ConnectionParameter::Receive>(num); throughput_measurement<typename hxcomm::vx::ConnectionParameter::Receive>(num);
auto decode_mega_rate = result.second; auto decode_mega_rate = result.second;
if (hxcomm_verbose) { auto logger = log4cxx::Logger::getLogger("hxcomm.swtest.Decoder.Throughput");
std::cout << "[ INFO ] Decode rate: " << decode_mega_rate << " MB/s" << std::endl; HXCOMM_LOG_INFO(logger, "Decode rate: " << decode_mega_rate << " MB/s");
}
EXPECT_GT(decode_mega_rate, 125.); // reach minimally 1GBit EXPECT_GT(decode_mega_rate, 125.); // reach minimally 1GBit
} }
...@@ -142,7 +142,7 @@ def build(bld): ...@@ -142,7 +142,7 @@ def build(bld):
bld.shlib( bld.shlib(
target = 'hxcomm_tests_helper', target = 'hxcomm_tests_helper',
features = 'cxx', features = 'cxx',
source = bld.path.ant_glob('tests/common/src/*.cpp'), source = bld.path.ant_glob('tests/common/src/test-*.cpp'),
use = ['hxcomm', 'hxcomm_tests_inc'], use = ['hxcomm', 'hxcomm_tests_inc'],
) )
...@@ -156,7 +156,7 @@ def build(bld): ...@@ -156,7 +156,7 @@ def build(bld):
use = ['hxcomm', 'hxcomm_tests_helper', 'BOOST4HXCOMMTOOLS'] + loopbackconnection_obj_targets, use = ['hxcomm', 'hxcomm_tests_helper', 'BOOST4HXCOMMTOOLS'] + loopbackconnection_obj_targets,
test_timeout = 120, test_timeout = 120,
uselib = 'HXCOMM', uselib = 'HXCOMM',
test_main = 'tests/sw/hxcomm/main.cpp', test_main = 'tests/common/src/main.cpp',
) )
bld( bld(
...@@ -164,7 +164,7 @@ def build(bld): ...@@ -164,7 +164,7 @@ def build(bld):
features = 'gtest cxx cxxprogram', features = 'gtest cxx cxxprogram',
source = bld.path.ant_glob('tests/sw/hxcomm/test-*_throughput.cpp'), source = bld.path.ant_glob('tests/sw/hxcomm/test-*_throughput.cpp'),
use = ['hxcomm', 'hxcomm_tests_helper', 'BOOST4HXCOMMTOOLS'], use = ['hxcomm', 'hxcomm_tests_helper', 'BOOST4HXCOMMTOOLS'],
test_main = 'tests/sw/hxcomm/main.cpp', test_main = 'tests/common/src/main.cpp',
cxxflags = ['-O2'], cxxflags = ['-O2'],
# Throughput targets are only valid for HBPHosts and AMTHosts # Throughput targets are only valid for HBPHosts and AMTHosts
skip_run = not (gethostname().startswith("HBPHost") or skip_run = not (gethostname().startswith("HBPHost") or
...@@ -177,7 +177,7 @@ def build(bld): ...@@ -177,7 +177,7 @@ def build(bld):
features = 'gtest cxx cxxprogram', features = 'gtest cxx cxxprogram',
source = bld.path.ant_glob('tests/hw/hxcomm/test-*.cpp'), source = bld.path.ant_glob('tests/hw/hxcomm/test-*.cpp'),
skip_run = not (bld.env.DLSvx_HARDWARE_AVAILABLE or bld.env.DLSvx_SIM_AVAILABLE), skip_run = not (bld.env.DLSvx_HARDWARE_AVAILABLE or bld.env.DLSvx_SIM_AVAILABLE),
test_main = 'tests/hw/hxcomm/main.cpp', test_main = 'tests/common/src/main.cpp',
use = ['hxcomm', 'hxcomm_tests_helper', 'BOOST4HXCOMMTOOLS'], use = ['hxcomm', 'hxcomm_tests_helper', 'BOOST4HXCOMMTOOLS'],
test_timeout = 60, test_timeout = 60,
uselib = 'HXCOMM', uselib = 'HXCOMM',
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment