diff options
author | Andrejs Griščenko <andrejs.griscenko@zabbix.com> | 2021-05-07 17:01:32 +0300 |
---|---|---|
committer | Andrejs Griščenko <andrejs.griscenko@zabbix.com> | 2021-05-07 17:01:32 +0300 |
commit | 19e88a15b0d17fb5381df43db83e3e452c3ae35a (patch) | |
tree | 95582b6d1bbe9f7c42ccc26dab772e6599e7f704 /tests | |
parent | 7968c3d4b1f4cacfd3191f11ba56a0f6f6601b29 (diff) | |
parent | 27d4e37650a3cd785ffc481dcb5c831c7b58f9e1 (diff) |
.......... [ZBXNEXT-6544] updated to the latest from 'feature/ZBXNEXT-6452-5.3'; resolved conflicts in:
- ui/include/classes/validators/CMathFunctionValidator.php
Diffstat (limited to 'tests')
-rw-r--r-- | tests/libs/zbxeval/zbx_eval_parse_expression.yaml | 2 | ||||
-rw-r--r-- | tests/libs/zbxeval/zbx_eval_prepare_filter.c | 17 | ||||
-rw-r--r-- | tests/libs/zbxeval/zbx_eval_prepare_filter.yaml | 80 |
3 files changed, 92 insertions, 7 deletions
diff --git a/tests/libs/zbxeval/zbx_eval_parse_expression.yaml b/tests/libs/zbxeval/zbx_eval_parse_expression.yaml index bedecd798e8..00ff02bbbfc 100644 --- a/tests/libs/zbxeval/zbx_eval_parse_expression.yaml +++ b/tests/libs/zbxeval/zbx_eval_parse_expression.yaml @@ -1700,7 +1700,7 @@ in: out: result: FAIL --- -test case: Succeed 'group="xyz" = tag' +test case: Fail 'group="xyz" = tag' in: rules: [ZBX_EVAL_PARSE_PROPERTY,ZBX_EVAL_PARSE_VAR_STR,ZBX_EVAL_PARSE_COMPARE_EQ,ZBX_EVAL_PARSE_LOGIC,ZBX_EVAL_PARSE_GROUP] expression: 'group="xyz" = tag' diff --git a/tests/libs/zbxeval/zbx_eval_prepare_filter.c b/tests/libs/zbxeval/zbx_eval_prepare_filter.c index e972d3d1fd8..65dbd5fd88a 100644 --- a/tests/libs/zbxeval/zbx_eval_prepare_filter.c +++ b/tests/libs/zbxeval/zbx_eval_prepare_filter.c @@ -31,19 +31,24 @@ void zbx_mock_test_entry(void **state) { zbx_eval_context_t ctx; char *error = NULL; + int expected_ret, returned_ret; ZBX_UNUSED(state); - - if (SUCCEED != zbx_eval_parse_expression(&ctx, zbx_mock_get_parameter_string("in.expression"), - ZBX_EVAL_PARSE_QUERY_EXPRESSION, &error)) + expected_ret = zbx_mock_str_to_return_code(zbx_mock_get_parameter_string("out.result")); + if (SUCCEED != (returned_ret = zbx_eval_parse_expression(&ctx, zbx_mock_get_parameter_string("in.expression"), + ZBX_EVAL_PARSE_QUERY_EXPRESSION, &error))) { - fail_msg("failed to parse expression: %s", error); + printf("ERROR: %s\n", error); } - zbx_eval_prepare_filter(&ctx); + zbx_mock_assert_result_eq("return value", expected_ret, returned_ret); - mock_compare_stack(&ctx, "out.stack"); + if (SUCCEED == expected_ret) + { + zbx_eval_prepare_filter(&ctx); + mock_compare_stack(&ctx, "out.stack"); + } zbx_free(error); zbx_eval_clear(&ctx); diff --git a/tests/libs/zbxeval/zbx_eval_prepare_filter.yaml b/tests/libs/zbxeval/zbx_eval_prepare_filter.yaml index 62f51f623b4..40ab103db35 100644 --- a/tests/libs/zbxeval/zbx_eval_prepare_filter.yaml +++ b/tests/libs/zbxeval/zbx_eval_prepare_filter.yaml @@ -3,6 +3,7 @@ test case: Expression 'group="x"' in: expression: 'group="x"' out: + result: SUCCEED stack: - {type: ZBX_EVAL_TOKEN_VAR_STR, token: '"x"', opt: 0} - {type: ZBX_EVAL_TOKEN_FUNCTION, token: 'group', opt: 1} @@ -12,6 +13,7 @@ test case: Expression 'group="x"' in: expression: 'group<>"x"' out: + result: SUCCEED stack: - {type: ZBX_EVAL_TOKEN_VAR_STR, token: '"x"', opt: 0} - {type: ZBX_EVAL_TOKEN_FUNCTION, token: 'group', opt: 1} @@ -21,6 +23,7 @@ test case: Expression 'group="x" and tag="a"' in: expression: 'group="x" and tag="a"' out: + result: SUCCEED stack: - {type: ZBX_EVAL_TOKEN_VAR_STR, token: '"x"', opt: 0} - {type: ZBX_EVAL_TOKEN_FUNCTION, token: 'group', opt: 1} @@ -34,6 +37,7 @@ test case: Expression 'group="x" or group="y" and tag="a"' in: expression: 'group="x" or group="y" and tag="a"' out: + result: SUCCEED stack: - {type: ZBX_EVAL_TOKEN_VAR_STR, token: '"x"', opt: 0} - {type: ZBX_EVAL_TOKEN_FUNCTION, token: 'group', opt: 1} @@ -51,6 +55,7 @@ test case: Expression 'group<>"x" or tag<>"a"' in: expression: 'group<>"x" or tag<>"a"' out: + result: SUCCEED stack: - {type: ZBX_EVAL_TOKEN_VAR_STR, token: '"x"', opt: 0} - {type: ZBX_EVAL_TOKEN_FUNCTION, token: 'group', opt: 1} @@ -64,6 +69,7 @@ test case: Expression '(group="Zabbix servers") or ("Zabbix servers"=group)' in: expression: '(group="Zabbix servers") or ("Zabbix servers"=group)' out: + result: SUCCEED stack: - {type: ZBX_EVAL_TOKEN_VAR_STR, token: '"Zabbix servers"', opt: 0} - {type: ZBX_EVAL_TOKEN_FUNCTION, token: 'group', opt: 1} @@ -72,5 +78,79 @@ out: - {type: ZBX_EVAL_TOKEN_FUNCTION, token: 'group', opt: 1} - {type: ZBX_EVAL_TOKEN_NOP, token: '', opt: 0} - {type: ZBX_EVAL_TOKEN_OP_OR, token: 'or', opt: 0} +--- +test case: Expression 'group=tag' +in: + expression: 'group=tag' +out: + result: FAIL +--- +test case: Expression '(group)=("x")' +in: + expression: '(group)=("x")' +out: + result: SUCCEED + stack: + - {type: ZBX_EVAL_TOKEN_VAR_STR, token: '"x"', opt: 0} + - {type: ZBX_EVAL_TOKEN_FUNCTION, token: 'group', opt: 1} + - {type: ZBX_EVAL_TOKEN_NOP, token: '', opt: 0} +--- +test case: Expression '"a"="b"' +in: + expression: '"a"="b"' +out: + result: SUCCEED + stack: + - {type: ZBX_EVAL_TOKEN_VAR_STR, token: '"a"', opt: 0} + - {type: ZBX_EVAL_TOKEN_VAR_STR, token: '"b"', opt: 0} + - {type: ZBX_EVAL_TOKEN_OP_EQ, token: '=', opt: 0} +--- +test case: Expression 'group=(tag="x")' +in: + expression: 'group=(tag="x")' +out: + result: FAIL +--- +test case: Expression 'tag=("x"="y")' +in: + expression: 'tag=("x"="y")' +out: + result: FAIL +--- +test case: Expression 'tag' +in: + expression: 'tag' +out: + result: FAIL +--- +test case: Expression 'group={$M}' +in: + expression: 'group={$M}' +out: + result: SUCCEED + stack: + - {type: ZBX_EVAL_TOKEN_VAR_USERMACRO, token: '{$M}', opt: 0} + - {type: ZBX_EVAL_TOKEN_FUNCTION, token: 'group', opt: 1} + - {type: ZBX_EVAL_TOKEN_NOP, token: '', opt: 0} +--- +test case: Expression 'tag=("a" or "b")' +in: + expression: 'tag=("a" or "b")' +out: + result: FAIL +--- +test case: Expression 'tag=("a" or tag = "b")' +in: + expression: 'tag=("a" or tag = "b")' +out: + result: FAIL +--- +test case: Expression 'group="xyz" = tag' +in: + expression: 'group="xyz" = tag' +out: + result: FAIL ... + + |