[PATCH 0/4] tools/nolibc: add testcases for vfprintf

Willy Tarreau posted 4 patches 2 years, 10 months ago
There is a newer version of this series
tools/include/nolibc/stdio.h                 | 95 ++++++++++++++------
tools/include/nolibc/sys.h                   | 23 +++++
tools/testing/selftests/nolibc/.gitignore    |  1 +
tools/testing/selftests/nolibc/Makefile      |  6 ++
tools/testing/selftests/nolibc/nolibc-test.c | 86 ++++++++++++++++++
5 files changed, 184 insertions(+), 27 deletions(-)
[PATCH 0/4] tools/nolibc: add testcases for vfprintf
Posted by Willy Tarreau 2 years, 10 months ago
Hello Paul,

Thomas added new tests for vfprintf(), which is a good idea because it
was a new implementation, we use it a lot in the tests so we'd rather
make sure it works! This required to implement support for memfd_create()
that is used to collect the output into a buffer, as well as to complete
a little bit the minimalistic FILE emulation with fileno(), fdopen(),
fflush() and fclose(). The result is neat and works equally on glibc and
nolibc. We just had to cheat on the pointer test because for NULL nolibc
prints "0x0" while glibc prints "(nil)" so we check 0x1 instead to avoid
this special case.

Finally Thomas added a new target to the makefile to ease building the
test against the default libc. This should help detect incompatibilities
when new features are added.

I've tested it locally with my libc and against all supported architectures
(userland tests only), and all tests passed.

This can be added to your dev tree for 6.5 on top of the previous series.

Thanks!
Willy

Thomas Weißschuh (4):
  tools/nolibc: add libc-test binary
  tools/nolibc: add wrapper for memfd_create
  tools/nolibc: implement fd-based FILE streams
  tools/nolibc: add testcases for vfprintf

 tools/include/nolibc/stdio.h                 | 95 ++++++++++++++------
 tools/include/nolibc/sys.h                   | 23 +++++
 tools/testing/selftests/nolibc/.gitignore    |  1 +
 tools/testing/selftests/nolibc/Makefile      |  6 ++
 tools/testing/selftests/nolibc/nolibc-test.c | 86 ++++++++++++++++++
 5 files changed, 184 insertions(+), 27 deletions(-)

-- 
2.17.5

Re: [PATCH 0/4] tools/nolibc: add testcases for vfprintf
Posted by Paul E. McKenney 2 years, 10 months ago
On Sun, Apr 02, 2023 at 08:48:02PM +0200, Willy Tarreau wrote:
> Hello Paul,
> 
> Thomas added new tests for vfprintf(), which is a good idea because it
> was a new implementation, we use it a lot in the tests so we'd rather
> make sure it works! This required to implement support for memfd_create()
> that is used to collect the output into a buffer, as well as to complete
> a little bit the minimalistic FILE emulation with fileno(), fdopen(),
> fflush() and fclose(). The result is neat and works equally on glibc and
> nolibc. We just had to cheat on the pointer test because for NULL nolibc
> prints "0x0" while glibc prints "(nil)" so we check 0x1 instead to avoid
> this special case.
> 
> Finally Thomas added a new target to the makefile to ease building the
> test against the default libc. This should help detect incompatibilities
> when new features are added.
> 
> I've tested it locally with my libc and against all supported architectures
> (userland tests only), and all tests passed.
> 
> This can be added to your dev tree for 6.5 on top of the previous series.

Looks like some useful code to make testing more comprehensive, thank
you both!  Queued and pushed.

							Thanx, Paul

> Thanks!
> Willy
> 
> Thomas Weißschuh (4):
>   tools/nolibc: add libc-test binary
>   tools/nolibc: add wrapper for memfd_create
>   tools/nolibc: implement fd-based FILE streams
>   tools/nolibc: add testcases for vfprintf
> 
>  tools/include/nolibc/stdio.h                 | 95 ++++++++++++++------
>  tools/include/nolibc/sys.h                   | 23 +++++
>  tools/testing/selftests/nolibc/.gitignore    |  1 +
>  tools/testing/selftests/nolibc/Makefile      |  6 ++
>  tools/testing/selftests/nolibc/nolibc-test.c | 86 ++++++++++++++++++
>  5 files changed, 184 insertions(+), 27 deletions(-)
> 
> -- 
> 2.17.5
> 
Re: [PATCH 0/4] tools/nolibc: add testcases for vfprintf
Posted by Paul E. McKenney 2 years, 10 months ago
On Sun, Apr 02, 2023 at 02:24:04PM -0700, Paul E. McKenney wrote:
> On Sun, Apr 02, 2023 at 08:48:02PM +0200, Willy Tarreau wrote:
> > Hello Paul,
> > 
> > Thomas added new tests for vfprintf(), which is a good idea because it
> > was a new implementation, we use it a lot in the tests so we'd rather
> > make sure it works! This required to implement support for memfd_create()
> > that is used to collect the output into a buffer, as well as to complete
> > a little bit the minimalistic FILE emulation with fileno(), fdopen(),
> > fflush() and fclose(). The result is neat and works equally on glibc and
> > nolibc. We just had to cheat on the pointer test because for NULL nolibc
> > prints "0x0" while glibc prints "(nil)" so we check 0x1 instead to avoid
> > this special case.
> > 
> > Finally Thomas added a new target to the makefile to ease building the
> > test against the default libc. This should help detect incompatibilities
> > when new features are added.
> > 
> > I've tested it locally with my libc and against all supported architectures
> > (userland tests only), and all tests passed.
> > 
> > This can be added to your dev tree for 6.5 on top of the previous series.
> 
> Looks like some useful code to make testing more comprehensive, thank
> you both!  Queued and pushed.

And finally tested:

Kernel: arch/x86/boot/bzImage is ready  (#7)
make[1]: Leaving directory '/home/git/linux-build'
133 test(s) passed.

  CC      nolibc-test
133 test(s) passed.

So good agreement between user and kernel, anyway.  Usermode tests
note that two of the tests are skipped (chroot_root and link_blah).
Kernelmode tests all say "[OK]".

							Thanx, Paul
Re: [PATCH 0/4] tools/nolibc: add testcases for vfprintf
Posted by Willy Tarreau 2 years, 10 months ago
On Tue, Apr 04, 2023 at 01:40:32PM -0700, Paul E. McKenney wrote:
> On Sun, Apr 02, 2023 at 02:24:04PM -0700, Paul E. McKenney wrote:
> > On Sun, Apr 02, 2023 at 08:48:02PM +0200, Willy Tarreau wrote:
> > > Hello Paul,
> > > 
> > > Thomas added new tests for vfprintf(), which is a good idea because it
> > > was a new implementation, we use it a lot in the tests so we'd rather
> > > make sure it works! This required to implement support for memfd_create()
> > > that is used to collect the output into a buffer, as well as to complete
> > > a little bit the minimalistic FILE emulation with fileno(), fdopen(),
> > > fflush() and fclose(). The result is neat and works equally on glibc and
> > > nolibc. We just had to cheat on the pointer test because for NULL nolibc
> > > prints "0x0" while glibc prints "(nil)" so we check 0x1 instead to avoid
> > > this special case.
> > > 
> > > Finally Thomas added a new target to the makefile to ease building the
> > > test against the default libc. This should help detect incompatibilities
> > > when new features are added.
> > > 
> > > I've tested it locally with my libc and against all supported architectures
> > > (userland tests only), and all tests passed.
> > > 
> > > This can be added to your dev tree for 6.5 on top of the previous series.
> > 
> > Looks like some useful code to make testing more comprehensive, thank
> > you both!  Queued and pushed.
> 
> And finally tested:
> 
> Kernel: arch/x86/boot/bzImage is ready  (#7)
> make[1]: Leaving directory '/home/git/linux-build'
> 133 test(s) passed.
> 
>   CC      nolibc-test
> 133 test(s) passed.
> 
> So good agreement between user and kernel, anyway.  Usermode tests
> note that two of the tests are skipped (chroot_root and link_blah).
> Kernelmode tests all say "[OK]".

This is perfect, thank you Paul!

Eventually I'll clean up my test script I use to build and test for all
archs, and commit it to help with such testing.

thanks!
Willy
Re: [PATCH 0/4] tools/nolibc: add testcases for vfprintf
Posted by Paul E. McKenney 2 years, 10 months ago
On Tue, Apr 04, 2023 at 10:46:23PM +0200, Willy Tarreau wrote:
> On Tue, Apr 04, 2023 at 01:40:32PM -0700, Paul E. McKenney wrote:
> > On Sun, Apr 02, 2023 at 02:24:04PM -0700, Paul E. McKenney wrote:
> > > On Sun, Apr 02, 2023 at 08:48:02PM +0200, Willy Tarreau wrote:
> > > > Hello Paul,
> > > > 
> > > > Thomas added new tests for vfprintf(), which is a good idea because it
> > > > was a new implementation, we use it a lot in the tests so we'd rather
> > > > make sure it works! This required to implement support for memfd_create()
> > > > that is used to collect the output into a buffer, as well as to complete
> > > > a little bit the minimalistic FILE emulation with fileno(), fdopen(),
> > > > fflush() and fclose(). The result is neat and works equally on glibc and
> > > > nolibc. We just had to cheat on the pointer test because for NULL nolibc
> > > > prints "0x0" while glibc prints "(nil)" so we check 0x1 instead to avoid
> > > > this special case.
> > > > 
> > > > Finally Thomas added a new target to the makefile to ease building the
> > > > test against the default libc. This should help detect incompatibilities
> > > > when new features are added.
> > > > 
> > > > I've tested it locally with my libc and against all supported architectures
> > > > (userland tests only), and all tests passed.
> > > > 
> > > > This can be added to your dev tree for 6.5 on top of the previous series.
> > > 
> > > Looks like some useful code to make testing more comprehensive, thank
> > > you both!  Queued and pushed.
> > 
> > And finally tested:
> > 
> > Kernel: arch/x86/boot/bzImage is ready  (#7)
> > make[1]: Leaving directory '/home/git/linux-build'
> > 133 test(s) passed.
> > 
> >   CC      nolibc-test
> > 133 test(s) passed.
> > 
> > So good agreement between user and kernel, anyway.  Usermode tests
> > note that two of the tests are skipped (chroot_root and link_blah).
> > Kernelmode tests all say "[OK]".
> 
> This is perfect, thank you Paul!
> 
> Eventually I'll clean up my test script I use to build and test for all
> archs, and commit it to help with such testing.

Thank you for confirming the test results!

							Thanx, Paul