From: Tom Rini Date: Mon, 14 Oct 2019 18:41:46 -0400 Subject: [U-Boot] [PATCH 2/2] test: provide test for errno_str() In-Reply-To: <0dce6176-b8e1-1b50-1858-50382533aa79@gmx.de> References: <20191006123339.27533-1-xypron.glpk@gmx.de> <20191006123339.27533-4-xypron.glpk@gmx.de> <0dce6176-b8e1-1b50-1858-50382533aa79@gmx.de> Message-ID: <20191014224146.GE16029@bill-the-cat> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Sun, Oct 13, 2019 at 05:36:06PM +0200, Heinrich Schuchardt wrote: > On 10/13/19 5:03 PM, Simon Glass wrote: > > Hi Heinrich, > > > > On Sun, 6 Oct 2019 at 06:33, Heinrich Schuchardt wrote: > > > > > > Provide a unit test for errno_str(). Test that known and unknown error > > > numbers are handled correctly. > > > > > > Signed-off-by: Heinrich Schuchardt > > > --- > > > test/lib/Makefile | 1 + > > > test/lib/test_errno_str.c | 50 +++++++++++++++++++++++++++++++++++++++ > > > 2 files changed, 51 insertions(+) > > > create mode 100644 test/lib/test_errno_str.c > > > > > > diff --git a/test/lib/Makefile b/test/lib/Makefile > > > index 308c61708e..b13aaca7ce 100644 > > > --- a/test/lib/Makefile > > > +++ b/test/lib/Makefile > > > @@ -6,3 +6,4 @@ obj-y += cmd_ut_lib.o > > > obj-y += hexdump.o > > > obj-y += lmb.o > > > obj-y += string.o > > > +obj-$(CONFIG_ERRNO_STR) += test_errno_str.o > > > diff --git a/test/lib/test_errno_str.c b/test/lib/test_errno_str.c > > > new file mode 100644 > > > index 0000000000..77072d04f9 > > > --- /dev/null > > > +++ b/test/lib/test_errno_str.c > > > @@ -0,0 +1,50 @@ > > > +// SPDX-License-Identifier: GPL-2.0+ > > > +/* > > > + * Copyright (c) 2019 Heinrich Schuchardt > > > + * > > > + * Unit tests for memory functions > > > + * > > > + * The architecture dependent implementations run through different lines of > > > + * code depending on the alignment and length of memory regions copied or set. > > > + * This has to be considered in testing. > > > + */ > > > + > > > +#include > > > +#include > > > +#include > > > +#include > > > +#include > > > +#include > > > + > > > +static const char errno_str_ok[] = "Success"; > > > +static const char errno_str_enomem[] = "Out of memory"; > > > +static const char errno_str_unknown[] = "Unknown error"; > > > > I think in a test it is better to open-code the strings below rather > > than put them in separate constants. > > Thanks for reviewing. > > The string errno_str_ok is used twice. That is why I opted for > constants. test/compression.c is also using predefined constants. So it > is not without precedent. > > But this is only a matter of taste. > > @Tom > Which way do you want it (as maintainer for 'THE REST')? I think the compression test is special and otherwise yes, we should open-code them and let the compiler do its thing. -- Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: