gitlab-ci: explicitly set "NMTST_DEBUG=debug,..." for second debug run

"debug" is implied when setting NMTST_DEBUG, but not specifying
"no-debug". This change has thus no effect, but it seems clearer to be
explicit.

The "debug" flag affects nmtst_is_debug(). Note that tests *must* not
result in different code paths based on debug, they may only

 1) print more debug logging
 2) do more assertion checks.

Having more assertion checks can result in different outcome of the
test, that is, that the additional assertion fails first. That is
acceptable, because failing earlier is possibly closer to the issue and
helps debugging. Also, when the additional failure is fixed and passes,
we still will fail at the assertion we are trying to debug.

In particular, an access to nmtst_get_rand*()/nmtst_rand*() must not
depend on nmtst_is_debug(), because then different randomized paths
are taken based on whether debugging is enabled.
This commit is contained in:
Thomas Haller 2023-01-26 13:50:33 +01:00
parent 3bad3f8b24
commit 3f2ad76363
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728
2 changed files with 7 additions and 1 deletions

View file

@ -201,7 +201,7 @@ run_autotools() {
_print_test_logs "first-test"
echo ">>>> RUN SECOND TEST (start)"
NMTST_DEBUG=TRACE,no-expect-message make check -k || :
NMTST_DEBUG="debug,TRACE,no-expect-message" make check -k || :
echo ">>>> RUN SECOND TEST (done)"
_print_test_logs "second-test"

View file

@ -772,6 +772,12 @@ nmtst_init(int *argc, char ***argv, gboolean assert_logging)
static inline gboolean
nmtst_is_debug(void)
{
/* This is based on the "debug"/"no-debug" flag in "$NMTST_DEBUG".
*
* If debugging is enabled, print more information. However, make sure
* that the test behaves still in a similar manner and that the same code
* path are taken where it matters (it matters for example, if the code path
* consumes random numbers). */
g_assert(nmtst_initialized());
return __nmtst_internal.is_debug;
}