Bruno Haible <[email protected]> writes: > Collin Funk wrote: >> How does the attached patch look? I tested them in a glibc build as well >> and they work fine there. > > The purpose of > > return test_exit_status; > > is to get a test failure if some assertion failed and CONTINUE_AFTER_ASSERT > is defined to 1 (which is the preferred setting in a CI). > > Can you accommodate it via GNULIB_TEST_STDBIT?
Right. I planned to do that when I started writing the patch, but forgot to in the process. I pushed the attached v2 patch, defining TEST_EXIT_STATUS to expand to the proper variable/value. Collin
>From 79ee7bb214ccfd4d9cc7ee765f847833dfe7f539 Mon Sep 17 00:00:00 2001 Message-ID: <79ee7bb214ccfd4d9cc7ee765f847833dfe7f539.1786602330.git.collin.fu...@gmail.com> From: Collin Funk <[email protected]> Date: Wed, 12 Aug 2026 19:00:17 -0700 Subject: [PATCH v2] stdc_rotate_{left,right}-tests: adjust to share with glibc * tests/from-glibc/tst-stdc_rotate_left.c: New file, based on tests/test-stdc_rotate_left.c with changes to also work with the glibc test framework. Relicense to LGPLv2.1+. * tests/from-glibc/tst-stdc_rotate_right.c: New file, based on tests/test-stdc_rotate_right.c with changes to also work with the glibc test framework. Relicense to LGPLv2.1+. * modules/stdc_rotate_left-tests (Files): List the new file. (Depends-on): Add the new file as a source for the test program. Define GNULIB_TEST_STDBIT when compiling. * modules/stdc_rotate_right-tests (Files): List the new file. (Depends-on): Add the new file as a source for the test program. Define GNULIB_TEST_STDBIT when compiling. --- ChangeLog | 16 ++++++ modules/stdc_rotate_left-tests | 4 +- modules/stdc_rotate_right-tests | 4 +- .../tst-stdc_rotate_left.c} | 53 ++++++++++++------- .../tst-stdc_rotate_right.c} | 53 ++++++++++++------- 5 files changed, 90 insertions(+), 40 deletions(-) rename tests/{test-stdc_rotate_left.c => from-glibc/tst-stdc_rotate_left.c} (96%) rename tests/{test-stdc_rotate_right.c => from-glibc/tst-stdc_rotate_right.c} (96%) diff --git a/ChangeLog b/ChangeLog index 4d08951061..0774c8725d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +2026-08-12 Collin Funk <[email protected]> + + stdc_rotate_{left,right}-tests: adjust to share with glibc + * tests/from-glibc/tst-stdc_rotate_left.c: New file, based on + tests/test-stdc_rotate_left.c with changes to also work with the glibc + test framework. Relicense to LGPLv2.1+. + * tests/from-glibc/tst-stdc_rotate_right.c: New file, based on + tests/test-stdc_rotate_right.c with changes to also work with the glibc + test framework. Relicense to LGPLv2.1+. + * modules/stdc_rotate_left-tests (Files): List the new file. + (Depends-on): Add the new file as a source for the test program. Define + GNULIB_TEST_STDBIT when compiling. + * modules/stdc_rotate_right-tests (Files): List the new file. + (Depends-on): Add the new file as a source for the test program. Define + GNULIB_TEST_STDBIT when compiling. + 2026-08-12 Paul Eggert <[email protected]> stdc_rotate_left-tests: pacify -Woverflow diff --git a/modules/stdc_rotate_left-tests b/modules/stdc_rotate_left-tests index f88e0adf97..0739a719ea 100644 --- a/modules/stdc_rotate_left-tests +++ b/modules/stdc_rotate_left-tests @@ -1,5 +1,5 @@ Files: -tests/test-stdc_rotate_left.c +tests/from-glibc/tst-stdc_rotate_left.c tests/macros.h Depends-on: @@ -9,3 +9,5 @@ configure.ac: Makefile.am: TESTS += test-stdc_rotate_left check_PROGRAMS += test-stdc_rotate_left +test_stdc_rotate_left_SOURCES = from-glibc/tst-stdc_rotate_left.c +test_stdc_rotate_left_CPPFLAGS = $(AM_CPPFLAGS) -DGNULIB_TEST_STDBIT diff --git a/modules/stdc_rotate_right-tests b/modules/stdc_rotate_right-tests index 8a8047010e..2b440d0981 100644 --- a/modules/stdc_rotate_right-tests +++ b/modules/stdc_rotate_right-tests @@ -1,5 +1,5 @@ Files: -tests/test-stdc_rotate_right.c +tests/from-glibc/tst-stdc_rotate_right.c tests/macros.h Depends-on: @@ -9,3 +9,5 @@ configure.ac: Makefile.am: TESTS += test-stdc_rotate_right check_PROGRAMS += test-stdc_rotate_right +test_stdc_rotate_right_SOURCES = from-glibc/tst-stdc_rotate_right.c +test_stdc_rotate_right_CPPFLAGS = $(AM_CPPFLAGS) -DGNULIB_TEST_STDBIT diff --git a/tests/test-stdc_rotate_left.c b/tests/from-glibc/tst-stdc_rotate_left.c similarity index 96% rename from tests/test-stdc_rotate_left.c rename to tests/from-glibc/tst-stdc_rotate_left.c index 10723d4afc..ec89f4ae52 100644 --- a/tests/test-stdc_rotate_left.c +++ b/tests/from-glibc/tst-stdc_rotate_left.c @@ -1,37 +1,48 @@ /* Test the stdc_rotate_left_* functions and macro. Copyright (C) 2026 Free Software Foundation, Inc. - This file is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published - by the Free Software Foundation, either version 3 of the License, - or (at your option) any later version. + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. - This file is distributed in the hope that it will be useful, + The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program. If not, see <https://www.gnu.org/licenses/>. */ + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <https://www.gnu.org/licenses/>. */ -/* Written by Collin Funk <[email protected]>, 2026. */ - -#include <config.h> +#ifdef GNULIB_TEST_STDBIT +# include <config.h> +#endif /* Specification. */ #include <stdbit.h> #include <limits.h> -#include "macros.h" +#ifdef GNULIB_TEST_STDBIT +# include "macros.h" +# define MAIN_STATIC +# define MAIN main +# define TEST_COMPARE(a, b) ASSERT ((a) == (b)) +# define TEST_EXIT_STATUS test_exit_status +#else +# include <support/check.h> +# define MAIN_STATIC static +# define MAIN do_test +# define TEST_EXIT_STATUS 0 +#endif #define TEST_CASE(type, function, value, shift, expect) \ do \ { \ type v = value; \ - type e = expect; \ - ASSERT (function (v, shift) == e); \ - ASSERT (stdc_rotate_left (v, shift) == e); \ + TEST_COMPARE (function (v, shift), expect); \ + TEST_COMPARE (stdc_rotate_left (v, shift), expect); \ } \ while (false) @@ -452,13 +463,17 @@ test_stdc_rotate_left_ull (void) TEST_CASES_64 (unsigned long long int, stdc_rotate_left_ull); } -int -main (void) +MAIN_STATIC int +MAIN (void) { test_stdc_rotate_left_uc (); test_stdc_rotate_left_us (); test_stdc_rotate_left_ui (); test_stdc_rotate_left_ul (); test_stdc_rotate_left_ull (); - return test_exit_status; + return TEST_EXIT_STATUS; } + +#ifndef GNULIB_TEST_STDBIT +# include <support/test-driver.c> +#endif diff --git a/tests/test-stdc_rotate_right.c b/tests/from-glibc/tst-stdc_rotate_right.c similarity index 96% rename from tests/test-stdc_rotate_right.c rename to tests/from-glibc/tst-stdc_rotate_right.c index 0ffdd928d5..01b28cd957 100644 --- a/tests/test-stdc_rotate_right.c +++ b/tests/from-glibc/tst-stdc_rotate_right.c @@ -1,37 +1,48 @@ /* Test the stdc_rotate_right_* functions and macro. Copyright (C) 2026 Free Software Foundation, Inc. - This file is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published - by the Free Software Foundation, either version 3 of the License, - or (at your option) any later version. + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. - This file is distributed in the hope that it will be useful, + The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program. If not, see <https://www.gnu.org/licenses/>. */ + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <https://www.gnu.org/licenses/>. */ -/* Written by Collin Funk <[email protected]>, 2026. */ - -#include <config.h> +#ifdef GNULIB_TEST_STDBIT +# include <config.h> +#endif /* Specification. */ #include <stdbit.h> #include <limits.h> -#include "macros.h" +#ifdef GNULIB_TEST_STDBIT +# include "macros.h" +# define MAIN_STATIC +# define MAIN main +# define TEST_COMPARE(a, b) ASSERT ((a) == (b)) +# define TEST_EXIT_STATUS test_exit_status +#else +# include <support/check.h> +# define MAIN_STATIC static +# define MAIN do_test +# define TEST_EXIT_STATUS 0 +#endif #define TEST_CASE(type, function, value, shift, expect) \ do \ { \ type v = value; \ - type e = expect; \ - ASSERT (function (v, shift) == e); \ - ASSERT (stdc_rotate_right (v, shift) == e); \ + TEST_COMPARE (function (v, shift), expect); \ + TEST_COMPARE (stdc_rotate_right (v, shift), expect); \ } \ while (false) @@ -452,13 +463,17 @@ test_stdc_rotate_right_ull (void) TEST_CASES_64 (unsigned long long int, stdc_rotate_right_ull); } -int -main (void) +MAIN_STATIC int +MAIN (void) { test_stdc_rotate_right_uc (); test_stdc_rotate_right_us (); test_stdc_rotate_right_ui (); test_stdc_rotate_right_ul (); test_stdc_rotate_right_ull (); - return test_exit_status; + return TEST_EXIT_STATUS; } + +#ifndef GNULIB_TEST_STDBIT +# include <support/test-driver.c> +#endif -- 2.55.0
