[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v5 02/13] qtest: Don't perform side effects insi
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH v5 02/13] qtest: Don't perform side effects inside assertion |
Date: |
Fri, 18 Aug 2017 16:58:09 -0500 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 |
On 08/18/2017 04:39 PM, Eric Blake wrote:
> On 08/18/2017 04:33 PM, Philippe Mathieu-Daudé wrote:
>> Hi Eric,
>>
>> On 08/18/2017 06:15 PM, Eric Blake wrote:
>>> Assertions should be separate from the side effects, since in
>>> theory, g_assert() can be disabled (in practice, we can't really
>>> ever do that).
>>
>> What about the suggestion on your "Hacks for building on gcc 7 / Fedora
>> 26" series about avoid building without assertions?
>
> NDEBUG doesn't affect g_assert() (only assert(), but that wasn't in use
> here) - I have to double-check glib documentation to see whether
> g_assert() can be crippled in a manner similar to how I know assert()
> can be crippled. Ideally, we have a form that always performs side
> effects exactly once, whether or not abort-on-error is enabled (assert()
> does not have that, but I don't know whether glib does).
Per https://developer.gnome.org/glib/stable/glib-Testing.html#g-assert,
G_DISABLE_ASSERT has the same compile-time effect on g_assert() as
NDEBUG on assert(). Even worse, g_assert_not_reached() has the same
problem.
Then there is the runtime switch g_test_set_nonfatal_assertions() which
affects the REST of the g_assert_*() family (such as g_assert_cmpint(),
g_assert_true(), g_assert_null()) - but NOT g_assert() proper. And I
recall Markus has posted in the past about complaining that
g_assert_cmpint() should not be used outside of tests/.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
signature.asc
Description: OpenPGP digital signature
[Qemu-devel] [PATCH v5 03/13] libqtest: Remove dead qtest_instances variable, Eric Blake, 2017/08/18
[Qemu-devel] [PATCH v5 01/13] test-qga: Kill broken and dead QGA_TEST_SIDE_EFFECTING code, Eric Blake, 2017/08/18
[Qemu-devel] [PATCH v5 06/13] libqtest: Topologically sort functions, Eric Blake, 2017/08/18
[Qemu-devel] [PATCH v5 04/13] libqtest: Let socket_send() compute length, Eric Blake, 2017/08/18
[Qemu-devel] [PATCH v5 05/13] libqtest: Use qemu_strtoul(), Eric Blake, 2017/08/18
[Qemu-devel] [PATCH v5 07/13] libqtest: Inline qtest_query_target_endianness(), Eric Blake, 2017/08/18