Re: [PATCH] [testsuite] introduce strndup effective target
On Apr 18, 2024, at 4:32 AM, Alexandre Oliva wrote: > > On Apr 16, 2024, Alexandre Oliva wrote: > >> * gcc.dg/builtin-dynamic-object-size-1.c: Likewise. >> * gcc.dg/builtin-dynamic-object-size-2.c: Likewise. >> * gcc.dg/builtin-dynamic-object-size-3.c: Likewise. >> * gcc.dg/builtin-dynamic-object-size-4.c: Likewise. > > These hunks were missing from the patch I posted No worries, thanks for all the hard work.
Re: [PATCH] [testsuite] introduce strndup effective target
On Apr 16, 2024, Alexandre Oliva wrote: > * gcc.dg/builtin-dynamic-object-size-1.c: Likewise. > * gcc.dg/builtin-dynamic-object-size-2.c: Likewise. > * gcc.dg/builtin-dynamic-object-size-3.c: Likewise. > * gcc.dg/builtin-dynamic-object-size-4.c: Likewise. These hunks were missing from the patch I posted, sorry. I goofed when resolving the conflicts because the tests had been modified after gcc-13. I hope the intent was clear from the ChangeLog entry. Here they are. diff --git a/gcc/testsuite/gcc.dg/builtin-dynamic-object-size-1.c b/gcc/testsuite/gcc.dg/builtin-dynamic-object-size-1.c index ffa59985024f5..76b4f704fed9c 100644 --- a/gcc/testsuite/gcc.dg/builtin-dynamic-object-size-1.c +++ b/gcc/testsuite/gcc.dg/builtin-dynamic-object-size-1.c @@ -1,7 +1,7 @@ /* { dg-do run } */ /* { dg-options "-O2 -Wno-stringop-overread" } */ /* { dg-require-effective-target alloca } */ -/* { dg-skip-if "no strndup" { hppa*-*-hpux* } } */ +/* { dg-additional-options "-DSKIP_STRNDUP" { target { ! strndup } } } */ #define __builtin_object_size __builtin_dynamic_object_size #include "builtin-object-size-1.c" diff --git a/gcc/testsuite/gcc.dg/builtin-dynamic-object-size-2.c b/gcc/testsuite/gcc.dg/builtin-dynamic-object-size-2.c index fff32da7aea14..cb757a8d699cf 100644 --- a/gcc/testsuite/gcc.dg/builtin-dynamic-object-size-2.c +++ b/gcc/testsuite/gcc.dg/builtin-dynamic-object-size-2.c @@ -1,7 +1,7 @@ /* { dg-do run } */ /* { dg-options "-O2 -Wno-stringop-overread" } */ /* { dg-require-effective-target alloca } */ -/* { dg-skip-if "no strndup" { hppa*-*-hpux* } } */ +/* { dg-additional-options "-DSKIP_STRNDUP" { target { ! strndup } } } */ #define __builtin_object_size __builtin_dynamic_object_size #include "builtin-object-size-2.c" diff --git a/gcc/testsuite/gcc.dg/builtin-dynamic-object-size-3.c b/gcc/testsuite/gcc.dg/builtin-dynamic-object-size-3.c index ac223d67b10a4..8a12f023f27bc 100644 --- a/gcc/testsuite/gcc.dg/builtin-dynamic-object-size-3.c +++ b/gcc/testsuite/gcc.dg/builtin-dynamic-object-size-3.c @@ -1,7 +1,7 @@ /* { dg-do run } */ /* { dg-options "-O2 -Wno-stringop-overread" } */ /* { dg-require-effective-target alloca } */ -/* { dg-skip-if "no strndup" { hppa*-*-hpux* } } */ +/* { dg-additional-options "-DSKIP_STRNDUP" { target { ! strndup } } } */ #define __builtin_object_size __builtin_dynamic_object_size #include "builtin-object-size-3.c" diff --git a/gcc/testsuite/gcc.dg/builtin-dynamic-object-size-4.c b/gcc/testsuite/gcc.dg/builtin-dynamic-object-size-4.c index fdf4284ae1158..0efc2d9858422 100644 --- a/gcc/testsuite/gcc.dg/builtin-dynamic-object-size-4.c +++ b/gcc/testsuite/gcc.dg/builtin-dynamic-object-size-4.c @@ -1,7 +1,7 @@ /* { dg-do run } */ /* { dg-options "-O2 -Wno-stringop-overread" } */ /* { dg-require-effective-target alloca } */ -/* { dg-skip-if "no strndup" { hppa*-*-hpux* } } */ +/* { dg-additional-options "-DSKIP_STRNDUP" { target { ! strndup } } } */ #define __builtin_object_size __builtin_dynamic_object_size #include "builtin-object-size-4.c" -- Alexandre Oliva, happy hackerhttps://FSFLA.org/blogs/lxo/ Free Software Activist GNU Toolchain Engineer More tolerance and less prejudice are key for inclusion and diversity Excluding neuro-others for not behaving ""normal"" is *not* inclusive
Re: [PATCH] [testsuite] introduce strndup effective target
On Tue, Apr 16, 2024 at 5:23 AM Alexandre Oliva wrote: > > > A number of tests that call strndup fail on vxworks, where there's no > strndup. Some of them already had workarounds to skip the strndup > parts of the tests on platforms that don't offer it. I've changed > them to rely on a strndup effective target instead, and extended the > logic to other tests that were otherwise skipped entirely. > > Regstrapped on x86_64-linux-gnu. Also tested with gcc-13 on arm-, > aarch64-, x86- and x86_64-vxworks7r2. Ok to install? OK > > for gcc/ChangeLog > > * doc/sourcebuild.texi (strndup): Add effective target. > > for gcc/testsuite/ChangeLog > > * lib/target-supports.exp (check_effective_target_strndup): New. > * gcc.dg/builtin-dynamic-object-size-0.c: Skip strndup tests > when the function is not available. > * gcc.dg/builtin-dynamic-object-size-1.c: Likewise. > * gcc.dg/builtin-dynamic-object-size-2.c: Likewise. > * gcc.dg/builtin-dynamic-object-size-3.c: Likewise. > * gcc.dg/builtin-dynamic-object-size-4.c: Likewise. > * gcc.dg/builtin-object-size-1.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/doc/sourcebuild.texi |3 +++ > .../gcc.dg/builtin-dynamic-object-size-0.c | 10 +- > gcc/testsuite/gcc.dg/builtin-object-size-1.c |7 --- > gcc/testsuite/gcc.dg/builtin-object-size-2.c |7 --- > gcc/testsuite/gcc.dg/builtin-object-size-3.c |7 --- > gcc/testsuite/gcc.dg/builtin-object-size-4.c |7 --- > gcc/testsuite/lib/target-supports.exp | 11 +++ > 7 files changed, 39 insertions(+), 13 deletions(-) > > diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi > index 7c0df90e82236..8e4e59ac44c74 100644 > --- a/gcc/doc/sourcebuild.texi > +++ b/gcc/doc/sourcebuild.texi > @@ -2837,6 +2837,9 @@ can be included without error when > @option{-mbig-endian} is passed. > @item stpcpy > Target provides @code{stpcpy} function. > > +@item strndup > +Target provides @code{strndup} function. > + > @item sysconf > Target supports @code{sysconf}. > > diff --git a/gcc/testsuite/gcc.dg/builtin-dynamic-object-size-0.c > b/gcc/testsuite/gcc.dg/builtin-dynamic-object-size-0.c > index 173e7c755f4c9..d02e37f79d95f 100644 > --- a/gcc/testsuite/gcc.dg/builtin-dynamic-object-size-0.c > +++ b/gcc/testsuite/gcc.dg/builtin-dynamic-object-size-0.c > @@ -1,7 +1,7 @@ > /* { dg-do run } */ > /* { dg-options "-O2" } */ > /* { dg-require-effective-target size20plus } */ > -/* { dg-skip-if "no strndup" { hppa*-*-hpux* } } */ > +/* { dg-additional-options "-DSKIP_STRNDUP" { target { ! strndup } } } */ > > #include "builtin-object-size-common.h" > > @@ -567,6 +567,7 @@ test_strdup (const char *in) >return sz; > } > > +#ifndef SKIP_STRNDUP > size_t > __attribute__ ((noinline)) > test_strndup (const char *in, size_t bound) > @@ -577,6 +578,7 @@ test_strndup (const char *in, size_t bound) >__builtin_free (res); >return sz; > } > +#endif > > size_t > __attribute__ ((noinline)) > @@ -589,6 +591,7 @@ test_strdup_min (const char *in) >return sz; > } > > +#ifndef SKIP_STRNDUP > size_t > __attribute__ ((noinline)) > test_strndup_min (const char *in, size_t bound) > @@ -599,6 +602,7 @@ test_strndup_min (const char *in, size_t bound) >__builtin_free (res); >return sz; > } > +#endif > > /* Other tests. */ > > @@ -788,12 +792,16 @@ main (int argc, char **argv) >const char *str = "hello world"; >if (test_strdup (str) != __builtin_strlen (str) + 1) > FAIL (); > +#ifndef SKIP_STRNDUP >if (test_strndup (str, 4) != 5) > FAIL (); > +#endif >if (test_strdup_min (str) != __builtin_strlen (str) + 1) > FAIL (); > +#ifndef SKIP_STRNDUP >if (test_strndup_min (str, 4) != 1) > FAIL (); > +#endif > >DONE (); > } > diff --git a/gcc/testsuite/gcc.dg/builtin-object-size-1.c > b/gcc/testsuite/gcc.dg/builtin-object-size-1.c > index 4f7d4c0b370f5..d6d13c5ef7a29 100644 > --- a/gcc/testsuite/gcc.dg/builtin-object-size-1.c > +++ b/gcc/testsuite/gcc.dg/builtin-object-size-1.c > @@ -1,6 +1,7 @@ > /* { dg-do run } */ > /* { dg-options "-O2 -Wno-stringop-overread" } */ > /* { dg-require-effective-target alloca } */ > +/* { dg-additional-options "-DSKIP_STRNDUP" { target { ! strndup } } } */ > > #include "builtin-object-size-common.h" > > @@ -621,7 +622,7 @@ test10 (void) > } > } > > -#if !defined(__AVR__) && !defined(__hpux__) /* avr and hpux have no strndup > */ > +#ifndef SKIP_STRNDUP > /* Tests for strdup/strndup. */ > size_t > __attribute__ ((noinline)) > @@ -709,7 +710,7 @@ test11 (void) > FAIL (); >free (res); > } > -#endif /* avr */ > +#endif > > int > main (void) > @@ -726,7 +727,7 @@ main (void) >test8 (); >tes
[PATCH] [testsuite] introduce strndup effective target
A number of tests that call strndup fail on vxworks, where there's no strndup. Some of them already had workarounds to skip the strndup parts of the tests on platforms that don't offer it. I've changed them to rely on a strndup effective target instead, and extended the logic to other tests that were otherwise skipped entirely. Regstrapped on x86_64-linux-gnu. Also tested with gcc-13 on arm-, aarch64-, x86- and x86_64-vxworks7r2. Ok to install? for gcc/ChangeLog * doc/sourcebuild.texi (strndup): Add effective target. for gcc/testsuite/ChangeLog * lib/target-supports.exp (check_effective_target_strndup): New. * gcc.dg/builtin-dynamic-object-size-0.c: Skip strndup tests when the function is not available. * gcc.dg/builtin-dynamic-object-size-1.c: Likewise. * gcc.dg/builtin-dynamic-object-size-2.c: Likewise. * gcc.dg/builtin-dynamic-object-size-3.c: Likewise. * gcc.dg/builtin-dynamic-object-size-4.c: Likewise. * gcc.dg/builtin-object-size-1.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/doc/sourcebuild.texi |3 +++ .../gcc.dg/builtin-dynamic-object-size-0.c | 10 +- gcc/testsuite/gcc.dg/builtin-object-size-1.c |7 --- gcc/testsuite/gcc.dg/builtin-object-size-2.c |7 --- gcc/testsuite/gcc.dg/builtin-object-size-3.c |7 --- gcc/testsuite/gcc.dg/builtin-object-size-4.c |7 --- gcc/testsuite/lib/target-supports.exp | 11 +++ 7 files changed, 39 insertions(+), 13 deletions(-) diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi index 7c0df90e82236..8e4e59ac44c74 100644 --- a/gcc/doc/sourcebuild.texi +++ b/gcc/doc/sourcebuild.texi @@ -2837,6 +2837,9 @@ can be included without error when @option{-mbig-endian} is passed. @item stpcpy Target provides @code{stpcpy} function. +@item strndup +Target provides @code{strndup} function. + @item sysconf Target supports @code{sysconf}. diff --git a/gcc/testsuite/gcc.dg/builtin-dynamic-object-size-0.c b/gcc/testsuite/gcc.dg/builtin-dynamic-object-size-0.c index 173e7c755f4c9..d02e37f79d95f 100644 --- a/gcc/testsuite/gcc.dg/builtin-dynamic-object-size-0.c +++ b/gcc/testsuite/gcc.dg/builtin-dynamic-object-size-0.c @@ -1,7 +1,7 @@ /* { dg-do run } */ /* { dg-options "-O2" } */ /* { dg-require-effective-target size20plus } */ -/* { dg-skip-if "no strndup" { hppa*-*-hpux* } } */ +/* { dg-additional-options "-DSKIP_STRNDUP" { target { ! strndup } } } */ #include "builtin-object-size-common.h" @@ -567,6 +567,7 @@ test_strdup (const char *in) return sz; } +#ifndef SKIP_STRNDUP size_t __attribute__ ((noinline)) test_strndup (const char *in, size_t bound) @@ -577,6 +578,7 @@ test_strndup (const char *in, size_t bound) __builtin_free (res); return sz; } +#endif size_t __attribute__ ((noinline)) @@ -589,6 +591,7 @@ test_strdup_min (const char *in) return sz; } +#ifndef SKIP_STRNDUP size_t __attribute__ ((noinline)) test_strndup_min (const char *in, size_t bound) @@ -599,6 +602,7 @@ test_strndup_min (const char *in, size_t bound) __builtin_free (res); return sz; } +#endif /* Other tests. */ @@ -788,12 +792,16 @@ main (int argc, char **argv) const char *str = "hello world"; if (test_strdup (str) != __builtin_strlen (str) + 1) FAIL (); +#ifndef SKIP_STRNDUP if (test_strndup (str, 4) != 5) FAIL (); +#endif if (test_strdup_min (str) != __builtin_strlen (str) + 1) FAIL (); +#ifndef SKIP_STRNDUP if (test_strndup_min (str, 4) != 1) FAIL (); +#endif DONE (); } diff --git a/gcc/testsuite/gcc.dg/builtin-object-size-1.c b/gcc/testsuite/gcc.dg/builtin-object-size-1.c index 4f7d4c0b370f5..d6d13c5ef7a29 100644 --- a/gcc/testsuite/gcc.dg/builtin-object-size-1.c +++ b/gcc/testsuite/gcc.dg/builtin-object-size-1.c @@ -1,6 +1,7 @@ /* { dg-do run } */ /* { dg-options "-O2 -Wno-stringop-overread" } */ /* { dg-require-effective-target alloca } */ +/* { dg-additional-options "-DSKIP_STRNDUP" { target { ! strndup } } } */ #include "builtin-object-size-common.h" @@ -621,7 +622,7 @@ test10 (void) } } -#if !defined(__AVR__) && !defined(__hpux__) /* avr and hpux have no strndup */ +#ifndef SKIP_STRNDUP /* Tests for strdup/strndup. */ size_t __attribute__ ((noinline)) @@ -709,7 +710,7 @@ test11 (void) FAIL (); free (res); } -#endif /* avr */ +#endif int main (void) @@ -726,7 +727,7 @@ main (void) test8 (); test9 (1); test10 (); -#if !defined(__AVR__) && !defined(__hpux__) /* avr and hpux have no strndup */ +#ifndef SKIP_STRNDUP test11 (); #endif DONE (); diff --git a/gcc/testsuite/gcc.dg/builtin-object-size-2.c b/gcc/testsuite/gcc.dg/builtin-object-size-2.c index 37d3dcc6f5689..c28d72eee9bfe 100644 --- a/gcc/testsuite/g