blob: 2b9528f7d1de862e1185f6b29898d987863e43f3 [file] [log] [blame]
David Chendd896942017-09-26 11:44:40 -07001// Copyright (C) 2017 The Android Open Source Project
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
Joe Onorato9fc9edf2017-10-15 20:08:52 -070015#include "frameworks/base/cmds/statsd/src/statsd_config.pb.h"
16#include "matchers/matcher_util.h"
Yao Chen8a8d16c2018-02-08 14:50:40 -080017#include "stats_log_util.h"
Joe Onorato9fc9edf2017-10-15 20:08:52 -070018#include "stats_util.h"
David Chendd896942017-09-26 11:44:40 -070019
Yao Chen44cf27c2017-09-14 22:32:50 -070020#include <gtest/gtest.h>
21#include <log/log_event_list.h>
22#include <log/log_read.h>
23#include <log/logprint.h>
David Chendd896942017-09-26 11:44:40 -070024
25#include <stdio.h>
26
27using namespace android::os::statsd;
28using std::unordered_map;
Yao Chencaf339d2017-10-06 16:01:10 -070029using std::vector;
David Chendd896942017-09-26 11:44:40 -070030
Yao Chen80235402017-11-13 20:42:25 -080031const int32_t TAG_ID = 123;
Joe Onoratoc4dfae52017-10-17 23:38:21 -070032const int FIELD_ID_1 = 1;
33const int FIELD_ID_2 = 2;
34const int FIELD_ID_3 = 2;
35
Yangster-mac20877162017-12-22 17:19:39 -080036const int ATTRIBUTION_UID_FIELD_ID = 1;
37const int ATTRIBUTION_TAG_FIELD_ID = 2;
38
Stefan Lafoncdb1a0e2017-09-27 20:24:15 -070039
David Chendd896942017-09-26 11:44:40 -070040#ifdef __ANDROID__
Stefan Lafonb8c9aa82017-12-03 14:27:25 -080041TEST(AtomMatcherTest, TestSimpleMatcher) {
Yangster-mac20877162017-12-22 17:19:39 -080042 UidMap uidMap;
43
David Chendd896942017-09-26 11:44:40 -070044 // Set up the matcher
Stefan Lafonb8c9aa82017-12-03 14:27:25 -080045 AtomMatcher matcher;
46 auto simpleMatcher = matcher.mutable_simple_atom_matcher();
Yangster-mac20877162017-12-22 17:19:39 -080047 simpleMatcher->set_atom_id(TAG_ID);
David Chendd896942017-09-26 11:44:40 -070048
Yao Chen93fe3a32017-11-02 13:52:59 -070049 LogEvent event(TAG_ID, 0);
Yangster-mac20877162017-12-22 17:19:39 -080050 EXPECT_TRUE(event.write(11));
David Chen1481fe12017-10-16 13:16:34 -070051 event.init();
Joe Onoratoc4dfae52017-10-17 23:38:21 -070052
53 // Test
Yangster-mac20877162017-12-22 17:19:39 -080054 EXPECT_TRUE(matchesSimple(uidMap, *simpleMatcher, event));
55
56 // Wrong tag id.
57 simpleMatcher->set_atom_id(TAG_ID + 1);
58 EXPECT_FALSE(matchesSimple(uidMap, *simpleMatcher, event));
David Chendd896942017-09-26 11:44:40 -070059}
60
Yangster-mac20877162017-12-22 17:19:39 -080061TEST(AtomMatcherTest, TestAttributionMatcher) {
62 UidMap uidMap;
Yao Chen9c1debe2018-02-19 14:39:19 -080063 AttributionNodeInternal attribution_node1;
Yangster-mac20877162017-12-22 17:19:39 -080064 attribution_node1.set_uid(1111);
65 attribution_node1.set_tag("location1");
66
Yao Chen9c1debe2018-02-19 14:39:19 -080067 AttributionNodeInternal attribution_node2;
Yangster-mac20877162017-12-22 17:19:39 -080068 attribution_node2.set_uid(2222);
69 attribution_node2.set_tag("location2");
70
Yao Chen9c1debe2018-02-19 14:39:19 -080071 AttributionNodeInternal attribution_node3;
Yangster-mac20877162017-12-22 17:19:39 -080072 attribution_node3.set_uid(3333);
73 attribution_node3.set_tag("location3");
Yao Chen9c1debe2018-02-19 14:39:19 -080074 std::vector<AttributionNodeInternal> attribution_nodes = {attribution_node1, attribution_node2,
75 attribution_node3};
David Chendd896942017-09-26 11:44:40 -070076
Joe Onoratoc4dfae52017-10-17 23:38:21 -070077 // Set up the event
Yao Chen93fe3a32017-11-02 13:52:59 -070078 LogEvent event(TAG_ID, 0);
Yangster-mac20877162017-12-22 17:19:39 -080079 event.write(attribution_nodes);
80 event.write("some value");
81 // Convert to a LogEvent
82 event.init();
83
84 // Set up the matcher
85 AtomMatcher matcher;
86 auto simpleMatcher = matcher.mutable_simple_atom_matcher();
87 simpleMatcher->set_atom_id(TAG_ID);
88
89 // Match first node.
90 auto attributionMatcher = simpleMatcher->add_field_value_matcher();
91 attributionMatcher->set_field(FIELD_ID_1);
92 attributionMatcher->set_position(Position::FIRST);
93 attributionMatcher->mutable_matches_tuple()->add_field_value_matcher()->set_field(
94 ATTRIBUTION_TAG_FIELD_ID);
95 attributionMatcher->mutable_matches_tuple()->mutable_field_value_matcher(0)->set_eq_string("tag");
96
97 auto fieldMatcher = simpleMatcher->add_field_value_matcher();
98 fieldMatcher->set_field(FIELD_ID_2);
99 fieldMatcher->set_eq_string("some value");
100
101 // Tag not matched.
102 EXPECT_FALSE(matchesSimple(uidMap, *simpleMatcher, event));
103 attributionMatcher->mutable_matches_tuple()->mutable_field_value_matcher(0)
104 ->set_eq_string("location3");
105 EXPECT_FALSE(matchesSimple(uidMap, *simpleMatcher, event));
106 attributionMatcher->mutable_matches_tuple()->mutable_field_value_matcher(0)
107 ->set_eq_string("location1");
108 EXPECT_TRUE(matchesSimple(uidMap, *simpleMatcher, event));
109
110 // Match last node.
111 attributionMatcher->set_position(Position::LAST);
112 EXPECT_FALSE(matchesSimple(uidMap, *simpleMatcher, event));
113 attributionMatcher->mutable_matches_tuple()->mutable_field_value_matcher(0)
114 ->set_eq_string("location3");
115 EXPECT_TRUE(matchesSimple(uidMap, *simpleMatcher, event));
116
117 // Match any node.
118 attributionMatcher->set_position(Position::ANY);
119 EXPECT_TRUE(matchesSimple(uidMap, *simpleMatcher, event));
120 attributionMatcher->mutable_matches_tuple()->mutable_field_value_matcher(0)
121 ->set_eq_string("location1");
122 EXPECT_TRUE(matchesSimple(uidMap, *simpleMatcher, event));
123 attributionMatcher->mutable_matches_tuple()->mutable_field_value_matcher(0)
124 ->set_eq_string("location2");
125 EXPECT_TRUE(matchesSimple(uidMap, *simpleMatcher, event));
126 attributionMatcher->mutable_matches_tuple()->mutable_field_value_matcher(0)
127 ->set_eq_string("location3");
128 EXPECT_TRUE(matchesSimple(uidMap, *simpleMatcher, event));
129 attributionMatcher->mutable_matches_tuple()->mutable_field_value_matcher(0)
130 ->set_eq_string("location4");
131 EXPECT_FALSE(matchesSimple(uidMap, *simpleMatcher, event));
132
133 // Attribution match but primitive field not match.
134 attributionMatcher->set_position(Position::ANY);
135 attributionMatcher->mutable_matches_tuple()->mutable_field_value_matcher(0)
136 ->set_eq_string("location2");
137 fieldMatcher->set_eq_string("wrong value");
138 EXPECT_FALSE(matchesSimple(uidMap, *simpleMatcher, event));
139
140 fieldMatcher->set_eq_string("some value");
141
142 // Uid match.
143 attributionMatcher->set_position(Position::ANY);
144 attributionMatcher->mutable_matches_tuple()->mutable_field_value_matcher(0)->set_field(
145 ATTRIBUTION_UID_FIELD_ID);
146 attributionMatcher->mutable_matches_tuple()->mutable_field_value_matcher(0)->set_eq_string("pkg0");
147 EXPECT_FALSE(matchesSimple(uidMap, *simpleMatcher, event));
148
David Chenbd125272018-04-04 19:02:50 -0700149 uidMap.updateMap(
150 1, {1111, 1111, 2222, 3333, 3333} /* uid list */, {1, 1, 2, 1, 2} /* version list */,
dwchen730403e2018-10-29 11:41:56 -0700151 {android::String16("v1"), android::String16("v1"), android::String16("v2"),
152 android::String16("v1"), android::String16("v2")},
David Chenbd125272018-04-04 19:02:50 -0700153 {android::String16("pkg0"), android::String16("pkg1"), android::String16("pkg1"),
dwchen730403e2018-10-29 11:41:56 -0700154 android::String16("Pkg2"), android::String16("PkG3")} /* package name list */,
155 {android::String16(""), android::String16(""), android::String16(""),
156 android::String16(""), android::String16("")});
Yangster-mac20877162017-12-22 17:19:39 -0800157
158 EXPECT_TRUE(matchesSimple(uidMap, *simpleMatcher, event));
159 attributionMatcher->mutable_matches_tuple()->mutable_field_value_matcher(0)
160 ->set_eq_string("pkg3");
161 EXPECT_TRUE(matchesSimple(uidMap, *simpleMatcher, event));
162 attributionMatcher->mutable_matches_tuple()->mutable_field_value_matcher(0)
163 ->set_eq_string("pkg2");
164 EXPECT_TRUE(matchesSimple(uidMap, *simpleMatcher, event));
165 attributionMatcher->mutable_matches_tuple()->mutable_field_value_matcher(0)
166 ->set_eq_string("pkg1");
167 EXPECT_TRUE(matchesSimple(uidMap, *simpleMatcher, event));
168 attributionMatcher->mutable_matches_tuple()->mutable_field_value_matcher(0)
169 ->set_eq_string("pkg0");
170 EXPECT_TRUE(matchesSimple(uidMap, *simpleMatcher, event));
171
172 attributionMatcher->set_position(Position::FIRST);
173 attributionMatcher->mutable_matches_tuple()->mutable_field_value_matcher(0)
174 ->set_eq_string("pkg0");
175 EXPECT_TRUE(matchesSimple(uidMap, *simpleMatcher, event));
176 attributionMatcher->mutable_matches_tuple()->mutable_field_value_matcher(0)
177 ->set_eq_string("pkg3");
178 EXPECT_FALSE(matchesSimple(uidMap, *simpleMatcher, event));
179 attributionMatcher->mutable_matches_tuple()->mutable_field_value_matcher(0)
180 ->set_eq_string("pkg2");
181 EXPECT_FALSE(matchesSimple(uidMap, *simpleMatcher, event));
182 attributionMatcher->mutable_matches_tuple()->mutable_field_value_matcher(0)
183 ->set_eq_string("pkg1");
184 EXPECT_TRUE(matchesSimple(uidMap, *simpleMatcher, event));
185
186 attributionMatcher->set_position(Position::LAST);
187 attributionMatcher->mutable_matches_tuple()->mutable_field_value_matcher(0)
188 ->set_eq_string("pkg0");
189 EXPECT_FALSE(matchesSimple(uidMap, *simpleMatcher, event));
190 attributionMatcher->mutable_matches_tuple()->mutable_field_value_matcher(0)
191 ->set_eq_string("pkg3");
192 EXPECT_TRUE(matchesSimple(uidMap, *simpleMatcher, event));
193 attributionMatcher->mutable_matches_tuple()->mutable_field_value_matcher(0)
194 ->set_eq_string("pkg2");
195 EXPECT_TRUE(matchesSimple(uidMap, *simpleMatcher, event));
196 attributionMatcher->mutable_matches_tuple()->mutable_field_value_matcher(0)
197 ->set_eq_string("pkg1");
198 EXPECT_FALSE(matchesSimple(uidMap, *simpleMatcher, event));
199
200 // Uid + tag.
201 attributionMatcher->set_position(Position::ANY);
202 attributionMatcher->mutable_matches_tuple()->add_field_value_matcher()->set_field(
203 ATTRIBUTION_TAG_FIELD_ID);
204 attributionMatcher->mutable_matches_tuple()->mutable_field_value_matcher(0)
205 ->set_eq_string("pkg0");
206 attributionMatcher->mutable_matches_tuple()->mutable_field_value_matcher(1)
207 ->set_eq_string("location1");
208 EXPECT_TRUE(matchesSimple(uidMap, *simpleMatcher, event));
209 attributionMatcher->mutable_matches_tuple()->mutable_field_value_matcher(0)
210 ->set_eq_string("pkg1");
211 attributionMatcher->mutable_matches_tuple()->mutable_field_value_matcher(1)
212 ->set_eq_string("location1");
213 EXPECT_TRUE(matchesSimple(uidMap, *simpleMatcher, event));
214 attributionMatcher->mutable_matches_tuple()->mutable_field_value_matcher(0)
215 ->set_eq_string("pkg1");
216 attributionMatcher->mutable_matches_tuple()->mutable_field_value_matcher(1)
217 ->set_eq_string("location2");
218 EXPECT_TRUE(matchesSimple(uidMap, *simpleMatcher, event));
219 attributionMatcher->mutable_matches_tuple()->mutable_field_value_matcher(0)
220 ->set_eq_string("pkg2");
221 attributionMatcher->mutable_matches_tuple()->mutable_field_value_matcher(1)
222 ->set_eq_string("location3");
223 EXPECT_TRUE(matchesSimple(uidMap, *simpleMatcher, event));
224 attributionMatcher->mutable_matches_tuple()->mutable_field_value_matcher(0)
225 ->set_eq_string("pkg3");
226 attributionMatcher->mutable_matches_tuple()->mutable_field_value_matcher(1)
227 ->set_eq_string("location3");
228 EXPECT_TRUE(matchesSimple(uidMap, *simpleMatcher, event));
229 attributionMatcher->mutable_matches_tuple()->mutable_field_value_matcher(0)
230 ->set_eq_string("pkg3");
231 attributionMatcher->mutable_matches_tuple()->mutable_field_value_matcher(1)
232 ->set_eq_string("location1");
233 EXPECT_FALSE(matchesSimple(uidMap, *simpleMatcher, event));
234
235 attributionMatcher->set_position(Position::FIRST);
236 attributionMatcher->mutable_matches_tuple()->mutable_field_value_matcher(0)
237 ->set_eq_string("pkg0");
238 attributionMatcher->mutable_matches_tuple()->mutable_field_value_matcher(1)
239 ->set_eq_string("location1");
240 EXPECT_TRUE(matchesSimple(uidMap, *simpleMatcher, event));
241 attributionMatcher->mutable_matches_tuple()->mutable_field_value_matcher(0)
242 ->set_eq_string("pkg1");
243 attributionMatcher->mutable_matches_tuple()->mutable_field_value_matcher(1)
244 ->set_eq_string("location1");
245 EXPECT_TRUE(matchesSimple(uidMap, *simpleMatcher, event));
246 attributionMatcher->mutable_matches_tuple()->mutable_field_value_matcher(0)
247 ->set_eq_string("pkg1");
248 attributionMatcher->mutable_matches_tuple()->mutable_field_value_matcher(1)
249 ->set_eq_string("location2");
250 EXPECT_FALSE(matchesSimple(uidMap, *simpleMatcher, event));
251 attributionMatcher->mutable_matches_tuple()->mutable_field_value_matcher(0)
252 ->set_eq_string("pkg2");
253 attributionMatcher->mutable_matches_tuple()->mutable_field_value_matcher(1)
254 ->set_eq_string("location3");
255 EXPECT_FALSE(matchesSimple(uidMap, *simpleMatcher, event));
256 attributionMatcher->mutable_matches_tuple()->mutable_field_value_matcher(0)
257 ->set_eq_string("pkg3");
258 attributionMatcher->mutable_matches_tuple()->mutable_field_value_matcher(1)
259 ->set_eq_string("location3");
260 EXPECT_FALSE(matchesSimple(uidMap, *simpleMatcher, event));
261 attributionMatcher->mutable_matches_tuple()->mutable_field_value_matcher(0)
262 ->set_eq_string("pkg3");
263 attributionMatcher->mutable_matches_tuple()->mutable_field_value_matcher(1)
264 ->set_eq_string("location1");
265 EXPECT_FALSE(matchesSimple(uidMap, *simpleMatcher, event));
266
267 attributionMatcher->set_position(Position::LAST);
268 attributionMatcher->mutable_matches_tuple()->mutable_field_value_matcher(0)
269 ->set_eq_string("pkg0");
270 attributionMatcher->mutable_matches_tuple()->mutable_field_value_matcher(1)
271 ->set_eq_string("location1");
272 EXPECT_FALSE(matchesSimple(uidMap, *simpleMatcher, event));
273 attributionMatcher->mutable_matches_tuple()->mutable_field_value_matcher(0)
274 ->set_eq_string("pkg1");
275 attributionMatcher->mutable_matches_tuple()->mutable_field_value_matcher(1)
276 ->set_eq_string("location1");
277 EXPECT_FALSE(matchesSimple(uidMap, *simpleMatcher, event));
278 attributionMatcher->mutable_matches_tuple()->mutable_field_value_matcher(0)
279 ->set_eq_string("pkg1");
280 attributionMatcher->mutable_matches_tuple()->mutable_field_value_matcher(1)
281 ->set_eq_string("location2");
282 EXPECT_FALSE(matchesSimple(uidMap, *simpleMatcher, event));
283 attributionMatcher->mutable_matches_tuple()->mutable_field_value_matcher(0)
284 ->set_eq_string("pkg2");
285 attributionMatcher->mutable_matches_tuple()->mutable_field_value_matcher(1)
286 ->set_eq_string("location3");
287 EXPECT_TRUE(matchesSimple(uidMap, *simpleMatcher, event));
288 attributionMatcher->mutable_matches_tuple()->mutable_field_value_matcher(0)
289 ->set_eq_string("pkg3");
290 attributionMatcher->mutable_matches_tuple()->mutable_field_value_matcher(1)
291 ->set_eq_string("location3");
292 EXPECT_TRUE(matchesSimple(uidMap, *simpleMatcher, event));
293 attributionMatcher->mutable_matches_tuple()->mutable_field_value_matcher(0)
294 ->set_eq_string("pkg3");
295 attributionMatcher->mutable_matches_tuple()->mutable_field_value_matcher(1)
296 ->set_eq_string("location1");
297 EXPECT_FALSE(matchesSimple(uidMap, *simpleMatcher, event));
298}
299
Yao Chen9b1140e2018-02-27 10:55:54 -0800300TEST(AtomMatcherTest, TestNeqAnyStringMatcher) {
301 UidMap uidMap;
302 uidMap.updateMap(
David Chenbd125272018-04-04 19:02:50 -0700303 1, {1111, 1111, 2222, 3333, 3333} /* uid list */, {1, 1, 2, 1, 2} /* version list */,
dwchen730403e2018-10-29 11:41:56 -0700304 {android::String16("v1"), android::String16("v1"), android::String16("v2"),
305 android::String16("v1"), android::String16("v2")},
Yao Chen9b1140e2018-02-27 10:55:54 -0800306 {android::String16("pkg0"), android::String16("pkg1"), android::String16("pkg1"),
dwchen730403e2018-10-29 11:41:56 -0700307 android::String16("Pkg2"), android::String16("PkG3")} /* package name list */,
308 {android::String16(""), android::String16(""), android::String16(""),
309 android::String16(""), android::String16("")});
Yao Chen9b1140e2018-02-27 10:55:54 -0800310
311 AttributionNodeInternal attribution_node1;
312 attribution_node1.set_uid(1111);
313 attribution_node1.set_tag("location1");
314
315 AttributionNodeInternal attribution_node2;
316 attribution_node2.set_uid(2222);
317 attribution_node2.set_tag("location2");
318
319 AttributionNodeInternal attribution_node3;
320 attribution_node3.set_uid(3333);
321 attribution_node3.set_tag("location3");
322
323 AttributionNodeInternal attribution_node4;
324 attribution_node4.set_uid(1066);
325 attribution_node4.set_tag("location3");
326 std::vector<AttributionNodeInternal> attribution_nodes = {attribution_node1, attribution_node2,
327 attribution_node3, attribution_node4};
328
329 // Set up the event
330 LogEvent event(TAG_ID, 0);
331 event.write(attribution_nodes);
332 event.write("some value");
333 // Convert to a LogEvent
334 event.init();
335
336 // Set up the matcher
337 AtomMatcher matcher;
338 auto simpleMatcher = matcher.mutable_simple_atom_matcher();
339 simpleMatcher->set_atom_id(TAG_ID);
340
341 // Match first node.
342 auto attributionMatcher = simpleMatcher->add_field_value_matcher();
343 attributionMatcher->set_field(FIELD_ID_1);
344 attributionMatcher->set_position(Position::FIRST);
345 attributionMatcher->mutable_matches_tuple()->add_field_value_matcher()->set_field(
346 ATTRIBUTION_UID_FIELD_ID);
347 auto neqStringList = attributionMatcher->mutable_matches_tuple()
348 ->mutable_field_value_matcher(0)
Yao Chend50f2ae2018-03-23 11:10:13 -0700349 ->mutable_neq_any_string();
Yao Chen9b1140e2018-02-27 10:55:54 -0800350 neqStringList->add_str_value("pkg2");
351 neqStringList->add_str_value("pkg3");
352
353 auto fieldMatcher = simpleMatcher->add_field_value_matcher();
354 fieldMatcher->set_field(FIELD_ID_2);
355 fieldMatcher->set_eq_string("some value");
356
357 EXPECT_TRUE(matchesSimple(uidMap, *simpleMatcher, event));
358
359 neqStringList->Clear();
360 neqStringList->add_str_value("pkg1");
361 neqStringList->add_str_value("pkg3");
362 EXPECT_FALSE(matchesSimple(uidMap, *simpleMatcher, event));
363
364 attributionMatcher->set_position(Position::ANY);
365 neqStringList->Clear();
366 neqStringList->add_str_value("maps.com");
367 EXPECT_TRUE(matchesSimple(uidMap, *simpleMatcher, event));
368
369 neqStringList->Clear();
370 neqStringList->add_str_value("PkG3");
371 EXPECT_TRUE(matchesSimple(uidMap, *simpleMatcher, event));
372
373 attributionMatcher->set_position(Position::LAST);
374 neqStringList->Clear();
375 neqStringList->add_str_value("AID_STATSD");
376 EXPECT_FALSE(matchesSimple(uidMap, *simpleMatcher, event));
377}
378
379TEST(AtomMatcherTest, TestEqAnyStringMatcher) {
380 UidMap uidMap;
381 uidMap.updateMap(
David Chenbd125272018-04-04 19:02:50 -0700382 1, {1111, 1111, 2222, 3333, 3333} /* uid list */, {1, 1, 2, 1, 2} /* version list */,
dwchen730403e2018-10-29 11:41:56 -0700383 {android::String16("v1"), android::String16("v1"), android::String16("v2"),
384 android::String16("v1"), android::String16("v2")},
Yao Chen9b1140e2018-02-27 10:55:54 -0800385 {android::String16("pkg0"), android::String16("pkg1"), android::String16("pkg1"),
dwchen730403e2018-10-29 11:41:56 -0700386 android::String16("Pkg2"), android::String16("PkG3")} /* package name list */,
387 {android::String16(""), android::String16(""), android::String16(""),
388 android::String16(""), android::String16("")});
Yao Chen9b1140e2018-02-27 10:55:54 -0800389
390 AttributionNodeInternal attribution_node1;
391 attribution_node1.set_uid(1067);
392 attribution_node1.set_tag("location1");
393
394 AttributionNodeInternal attribution_node2;
395 attribution_node2.set_uid(2222);
396 attribution_node2.set_tag("location2");
397
398 AttributionNodeInternal attribution_node3;
399 attribution_node3.set_uid(3333);
400 attribution_node3.set_tag("location3");
401
402 AttributionNodeInternal attribution_node4;
403 attribution_node4.set_uid(1066);
404 attribution_node4.set_tag("location3");
405 std::vector<AttributionNodeInternal> attribution_nodes = {attribution_node1, attribution_node2,
406 attribution_node3, attribution_node4};
407
408 // Set up the event
409 LogEvent event(TAG_ID, 0);
410 event.write(attribution_nodes);
411 event.write("some value");
412 // Convert to a LogEvent
413 event.init();
414
415 // Set up the matcher
416 AtomMatcher matcher;
417 auto simpleMatcher = matcher.mutable_simple_atom_matcher();
418 simpleMatcher->set_atom_id(TAG_ID);
419
420 // Match first node.
421 auto attributionMatcher = simpleMatcher->add_field_value_matcher();
422 attributionMatcher->set_field(FIELD_ID_1);
423 attributionMatcher->set_position(Position::FIRST);
424 attributionMatcher->mutable_matches_tuple()->add_field_value_matcher()->set_field(
425 ATTRIBUTION_UID_FIELD_ID);
426 auto eqStringList = attributionMatcher->mutable_matches_tuple()
427 ->mutable_field_value_matcher(0)
428 ->mutable_eq_any_string();
429 eqStringList->add_str_value("AID_ROOT");
430 eqStringList->add_str_value("AID_INCIDENTD");
431
432 auto fieldMatcher = simpleMatcher->add_field_value_matcher();
433 fieldMatcher->set_field(FIELD_ID_2);
434 fieldMatcher->set_eq_string("some value");
435
436 EXPECT_TRUE(matchesSimple(uidMap, *simpleMatcher, event));
437
438 attributionMatcher->set_position(Position::ANY);
439 eqStringList->Clear();
440 eqStringList->add_str_value("AID_STATSD");
441 EXPECT_TRUE(matchesSimple(uidMap, *simpleMatcher, event));
442
443 eqStringList->Clear();
444 eqStringList->add_str_value("pkg1");
445 EXPECT_TRUE(matchesSimple(uidMap, *simpleMatcher, event));
446
447 auto normalStringField = fieldMatcher->mutable_eq_any_string();
448 normalStringField->add_str_value("some value123");
449 normalStringField->add_str_value("some value");
450 EXPECT_TRUE(matchesSimple(uidMap, *simpleMatcher, event));
451
452 normalStringField->Clear();
453 normalStringField->add_str_value("AID_STATSD");
454 EXPECT_FALSE(matchesSimple(uidMap, *simpleMatcher, event));
455
456 eqStringList->Clear();
457 eqStringList->add_str_value("maps.com");
458 EXPECT_FALSE(matchesSimple(uidMap, *simpleMatcher, event));
459}
460
Yangster-mac20877162017-12-22 17:19:39 -0800461TEST(AtomMatcherTest, TestBoolMatcher) {
462 UidMap uidMap;
463 // Set up the matcher
464 AtomMatcher matcher;
465 auto simpleMatcher = matcher.mutable_simple_atom_matcher();
466 simpleMatcher->set_atom_id(TAG_ID);
467 auto keyValue1 = simpleMatcher->add_field_value_matcher();
468 keyValue1->set_field(FIELD_ID_1);
469 auto keyValue2 = simpleMatcher->add_field_value_matcher();
470 keyValue2->set_field(FIELD_ID_2);
471
472 // Set up the event
473 LogEvent event(TAG_ID, 0);
474 EXPECT_TRUE(event.write(true));
475 EXPECT_TRUE(event.write(false));
Joe Onoratoc4dfae52017-10-17 23:38:21 -0700476 // Convert to a LogEvent
David Chen1481fe12017-10-16 13:16:34 -0700477 event.init();
David Chendd896942017-09-26 11:44:40 -0700478
Joe Onoratoc4dfae52017-10-17 23:38:21 -0700479 // Test
480 keyValue1->set_eq_bool(true);
481 keyValue2->set_eq_bool(false);
Yangster-mac20877162017-12-22 17:19:39 -0800482 EXPECT_TRUE(matchesSimple(uidMap, *simpleMatcher, event));
David Chendd896942017-09-26 11:44:40 -0700483
Joe Onoratoc4dfae52017-10-17 23:38:21 -0700484 keyValue1->set_eq_bool(false);
485 keyValue2->set_eq_bool(false);
Yangster-mac20877162017-12-22 17:19:39 -0800486 EXPECT_FALSE(matchesSimple(uidMap, *simpleMatcher, event));
Joe Onoratoc4dfae52017-10-17 23:38:21 -0700487
Yangster-mac20877162017-12-22 17:19:39 -0800488 keyValue1->set_eq_bool(false);
489 keyValue2->set_eq_bool(true);
490 EXPECT_FALSE(matchesSimple(uidMap, *simpleMatcher, event));
Joe Onoratoc4dfae52017-10-17 23:38:21 -0700491
492 keyValue1->set_eq_bool(true);
493 keyValue2->set_eq_bool(true);
Yangster-mac20877162017-12-22 17:19:39 -0800494 EXPECT_FALSE(matchesSimple(uidMap, *simpleMatcher, event));
David Chendd896942017-09-26 11:44:40 -0700495}
496
Stefan Lafonb8c9aa82017-12-03 14:27:25 -0800497TEST(AtomMatcherTest, TestStringMatcher) {
Yangster-mac20877162017-12-22 17:19:39 -0800498 UidMap uidMap;
David Chendd896942017-09-26 11:44:40 -0700499 // Set up the matcher
Stefan Lafonb8c9aa82017-12-03 14:27:25 -0800500 AtomMatcher matcher;
501 auto simpleMatcher = matcher.mutable_simple_atom_matcher();
Yangster-mac20877162017-12-22 17:19:39 -0800502 simpleMatcher->set_atom_id(TAG_ID);
503 auto keyValue = simpleMatcher->add_field_value_matcher();
504 keyValue->set_field(FIELD_ID_1);
Joe Onoratoc4dfae52017-10-17 23:38:21 -0700505 keyValue->set_eq_string("some value");
David Chendd896942017-09-26 11:44:40 -0700506
Joe Onoratoc4dfae52017-10-17 23:38:21 -0700507 // Set up the event
Yao Chen93fe3a32017-11-02 13:52:59 -0700508 LogEvent event(TAG_ID, 0);
Yao Chen80235402017-11-13 20:42:25 -0800509 event.write("some value");
Joe Onoratoc4dfae52017-10-17 23:38:21 -0700510 // Convert to a LogEvent
David Chen1481fe12017-10-16 13:16:34 -0700511 event.init();
David Chendd896942017-09-26 11:44:40 -0700512
Joe Onoratoc4dfae52017-10-17 23:38:21 -0700513 // Test
Yangster-mac20877162017-12-22 17:19:39 -0800514 EXPECT_TRUE(matchesSimple(uidMap, *simpleMatcher, event));
David Chendd896942017-09-26 11:44:40 -0700515}
516
Stefan Lafonb8c9aa82017-12-03 14:27:25 -0800517TEST(AtomMatcherTest, TestMultiFieldsMatcher) {
Yangster-mac20877162017-12-22 17:19:39 -0800518 UidMap uidMap;
Yao Chend41c4222017-11-15 19:26:14 -0800519 // Set up the matcher
Stefan Lafonb8c9aa82017-12-03 14:27:25 -0800520 AtomMatcher matcher;
521 auto simpleMatcher = matcher.mutable_simple_atom_matcher();
Yangster-mac20877162017-12-22 17:19:39 -0800522 simpleMatcher->set_atom_id(TAG_ID);
523 auto keyValue1 = simpleMatcher->add_field_value_matcher();
524 keyValue1->set_field(FIELD_ID_1);
525 auto keyValue2 = simpleMatcher->add_field_value_matcher();
526 keyValue2->set_field(FIELD_ID_2);
Yao Chend41c4222017-11-15 19:26:14 -0800527
528 // Set up the event
529 LogEvent event(TAG_ID, 0);
Yao Chen80235402017-11-13 20:42:25 -0800530 event.write(2);
531 event.write(3);
Yao Chend41c4222017-11-15 19:26:14 -0800532
533 // Convert to a LogEvent
534 event.init();
535
536 // Test
537 keyValue1->set_eq_int(2);
538 keyValue2->set_eq_int(3);
Yangster-mac20877162017-12-22 17:19:39 -0800539 EXPECT_TRUE(matchesSimple(uidMap, *simpleMatcher, event));
Yao Chend41c4222017-11-15 19:26:14 -0800540
541 keyValue1->set_eq_int(2);
542 keyValue2->set_eq_int(4);
Yangster-mac20877162017-12-22 17:19:39 -0800543 EXPECT_FALSE(matchesSimple(uidMap, *simpleMatcher, event));
Yao Chend41c4222017-11-15 19:26:14 -0800544
545 keyValue1->set_eq_int(4);
546 keyValue2->set_eq_int(3);
Yangster-mac20877162017-12-22 17:19:39 -0800547 EXPECT_FALSE(matchesSimple(uidMap, *simpleMatcher, event));
Yao Chend41c4222017-11-15 19:26:14 -0800548}
549
Stefan Lafonb8c9aa82017-12-03 14:27:25 -0800550TEST(AtomMatcherTest, TestIntComparisonMatcher) {
Yangster-mac20877162017-12-22 17:19:39 -0800551 UidMap uidMap;
David Chendd896942017-09-26 11:44:40 -0700552 // Set up the matcher
Stefan Lafonb8c9aa82017-12-03 14:27:25 -0800553 AtomMatcher matcher;
554 auto simpleMatcher = matcher.mutable_simple_atom_matcher();
Yao Chen729093d2017-10-16 10:33:26 -0700555
Yangster-mac20877162017-12-22 17:19:39 -0800556 simpleMatcher->set_atom_id(TAG_ID);
557 auto keyValue = simpleMatcher->add_field_value_matcher();
558 keyValue->set_field(FIELD_ID_1);
David Chendd896942017-09-26 11:44:40 -0700559
Joe Onoratoc4dfae52017-10-17 23:38:21 -0700560 // Set up the event
Yao Chen93fe3a32017-11-02 13:52:59 -0700561 LogEvent event(TAG_ID, 0);
Yao Chen80235402017-11-13 20:42:25 -0800562 event.write(11);
David Chen1481fe12017-10-16 13:16:34 -0700563 event.init();
Joe Onoratoc4dfae52017-10-17 23:38:21 -0700564
565 // Test
566
567 // eq_int
568 keyValue->set_eq_int(10);
Yangster-mac20877162017-12-22 17:19:39 -0800569 EXPECT_FALSE(matchesSimple(uidMap, *simpleMatcher, event));
Joe Onoratoc4dfae52017-10-17 23:38:21 -0700570 keyValue->set_eq_int(11);
Yangster-mac20877162017-12-22 17:19:39 -0800571 EXPECT_TRUE(matchesSimple(uidMap, *simpleMatcher, event));
Joe Onoratoc4dfae52017-10-17 23:38:21 -0700572 keyValue->set_eq_int(12);
Yangster-mac20877162017-12-22 17:19:39 -0800573 EXPECT_FALSE(matchesSimple(uidMap, *simpleMatcher, event));
Joe Onoratoc4dfae52017-10-17 23:38:21 -0700574
575 // lt_int
David Chendd896942017-09-26 11:44:40 -0700576 keyValue->set_lt_int(10);
Yangster-mac20877162017-12-22 17:19:39 -0800577 EXPECT_FALSE(matchesSimple(uidMap, *simpleMatcher, event));
Joe Onoratoc4dfae52017-10-17 23:38:21 -0700578 keyValue->set_lt_int(11);
Yangster-mac20877162017-12-22 17:19:39 -0800579 EXPECT_FALSE(matchesSimple(uidMap, *simpleMatcher, event));
Joe Onoratoc4dfae52017-10-17 23:38:21 -0700580 keyValue->set_lt_int(12);
Yangster-mac20877162017-12-22 17:19:39 -0800581 EXPECT_TRUE(matchesSimple(uidMap, *simpleMatcher, event));
David Chendd896942017-09-26 11:44:40 -0700582
Joe Onoratoc4dfae52017-10-17 23:38:21 -0700583 // lte_int
David Chendd896942017-09-26 11:44:40 -0700584 keyValue->set_lte_int(10);
Yangster-mac20877162017-12-22 17:19:39 -0800585 EXPECT_FALSE(matchesSimple(uidMap, *simpleMatcher, event));
Joe Onoratoc4dfae52017-10-17 23:38:21 -0700586 keyValue->set_lte_int(11);
Yangster-mac20877162017-12-22 17:19:39 -0800587 EXPECT_TRUE(matchesSimple(uidMap, *simpleMatcher, event));
Joe Onoratoc4dfae52017-10-17 23:38:21 -0700588 keyValue->set_lte_int(12);
Yangster-mac20877162017-12-22 17:19:39 -0800589 EXPECT_TRUE(matchesSimple(uidMap, *simpleMatcher, event));
David Chendd896942017-09-26 11:44:40 -0700590
Joe Onoratoc4dfae52017-10-17 23:38:21 -0700591 // gt_int
592 keyValue->set_gt_int(10);
Yangster-mac20877162017-12-22 17:19:39 -0800593 EXPECT_TRUE(matchesSimple(uidMap, *simpleMatcher, event));
Joe Onoratoc4dfae52017-10-17 23:38:21 -0700594 keyValue->set_gt_int(11);
Yangster-mac20877162017-12-22 17:19:39 -0800595 EXPECT_FALSE(matchesSimple(uidMap, *simpleMatcher, event));
Joe Onoratoc4dfae52017-10-17 23:38:21 -0700596 keyValue->set_gt_int(12);
Yangster-mac20877162017-12-22 17:19:39 -0800597 EXPECT_FALSE(matchesSimple(uidMap, *simpleMatcher, event));
Joe Onoratoc4dfae52017-10-17 23:38:21 -0700598
599 // gte_int
David Chendd896942017-09-26 11:44:40 -0700600 keyValue->set_gte_int(10);
Yangster-mac20877162017-12-22 17:19:39 -0800601 EXPECT_TRUE(matchesSimple(uidMap, *simpleMatcher, event));
Joe Onoratoc4dfae52017-10-17 23:38:21 -0700602 keyValue->set_gte_int(11);
Yangster-mac20877162017-12-22 17:19:39 -0800603 EXPECT_TRUE(matchesSimple(uidMap, *simpleMatcher, event));
Joe Onoratoc4dfae52017-10-17 23:38:21 -0700604 keyValue->set_gte_int(12);
Yangster-mac20877162017-12-22 17:19:39 -0800605 EXPECT_FALSE(matchesSimple(uidMap, *simpleMatcher, event));
David Chendd896942017-09-26 11:44:40 -0700606}
607
Stefan Lafonb8c9aa82017-12-03 14:27:25 -0800608TEST(AtomMatcherTest, TestFloatComparisonMatcher) {
Yangster-mac20877162017-12-22 17:19:39 -0800609 UidMap uidMap;
David Chendd896942017-09-26 11:44:40 -0700610 // Set up the matcher
Stefan Lafonb8c9aa82017-12-03 14:27:25 -0800611 AtomMatcher matcher;
612 auto simpleMatcher = matcher.mutable_simple_atom_matcher();
Yangster-mac20877162017-12-22 17:19:39 -0800613 simpleMatcher->set_atom_id(TAG_ID);
Yao Chen729093d2017-10-16 10:33:26 -0700614
Yangster-mac20877162017-12-22 17:19:39 -0800615 auto keyValue = simpleMatcher->add_field_value_matcher();
616 keyValue->set_field(FIELD_ID_1);
David Chendd896942017-09-26 11:44:40 -0700617
Yao Chen80235402017-11-13 20:42:25 -0800618 LogEvent event1(TAG_ID, 0);
David Chendd896942017-09-26 11:44:40 -0700619 keyValue->set_lt_float(10.0);
Yao Chen80235402017-11-13 20:42:25 -0800620 event1.write(10.1f);
621 event1.init();
Yangster-mac20877162017-12-22 17:19:39 -0800622 EXPECT_FALSE(matchesSimple(uidMap, *simpleMatcher, event1));
David Chendd896942017-09-26 11:44:40 -0700623
Yao Chen80235402017-11-13 20:42:25 -0800624 LogEvent event2(TAG_ID, 0);
625 event2.write(9.9f);
626 event2.init();
Yangster-mac20877162017-12-22 17:19:39 -0800627 EXPECT_TRUE(matchesSimple(uidMap, *simpleMatcher, event2));
Yao Chen80235402017-11-13 20:42:25 -0800628
629 LogEvent event3(TAG_ID, 0);
630 event3.write(10.1f);
631 event3.init();
David Chendd896942017-09-26 11:44:40 -0700632 keyValue->set_gt_float(10.0);
Yangster-mac20877162017-12-22 17:19:39 -0800633 EXPECT_TRUE(matchesSimple(uidMap, *simpleMatcher, event3));
Yao Chen80235402017-11-13 20:42:25 -0800634
635 LogEvent event4(TAG_ID, 0);
636 event4.write(9.9f);
637 event4.init();
Yangster-mac20877162017-12-22 17:19:39 -0800638 EXPECT_FALSE(matchesSimple(uidMap, *simpleMatcher, event4));
David Chendd896942017-09-26 11:44:40 -0700639}
640
641// Helper for the composite matchers.
Stefan Lafonb8c9aa82017-12-03 14:27:25 -0800642void addSimpleMatcher(SimpleAtomMatcher* simpleMatcher, int tag, int key, int val) {
Yangster-mac20877162017-12-22 17:19:39 -0800643 simpleMatcher->set_atom_id(tag);
644 auto keyValue = simpleMatcher->add_field_value_matcher();
645 keyValue->set_field(key);
David Chendd896942017-09-26 11:44:40 -0700646 keyValue->set_eq_int(val);
647}
648
Stefan Lafonb8c9aa82017-12-03 14:27:25 -0800649TEST(AtomMatcherTest, TestAndMatcher) {
David Chendd896942017-09-26 11:44:40 -0700650 // Set up the matcher
Yao Chencaf339d2017-10-06 16:01:10 -0700651 LogicalOperation operation = LogicalOperation::AND;
David Chendd896942017-09-26 11:44:40 -0700652
Yao Chencaf339d2017-10-06 16:01:10 -0700653 vector<int> children;
654 children.push_back(0);
655 children.push_back(1);
656 children.push_back(2);
David Chendd896942017-09-26 11:44:40 -0700657
Yao Chencaf339d2017-10-06 16:01:10 -0700658 vector<MatchingState> matcherResults;
659 matcherResults.push_back(MatchingState::kMatched);
660 matcherResults.push_back(MatchingState::kNotMatched);
661 matcherResults.push_back(MatchingState::kMatched);
David Chendd896942017-09-26 11:44:40 -0700662
Yao Chencaf339d2017-10-06 16:01:10 -0700663 EXPECT_FALSE(combinationMatch(children, operation, matcherResults));
664
665 matcherResults.clear();
666 matcherResults.push_back(MatchingState::kMatched);
667 matcherResults.push_back(MatchingState::kMatched);
668 matcherResults.push_back(MatchingState::kMatched);
669
670 EXPECT_TRUE(combinationMatch(children, operation, matcherResults));
David Chendd896942017-09-26 11:44:40 -0700671}
672
Stefan Lafonb8c9aa82017-12-03 14:27:25 -0800673TEST(AtomMatcherTest, TestOrMatcher) {
David Chendd896942017-09-26 11:44:40 -0700674 // Set up the matcher
Yao Chencaf339d2017-10-06 16:01:10 -0700675 LogicalOperation operation = LogicalOperation::OR;
David Chendd896942017-09-26 11:44:40 -0700676
Yao Chencaf339d2017-10-06 16:01:10 -0700677 vector<int> children;
678 children.push_back(0);
679 children.push_back(1);
680 children.push_back(2);
David Chendd896942017-09-26 11:44:40 -0700681
Yao Chencaf339d2017-10-06 16:01:10 -0700682 vector<MatchingState> matcherResults;
683 matcherResults.push_back(MatchingState::kMatched);
684 matcherResults.push_back(MatchingState::kNotMatched);
685 matcherResults.push_back(MatchingState::kMatched);
David Chendd896942017-09-26 11:44:40 -0700686
Yao Chencaf339d2017-10-06 16:01:10 -0700687 EXPECT_TRUE(combinationMatch(children, operation, matcherResults));
688
689 matcherResults.clear();
690 matcherResults.push_back(MatchingState::kNotMatched);
691 matcherResults.push_back(MatchingState::kNotMatched);
692 matcherResults.push_back(MatchingState::kNotMatched);
693
694 EXPECT_FALSE(combinationMatch(children, operation, matcherResults));
David Chendd896942017-09-26 11:44:40 -0700695}
696
Stefan Lafonb8c9aa82017-12-03 14:27:25 -0800697TEST(AtomMatcherTest, TestNotMatcher) {
David Chendd896942017-09-26 11:44:40 -0700698 // Set up the matcher
Yao Chencaf339d2017-10-06 16:01:10 -0700699 LogicalOperation operation = LogicalOperation::NOT;
David Chendd896942017-09-26 11:44:40 -0700700
Yao Chencaf339d2017-10-06 16:01:10 -0700701 vector<int> children;
702 children.push_back(0);
David Chendd896942017-09-26 11:44:40 -0700703
Yao Chencaf339d2017-10-06 16:01:10 -0700704 vector<MatchingState> matcherResults;
705 matcherResults.push_back(MatchingState::kMatched);
David Chendd896942017-09-26 11:44:40 -0700706
Yao Chencaf339d2017-10-06 16:01:10 -0700707 EXPECT_FALSE(combinationMatch(children, operation, matcherResults));
708
709 matcherResults.clear();
710 matcherResults.push_back(MatchingState::kNotMatched);
711 EXPECT_TRUE(combinationMatch(children, operation, matcherResults));
David Chendd896942017-09-26 11:44:40 -0700712}
713
Stefan Lafonb8c9aa82017-12-03 14:27:25 -0800714TEST(AtomMatcherTest, TestNandMatcher) {
David Chendd896942017-09-26 11:44:40 -0700715 // Set up the matcher
Yao Chencaf339d2017-10-06 16:01:10 -0700716 LogicalOperation operation = LogicalOperation::NAND;
David Chendd896942017-09-26 11:44:40 -0700717
Yao Chencaf339d2017-10-06 16:01:10 -0700718 vector<int> children;
719 children.push_back(0);
720 children.push_back(1);
David Chendd896942017-09-26 11:44:40 -0700721
Yao Chencaf339d2017-10-06 16:01:10 -0700722 vector<MatchingState> matcherResults;
723 matcherResults.push_back(MatchingState::kMatched);
724 matcherResults.push_back(MatchingState::kNotMatched);
David Chendd896942017-09-26 11:44:40 -0700725
Yao Chencaf339d2017-10-06 16:01:10 -0700726 EXPECT_TRUE(combinationMatch(children, operation, matcherResults));
727
728 matcherResults.clear();
729 matcherResults.push_back(MatchingState::kNotMatched);
730 matcherResults.push_back(MatchingState::kNotMatched);
731 EXPECT_TRUE(combinationMatch(children, operation, matcherResults));
732
733 matcherResults.clear();
734 matcherResults.push_back(MatchingState::kMatched);
735 matcherResults.push_back(MatchingState::kMatched);
736 EXPECT_FALSE(combinationMatch(children, operation, matcherResults));
David Chendd896942017-09-26 11:44:40 -0700737}
738
Stefan Lafonb8c9aa82017-12-03 14:27:25 -0800739TEST(AtomMatcherTest, TestNorMatcher) {
David Chendd896942017-09-26 11:44:40 -0700740 // Set up the matcher
Yao Chencaf339d2017-10-06 16:01:10 -0700741 LogicalOperation operation = LogicalOperation::NOR;
David Chendd896942017-09-26 11:44:40 -0700742
Yao Chencaf339d2017-10-06 16:01:10 -0700743 vector<int> children;
744 children.push_back(0);
745 children.push_back(1);
David Chendd896942017-09-26 11:44:40 -0700746
Yao Chencaf339d2017-10-06 16:01:10 -0700747 vector<MatchingState> matcherResults;
748 matcherResults.push_back(MatchingState::kMatched);
749 matcherResults.push_back(MatchingState::kNotMatched);
David Chendd896942017-09-26 11:44:40 -0700750
Yao Chencaf339d2017-10-06 16:01:10 -0700751 EXPECT_FALSE(combinationMatch(children, operation, matcherResults));
David Chendd896942017-09-26 11:44:40 -0700752
Yao Chencaf339d2017-10-06 16:01:10 -0700753 matcherResults.clear();
754 matcherResults.push_back(MatchingState::kNotMatched);
755 matcherResults.push_back(MatchingState::kNotMatched);
756 EXPECT_TRUE(combinationMatch(children, operation, matcherResults));
David Chendd896942017-09-26 11:44:40 -0700757
Yao Chencaf339d2017-10-06 16:01:10 -0700758 matcherResults.clear();
759 matcherResults.push_back(MatchingState::kMatched);
760 matcherResults.push_back(MatchingState::kMatched);
761 EXPECT_FALSE(combinationMatch(children, operation, matcherResults));
David Chendd896942017-09-26 11:44:40 -0700762}
David Chendd896942017-09-26 11:44:40 -0700763#else
Yao Chen44cf27c2017-09-14 22:32:50 -0700764GTEST_LOG_(INFO) << "This test does nothing.\n";
David Chendd896942017-09-26 11:44:40 -0700765#endif