index 1d4bf7aa267bda7a358de48ce58dd788391691aa..d6a71e566aea8e0919819984cec6814d55ef0c82 100644 (file)
const char *obj_type;
const char *attr;
const char *op;
const char *obj_type;
const char *attr;
const char *op;
- const sdb_data_t value;
+ const sdb_data_t *value;
int expected;
} golden_data[] = {
int expected;
} golden_data[] = {
- { "host", "name", "=", hostname, MATCHER_NAME },
- { "host", "name", "!=", hostname, MATCHER_NOT },
- { "host", "name", "=~", hostname, MATCHER_NAME },
- { "host", "name", "!~", hostname, MATCHER_NOT },
- { "host", "attr", "=", hostname, -1 },
- { "host", "attr", "!=", hostname, -1 },
- { "host", "name", "&^", hostname, -1 },
- { "host", "name", "<", hostname, -1 },
- { "host", "name", "<=", hostname, -1 },
- { "host", "name", ">=", hostname, -1 },
- { "host", "name", ">", hostname, -1 },
- { "service", "name", "=", srvname, MATCHER_NAME },
- { "service", "name", "!=", srvname, MATCHER_NOT },
- { "service", "name", "=~", srvname, MATCHER_NAME },
- { "service", "name", "!~", srvname, MATCHER_NOT },
- { "service", "attr", "=", srvname, -1 },
- { "service", "attr", "!=", srvname, -1 },
- { "service", "name", "&^", srvname, -1 },
- { "service", "name", "<", srvname, -1 },
- { "service", "name", "<=", srvname, -1 },
- { "service", "name", ">=", srvname, -1 },
- { "service", "name", ">", srvname, -1 },
- { "attribute", "name", "=", attrname, MATCHER_NAME },
- { "attribute", "name", "!=", attrname, MATCHER_NOT },
- { "attribute", "name", "=~", attrname, MATCHER_NAME },
- { "attribute", "name", "!~", attrname, MATCHER_NOT },
- { "attribute", "name", "<", attrname, -1 },
- { "attribute", "name", "<=", attrname, -1 },
- { "attribute", "name", ">=", attrname, -1 },
- { "attribute", "name", ">", attrname, -1 },
- { "attribute", "attr", "=", attrname, MATCHER_ATTR },
- { "attribute", "attr", "!=", attrname, MATCHER_NOT },
- { "attribute", "attr", "=~", attrname, MATCHER_ATTR },
- { "attribute", "attr", "!~", attrname, MATCHER_NOT },
- { "attribute", "attr", "&^", attrname, -1 },
- { "attribute", "attr", "<", attrname, MATCHER_LT },
- { "attribute", "attr", "<=", attrname, MATCHER_LE },
-/* { "attribute", "attr", "=", attrname, MATCHER_EQ }, */
- { "attribute", "attr", ">=", attrname, MATCHER_GE },
- { "attribute", "attr", ">", attrname, MATCHER_GT },
- { "foo", "name", "=", attrname, -1 },
- { "foo", "attr", "=", attrname, -1 },
+ { "host", "name", "=", &hostname, MATCHER_NAME },
+ { "host", "name", "!=", &hostname, MATCHER_NOT },
+ { "host", "name", "=~", &hostname, MATCHER_NAME },
+ { "host", "name", "!~", &hostname, MATCHER_NOT },
+ { "host", "attr", "=", &hostname, -1 },
+ { "host", "attr", "!=", &hostname, -1 },
+ { "host", "name", "&^", &hostname, -1 },
+ { "host", "name", "<", &hostname, -1 },
+ { "host", "name", "<=", &hostname, -1 },
+ { "host", "name", ">=", &hostname, -1 },
+ { "host", "name", ">", &hostname, -1 },
+ { "service", "name", "=", &srvname, MATCHER_NAME },
+ { "service", "name", "!=", &srvname, MATCHER_NOT },
+ { "service", "name", "=~", &srvname, MATCHER_NAME },
+ { "service", "name", "!~", &srvname, MATCHER_NOT },
+ { "service", "attr", "=", &srvname, -1 },
+ { "service", "attr", "!=", &srvname, -1 },
+ { "service", "name", "&^", &srvname, -1 },
+ { "service", "name", "<", &srvname, -1 },
+ { "service", "name", "<=", &srvname, -1 },
+ { "service", "name", ">=", &srvname, -1 },
+ { "service", "name", ">", &srvname, -1 },
+ { "attribute", "name", "=", &attrname, MATCHER_NAME },
+ { "attribute", "name", "!=", &attrname, MATCHER_NOT },
+ { "attribute", "name", "=~", &attrname, MATCHER_NAME },
+ { "attribute", "name", "!~", &attrname, MATCHER_NOT },
+ { "attribute", "name", "<", &attrname, -1 },
+ { "attribute", "name", "<=", &attrname, -1 },
+ { "attribute", "name", ">=", &attrname, -1 },
+ { "attribute", "name", ">", &attrname, -1 },
+ { "attribute", "attr", "=", &attrname, MATCHER_ATTR },
+ { "attribute", "attr", "!=", &attrname, MATCHER_NOT },
+ { "attribute", "attr", "=~", &attrname, MATCHER_ATTR },
+ { "attribute", "attr", "!~", &attrname, MATCHER_NOT },
+ { "attribute", "attr", "&^", &attrname, -1 },
+ { "attribute", "attr", "<", &attrname, MATCHER_LT },
+ { "attribute", "attr", "<=", &attrname, MATCHER_LE },
+/* { "attribute", "attr", "=", &attrname, MATCHER_EQ }, */
+ { "attribute", "attr", ">=", &attrname, MATCHER_GE },
+ { "attribute", "attr", ">", &attrname, MATCHER_GT },
+ { "attribute", "attr", "IS", NULL, MATCHER_ISNULL },
+ { "foo", "name", "=", &attrname, -1 },
+ { "foo", "attr", "=", &attrname, -1 },
};
for (i = 0; i < SDB_STATIC_ARRAY_LEN(golden_data); ++i) {
};
for (i = 0; i < SDB_STATIC_ARRAY_LEN(golden_data); ++i) {
check = sdb_store_matcher_parse_cmp(golden_data[i].obj_type,
golden_data[i].attr, golden_data[i].op,
check = sdb_store_matcher_parse_cmp(golden_data[i].obj_type,
golden_data[i].attr, golden_data[i].op,
- &golden_data[i].value);
+ golden_data[i].value);
- if (sdb_data_format(&golden_data[i].value,
+ if (sdb_data_format(golden_data[i].value,
buf, sizeof(buf), SDB_UNQUOTED) < 0)
snprintf(buf, sizeof(buf), "ERR");
buf, sizeof(buf), SDB_UNQUOTED) < 0)
snprintf(buf, sizeof(buf), "ERR");
int expected;
const char *tostring_re;
} golden_data[] = {
int expected;
const char *tostring_re;
} golden_data[] = {
- { "host.name = 'a'", 1,
+ { "host.name = 'a'", 1,
"OBJ\\[host\\]\\{ NAME\\{ 'a', \\(nil\\) \\} \\}" },
"OBJ\\[host\\]\\{ NAME\\{ 'a', \\(nil\\) \\} \\}" },
- { "host.name =~ 'a|b'", 2,
+ { "host.name =~ 'a|b'", 2,
"OBJ\\[host\\]\\{ NAME\\{ NULL, "PTR_RE" \\} \\}" },
"OBJ\\[host\\]\\{ NAME\\{ NULL, "PTR_RE" \\} \\}" },
- { "host.name =~ 'host'", 0,
+ { "host.name =~ 'host'", 0,
"OBJ\\[host\\]\\{ NAME\\{ NULL, "PTR_RE" \\} \\}" },
"OBJ\\[host\\]\\{ NAME\\{ NULL, "PTR_RE" \\} \\}" },
- { "host.name =~ '.'", 3,
+ { "host.name =~ '.'", 3,
"OBJ\\[host\\]\\{ NAME\\{ NULL, "PTR_RE" \\} \\}" },
"OBJ\\[host\\]\\{ NAME\\{ NULL, "PTR_RE" \\} \\}" },
- { "service.name = 's1'", 2,
+ { "service.name = 's1'", 2,
"OBJ\\[service\\]\\{ NAME\\{ 's1', \\(nil\\) } \\}" },
"OBJ\\[service\\]\\{ NAME\\{ 's1', \\(nil\\) } \\}" },
- { "service.name =~ 's'", 2,
+ { "service.name =~ 's'", 2,
"OBJ\\[service\\]\\{ NAME\\{ NULL, "PTR_RE" } \\}" },
"OBJ\\[service\\]\\{ NAME\\{ NULL, "PTR_RE" } \\}" },
- { "service.name !~ 's'", 1,
+ { "service.name !~ 's'", 1,
"\\(NOT, OBJ\\[service\\]\\{ NAME\\{ NULL, "PTR_RE" } \\}\\)" },
"\\(NOT, OBJ\\[service\\]\\{ NAME\\{ NULL, "PTR_RE" } \\}\\)" },
- { "attribute.name = 'k1'", 1,
+ { "attribute.name = 'k1'", 1,
"OBJ\\[attribute\\]\\{ NAME\\{ 'k1', \\(nil\\) \\} " },
"OBJ\\[attribute\\]\\{ NAME\\{ 'k1', \\(nil\\) \\} " },
- { "attribute.name = 'x'", 0,
+ { "attribute.name = 'x'", 0,
"OBJ\\[attribute\\]\\{ NAME\\{ 'x', \\(nil\\) \\}" },
"OBJ\\[attribute\\]\\{ NAME\\{ 'x', \\(nil\\) \\}" },
- { "attribute.k1 = 'v1'", 1,
+ { "attribute.k1 = 'v1'", 1,
"ATTR\\[k1\\]\\{ VALUE\\{ 'v1', \\(nil\\) \\} \\}" },
"ATTR\\[k1\\]\\{ VALUE\\{ 'v1', \\(nil\\) \\} \\}" },
- { "attribute.k2 < 123", 0,
+ { "attribute.k1 IS NULL", 2,
+ "\\(IS NULL, ATTR\\[k1\\]\\)" },
+ { "attribute.x1 IS NULL", 3,
+ "\\(IS NULL, ATTR\\[x1\\]\\)" },
+ { "attribute.k1 IS NOT NULL", 1,
+ "\\(NOT, \\(IS NULL, ATTR\\[k1\\]\\)\\)" },
+ { "attribute.x1 IS NOT NULL", 0,
+ "\\(NOT, \\(IS NULL, ATTR\\[x1\\]\\)\\)" },
+ { "attribute.k2 < 123", 0,
"ATTR\\[k2\\]\\{ < 123 \\}" },
"ATTR\\[k2\\]\\{ < 123 \\}" },
- { "attribute.k2 <= 123", 1,
+ { "attribute.k2 <= 123", 1,
"ATTR\\[k2\\]\\{ <= 123 \\}" },
"ATTR\\[k2\\]\\{ <= 123 \\}" },
- { "attribute.k2 >= 123", 1,
+ { "attribute.k2 >= 123", 1,
"ATTR\\[k2\\]\\{ >= 123 \\}" },
"ATTR\\[k2\\]\\{ >= 123 \\}" },
- { "attribute.k2 > 123", 0,
+ { "attribute.k2 > 123", 0,
"ATTR\\[k2\\]\\{ > 123 \\}" },
"ATTR\\[k2\\]\\{ > 123 \\}" },
- { "attribute.k2 = 123", 1,
+ { "attribute.k2 = 123", 1,
"ATTR\\[k2\\]\\{ = 123 \\}" },
"ATTR\\[k2\\]\\{ = 123 \\}" },
- { "attribute.k2 != 123", 2,
+ { "attribute.k2 != 123", 2,
"\\(NOT, ATTR\\[k2\\]\\{ = 123 \\}\\)" },
"\\(NOT, ATTR\\[k2\\]\\{ = 123 \\}\\)" },
- { "attribute.k1 != 'v1'", 2,
+ { "attribute.k1 != 'v1'", 2,
"\\(NOT, ATTR\\[k1\\]\\{ VALUE\\{ 'v1', \\(nil\\) \\} \\}\\)" },
"\\(NOT, ATTR\\[k1\\]\\{ VALUE\\{ 'v1', \\(nil\\) \\} \\}\\)" },
- { "attribute.k1 != 'v2'", 3,
+ { "attribute.k1 != 'v2'", 3,
"\\(NOT, ATTR\\[k1\\]\\{ VALUE\\{ 'v2', \\(nil\\) \\} \\}\\)" },
{ "attribute.name != 'x' "
"\\(NOT, ATTR\\[k1\\]\\{ VALUE\\{ 'v2', \\(nil\\) \\} \\}\\)" },
{ "attribute.name != 'x' "
- "AND attribute.y !~ 'x'", 3,
+ "AND attribute.y !~ 'x'", 3,
"\\(AND, "
"\\(NOT, OBJ\\[attribute\\]\\{ NAME\\{ 'x', \\(nil\\) \\} \\}\\), "
"\\(NOT, ATTR\\[y\\]\\{ VALUE\\{ NULL, "PTR_RE" \\} \\}\\)\\)" },
"\\(AND, "
"\\(NOT, OBJ\\[attribute\\]\\{ NAME\\{ 'x', \\(nil\\) \\} \\}\\), "
"\\(NOT, ATTR\\[y\\]\\{ VALUE\\{ NULL, "PTR_RE" \\} \\}\\)\\)" },