From 84777b06df82dbff70abf1922f31dfbff4c83f4a Mon Sep 17 00:00:00 2001 From: Bernie Innocenti Date: Fri, 27 Apr 2018 17:34:30 +0900 Subject: [PATCH] Fix NetdHidlTest.TestAddRemoveInterfaces() The regex in countRulesForFwmark() overeagerly matched rules ending in the same hex digit. For instance, fwmark=3 would match both these lines: from all fwmark 0xd0003/0xdffff iif lo lookup netd13474_27190 from all fwmark 0x10063/0x1ffff iif lo lookup local_network This fix consists in matching either just 0x3, or the zero-padded 0003. Bug: 74922133 Test: as follows: m VtsHalNetNetdV1_1TargetTest && \ adb push out/.../VtsHalNetNetdV1_1TargetTest /data/ && \ adb shell /data/VtsHalNetNetdV1_1TargetTest Change-Id: If6df9fa6cf843a5593ce61d87366c23383bb4d81 (cherry picked from commit 64848957ba49275896c80790ceeeb6219930f687) --- net/netd/testutils/VtsHalNetNetdTestUtils.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/netd/testutils/VtsHalNetNetdTestUtils.cpp b/net/netd/testutils/VtsHalNetNetdTestUtils.cpp index da377c4..0d4189d 100644 --- a/net/netd/testutils/VtsHalNetNetdTestUtils.cpp +++ b/net/netd/testutils/VtsHalNetNetdTestUtils.cpp @@ -88,7 +88,8 @@ int countMatchingIpRules(const std::string& regexString) { int countRulesForFwmark(const uint32_t fwmark) { // Skip top nibble, which differs between rules. - std::string regex = StringPrintf("from all fwmark 0x[0-9a-f]+%x/.* lookup ", fwmark); + std::string regex = + StringPrintf("from all fwmark 0x(%x|[0-9a-f]+%04x)/.* lookup ", fwmark, fwmark); return countMatchingIpRules(regex); } -- 2.11.0