diff options
author | Mike Yu <yumike@google.com> | 2019-10-31 16:12:23 +0800 |
---|---|---|
committer | Mike Yu <yumike@google.com> | 2019-12-11 22:31:45 +0800 |
commit | 39df0b13bb000abfbc9fbb01edacd54f4fc421c9 (patch) | |
tree | 5c46857705be0841cc4b895cfa8e3994a2cae8f8 /DnsQueryLog.cpp | |
parent | 939e3690aeb0142679678313a74bf024cfba7129 (diff) | |
download | DnsResolver-39df0b13bb000abfbc9fbb01edacd54f4fc421c9.tar.gz |
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
Diffstat (limited to 'DnsQueryLog.cpp')
-rw-r--r-- | DnsQueryLog.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
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); |