[libvirt] [PATCH 02/12] test: utils: Add helpers for automatic numbering of test cases
Peter Krempa
pkrempa at redhat.com
Fri Jan 30 08:21:08 UTC 2015
On Thu, Jan 29, 2015 at 14:23:52 -0500, John Ferlan wrote:
>
> I don't see this being used anywhere in this set of patches... I assume
> you have some other upcoming patch series that will use it...
>
> NITs
>
> On 01/28/2015 05:30 AM, Peter Krempa wrote:
> > Adding or reordering test cases is usually a pain due to static test
> > case names that are then passed to virtTestRun(). To ease the numbering
> > of test cases, this patch adds two simple helpers that generate the test
> > names according to the order they are run. The test name can be
> > configured via the reset function.
> >
> > This will allow us to freely add test cases in mid of test groups
>
> s/in mid of/in the middle of/
>
> > without the need to re-number the rest of test cases.
> > ---
> > tests/testutils.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
> > tests/testutils.h | 3 +++
> > 2 files changed, 49 insertions(+)
> >
> > diff --git a/tests/testutils.c b/tests/testutils.c
> > index 9a79f98..c7d2615 100644
> > --- a/tests/testutils.c
> > +++ b/tests/testutils.c
> > @@ -986,3 +986,49 @@ virDomainXMLOptionPtr virTestGenericDomainXMLConfInit(void)
> > &virTestGenericPrivateDataCallbacks,
> > NULL);
> > }
> > +
> > +
> > +static int virtTestCounter;
> > +static char virtTestCounterStr[128];
> > +static char *virtTestCounterPrefixEndOffset;
> > +
> > +
> > +/**
> > + * virtTestCounterReset:
> > + * @prefix: name of the test group
> > + *
> > + * Resets the counter and sets up the test group name to use with
> > + * virtTestCounterNext(). This function is not thread safe.
> > + */
> > +void
> > +virtTestCounterReset(const char *prefix)
> > +{
> > + virtTestCounter = 0;
>
> Not that it'd happen, but if the prefix was larger than 128
> characters... ;-)
I can document it if it would help. I wanted to avoid memory allocation
in the testsuite so that this code can't introduce a failure.
A worst case scenario here should be that the test names will be
truncated which will make it less obvious in case of a failure. In such
case we can always bump the size of the string.
>
Peter
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20150130/0e8b6f8f/attachment-0001.sig>
More information about the libvir-list
mailing list