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)); }