提交 2f3472ca 编写于 作者: E Erik Skultety

tests: Add new testcases to test parsing of log filters in virlogtest

上级 f2b799cf
......@@ -74,6 +74,37 @@ testLogParseOutputs(const void *opaque)
return ret;
}
static int
testLogParseFilters(const void *opaque)
{
int ret = -1;
int nfilters;
const struct testLogData *data = opaque;
nfilters = virLogParseFilters(data->str);
if (nfilters < 0) {
if (!data->pass) {
VIR_TEST_DEBUG("Got expected error: %s\n",
virGetLastErrorMessage());
virResetLastError();
ret = 0;
goto cleanup;
}
} else if (nfilters != data->count) {
VIR_TEST_DEBUG("Expected number of parsed outputs is %d, "
"but got %d\n", data->count, nfilters);
goto cleanup;
} else if (!data->pass) {
VIR_TEST_DEBUG("Test should have failed\n");
goto cleanup;
}
ret = 0;
cleanup:
virLogReset();
return ret;
}
static int
mymain(void)
{
......@@ -97,6 +128,10 @@ mymain(void)
DO_TEST_FULL("testLogParseOutputs " # str, testLogParseOutputs, str, count, false)
#define TEST_PARSE_OUTPUTS(str, count) \
DO_TEST_FULL("testLogParseOutputs " # str, testLogParseOutputs, str, count, true)
#define TEST_PARSE_FILTERS_FAIL(str, count) \
DO_TEST_FULL("testLogParseFilters " # str, testLogParseFilters, str, count, false)
#define TEST_PARSE_FILTERS(str, count) \
DO_TEST_FULL("testLogParseFilters " # str, testLogParseFilters, str, count, true)
TEST_LOG_MATCH("2013-10-11 15:43:43.866+0000: 28302: info : libvirt version: 1.1.3");
......@@ -107,6 +142,12 @@ mymain(void)
TEST_PARSE_OUTPUTS_FAIL("foo:stderr", 1);
TEST_PARSE_OUTPUTS_FAIL("1:bar", 1);
TEST_PARSE_OUTPUTS_FAIL("1:stderr:foobar", 1);
TEST_PARSE_FILTERS("1:foo", 1);
TEST_PARSE_FILTERS("1:foo 2:bar 3:foobar", 3);
TEST_PARSE_FILTERS_FAIL("5:foo", 1);
TEST_PARSE_FILTERS_FAIL("1:", 1);
TEST_PARSE_FILTERS_FAIL(":foo", 1);
TEST_PARSE_FILTERS_FAIL("1:+", 1);
return ret;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册