On Sat, Jun 01, 2019 at 02:46:56PM +0200, Ilias Stamatis wrote:
Validate @keycodes and sleep for @holdtime before successfully
returning.
Signed-off-by: Ilias Stamatis <stamatis.iliass(a)gmail.com>
---
Reviewed-by: Erik Skultety <eskultet(a)redhat.com>
src/test/test_driver.c | 40
++++++++++++++++++++++++++++++++++++++++
1 file changed, 40 insertions(+)
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 2f58a1da95..51ded256be 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -64,6 +64,7 @@
#include "virinterfaceobj.h"
#include "virhostcpu.h"
#include "virdomainsnapshotobjlist.h"
+#include "virkeycode.h"
#define VIR_FROM_THIS VIR_FROM_TEST
@@ -5980,6 +5981,44 @@ testDomainScreenshot(virDomainPtr dom ATTRIBUTE_UNUSED,
return ret;
}
Some time ago we decided that we'd put 2 line in between function definitions,
this is mostly to be somewhat consistent, but we're not enforcing it in any way
and the test driver hasn't been following this, but since these are new APIs, I
added the 2 lines there. But again, it's not something that would be normally
worth mentioning during review, but you should know that I made that
adjustment.
Reviewed-by: Erik Skultety <eskultet(a)redhat.com>
+static int
+testDomainSendKey(virDomainPtr domain,
+ unsigned int codeset,
+ unsigned int holdtime,
+ unsigned int *keycodes,
+ int nkeycodes,
+ unsigned int flags)
+{
+ int ret = -1;
+ size_t i;
+ virDomainObjPtr vm = NULL;
+
+ virCheckFlags(0, -1);
+
+ if (!(vm = testDomObjFromDomain(domain)))
+ goto cleanup;
+
+ if (virDomainObjCheckActive(vm) < 0)
+ goto cleanup;
+
+ for (i = 0; i < nkeycodes; i++) {
+ if (virKeycodeValueTranslate(codeset, codeset, keycodes[i]) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("invalid keycode %u of %s codeset"),
+ keycodes[i],
+ virKeycodeSetTypeToString(codeset));
+ goto cleanup;
+ }
+ }
+
+ usleep(holdtime * 1000);
+ ret = 0;
+
+ cleanup:
+ virDomainObjEndAPI(&vm);
+ return ret;
+}
+
static int
testConnectGetCPUModelNames(virConnectPtr conn ATTRIBUTE_UNUSED,
const char *archName,
@@ -7000,6 +7039,7 @@ static virHypervisorDriver testHypervisorDriver = {
.nodeGetCPUMap = testNodeGetCPUMap, /* 1.0.0 */
.domainRename = testDomainRename, /* 4.1.0 */
.domainScreenshot = testDomainScreenshot, /* 1.0.5 */
+ .domainSendKey = testDomainSendKey, /* 5.5.0 */
.domainGetMetadata = testDomainGetMetadata, /* 1.1.3 */
.domainSetMetadata = testDomainSetMetadata, /* 1.1.3 */
.connectGetCPUModelNames = testConnectGetCPUModelNames, /* 1.1.3 */
--
2.21.0
--
libvir-list mailing list
libvir-list(a)redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list