From: Andrew Morton <akpm@linux-foundation.org>
To: Trent Piepho <tpiepho@gmail.com>
Cc: linux-kernel@vger.kernel.org, andy@kernel.org, oskar@scara.com,
Daniel Latypov <dlatypov@google.com>
Subject: Re: [PATCH v2 2/2] lib/math/rational: Add Kunit test cases
Date: Tue, 25 May 2021 14:49:48 -0700 [thread overview]
Message-ID: <20210525144948.5bf487414edd6e0655902cf4@linux-foundation.org> (raw)
In-Reply-To: <20210525144250.214670-2-tpiepho@gmail.com>
On Tue, 25 May 2021 07:42:50 -0700 Trent Piepho <tpiepho@gmail.com> wrote:
> Adds a number of test cases that cover a range of possible code paths.
>
> --- /dev/null
> +++ b/lib/math/rational-test.c
> @@ -0,0 +1,56 @@
> +// SPDX-License-Identifier: GPL-2.0
> +
> +#include <kunit/test.h>
> +
> +#include <linux/rational.h>
> +
> +struct rational_test_param {
> + unsigned long num, den;
> + unsigned long max_num, max_den;
> + unsigned long exp_num, exp_den;
> +
> + const char *name;
> +};
> +
> +static const struct rational_test_param test_parameters[] = {
> + { 1230, 10, 100, 20, 100, 1, "Exceeds bounds, semi-convergent term > ½ last term" },
> + { 34567,100, 120, 20, 120, 1, "Exceeds bounds, semi-convergent term < ½ last term" },
It seems to be asking for trouble to use these characters in kernel
output - heaven knows what sort of weird output devices people
are using. So I think I'll switch to "1/2", OK?
> + { 1, 30, 100, 10, 0, 1, "Closest to zero" },
> + { 1, 19, 100, 10, 1, 10, "Closest to smallest non-zero" },
> + { 27,32, 16, 16, 11, 13, "Use convergent" },
> + { 1155, 7735, 255, 255, 33, 221, "Exact answer" },
> + { 87, 32, 70, 32, 68, 25, "Semiconvergent, numerator limit" },
> + { 14533, 4626, 15000, 2400, 7433, 2366, "Semiconvergent, demominator limit" },
> +};
> ...
> +static struct kunit_case rational_test_cases[] = {
> + KUNIT_CASE_PARAM(rational_test, rational_gen_params),
> + {}
> +};
> +
> +static struct kunit_suite rational_test_suite = {
> + .name = "rational",
> + .test_cases = rational_test_cases,
> +};
And let's use tabs to indent here. checkpatch detects this.
next prev parent reply other threads:[~2021-05-25 21:49 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-25 14:42 [PATCH v2 1/2] lib/math/rational.c: Fix divide by zero Trent Piepho
2021-05-25 14:42 ` [PATCH v2 2/2] lib/math/rational: Add Kunit test cases Trent Piepho
2021-05-25 16:00 ` Andy Shevchenko
2021-05-25 17:34 ` Daniel Latypov
2021-05-25 21:09 ` Trent Piepho
2021-05-25 22:03 ` Daniel Latypov
2021-05-25 21:49 ` Andrew Morton [this message]
2021-05-25 16:00 ` [PATCH v2 1/2] lib/math/rational.c: Fix divide by zero Andy Shevchenko
2021-05-25 21:46 ` Andrew Morton
2021-05-26 8:00 ` Andy Shevchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210525144948.5bf487414edd6e0655902cf4@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=andy@kernel.org \
--cc=dlatypov@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=oskar@scara.com \
--cc=tpiepho@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®