Signed-off-by: Luke Yue <lukedyue@gmail.com>
---
src/test/test_driver.c | 53 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 53 insertions(+)
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index ae1b8ebc23..a7ea05464d 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -9331,6 +9331,58 @@ testDomainCheckpointDelete(virDomainCheckpointPtr checkpoint,
return ret;
}
+static int
+testDomainGetMessages(virDomainPtr dom,
+ char ***msgs,
+ unsigned int flags)
+{
+ virDomainObj *vm = NULL;
+ int rv = -1;
+ size_t i, n;
+ int nmsgs;
+
+ virCheckFlags(VIR_DOMAIN_MESSAGE_DEPRECATION |
+ VIR_DOMAIN_MESSAGE_TAINTING, -1);
+
+ if (!(vm = testDomObjFromDomain(dom)))
+ return -1;
+
+ *msgs = NULL;
+ nmsgs = 0;
+ n = 0;
+
+ if (!flags || (flags & VIR_DOMAIN_MESSAGE_TAINTING)) {
+ nmsgs += __builtin_popcount(vm->taint);
+ *msgs = g_renew(char *, *msgs, nmsgs+1);
+
+ for (i = 0; i < VIR_DOMAIN_TAINT_LAST; i++) {
+ if (vm->taint & (1 << i)) {
+ (*msgs)[n++] = g_strdup_printf(
+ _("tainted: %s"),
+ _(virDomainTaintMessageTypeToString(i)));
+ }
+ }
+ }
+
+ if (!flags || (flags & VIR_DOMAIN_MESSAGE_DEPRECATION)) {
+ nmsgs += vm->ndeprecations;
+ *msgs = g_renew(char *, *msgs, nmsgs+1);
+
+ for (i = 0; i < vm->ndeprecations; i++) {
+ (*msgs)[n++] = g_strdup_printf(
+ _("deprecated configuration: %s"),
+ vm->deprecations[i]);
+ }
+ }
+
+ (*msgs)[nmsgs] = NULL;
+
+ rv = nmsgs;
+
+ virDomainObjEndAPI(&vm);
+ return rv;
+}
+
/*
* Test driver
*/
@@ -9489,6 +9541,7 @@ static virHypervisorDriver testHypervisorDriver = {
.domainCheckpointLookupByName = testDomainCheckpointLookupByName, /* 5.6.0 */
.domainCheckpointGetParent = testDomainCheckpointGetParent, /* 5.6.0 */
.domainCheckpointDelete = testDomainCheckpointDelete, /* 5.6.0 */
+ .domainGetMessages = testDomainGetMessages, /* 7.5.0 */
};
static virNetworkDriver testNetworkDriver = {
--
2.32.0
On Mon, Jun 14, 2021 at 09:13:17PM +0800, Luke Yue wrote: >Signed-off-by: Luke Yue <lukedyue@gmail.com> >--- > src/test/test_driver.c | 53 ++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 53 insertions(+) > Similarly to the other patch with virDomainGetSecurityLabelList() this one should also test the added code. Thanks, Martin
On Tue, 2021-06-15 at 10:09 +0200, Martin Kletzander wrote: > On Mon, Jun 14, 2021 at 09:13:17PM +0800, Luke Yue wrote: > > Signed-off-by: Luke Yue <lukedyue@gmail.com> > > --- > > src/test/test_driver.c | 53 > > ++++++++++++++++++++++++++++++++++++++++++ > > 1 file changed, 53 insertions(+) > > > > Similarly to the other patch with virDomainGetSecurityLabelList() > this > one should also test the added code. > > Thanks, > Martin I will try to add test in v2, thanks!
[Another one of those lost e-mails] On Wed, Jun 16, 2021 at 05:23:36PM +0800, Luke Yue wrote: >On Tue, 2021-06-15 at 10:09 +0200, Martin Kletzander wrote: >> On Mon, Jun 14, 2021 at 09:13:17PM +0800, Luke Yue wrote: >> > Signed-off-by: Luke Yue <lukedyue@gmail.com> >> > --- >> > src/test/test_driver.c | 53 >> > ++++++++++++++++++++++++++++++++++++++++++ >> > 1 file changed, 53 insertions(+) >> > >> >> Similarly to the other patch with virDomainGetSecurityLabelList() >> this >> one should also test the added code. >> >> Thanks, >> Martin > >I will try to add test in v2, thanks! > You might need to add an extra VM to the default test driver setup which has some taint or something so that it is nicer to test. We will need to add more in the future in any case, not all new APIs will be testable with the current limited set.
On Wed, 2021-06-23 at 00:09 +0200, Martin Kletzander wrote: > [Another one of those lost e-mails] > > On Wed, Jun 16, 2021 at 05:23:36PM +0800, Luke Yue wrote: > > On Tue, 2021-06-15 at 10:09 +0200, Martin Kletzander wrote: > > > On Mon, Jun 14, 2021 at 09:13:17PM +0800, Luke Yue wrote: > > > > Signed-off-by: Luke Yue <lukedyue@gmail.com> > > > > --- > > > > src/test/test_driver.c | 53 > > > > ++++++++++++++++++++++++++++++++++++++++++ > > > > 1 file changed, 53 insertions(+) > > > > > > > > > > Similarly to the other patch with virDomainGetSecurityLabelList() > > > this > > > one should also test the added code. > > > > > > Thanks, > > > Martin > > > > I will try to add test in v2, thanks! > > > > You might need to add an extra VM to the default test driver setup > which has > some taint or something so that it is nicer to test. We will need to > add more > in the future in any case, not all new APIs will be testable with the > current > limited set. Just sent v2 patches, for taint messages we don't need an extra VM (but deprecation messages may need). I will add more in the future when it's required for testing new APIs.
© 2016 - 2024 Red Hat, Inc.