Commit 530e209f authored by gabime's avatar gabime

Fixed async tests to pass TASN checks

parent 566df7e8
......@@ -26,8 +26,9 @@ TEST_CASE("discard policy ", "[async]")
{
using namespace spdlog;
auto test_sink = std::make_shared<sinks::test_sink_mt>();
size_t queue_size = 2;
size_t messages = 10240;
test_sink->set_delay(std::chrono::milliseconds(1));
size_t queue_size = 4;
size_t messages = 1024;
auto tp = std::make_shared<details::thread_pool>(queue_size, 1);
auto logger = std::make_shared<async_logger>("as", test_sink, tp, async_overflow_policy::overrun_oldest);
......@@ -41,17 +42,20 @@ TEST_CASE("discard policy ", "[async]")
TEST_CASE("discard policy using factory ", "[async]")
{
using namespace spdlog;
size_t queue_size = 2;
size_t messages = 10240;
size_t queue_size = 4;
size_t messages = 1024;
spdlog::init_thread_pool(queue_size, 1);
auto logger = spdlog::create_async_nb<sinks::test_sink_mt>("as2");
auto test_sink = std::static_pointer_cast<sinks::test_sink_mt>(logger->sinks()[0]);
test_sink->set_delay(std::chrono::milliseconds(1));
for (size_t i = 0; i < messages; i++)
{
logger->info("Hello message");
}
auto sink = std::static_pointer_cast<sinks::test_sink_mt>(logger->sinks()[0]);
REQUIRE(sink->msg_counter() < messages);
REQUIRE(test_sink->msg_counter() < messages);
spdlog::drop_all();
}
......
......@@ -21,11 +21,13 @@ class test_sink : public base_sink<Mutex>
public:
size_t msg_counter()
{
std::lock_guard<Mutex> lock(base_sink<Mutex>::mutex_);
return msg_counter_;
}
size_t flush_counter()
{
std::lock_guard<Mutex> lock(base_sink<Mutex>::mutex_);
return flush_counter_;
}
......
Markdown is supported
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