2013-10-11 11:07:54 -05:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2013 Red Hat, Inc.
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library. If not, see
|
|
|
|
* <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include "testutils.h"
|
|
|
|
|
|
|
|
#include "virlog.h"
|
|
|
|
|
2016-03-16 04:55:38 -05:00
|
|
|
struct testLogData {
|
2013-10-11 11:07:54 -05:00
|
|
|
const char *str;
|
2016-03-16 04:55:38 -05:00
|
|
|
bool pass;
|
2013-10-11 11:07:54 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
|
|
|
testLogMatch(const void *opaque)
|
|
|
|
{
|
2016-03-16 04:55:38 -05:00
|
|
|
const struct testLogData *data = opaque;
|
2013-10-11 11:07:54 -05:00
|
|
|
|
|
|
|
bool got = virLogProbablyLogMessage(data->str);
|
2016-03-16 04:55:38 -05:00
|
|
|
if (got != data->pass) {
|
|
|
|
VIR_TEST_DEBUG("Expected '%d' but got '%d' for '%s'\n",
|
|
|
|
data->pass, got, data->str);
|
2013-10-11 11:07:54 -05:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
mymain(void)
|
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
|
2016-03-16 04:55:38 -05:00
|
|
|
#define DO_TEST_FULL(name, test, str, pass) \
|
|
|
|
do { \
|
|
|
|
struct testLogData data = { \
|
|
|
|
str, pass \
|
|
|
|
}; \
|
|
|
|
if (virtTestRun(name, test, &data) < 0) \
|
|
|
|
ret = -1; \
|
2013-10-11 11:07:54 -05:00
|
|
|
} while (0)
|
|
|
|
|
2016-03-16 04:55:38 -05:00
|
|
|
#define TEST_LOG_MATCH_FAIL(str) \
|
|
|
|
DO_TEST_FULL("testLogMatch " # str, testLogMatch, str, false)
|
|
|
|
#define TEST_LOG_MATCH(str) \
|
|
|
|
DO_TEST_FULL("testLogMatch " # str, testLogMatch, str, true)
|
2013-10-11 11:07:54 -05:00
|
|
|
|
2016-03-16 04:55:38 -05:00
|
|
|
TEST_LOG_MATCH("2013-10-11 15:43:43.866+0000: 28302: info : libvirt version: 1.1.3");
|
|
|
|
|
|
|
|
TEST_LOG_MATCH_FAIL("libvirt: error : cannot execute binary /usr/libexec/libvirt_lxc: No such file or directory");
|
2013-10-11 11:07:54 -05:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
VIRT_TEST_MAIN(mymain)
|