[PATCH v5 3/4] support: Add FAIL test failure helper
DJ Delorie
dj@redhat.com
Tue Jul 23 01:10:09 GMT 2024
"Maciej W. Rozycki" <macro@orcam.me.uk> writes:
> Add a FAIL test failure helper analogous to FAIL_RET, that does not
> cause the current function to return,
Sort of a FAIL_NOP. Ok.
> - tst-fortify-syslog: provide a meaningful message in addition to the
> file name already added by <support/check.h>; 'support_record_failure'
> is already called by 'support_print_failure_impl' invoked by the new
> FAIL test failure helper.
Ok.
> - tst-ctype: no update to FAIL calls required, with the name of the file
> and the line number within of the failure site additionally included
> by the new FAIL test failure helper, and error counting plus count
> reporting upon test program termination also already provided by
> 'support_record_failure' and 'support_report_failure' respectively,
Ok.
> - test-tgmath2: no update to FAIL calls required, with the name of the
> file of the failure site additionally included by the new FAIL test
> failure helper. Also there is no need to track the return status by
> hand as any call to FAIL will eventually cause the test case to return
> an unsuccesful exit status regardless of the return status from the
> test function, via a call to 'adjust_exit_status' made by the test
> driver.
> ---
> Hi,
>
> I have verified, by inducing errors by hand across all three test cases
> affected, that replacement error reporting is at least equivalent to
> original one and that the return status is correct. Given the nature of
> the change all the test cases, even though independent from each other and
> the change to <support/check.h>, need to go in as a single commit so as to
> avoid transient regressions, which could then adversely affect bisection
> in the future.
>
> Maciej
>
> Changes from v4:
>
> - Remove local FAIL macro definitions from tst-fortify-syslog, tst-ctype,
> and test-tgmath2, adjusting call sites to make use of the macro now
> provided by <support/check.h>.
>
> No change from v3.
>
> New change in v3.
> ---
> debug/tst-fortify-syslog.c | 8 +-------
> localedata/tst-ctype.c | 40 +++++++++-------------------------------
> math/test-tgmath2.c | 13 +++----------
> support/check.h | 5 +++++
> 4 files changed, 18 insertions(+), 48 deletions(-)
>
> glibc-support-check-fail.diff
> Index: glibc/debug/tst-fortify-syslog.c
> #include <string.h>
> #include <unistd.h>
> -#include <stdio.h>
Ok.
> -#define FAIL() \
> - do { \
> - printf ("Failure on line %d\n", __LINE__); \
> - support_record_failure (); \
> - } while (0)
Ok.
> #define CHK_FAIL_END \
> chk_fail_ok = 0; \
> - FAIL (); \
> + FAIL ("not supposed to reach here"); \
> }
Ok.
> Index: glibc/localedata/tst-ctype.c
> ===================================================================
> --- glibc.orig/localedata/tst-ctype.c
> +++ glibc/localedata/tst-ctype.c
> @@ -21,6 +21,8 @@
> #include <stdio.h>
> #include <string.h>
>
> +#include <support/check.h>
> +
Ok.
> -#define FAIL(str, args...) \
> - { \
> - printf (" " str "\n", ##args); \
> - ++errors; \
> - }
Ok.
> - int errors = 0;
Ok.
> {
> if (((__ctype_b[(unsigned int) *inp] & classes[n].mask) != 0)
> != (*resp != '0'))
> - {
> - printf (" is%s('%c' = '\\x%02x') %s true\n", inpline,
> - *inp, *inp, *resp == '1' ? "not" : "is");
> - ++errors;
> - }
> + FAIL (" is%s('%c' = '\\x%02x') %s true\n", inpline,
> + *inp, *inp, *resp == '1' ? "not" : "is");
Ok 3x.
> - if (errors != 0)
> - {
> - printf (" %d error%s for `%s' locale\n\n\n", errors,
> - errors == 1 ? "" : "s", setlocale (LC_ALL, NULL));
> - return 1;
> - }
> -
> - printf (" No errors for `%s' locale\n\n\n", setlocale (LC_ALL, NULL));
> + printf ("Completed testing for `%s' locale\n\n\n", setlocale (LC_ALL, NULL));
> return 0;
> }
Failure count is reported by the skeleton, ok.
> Index: glibc/math/test-tgmath2.c
> +#include <support/check.h>
Ok.
> -#define FAIL(str) \
> - do \
> - { \
> - printf ("%s failure on line %d\n", (str), __LINE__); \
> - result = 1; \
> - } \
> - while (0)
Ok.
> int
> test_cos (const int Vint4, const long long int Vllong4)
> {
> - int result = 0;
> -
Ok.
> - return result;
> + return 0;
Ok.
> Index: glibc/support/check.h
> /* Record a test failure, print the failure message to standard output
> + and pass the result of 1 through. */
> +#define FAIL(...) \
> + support_print_failure_impl (__FILE__, __LINE__, __VA_ARGS__)
> +
> +/* Record a test failure, print the failure message to standard output
Ok.
LGTM
Reviewed-by: DJ Delorie <dj@redhat.com>
More information about the Libc-alpha
mailing list