[Libguestfs] [libnbd PATCH 4/6] tests: Avoid odd test behavior under NDEBUG [partial port]

Laszlo Ersek lersek at redhat.com
Wed Mar 1 13:00:08 UTC 2023


On 3/1/23 12:40, Laszlo Ersek wrote:
> From: Eric Blake <eblake at redhat.com>
> 
> Original (nbdkit) commit message:
> 
> While we support compilation with CFLAGS=-DNDEBUG for the brave user
> desiring to avoid assertion overhead, this causes the tests to be less
> powerful (the tests "fail open" for anything where we relied on an
> assert to validate nbdkit was behaving correctly; and this would be
> even worse if we had side effects in a test assert, such as we just
> fixed in d5cedf20).  Fortunately, a quick test of './configure
> CFLAGS=-DNDEBUG' didn't hit any test failures, but it seems better to
> just ensure that assertions always work in our tests, even when they
> are turned off for the main binary.
> 
> Porting notes:
> 
> This is a partial port. At this point, the test cases we have under
> common/ actually reflect our common/ header file usage (meaning that, if
> nbdkit has a test case for a header file we use, then we also have that
> test case). However, test case *content* remains different at this point;
> one piece is nbdkit commit 0b6d62668584 ("tests: Avoid odd test behavior
> under NDEBUG", 2020-07-07). Port those parts of it that modify such test
> cases that libnbd does have, at this point. Note that the nbdkit commit
> modifies "test-ispowerof2.c" as well, be we have ported that particular

s/be/but/

> NDEBUG addition earlier (in libnbd commit 6cc512341281, "common/include:
> Copy test-ispowerof2.c from nbdkit", 2022-08-25).
> 
> Signed-off-by: Eric Blake <eblake at redhat.com>
> Signed-off-by: Laszlo Ersek <lersek at redhat.com>
> (cherry picked from nbdkit commit 0b6d626685846d41ea113a394cb37e321c63e8bf)
> ---
>  common/include/test-byte-swapping.c | 1 +
>  common/include/test-isaligned.c     | 1 +
>  common/include/test-iszero.c        | 1 +
>  common/include/test-minmax.c        | 1 +
>  4 files changed, 4 insertions(+)




More information about the Libguestfs mailing list