Skip to content

Commit 8ad2f8c

Browse files
ilstameskultety
authored andcommitted
test_driver: implement virDomainSendKey
Validate @keycodes before successfully returning. Since this is test driver, @holdtime is being unused here. Signed-off-by: Ilias Stamatis <[email protected]> Reviewed-by: Erik Skultety <[email protected]>
1 parent a84922c commit 8ad2f8c

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

src/test/test_driver.c

+41
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
#include "virinterfaceobj.h"
6565
#include "virhostcpu.h"
6666
#include "virdomainsnapshotobjlist.h"
67+
#include "virkeycode.h"
6768

6869
#define VIR_FROM_THIS VIR_FROM_TEST
6970

@@ -6004,6 +6005,45 @@ testDomainScreenshot(virDomainPtr dom ATTRIBUTE_UNUSED,
60046005
return ret;
60056006
}
60066007

6008+
6009+
static int
6010+
testDomainSendKey(virDomainPtr domain,
6011+
unsigned int codeset,
6012+
unsigned int holdtime ATTRIBUTE_UNUSED,
6013+
unsigned int *keycodes,
6014+
int nkeycodes,
6015+
unsigned int flags)
6016+
{
6017+
int ret = -1;
6018+
size_t i;
6019+
virDomainObjPtr vm = NULL;
6020+
6021+
virCheckFlags(0, -1);
6022+
6023+
if (!(vm = testDomObjFromDomain(domain)))
6024+
goto cleanup;
6025+
6026+
if (virDomainObjCheckActive(vm) < 0)
6027+
goto cleanup;
6028+
6029+
for (i = 0; i < nkeycodes; i++) {
6030+
if (virKeycodeValueTranslate(codeset, codeset, keycodes[i]) < 0) {
6031+
virReportError(VIR_ERR_INTERNAL_ERROR,
6032+
_("invalid keycode %u of %s codeset"),
6033+
keycodes[i],
6034+
virKeycodeSetTypeToString(codeset));
6035+
goto cleanup;
6036+
}
6037+
}
6038+
6039+
ret = 0;
6040+
6041+
cleanup:
6042+
virDomainObjEndAPI(&vm);
6043+
return ret;
6044+
}
6045+
6046+
60076047
static int
60086048
testConnectGetCPUModelNames(virConnectPtr conn ATTRIBUTE_UNUSED,
60096049
const char *archName,
@@ -7025,6 +7065,7 @@ static virHypervisorDriver testHypervisorDriver = {
70257065
.nodeGetCPUMap = testNodeGetCPUMap, /* 1.0.0 */
70267066
.domainRename = testDomainRename, /* 4.1.0 */
70277067
.domainScreenshot = testDomainScreenshot, /* 1.0.5 */
7068+
.domainSendKey = testDomainSendKey, /* 5.5.0 */
70287069
.domainGetMetadata = testDomainGetMetadata, /* 1.1.3 */
70297070
.domainSetMetadata = testDomainSetMetadata, /* 1.1.3 */
70307071
.connectGetCPUModelNames = testConnectGetCPUModelNames, /* 1.1.3 */

0 commit comments

Comments
 (0)