[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 11/19] test-cutils: Refactor qemu_strtosz tests for less b
|
From: |
Eric Blake |
|
Subject: |
Re: [PATCH v2 11/19] test-cutils: Refactor qemu_strtosz tests for less boilerplate |
|
Date: |
Fri, 19 May 2023 12:54:19 -0500 |
|
User-agent: |
NeoMutt/20230517 |
On Fri, May 19, 2023 at 05:13:52PM +0200, Hanna Czenczek wrote:
> On 12.05.23 04:10, Eric Blake wrote:
> > No need to copy-and-paste lots of boilerplate per string tested, when
> > we can consolidate that behind helper functions. Plus, this adds a
> > bit more coverage (we now test all strings both with and without
> > endptr, whereas before some tests skipped the NULL endptr case), which
> > exposed a SEGFAULT on qemu_strtosz(NULL, NULL, &val) that will be
> > parsed in an upcoming patch.
s/parsed/fixed/
> >
> > Note that duplicating boilerplate has one advantage lost here - a
> > failed test tells you which line number failed; but a helper function
> > does not show the call stack that reached the failure. Since we call
> > the helper more than once within many of the "unit tests", even the
> > unit test name doesn't point out which call is failing. But that only
> > matters when tests fail (they normally pass); at which point I'm
> > debugging the failures under gdb anyways, so I'm not too worried about
> > it.
> >
> > Signed-off-by: Eric Blake <eblake@redhat.com>
> > ---
> > tests/unit/test-cutils.c | 503 ++++++++-------------------------------
> > 1 file changed, 100 insertions(+), 403 deletions(-)
>
> Reviewed-by: Hanna Czenczek <hreitz@redhat.com>
I'm debating about using similar boilerplate compression for the
strtol and strtod tests in v3 of the series. I can definitively state
that debugging a failed test was harder (had to open up gdb instead of
just seeing the line number of the failure), but that overall I got to
focus a lot more on the tests rather than the boilerplate.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
- Re: [PATCH v2 05/19] cutils: Fix wraparound parsing in qemu_strtoui, (continued)
- [PATCH v2 07/19] cutils: Adjust signature of parse_uint[_full], Eric Blake, 2023/05/11
- [PATCH v2 09/19] test-cutils: Add coverage of qemu_strtod, Eric Blake, 2023/05/11
- [PATCH v2 11/19] test-cutils: Refactor qemu_strtosz tests for less boilerplate, Eric Blake, 2023/05/11
- [PATCH v2 14/19] test-cutils: Add more coverage to qemu_strtosz11; rgb:1e1e/1e1e/1e1e, Eric Blake, 2023/05/11
- [PATCH v2 12/19] cutils: Allow NULL str in qemu_strtosz, Eric Blake, 2023/05/11
- [PATCH v2 16/19] cutils: Set value in all integral qemu_strto* error paths, Eric Blake, 2023/05/11
- [PATCH v2 15/19] cutils: Set value in all qemu_strtosz* error paths, Eric Blake, 2023/05/11
- [PATCH v2 06/19] cutils: Document differences between parse_uint and qemu_strtou64, Eric Blake, 2023/05/11