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

Commit 098e715f authored by paulhu's avatar paulhu Committed by Automerger Merge Worker
Browse files

Fix failed register null listener tests am: e84604d6 am: 90da7887 am: 276c53f0

Original change: https://android-review.googlesource.com/c/platform/packages/modules/DnsResolver/+/1579804

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I081d800916c543c39f26a761ada35441b7740c0c
parents 28347054 276c53f0
Loading
Loading
Loading
Loading
+14 −1
Original line number Diff line number Diff line
@@ -132,11 +132,24 @@ 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;
                        if (!std::regex_match(line, match, lineRegex)) return false;
                        return (match.size() == 2) && (match[1].str() == td.output);
                        if (match.size() != 2) return false;

                        // The binder_to_string format is changed from S that will add "(null)" to
                        // the log on method's argument if binder object is null. But Q and R don't
                        // 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());
                        }
                        return output == td.output;
                    });
            EXPECT_TRUE(found) << "Didn't find line '" << td.output << "' in dumpsys output.";
            if (found) continue;