mbox series

[v2,0/5] t/unit-tests: improve clar platform compatibility

Message ID cover.1729506329.git.ps@pks.im (mailing list archive)
Headers show
Series t/unit-tests: improve clar platform compatibility | expand

Message

Patrick Steinhardt Oct. 21, 2024, 10:56 a.m. UTC
Hi,

this is the second version of my patch series that addresses some
platform compatibility issues with clar. Changes compared to v1:

  - I've merged the CMake fixes at [1] into this patch series to avoid
    conflicts. @Taylor, please drop that other series, which is
    "ps/cmake-clar".

  - I've fixed up the "generate-clar-decls.h" script.

  - I've updated the clar such that it includes upstreamed changes for
    improved uClibc support when we lack support for `wchar_t`.

Thanks!

Patrick

[1]: <cover.1728914219.git.ps@pks.im>

Alejandro R. SedeƱo (1):
  Makefile: adjust sed command for generating "clar-decls.h"

Patrick Steinhardt (4):
  t/unit-tests: update clar to 206accb
  Makefile: extract script to generate clar declarations
  cmake: fix compilation of clar-based unit tests
  cmake: set up proper dependencies for generated clar headers

 Makefile                                   |   4 +-
 contrib/buildsystems/CMakeLists.txt        |  52 +++------
 t/unit-tests/clar/.editorconfig            |  13 +++
 t/unit-tests/clar/.github/workflows/ci.yml |  20 +++-
 t/unit-tests/clar/.gitignore               |   1 +
 t/unit-tests/clar/CMakeLists.txt           |  28 +++++
 t/unit-tests/clar/clar.c                   | 127 ++++++++++++---------
 t/unit-tests/clar/clar/print.h             |  11 +-
 t/unit-tests/clar/clar/sandbox.h           |  17 ++-
 t/unit-tests/clar/clar/summary.h           |  14 +--
 t/unit-tests/clar/test/.gitignore          |   4 -
 t/unit-tests/clar/test/CMakeLists.txt      |  39 +++++++
 t/unit-tests/clar/test/Makefile            |  39 -------
 t/unit-tests/generate-clar-decls.sh        |  16 +++
 14 files changed, 219 insertions(+), 166 deletions(-)
 create mode 100644 t/unit-tests/clar/.editorconfig
 create mode 100644 t/unit-tests/clar/.gitignore
 create mode 100644 t/unit-tests/clar/CMakeLists.txt
 delete mode 100644 t/unit-tests/clar/test/.gitignore
 create mode 100644 t/unit-tests/clar/test/CMakeLists.txt
 delete mode 100644 t/unit-tests/clar/test/Makefile
 create mode 100755 t/unit-tests/generate-clar-decls.sh

Range-diff against v1:
1:  a96fbdbb5f9 ! 1:  06145a141dd t/unit-tests: update clar to 0810a36
    @@ Metadata
     Author: Patrick Steinhardt <ps@pks.im>
     
      ## Commit message ##
    -    t/unit-tests: update clar to 0810a36
    +    t/unit-tests: update clar to 206accb
     
         Update clar from:
     
    @@ Commit message
     
         To:
     
    -        - 0810a36 (Merge pull request #107 from pks-t/pks-sunos-compatibility, 2024-10-14)
    +        - 206accb (Merge pull request #108 from pks-t/pks-uclibc-without-wchar, 2024-10-21)
     
         This update includes a bunch of fixes and improvements that we have
         discussed in Git when initial support for clar was merged:
    @@ Commit message
           - We now use the combination of mktemp(3) and mkdir(3) on SunOS, same
             as we do on NonStop.
     
    +      - We now support uClibc without support for <wchar.h>.
    +
         The most important bits here are the improved platform compatibility
    -    with Windows, OpenSUSE and SunOS.
    +    with Windows, OpenSUSE, SunOS and uClibc.
     
         Signed-off-by: Patrick Steinhardt <ps@pks.im>
     
    @@ t/unit-tests/clar/clar.c
      
      /* required for sandboxing */
      #include <sys/types.h>
    + #include <sys/stat.h>
    + 
    ++#if defined(__UCLIBC__) && ! defined(__UCLIBC_HAS_WCHAR__)
    ++	/*
    ++	 * uClibc can optionally be built without wchar support, in which case
    ++	 * the installed <wchar.h> is a stub that only defines the `whar_t`
    ++	 * type but none of the functions typically declared by it.
    ++	 */
    ++#else
    ++#	define CLAR_HAVE_WCHAR
    ++#endif
    ++
    + #ifdef _WIN32
    + #	define WIN32_LEAN_AND_MEAN
    + #	include <windows.h>
     @@
      
      #	ifndef stat
    @@ t/unit-tests/clar/clar.c: void clar__assert_equal(
      			}
      		}
      	}
    ++#ifdef CLAR_HAVE_WCHAR
    + 	else if (!strcmp("%ls", fmt)) {
    + 		const wchar_t *wcs1 = va_arg(args, const wchar_t *);
    + 		const wchar_t *wcs2 = va_arg(args, const wchar_t *);
    +@@ t/unit-tests/clar/clar.c: void clar__assert_equal(
    + 			}
    + 		}
    + 	}
     -	else if (!strcmp("%"PRIuZ, fmt) || !strcmp("%"PRIxZ, fmt)) {
     -		size_t sz1 = va_arg(args, size_t), sz2 = va_arg(args, size_t);
    ++#endif /* CLAR_HAVE_WCHAR */
     +	else if (!strcmp("%"PRIuMAX, fmt) || !strcmp("%"PRIxMAX, fmt)) {
     +		uintmax_t sz1 = va_arg(args, uintmax_t), sz2 = va_arg(args, uintmax_t);
      		is_equal = (sz1 == sz2);
2:  dda9b8e033c = 2:  17d77f36d41 Makefile: adjust sed command for generating "clar-decls.h"
-:  ----------- > 3:  c2e3fbcd853 Makefile: extract script to generate clar declarations
-:  ----------- > 4:  a30017a4d89 cmake: fix compilation of clar-based unit tests
-:  ----------- > 5:  bb005979e7e cmake: set up proper dependencies for generated clar headers

base-commit: 3a0677f8601d8937562ba14665d773fd8f2d71da

Comments

Taylor Blau Oct. 21, 2024, 8:52 p.m. UTC | #1
On Mon, Oct 21, 2024 at 12:56:30PM +0200, Patrick Steinhardt wrote:
> Hi,
>
> this is the second version of my patch series that addresses some
> platform compatibility issues with clar. Changes compared to v1:
>
>   - I've merged the CMake fixes at [1] into this patch series to avoid
>     conflicts. @Taylor, please drop that other series, which is
>     "ps/cmake-clar".
>
>   - I've fixed up the "generate-clar-decls.h" script.
>
>   - I've updated the clar such that it includes upstreamed changes for
>     improved uClibc support when we lack support for `wchar_t`.

Thanks (especially so for the suggestion to drop ps/cmake-clar), will
queue.

Thanks,
Taylor
karthik nayak Oct. 25, 2024, 12:17 p.m. UTC | #2
Patrick Steinhardt <ps@pks.im> writes:

> Hi,
>
> this is the second version of my patch series that addresses some
> platform compatibility issues with clar. Changes compared to v1:
>
>   - I've merged the CMake fixes at [1] into this patch series to avoid
>     conflicts. @Taylor, please drop that other series, which is
>     "ps/cmake-clar".
>
>   - I've fixed up the "generate-clar-decls.h" script.
>
>   - I've updated the clar such that it includes upstreamed changes for
>     improved uClibc support when we lack support for `wchar_t`.
>
> Thanks!
>

I went through the patches, played around with it locally too, couldn't
find any issues. So looks good to me!


[snip]