[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2feeece1-6d92-aa08-c9b6-1b0c646eed29@suse.de>
Date: Wed, 25 Jul 2018 00:28:15 +0800
From: Coly Li <colyli@...e.de>
To: Eric Biggers <ebiggers3@...il.com>
Cc: linux-kernel@...r.kernel.org, linux-bcache@...r.kernel.org,
linux-block@...r.kernel.org,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Thomas Gleixner <tglx@...utronix.de>,
Kate Stewart <kstewart@...uxfoundation.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Randy Dunlap <rdunlap@...radead.org>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Noah Massey <noah.massey@...il.com>
Subject: Re: [PATCH v4 3/3] lib/test_crc: Add test cases for crc calculation
On 2018/7/24 12:44 PM, Eric Biggers wrote:
> On Thu, Jul 19, 2018 at 12:55:45AM +0800, Coly Li wrote:
>> This patch adds a kernel module to test the consistency of multiple crc
>> calculation in Linux kernel. It is enabled with CONFIG_TEST_CRC enabled.
>>
>> The test results are printed into kernel message, which look like,
>>
>> test_crc: crc64_be: FAILED (0x03d4d0d85685d9a1, expected 0x3d4d0d85685d9a1f)
>>
>> kernel 0day system has framework to check kernel message, then the above
>> result can be handled by 0day system. If crc calculation inconsistency
>> happens, it can be detected quite soon.
>>
>> lib/test_crc.c is a testing frame work for many crc consistency
>> testings. For now, there is only one test caes for crc64_be().
>
> Are you aware there's already a CRC-32 test module: CONFIG_CRC32_SELFTEST and
> lib/crc32test.c? Confusingly, your patch uses a different naming convention for
> the new CRC-64 one, and puts the Kconfig option in a different place, and makes
> it sound like it's a generic test for all CRC implementations rather than just
> the CRC-64 one. Please use the existing convention (i.e. add
> CONFIG_CRC64_SELFTEST and lib/crc64test.c) unless you have a strong argument for
> why it should be done differently.
>
> (And I don't think it makes sense to combine all CRC tests into one module,
> since you should be able to e.g. enable just CRC32 and CRC32_SELFTEST without
> also pulling in a dependency on all the other CRC variants.)
>
Hi Eric,
The purpose of test_crc is to provide a unified crc calculation
consistency testing for 0day. So far it is only crc64, and I will add
more test cases later. I see there is crc-32 test module, which does
more testing then consistency check, and no unified format for 0day
system to detect. This is why people suggested me to add this test
framework.
>> +/* Add your crc test cases here */
>> +static void test_crc64_be(struct crc_test_record *rec)
>> +{
>> + u64 crc;
>> +
>> + crc = crc64_be(rec->initval, rec->data, sizeof(rec->data));
>> + chk_and_msg(rec->name, crc, rec->expval);
>> +}
>> +
>> +/*
>> + * Set up your crc test initial data here.
>> + * Do not change the existing items, they are hard coded with
>> + * pre-calculated values.
>> + */
>> +static struct crc_test_record test_data[] = {
>> + { .name = "crc64_be",
>> + .data = { 0x42F0E1EBA9EA3693, 0x85E1C3D753D46D26,
>> + 0xC711223CFA3E5BB5, 0x493366450E42ECDF },
>> + .initval = 0x61C8864680B583EB,
>> + .expval = 0xb2c863673f4292bf,
>> + .handler = test_crc64_be,
>> + },
>> + {}
>> +};
>
> This is incorrect; the test is checksumming data that has a CPU-specific
> endianness. So, it will fail on big-endian systems. The data needs to be
> declared as a byte or char array instead. See e.g. what crypto/testmgr.h does
> for crypto API algorithms.
>
> Also please mark the test data structures 'const'.
Sure, I will send fix patches (not rebase the posted patches because
they are in linux-next for now) soon.
Thanks for your comments.
Coly Li
Powered by blists - more mailing lists