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

Commit cbb09d0d authored by Jooyung Han's avatar Jooyung Han
Browse files

Fix binder log tests

This is a follow-up of aosp/1579804, which removed "(null)" from
output logs. This change does the same tidy-up with
android::base::StringReplace() which can replace every occurrence. This
is more future-proof in case there's more than one nullable arguments.

Bug: n/a
Test: atest DnsResolverBinderTest
Change-Id: Iee2d0ef4717c5ff69ab469997ea9c30d0437544a
parent fd4ac10e
Loading
Loading
Loading
Loading
+2 −6
Original line number Diff line number Diff line
@@ -132,7 +132,6 @@ class DnsResolverBinderTest : public ::testing::Test {
        // For each element of testdata, check that the expected output appears in the dump output.
        // If not, fail the test and use hintRegex to print similar lines to assist in debugging.
        for (const auto& td : mExpectedLogData) {
            const std::string toErase = "(null)";
            const bool found =
                    std::any_of(lines.begin(), lines.end(), [&](const std::string& line) {
                        std::smatch match;
@@ -144,11 +143,8 @@ class DnsResolverBinderTest : public ::testing::Test {
                        // have this format in log. So to make register null listener tests are
                        // compatible from all version, just remove the "(null)" argument from
                        // output logs if existed.
                        std::string output = match[1].str();
                        const auto pos = output.find(toErase);
                        if (pos != std::string::npos && pos < output.length()) {
                            output.erase(pos, toErase.length());
                        }
                        const std::string output = android::base::StringReplace(
                                match[1].str(), "(null)", "", /*all=*/true);
                        return output == td.output;
                    });
            EXPECT_TRUE(found) << "Didn't find line '" << td.output << "' in dumpsys output.";