Re: [PATCH 5/5] tests: Test detach-device and detach-device-alias for test driver

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

 



On Tue, 2021-08-17 at 14:22 +0200, Martin Kletzander wrote:
> On Mon, Aug 16, 2021 at 07:19:49PM +0800, Luke Yue wrote:
> > Signed-off-by: Luke Yue <lukedyue@xxxxxxxxx>
> > ---
> > tests/virshtest.c | 24 ++++++++++++++++++++++++
> > 1 file changed, 24 insertions(+)
> > 
> > diff --git a/tests/virshtest.c b/tests/virshtest.c
> > index 53db2aa19a..273596d636 100644
> > --- a/tests/virshtest.c
> > +++ b/tests/virshtest.c
> > @@ -291,6 +291,22 @@ static int
> > testCompareDomControlInfoByName(const void *data G_GNUC_UNUSED)
> >     return testCompareOutputLit(exp, NULL, argv);
> > }
> > 
> > +static int testCompareDetachDevice(const void *data G_GNUC_UNUSED)
> > +{
> > +    const char *const argv[] = { VIRSH_CUSTOM, "detach-device",
> > "fc5",
> > +                                
> > "../examples/xml/test/testdevif.xml", NULL };
> > +    const char *exp = "Device detached successfully\n\n";
> > +    return testCompareOutputLit(exp, NULL, argv);
> > +}
> > +
> > +static int testCompareDetachDeviceAlias(const void *data
> > G_GNUC_UNUSED)
> > +{
> > +    const char *const argv[] = { VIRSH_CUSTOM, "detach-device-
> > alias", "fc5",
> > +                                 "ua-testCD", NULL };
> > +    const char *exp = "Device detach request sent
> > successfully\n\n";
> > +    return testCompareOutputLit(exp, NULL, argv);
> > +}
> > +
> 
> Not many XMLs from the previous patch are used here.  There could
> also
> be some negative tests (failing on a device that does not exist for
> example).
> 
> But if you de-duplicate the code then you can also go the other route
> and test the generic functions without running 'virsh -c test:///...'
> for every piece of functionality.
> 

No problem, will reimplement and and more tests in v2.

> > struct testInfo {
> >     const char *const *argv;
> >     const char *result;
> > @@ -383,6 +399,14 @@ mymain(void)
> >                    testCompareDomControlInfoByName, NULL) != 0)
> >         ret = -1;
> > 
> > +    if (virTestRun("virsh detach-device",
> > +                   testCompareDetachDevice, NULL) != 0)
> > +        ret = -1;
> > +
> > +    if (virTestRun("virsh detach-device-alias",
> > +                   testCompareDetachDeviceAlias, NULL) != 0)
> > +        ret = -1;
> > +
> >     /* It's a bit awkward listing result before argument, but
> > that's a
> >      * limitation of C99 vararg macros.  */
> > # define DO_TEST(i, result, ...) \
> > -- 
> > 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