index 698226e23db360ac792a9a4776821c71da20e0f6..b8b8d7d4ecb1f275e12a907cf3b8b51ac53be1d7 100644 (file)
int expected;
} golden_data[] = {
/* TODO: check the name of the expected hosts */
- { "host = 'a'", NULL, 1 },
- { "host = 'a'", "host = 'x'", 0 }, /* filter never matches */
- { "host = 'a'",
+ { "name = 'a'", NULL, 1 },
+ { "name = 'a'", "name = 'x'", 0 }, /* filter never matches */
+ { "name = 'a'",
"NOT attribute['x'] = ''", 1 }, /* filter always matches */
- { "host =~ 'a|b'", NULL, 2 },
- { "host =~ 'host'", NULL, 0 },
- { "host =~ '.'", NULL, 3 },
+ { "name =~ 'a|b'", NULL, 2 },
+ { "name =~ 'host'", NULL, 0 },
+ { "name =~ '.'", NULL, 3 },
+ { "ANY backend = 'backend'", NULL, 0 },
+ { "ALL backend = ''", NULL, 3 }, /* backend is empty */
+ { "backend = ['backend']", NULL, 0 },
+ { "backend != ['backend']", NULL, 3 },
+ { "backend < ['backend']", NULL, 3 },
+ { "backend <= ['backend']", NULL, 3 },
+ { "backend >= ['backend']", NULL, 0 },
+ { "backend > ['backend']", NULL, 0 },
{ "ANY metric = 'm1'", NULL, 2 },
- { "ANY metric= 'm1'", "host = 'x'", 0 }, /* filter never matches */
+ { "ANY metric= 'm1'", "name = 'x'", 0 }, /* filter never matches */
{ "ANY metric = 'm1'",
"NOT attribute['x'] = ''", 2 }, /* filter always matches */
{ "ANY metric =~ 'm'", NULL, 2 },
{ "ALL metric !~ 'm'", NULL, 1 },
{ "ANY metric =~ 'x'", NULL, 0 },
{ "ANY service = 's1'", NULL, 2 },
- { "ANY service = 's1'", "host = 'x'", 0 }, /* filter never matches */
+ { "ANY service = 's1'", "name = 'x'", 0 }, /* filter never matches */
{ "ANY service = 's1'",
"NOT attribute['x'] = ''", 2 }, /* filter always matches */
{ "ANY service =~ 's'", NULL, 2 },
{ "ANY service =~ 's'", "name !~ '1'", 2 },
{ "ANY service !~ 's'", NULL, 0 },
{ "ANY attribute = 'k1'", NULL, 2 },
- { "ANY attribute = 'k1'", "host = 'x'",0 }, /* filter never matches */
+ { "ANY attribute = 'k1'", "name = 'x'",0 }, /* filter never matches */
{ "ANY attribute = 'k1'",
"NOT attribute['x'] = ''", 2 }, /* filter always matches */
{ "ANY attribute =~ 'k'", NULL, 2 },
{ "ANY attribute = 'x'", NULL, 0 },
{ "ANY attribute =~ 'x'", NULL, 0 },
{ "ALL attribute = 'k1'", NULL, 2 },
+ { "host.name = 'a'", NULL, 1 },
+ { "host.attribute['k1'] =~ 'v1'",
+ NULL, 1 },
+ { "host.attribute['x1'] IS NULL",
+ NULL, 3 },
{ "attribute['k1'] = 'v1'", NULL, 1 },
{ "attribute['k1'] = 'v1'",
"name != 'k1'", 0 },
{ "attribute['k1'] =~ '^v1$'", NULL, 1 },
{ "attribute['k1'] =~ 'v'", NULL, 2 },
{ "attribute['k1'] =~ '1'", NULL, 1 },
- { "attribute['k1'] !~ 'v'", NULL, 1 },
+ { "attribute['k1'] !~ 'v'", NULL, 0 },
{ "attribute['k1'] = 'v2'", NULL, 1 },
{ "attribute['k1'] =~ 'v2'", NULL, 1 },
{ "attribute['x1'] =~ 'v'", NULL, 0 },
{ "attribute['x1'] =~ 'NULL'", NULL, 0 },
- { "attribute['x1'] !~ 'v'", NULL, 3 },
+ { "attribute['x1'] !~ 'v'", NULL, 0 },
{ "attribute['k1'] IS NULL", NULL, 1 },
{ "attribute['x1'] IS NULL", NULL, 3 },
{ "attribute['k1'] IS NOT NULL", NULL, 2 },
{ "attribute['k1'] != 'v1'", NULL, 1 },
{ "attribute['k1'] != 'v2'", NULL, 1 },
{ "ANY attribute != 'x' "
- "AND attribute['y'] !~ 'x'", NULL, 2 },
+ "AND attribute['k1'] !~ 'x'", NULL, 2 },
};
+ sdb_strbuf_t *errbuf = sdb_strbuf_create(64);
int check, n;
size_t i;
for (i = 0; i < SDB_STATIC_ARRAY_LEN(golden_data); ++i) {
sdb_store_matcher_t *m, *filter = NULL;
- m = sdb_fe_parse_matcher(golden_data[i].query, -1);
+ m = sdb_fe_parse_matcher(golden_data[i].query, -1, errbuf);
fail_unless(m != NULL,
- "sdb_fe_parse_matcher(%s, -1) = NULL; expected: <matcher>",
- golden_data[i].query);
+ "sdb_fe_parse_matcher(%s, -1) = NULL; expected: <matcher> "
+ "(parser error: %s)", golden_data[i].query,
+ sdb_strbuf_string(errbuf));
if (golden_data[i].filter) {
- filter = sdb_fe_parse_matcher(golden_data[i].filter, -1);
+ filter = sdb_fe_parse_matcher(golden_data[i].filter, -1, errbuf);
fail_unless(filter != NULL,
"sdb_fe_parse_matcher(%s, -1) = NULL; "
- "expected: <matcher>", golden_data[i].filter);
+ "expected: <matcher> (parser error: %s)",
+ golden_data[i].filter, sdb_strbuf_string(errbuf));
}
n = 0;
sdb_object_deref(SDB_OBJ(filter));
sdb_object_deref(SDB_OBJ(m));
}
+
+ sdb_strbuf_destroy(errbuf);
}
END_TEST