我正在使用boost :: asio :: io_service调用std :: thread,如下所示。功能:
91 0 : void start_tcp( std::shared_ptr<mapping_t> m_mapping, l_publisher& ll_publisher,
92 : reg_publisher& reg_publisher, std::mutex& mtx, bool debug, const string& host,
93 : uint16_t port, uint16_t maximum_number_of_connections ) {
94 : spdlog::info( "start_tcp debug:{} host:{} port:{} max_connections:{}", debug, host, port,
95 0 : maximum_number_of_connections );
96 0 : modbus_t* ctx = nullptr;
97 0 : if( host == "0.0.0.0" ) {
98 0 : ctx = new_tcp( NULL, port );
99 : } else {
100 0 : ctx = new_tcp( host.c_str(), port );
101 : }
**Above function calling from thread insdie main.cpp:**
: std::thread tcp_thread{start_tcp,
424 : m_mapping,
425 0 : std::ref( l_publisher ),
426 0 : std::ref( reg_publisher ),
427 0 : std::ref( mtx ),
428 : debug_mode,
429 0 : input_file["bindAddress"].as<string>(),
430 0 : input_file["port"].as<unsigned>(),
431 0 : config["maximum-connections"].as<unsigned>()};
432 0 : io_service->run();
我编译时可以看到。gcno文件已生成。这意味着,我正确设置了 摘录自测试输出:-g -O0 --coverage
编译器标志,然后设置了-lgcov
链接器标志。而且,在测试运行之后,生成<.gcda>文件。但是,即使函数start_tcp被执行,也没有显示覆盖率。执行测试后,我可以看到以下内容已打印到控制台。这意味着将执行此功能。但是报道没有显示任何东西。spdlog::info( "start_tcp debug:{} host:{} port:{} max_connections:{}", debug,
有人可以帮我解决这个问题。我是在做错什么还是对于增强线程,是否需要其他一些特殊标志以获取正确的覆盖率报告?
我正在使用boost :: asio :: io_service调用std :: thread,如下所示。.函数:91 0:void start_tcp(std :: shared_ptr
m_mapping,l_publisher&ll_publisher,...