From 39df0b13bb000abfbc9fbb01edacd54f4fc421c9 Mon Sep 17 00:00:00 2001 From: Mike Yu Date: Thu, 31 Oct 2019 16:12:23 +0800 Subject: Add unit tests for DnsQueryLog Ensure the basic functions of DnsQueryLog work as expected. Bug: 139040977 Test: cd packages/modules/DnsResolver && atest Change-Id: I6b318beeed7ff5942e8d08474c354e48ebdac936 --- DnsQueryLog.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'DnsQueryLog.cpp') diff --git a/DnsQueryLog.cpp b/DnsQueryLog.cpp index 82ed581d..6f0e1795 100644 --- a/DnsQueryLog.cpp +++ b/DnsQueryLog.cpp @@ -61,19 +61,19 @@ std::string timestampToString(const std::chrono::system_clock::time_point& ts) { void DnsQueryLog::push(Record&& record) { std::lock_guard guard(mLock); mQueue.push_back(std::move(record)); - if (mQueue.size() > kLogSize) { + if (mQueue.size() > mCapacity) { mQueue.pop_front(); } } void DnsQueryLog::dump(netdutils::DumpWriter& dw) const { - dw.println("DNS query log (last %ld minutes):", kValidityMinutes.count()); + dw.println("DNS query log (last %lld minutes):", (mValidityTimeMs / 60000).count()); netdutils::ScopedIndent indentStats(dw); const auto now = std::chrono::system_clock::now(); std::lock_guard guard(mLock); for (const auto& record : mQueue) { - if (now - record.timestamp > kValidityMinutes) continue; + if (now - record.timestamp > mValidityTimeMs) continue; const std::string maskedHostname = maskHostname(record.hostname); const std::string maskedIpsStr = maskIps(record.addrs); -- cgit v1.2.3