From 56b9013bcbe33c8573feb5af81611e4a7576fad2 Mon Sep 17 00:00:00 2001 From: Hungming Chen Date: Thu, 9 Jun 2022 11:33:43 +0800 Subject: [PATCH] TrafficControllerTest: improve error declaration in dumpsysInvalidMaps Test: atest TrafficControllerTest Change-Id: Id2b2e8edefed615ccb3e94667bc91bc03e14ad81 --- service/native/TrafficControllerTest.cpp | 31 ++++++++++++++---------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/service/native/TrafficControllerTest.cpp b/service/native/TrafficControllerTest.cpp index fff99baaa1..2eabc26e03 100644 --- a/service/native/TrafficControllerTest.cpp +++ b/service/native/TrafficControllerTest.cpp @@ -842,20 +842,25 @@ TEST_F(TrafficControllerTest, TestDumpsys) { TEST_F(TrafficControllerTest, dumpsysInvalidMaps) { makeTrafficControllerMapsInvalid(); + const std::string kErrIterate = "print end with error: Get firstKey map -1 failed: " + "Bad file descriptor"; + const std::string kErrReadRulesConfig = "read ownerMatch configure failed with error: " + "Read value of map -1 failed: Bad file descriptor"; + const std::string kErrReadStatsMapConfig = "read stats map configure failed with error: " + "Read value of map -1 failed: Bad file descriptor"; + std::vector expectedLines = { - "mCookieTagMap print end with error: Get firstKey map -1 failed: Bad file descriptor", - "mUidCounterSetMap print end with error: Get firstKey map -1 failed: Bad file descriptor", - "mAppUidStatsMap print end with error: Get firstKey map -1 failed: Bad file descriptor", - "mStatsMapA print end with error: Get firstKey map -1 failed: Bad file descriptor", - "mStatsMapB print end with error: Get firstKey map -1 failed: Bad file descriptor", - "mIfaceIndexNameMap print end with error: Get firstKey map -1 failed: Bad file descriptor", - "mIfaceStatsMap print end with error: Get firstKey map -1 failed: Bad file descriptor", - "mConfigurationMap read ownerMatch configure failed with error: " - "Read value of map -1 failed: Bad file descriptor", - "mConfigurationMap read stats map configure failed with error: " - "Read value of map -1 failed: Bad file descriptor", - "mUidOwnerMap print end with error: Get firstKey map -1 failed: Bad file descriptor", - "mUidPermissionMap print end with error: Get firstKey map -1 failed: Bad file descriptor"}; + fmt::format("mCookieTagMap {}", kErrIterate), + fmt::format("mUidCounterSetMap {}", kErrIterate), + fmt::format("mAppUidStatsMap {}", kErrIterate), + fmt::format("mStatsMapA {}", kErrIterate), + fmt::format("mStatsMapB {}", kErrIterate), + fmt::format("mIfaceIndexNameMap {}", kErrIterate), + fmt::format("mIfaceStatsMap {}", kErrIterate), + fmt::format("mConfigurationMap {}", kErrReadRulesConfig), + fmt::format("mConfigurationMap {}", kErrReadStatsMapConfig), + fmt::format("mUidOwnerMap {}", kErrIterate), + fmt::format("mUidPermissionMap {}", kErrIterate)}; EXPECT_TRUE(expectDumpsysContains(expectedLines)); }