diff options
| author | 2019-09-18 11:31:13 -0700 | |
|---|---|---|
| committer | 2019-09-18 20:56:59 +0000 | |
| commit | 97ae0814c39b5e90c3444ba0260780441ca5bbfb (patch) | |
| tree | cdd5209cdbe92b7ff667016d4e7d5fc8bfb85c6c | |
| parent | 7c4334d25445d38ba42fb86b1fc3b89471df56ee (diff) | |
Fix log matching unit test bug
- Update matcher in TestUidFieldMatcher unit test to have correct atom
id
- Add atom id check in matchesSimple
Test: bit statsd_test:AtomMatcher.TestUidFieldMatcher
Bug: 141174720
Fix: 141174720
Change-Id: Icbfea7e33876dea36d68d3e3d064581c5a621a77
| -rw-r--r-- | cmds/statsd/src/matchers/matcher_util.cpp | 5 | ||||
| -rw-r--r-- | cmds/statsd/tests/LogEntryMatcher_test.cpp | 1 |
2 files changed, 4 insertions, 2 deletions
diff --git a/cmds/statsd/src/matchers/matcher_util.cpp b/cmds/statsd/src/matchers/matcher_util.cpp index 10ac4a182f87..476fae37899d 100644 --- a/cmds/statsd/src/matchers/matcher_util.cpp +++ b/cmds/statsd/src/matchers/matcher_util.cpp @@ -358,9 +358,10 @@ bool matchesSimple(const UidMap& uidMap, const FieldValueMatcher& matcher, bool matchesSimple(const UidMap& uidMap, const SimpleAtomMatcher& simpleMatcher, const LogEvent& event) { - if (simpleMatcher.field_value_matcher_size() <= 0) { - return event.GetTagId() == simpleMatcher.atom_id(); + if (event.GetTagId() != simpleMatcher.atom_id()) { + return false; } + for (const auto& matcher : simpleMatcher.field_value_matcher()) { if (!matchesSimple(uidMap, matcher, event.getValues(), 0, event.getValues().size(), 0)) { return false; diff --git a/cmds/statsd/tests/LogEntryMatcher_test.cpp b/cmds/statsd/tests/LogEntryMatcher_test.cpp index 70f0f6f75a59..441d3c896467 100644 --- a/cmds/statsd/tests/LogEntryMatcher_test.cpp +++ b/cmds/statsd/tests/LogEntryMatcher_test.cpp @@ -330,6 +330,7 @@ TEST(AtomMatcherTest, TestUidFieldMatcher) { EXPECT_FALSE(matchesSimple(uidMap, *simpleMatcher, event)); // Tag found in kAtomsWithUidField and has matching uid + simpleMatcher->set_atom_id(TAG_ID_2); EXPECT_TRUE(matchesSimple(uidMap, *simpleMatcher, event2)); // Tag found in kAtomsWithUidField but has non-matching uid |