Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5307FC433F5 for ; Wed, 19 Jan 2022 11:26:49 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 644BC8326B; Wed, 19 Jan 2022 12:26:46 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; secure) header.d=gmx.net header.i=@gmx.net header.b="C92jClcI"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0A366832E3; Wed, 19 Jan 2022 12:26:45 +0100 (CET) Received: from mout.gmx.net (mout.gmx.net [212.227.15.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id EFA5480FE4 for ; Wed, 19 Jan 2022 12:26:41 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=xypron.glpk@gmx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1642591597; bh=QHeZJx2i7lF4Ux4ue89OflaEyNkOnanT1rNiHDcbbNc=; h=X-UI-Sender-Class:Date:Subject:To:Cc:References:From:In-Reply-To; b=C92jClcIHIIs3yWuFdM+ByiE6AC7ugbtAKe9hR+eTCWzHpVEHnRCrsiSU+VE5x0lT qKfnKUgbyJk3YvrRzbh8z9bRGIFHibA0ZKffCk8BqBIPxit82vx4j6La1UzvqJXEnW CiCqDSMmUK8731IfHSjZEup1piGsC/x8UiOtQTkc= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [192.168.123.94] ([88.152.144.107]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MowKi-1mWurz2l8Y-00qPf0; Wed, 19 Jan 2022 12:26:37 +0100 Message-ID: <88d18cf2-4d20-ff52-778d-0021fac9039d@gmx.de> Date: Wed, 19 Jan 2022 12:26:35 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH v3 02/31] test: Add tests for trailing_strtol() Content-Language: en-US To: Simon Glass Cc: Ilias Apalodimas , Daniel Schwierzeck , Dennis Gilmore , Steffen Jaeckel , Lukas Auer , Michal Simek , Tom Rini , U-Boot Mailing List References: <20220119014315.1938157-1-sjg@chromium.org> <20220119014315.1938157-3-sjg@chromium.org> From: Heinrich Schuchardt In-Reply-To: <20220119014315.1938157-3-sjg@chromium.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:34chLnWX0UiyPm8/pcKvgq0++Jzrf7s3dcbKmIBosknIWzPPlqx 8mSst9No2eiaaKsGaOc6Fhfwi5y1lH5Tr0rcCnpi2IRox/3Y+wsSVEGW9RvDIn+2/xPL2wa PvQjSeX9YQsoUZfRtRlODdTqebxIQYEonxZAmOhPFKG/8PWSo/v/JMmpeGelN8fCIHuBBLD PzY3cCYMHwetseuddbpNQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:7UEr4yz4SmM=:WALqLwSHfpXaQT0s5/ngH0 JZAGW/y5N/sRfZJvG5JWve3kp3bDbDijqq1c7gzH+PYhZ1POjtmZ79Yqi/9pRfqjZABDcbtxq ng7RhKiwhXg8UyX/oVd7s3OGBJG3wqvUxTK2C0f0TYFHdPLW/jaDLjwVFooM7luFyihDJYhd+ AAwZRHM332FxaOF/m2ZbQBPIYrCMszTiUzUSRqoVIGT4cRPyR0mdpajRowRRmk92q6YG/rz69 8HxY9pD/ECqSdPXf9P/Y4dGnaezUGtmn9Bq0RY2/9YBZD3lHRzPzF45VfSqnMNorJhCLYyWIF g0RhxRi9iy5ZQLzaGTNEc/414AD95iJUMvZ5L1SElTkf2DlmPDqwmb6xhQnjBcZQW1pine4iI yLnlAdwBQiRy69ZboKV1aJPrlWV0Fy7taw7YYnxrA3W5qqyAllc65hagLNpsI8IsyIm5j3LnR T35FolOY7Afoo/eMIap42qcudwsc3ZDhxz/TfLfBSt7Mk50mTMgr+vml7MXDhecrNHjajbTrA +Ij+pOe2Mf/ZxNKyHxTSzDpkMSLeceVIZBAMYTlLZp6nqL6XzxlsNYvKb7g/afGgZpTZEvtuZ ryGd1lDbpXgtmVclj/CbHsPlPu4k6thkdM+x0fwLObdz+wLIjqDcRa2ddlOurUbC1VPs2q1q7 o9JwFSgQX289w76vfl2uyvmV3gu75CbMwlAO2O3qZ6LTXKUoHg4egoq+HHpUlhcqkBmqmTOWF J5o8nzL/t5JYavcpInPZ70Hqdt2Zvc21bmrqTkP1/szdPwGqL6b2O0Rbv53fIs6bM6I2hzDg5 pTveADpmfvVU9XcmA1RT/PVGHk2DHeX1jYsLO4R/sQ/7vouIP6CRVmFXRagGYAo8SKyjCv9ab v4+P4IYIUTryRc8niMRhgywBkX1w7phdJiBLvCY6lchoXq1fvsqKIaas8+NqUdxKaE4KcK+PM Xp5dKrS2ZtNPtCuJeTjlAxSXMR0aXy4Um4oNZCbZfSFFO+e/Ubr832B9skYA1wgGWpD0/SwrR QdbLlCK+1Yd8K6j3/is0X/gvbsDf0DHF6Dd1wLOj8saAzzbOoc79G3K+Rq9DWrkIJwHgZfHVQ IGtnRc1bhvolUU= X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean On 1/19/22 02:42, Simon Glass wrote: > This function currently has no tests. Add some. > > Signed-off-by: Simon Glass > --- > > (no changes since v1) > > include/vsprintf.h | 4 ++-- > test/str_ut.c | 19 +++++++++++++++++++ > 2 files changed, 21 insertions(+), 2 deletions(-) > > diff --git a/include/vsprintf.h b/include/vsprintf.h > index 8bfafa0d33f..01d2248e04d 100644 > --- a/include/vsprintf.h > +++ b/include/vsprintf.h > @@ -99,7 +99,7 @@ long long simple_strtoll(const char *cp, char **endp, = unsigned int base); > * For example, "abc123" would return 123. > * > * @str: String to exxamine > - * @return training number if found, else -1 > + * @return trailing number if found, else -1 %s/@return/Return:/ Cf. https://www.kernel.org/doc/html/latest/doc-guide/kernel-doc.html#function-= documentation Best regards Heinrich > */ > long trailing_strtol(const char *str); > > @@ -114,7 +114,7 @@ long trailing_strtol(const char *str); > * @str: String to exxamine > * @end: Pointer to end of string to examine, or NULL to use the > * whole string > - * @return training number if found, else -1 > + * @return trailing number if found, else -1 > */ > long trailing_strtoln(const char *str, const char *end); > > diff --git a/test/str_ut.c b/test/str_ut.c > index 6c817f6f72f..9674a59f2a6 100644 > --- a/test/str_ut.c > +++ b/test/str_ut.c > @@ -242,6 +242,25 @@ static int str_xtoa(struct unit_test_state *uts) > } > STR_TEST(str_xtoa, 0); > > +static int str_trailing(struct unit_test_state *uts) > +{ > + char str1[] =3D "abc123def"; > + > + ut_asserteq(-1, trailing_strtol("")); > + ut_asserteq(-1, trailing_strtol("123")); > + ut_asserteq(123, trailing_strtol("abc123")); > + ut_asserteq(4, trailing_strtol("12c4")); > + ut_asserteq(-1, trailing_strtol("abd")); > + ut_asserteq(-1, trailing_strtol("abc123def")); > + > + ut_asserteq(-1, trailing_strtoln(str1, NULL)); > + ut_asserteq(123, trailing_strtoln(str1, str1 + 6)); > + ut_asserteq(-1, trailing_strtoln(str1, str1 + 9)); > + > + return 0; > +} > +STR_TEST(str_trailing, 0); > + > int do_ut_str(struct cmd_tbl *cmdtp, int flag, int argc, char *const a= rgv[]) > { > struct unit_test *tests =3D UNIT_TEST_SUITE_START(str_test);