[PATCH 1/2] testsuite: Run __bos tests to completion
Jakub Jelinek
jakub@redhat.com
Tue Jan 31 12:33:41 GMT 2023
On Wed, Dec 21, 2022 at 05:25:53PM -0500, Siddhesh Poyarekar wrote:
> gcc/testsuite/ChangeLog:
>
> * gcc.dg/builtin-dynamic-object-size-0.c: Move FAIL and nfail
> into...
> * gcc.dg/builtin-object-size-common.h: ... new file.
> * g++.dg/ext/builtin-object-size1.C: Include
> builtin-object-size-common.h. Replace all abort with FAIL.
> (main): Call DONE.
> * g++.dg/ext/builtin-object-size2.C: Likewise.
> * gcc.dg/builtin-object-size-1.c: Likewise.
> * gcc.dg/builtin-object-size-12.c: Likewise.
> * gcc.dg/builtin-object-size-13.c: Likewise.
> * gcc.dg/builtin-object-size-15.c: Likewise.
> * gcc.dg/builtin-object-size-2.c: Likewise.
> * gcc.dg/builtin-object-size-3.c: Likewise.
> * gcc.dg/builtin-object-size-4.c: Likewise.
> * gcc.dg/builtin-object-size-6.c: Likewise.
> * gcc.dg/builtin-object-size-7.c: Likewise.
> * gcc.dg/builtin-object-size-8.c: Likewise.
> * gcc.dg/pr101836.c: Likewise.
> * gcc.dg/strict-flex-array-3.c: Likewise.
> --- a/gcc/testsuite/g++.dg/ext/builtin-object-size1.C
> +++ b/gcc/testsuite/g++.dg/ext/builtin-object-size1.C
> @@ -1,8 +1,9 @@
> // { dg-do run }
> // { dg-options "-O2" }
>
> +#include "../../gcc.dg/builtin-object-size-common.h"
> +
> typedef __SIZE_TYPE__ size_t;
> -extern "C" void abort ();
> extern "C" void exit (int);
> extern "C" void *malloc (size_t);
> extern "C" void free (void *);
I'd then wonder if size_t shouldn't be typedefed and perhaps
even exit/malloc/free etc. shouldn't be prototyped in
builtin-object-size-common.h too (of course, with extern "C"
conditionalized on __cplusplus).
> if (__builtin_object_size (r + 6, 0) != res - 6)
> - abort ();
> + FAIL ();
There should be a tab, not 8 spaces.
> @@ -335,13 +336,13 @@ test2 (void)
> if (res >= 12)
> {
> if (__builtin_object_size (r + 12, 0) != res - 12)
> - abort ();
> + FAIL ();
Ditto.
> --- /dev/null
> +++ b/gcc/testsuite/gcc.dg/builtin-object-size-common.h
> @@ -0,0 +1,12 @@
> +unsigned nfails = 0;
> +
> +#define FAIL() ({ \
> + __builtin_printf ("Failure at line: %d\n", __LINE__); \
> + nfails++; \
> +})
> +
> +#define DONE() ({ \
> + if (nfails > 0) \
> + __builtin_abort (); \
> + return 0; \
> +})
Why the statement expressions? do { and } while (0) would work too...
> - printf("WAT: %s == %zd (expected %zd)\n", #p, p, v); \
> - __builtin_abort (); \
> + __builtin_printf("WAT: %s == %zd (expected %zd)\n", #p, p, v); \
> + FAIL (); \
The above has rightly indented FAIL, but the line before that uses
10 spaces rather than tab + 2 spaces.
Otherwise LGTM.
Jakub
More information about the Gcc-patches
mailing list