[PATCH v3 4/5] test_driver: Introduce testDomainSetDummyData

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



We can't adjust all info of a domain in XML and it's hard to adjust some
with current API coverage, so use this function to set some dummy data
to specific domains, thus we can get different results in virsh tests.

Currently, only domain fc5's priv->jobState and priv->jobOperation are
being changed, in order to test virDomainGetJobInfo and
virDomainGetJobStats (domjobinfo in virsh).

Signed-off-by: Luke Yue <lukedyue@xxxxxxxxx>
---
 src/test/test_driver.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 35350edda9..372de8ba53 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -663,6 +663,32 @@ testDomObjFromDomain(virDomainPtr domain)
     return vm;
 }
 
+/**
+ * We can't adjust all info of a domain in XML and it's hard to
+ * adjust some with current API coverage, so use this function to
+ * set some dummy data to specific domains, thus we can get different
+ * results in virshtest.
+ */
+static int
+testDomainSetDummyData(virDomainObj *obj)
+{
+    virDomainDef *def;
+    testDomainObjPrivate *priv;
+
+    priv = obj->privateData;
+
+    if (!(def = virDomainObjGetOneDef(obj, VIR_DOMAIN_AFFECT_LIVE)))
+        return -1;
+
+    if (STREQ(def->name, "fc5")) {
+        /* For testing domjobinfo */
+        priv->jobState = VIR_DOMAIN_JOB_BOUNDED;
+        priv->jobOperation = VIR_DOMAIN_JOB_OPERATION_BACKUP;
+    }
+
+    return 0;
+}
+
 static char *
 testDomainGenerateIfname(virDomainDef *domdef)
 {
@@ -1055,6 +1081,9 @@ testParseDomains(testDriver *privconn,
 
         testDomainObjCheckTaint(obj);
 
+        if (testDomainSetDummyData(obj) < 0)
+            VIR_DEBUG("Failed to set dummy data");
+
         virDomainObjEndAPI(&obj);
     }
 
-- 
2.32.0




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux