tests: Learn qemuMonitorTestNew optional greeting

Currently, when creating a new mocked monitor, the greeting can't be
chosen. This is crucial for next patches, because some info as qemu
version is obtained in the greeting message.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Michal Privoznik 2013-09-19 13:56:30 +02:00
parent 64f1e1688d
commit 0badd8a43d
3 changed files with 10 additions and 7 deletions

View File

@ -250,7 +250,7 @@ testQemuHotplug(const void *data)
/* Now is the best time to feed the spoofed monitor with predefined
* replies. */
if (!(test_mon = qemuMonitorTestNew(true, driver.xmlopt, vm, &driver)))
if (!(test_mon = qemuMonitorTestNew(true, driver.xmlopt, vm, &driver, NULL)))
goto cleanup;
tmp = test->mon;

View File

@ -873,7 +873,8 @@ qemuMonitorTestPtr
qemuMonitorTestNew(bool json,
virDomainXMLOptionPtr xmlopt,
virDomainObjPtr vm,
virQEMUDriverPtr driver)
virQEMUDriverPtr driver,
const char *greeting)
{
qemuMonitorTestPtr test = NULL;
virDomainChrSourceDef src;
@ -893,9 +894,10 @@ qemuMonitorTestNew(bool json,
virObjectLock(test->mon);
if (qemuMonitorTestAddReponse(test, json ?
QEMU_JSON_GREETING :
QEMU_TEXT_GREETING) < 0)
if (!greeting)
greeting = json ? QEMU_JSON_GREETING : QEMU_TEXT_GREETING;
if (qemuMonitorTestAddReponse(test, greeting) < 0)
goto error;
if (qemuMonitorCommonTestInit(test) < 0)

View File

@ -61,12 +61,13 @@ int qemuMonitorTestAddItemParams(qemuMonitorTestPtr test,
ATTRIBUTE_SENTINEL;
# define qemuMonitorTestNewSimple(json, xmlopt) \
qemuMonitorTestNew(json, xmlopt, NULL, NULL)
qemuMonitorTestNew(json, xmlopt, NULL, NULL, NULL)
qemuMonitorTestPtr qemuMonitorTestNew(bool json,
virDomainXMLOptionPtr xmlopt,
virDomainObjPtr vm,
virQEMUDriverPtr driver);
virQEMUDriverPtr driver,
const char *greeting);
qemuMonitorTestPtr qemuMonitorTestNewAgent(virDomainXMLOptionPtr xmlopt);