mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-08 12:41:29 +00:00
tests: use GRegex in vboxsnapshotxmltest
Signed-off-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
parent
b96e0dbba9
commit
c4ae19d1ec
@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
#ifdef WITH_VBOX
|
#ifdef WITH_VBOX
|
||||||
|
|
||||||
# include <regex.h>
|
|
||||||
# include "vbox/vbox_snapshot_conf.h"
|
# include "vbox/vbox_snapshot_conf.h"
|
||||||
|
|
||||||
# define VIR_FROM_THIS VIR_FROM_NONE
|
# define VIR_FROM_THIS VIR_FROM_NONE
|
||||||
@ -12,7 +11,7 @@
|
|||||||
static const char *testSnapshotXMLVariableLineRegexStr =
|
static const char *testSnapshotXMLVariableLineRegexStr =
|
||||||
"lastStateChange=[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z";
|
"lastStateChange=[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z";
|
||||||
|
|
||||||
regex_t *testSnapshotXMLVariableLineRegex = NULL;
|
GRegex *testSnapshotXMLVariableLineRegex = NULL;
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
testFilterXML(char *xml)
|
testFilterXML(char *xml)
|
||||||
@ -29,8 +28,7 @@ testFilterXML(char *xml)
|
|||||||
VIR_FREE(xml);
|
VIR_FREE(xml);
|
||||||
|
|
||||||
for (xmlLine = xmlLines; *xmlLine; xmlLine++) {
|
for (xmlLine = xmlLines; *xmlLine; xmlLine++) {
|
||||||
if (regexec(testSnapshotXMLVariableLineRegex,
|
if (g_regex_match(testSnapshotXMLVariableLineRegex, *xmlLine, 0, NULL))
|
||||||
*xmlLine, 0, NULL, 0) == 0)
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
virBufferStrcat(&buf, *xmlLine, "\n", NULL);
|
virBufferStrcat(&buf, *xmlLine, "\n", NULL);
|
||||||
@ -112,12 +110,12 @@ static int
|
|||||||
mymain(void)
|
mymain(void)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
if (VIR_ALLOC(testSnapshotXMLVariableLineRegex) < 0)
|
g_autoptr(GError) err = NULL;
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
if (regcomp(testSnapshotXMLVariableLineRegex,
|
testSnapshotXMLVariableLineRegex = g_regex_new(testSnapshotXMLVariableLineRegexStr,
|
||||||
testSnapshotXMLVariableLineRegexStr,
|
0, 0, &err);
|
||||||
REG_EXTENDED | REG_NOSUB) != 0) {
|
|
||||||
|
if (!testSnapshotXMLVariableLineRegex) {
|
||||||
ret = -1;
|
ret = -1;
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
"failed to compile test regex");
|
"failed to compile test regex");
|
||||||
@ -136,9 +134,7 @@ mymain(void)
|
|||||||
DO_TEST("2disks-3snap-brother");
|
DO_TEST("2disks-3snap-brother");
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if (testSnapshotXMLVariableLineRegex)
|
g_regex_unref(testSnapshotXMLVariableLineRegex);
|
||||||
regfree(testSnapshotXMLVariableLineRegex);
|
|
||||||
VIR_FREE(testSnapshotXMLVariableLineRegex);
|
|
||||||
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user