Re: [PATCH v3 3/3] lib/test_crc: Add test cases for crc calculation

From: Randy Dunlap
Date: Tue Jul 17 2018 - 12:57:42 EST


Hi,

On 07/17/2018 07:55 AM, Coly Li wrote:

> diff --git a/lib/test_crc.c b/lib/test_crc.c
> new file mode 100644
> index 000000000000..441bf835fbd3
> --- /dev/null
> +++ b/lib/test_crc.c
> @@ -0,0 +1,138 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * CRC test driver
> + *
> + * Copyright (C) 2018 Coly Li <colyli@xxxxxxx>
> + *

> +
> +static int __init test_crc_init(void)
> +{
> + int i;
> + int v, err = 0;
> +
> + pr_info("Kernel CRC consitency testing:\n");

consistency

> + for (i = 0; test_data[i].name; i++) {
> + v = test_data[i].handler(&test_data[i]);
> + if (v < 0)
> + err++;
> + }
> +
> + if (err == 0)
> + pr_info("test_crc: all %d tests passed\n", i);
> + else
> + pr_err("test_crc: %d cases tested, %d passed, %d failed\n",
> + i, i - err, err);
> +
> + return (err == 0) ? 0 : -EINVAL;
> +}


--
~Randy