Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a211a0da authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 7993599 from c9560286 to mainline-ipsec-release

Change-Id: I738ce85373831b0d95b1ae38fff4916c67301b8a
parents 7f437462 c9560286
Loading
Loading
Loading
Loading
+3 −4
Original line number Diff line number Diff line
@@ -81,8 +81,7 @@ int StatsData::averageLatencyMs() const {
}

std::string StatsData::toString() const {
    if (total == 0)
        return fmt::format("{}:{} <no data>", sockAddr.ip().toString(), sockAddr.port());
    if (total == 0) return fmt::format("{} <no data>", sockAddr.toString());

    const auto now = std::chrono::steady_clock::now();
    const int lastUpdateSec = duration_cast<seconds>(now - lastUpdate).count();
@@ -92,8 +91,8 @@ std::string StatsData::toString() const {
            buf += fmt::format("{}:{} ", rcodeToName(rcode), counts);
        }
    }
    return fmt::format("{}:{} ({}, {}ms, [{}], {}s)", sockAddr.ip().toString(), sockAddr.port(),
                       total, averageLatencyMs(), buf, lastUpdateSec);
    return fmt::format("{} ({}, {}ms, [{}], {}s)", sockAddr.toString(), total, averageLatencyMs(),
                       buf, lastUpdateSec);
}

StatsRecords::StatsRecords(const IPSockAddr& ipSockAddr, size_t size)
+2 −3
Original line number Diff line number Diff line
@@ -121,7 +121,7 @@ class DnsStatsTest : public ::testing::Test {
                          const std::vector<StatsData>& dohData) {
        // A pattern to capture three matches:
        //     server address (empty allowed), the statistics, and the score.
        const std::regex pattern(R"(\s{4,}([0-9a-fA-F:\.]*)[ ]?([<(].*[>)])[ ]?(\S*))");
        const std::regex pattern(R"(\s{4,}([0-9a-fA-F:\.\]\[]*)[ ]?([<(].*[>)])[ ]?(\S*))");
        std::string dumpString = captureDumpOutput();

        const auto check = [&](const std::vector<StatsData>& statsData, const std::string& protocol,
@@ -142,8 +142,7 @@ class DnsStatsTest : public ::testing::Test {

            for (const auto& stats : statsData) {
                ASSERT_TRUE(std::regex_search(*dumpString, sm, pattern));
                EXPECT_EQ(sm[1], stats.sockAddr.ip().toString() + ":" +
                                         std::to_string(stats.sockAddr.port()));
                EXPECT_EQ(sm[1], stats.sockAddr.toString());
                EXPECT_FALSE(sm[2].str().empty());
                EXPECT_FALSE(sm[3].str().empty());
                *dumpString = sm.suffix();
+3 −2
Original line number Diff line number Diff line
@@ -17,10 +17,10 @@
#pragma once

#include <climits>
#include <map>
#include <mutex>
#include <string>
#include <string_view>
#include <unordered_map>

#include <android-base/thread_annotations.h>
#include <netdutils/DumpWriter.h>
@@ -45,7 +45,7 @@ class Experiments {
    Experiments() = delete;
    void updateInternal() EXCLUDES(mMutex);
    mutable std::mutex mMutex;
    std::unordered_map<std::string_view, int> mFlagsMapInt GUARDED_BY(mMutex);
    std::map<std::string_view, int> mFlagsMapInt GUARDED_BY(mMutex);
    // TODO: Migrate other experiment flags to here.
    // (retry_count, retransmission_time_interval)
    static constexpr const char* const kExperimentFlagKeyList[] = {
@@ -64,6 +64,7 @@ class Experiments {
            "doh",
            "doh_query_timeout_ms",
            "doh_probe_timeout_ms",
            "doh_idle_timeout_ms",
            "mdns_resolution",
    };
    // This value is used in updateInternal as the default value if any flags can't be found.
+4 −4
Original line number Diff line number Diff line
@@ -14,10 +14,10 @@
 * limitations under the License.
 */

#include <map>
#include <mutex>
#include <string>
#include <string_view>
#include <unordered_map>

#include <android-base/format.h>
#include <android-base/test_utils.h>
@@ -72,7 +72,7 @@ class ExperimentsTest : public ::testing::Test {
    }

    void expectGetDnsExperimentFlagInt() {
        std::unordered_map<std::string_view, int> tempMap;
        std::map<std::string_view, int> tempMap;
        for (const auto& key : Experiments::kExperimentFlagKeyList) {
            tempMap[key] = mExperiments.getFlag(key, 0);
        }
@@ -102,11 +102,11 @@ class ExperimentsTest : public ::testing::Test {
        EXPECT_EQ(dumpString.substr(startPos), "\n");
    }

    static std::unordered_map<std::string_view, int> sFakeFlagsMapInt;
    static std::map<std::string_view, int> sFakeFlagsMapInt;
    Experiments mExperiments;
};

std::unordered_map<std::string_view, int> ExperimentsTest::sFakeFlagsMapInt;
std::map<std::string_view, int> ExperimentsTest::sFakeFlagsMapInt;

TEST_F(ExperimentsTest, update) {
    std::vector<int> testValues = {50, 3, 5, 0};
+2 −1
Original line number Diff line number Diff line
include platform/system/netd:/OWNERS
set noparent
file:platform/packages/modules/Connectivity:master:/OWNERS_core_networking
Loading