Re: [PATCH 2/2] kfifo: add kfifo_skip() testcase

From: Andrew Morton
Date: Thu Aug 12 2010 - 17:22:48 EST


On Thu, 12 Aug 2010 17:32:38 +0200
Andrea Righi <arighi@xxxxxxxxxxx> wrote:

> Add a testcase for kfifo_skip() to the byte stream fifo example.
>
> Signed-off-by: Andrea Righi <arighi@xxxxxxxxxxx>
> ---
> samples/kfifo/bytestream-example.c | 4 ++++
> 1 files changed, 4 insertions(+), 0 deletions(-)
>
> diff --git a/samples/kfifo/bytestream-example.c b/samples/kfifo/bytestream-example.c
> index 642eef3..2e3a7a8 100644
> --- a/samples/kfifo/bytestream-example.c
> +++ b/samples/kfifo/bytestream-example.c
> @@ -73,6 +73,10 @@ static int __init testfunc(void)
> ret = kfifo_in(&test, buf, ret);
> printk(KERN_INFO "ret: %d\n", ret);
>
> + /* skip first element of the fifo */
> + printk(KERN_INFO "skip 1st element\n");
> + kfifo_skip(&test);
> +
> /* put values into the fifo until is full */
> for (i = 20; kfifo_put(&test, &i); i++)
> ;

hm, that's not a very good test harness. A better one would check that
the resulting kfifo actually contains the expected items in the
expected order. AFACIT this will "pass" even if kfifo_skip() is a
no-op, or execs nethack or something.

Oh well, it's more than we usually get.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/