From ea4b4b8775deb0aff5914a1659f8bead8ed69e99 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Thu, 26 Jan 2023 13:50:33 +0100 Subject: [PATCH] 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. (cherry picked from commit 3f2ad76363e2f53078829fb31406d5950de5e6f7) --- contrib/scripts/nm-ci-run.sh | 2 +- src/libnm-glib-aux/nm-test-utils.h | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/contrib/scripts/nm-ci-run.sh b/contrib/scripts/nm-ci-run.sh index 14a4a2fe53..22450d40c7 100755 --- a/contrib/scripts/nm-ci-run.sh +++ b/contrib/scripts/nm-ci-run.sh @@ -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" diff --git a/src/libnm-glib-aux/nm-test-utils.h b/src/libnm-glib-aux/nm-test-utils.h index b35eeb4b09..41e1a6cedf 100644 --- a/src/libnm-glib-aux/nm-test-utils.h +++ b/src/libnm-glib-aux/nm-test-utils.h @@ -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; }