On Tue, 2021-08-17 at 13:52 +0200, Martin Kletzander wrote:
> On Mon, Aug 16, 2021 at 07:13:37PM +0800, Luke Yue wrote:
> > Signed-off-by: Luke Yue <luked...@gmail.com>
> > ---
> > tests/virshtest.c | 11 +++++++++++
> > 1 file changed, 11 insertions(+)
> > 
> > diff --git a/tests/virshtest.c b/tests/virshtest.c
> > index 53db2aa19a..0c46496c74 100644
> > --- a/tests/virshtest.c
> > +++ b/tests/virshtest.c
> > @@ -291,6 +291,13 @@ static int
> > testCompareDomControlInfoByName(const void *data G_GNUC_UNUSED)
> >     return testCompareOutputLit(exp, NULL, argv);
> > }
> > 
> > +static int testCompareDomJobInfoByName(const void *data
> > G_GNUC_UNUSED)
> > +{
> > +    const char *const argv[] = { VIRSH_CUSTOM, "domjobinfo",
> > "fc4", NULL };
> 
> You should be able to do something like:
> 
>    argv[] = { VIRSH_CUSTOM, "domjobinfo fc4; domjobabort fc4;
> domjobinfo fc4", NULL };
> 
> to test the behaviour of aborting and similarly for --completed and
> --keep-completed.
> 

Thanks for telling me that! I was wondering how I can keep the state of
the domain in virshtest, just like using interactive shell, and this
answered my question. Will do these in v3 and other unmerged patches'
tests can be improved with this, too. Thanks! 

> Maybe you can also pick one VM name that gets initialised with a
> dummy
> job.  You can base it on a name or uuid or some other random data for
> now.
> 
> > +    const char *exp = "Job type:         None        \n\n";
> > +    return testCompareOutputLit(exp, NULL, argv);
> > +}
> > +
> > struct testInfo {
> >     const char *const *argv;
> >     const char *result;
> > @@ -383,6 +390,10 @@ mymain(void)
> >                    testCompareDomControlInfoByName, NULL) != 0)
> >         ret = -1;
> > 
> > +    if (virTestRun("virsh domjobinfo (by name)",
> > +                   testCompareDomJobInfoByName, 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
> > 


Reply via email to