Skip to content

Commit

Permalink
crc32: simplify unit test code
Browse files Browse the repository at this point in the history
Replace the unit test provided in crc32.c, which doesn't have a makefile
and doesn't compile with current headers, with a simpler self test
routine that also gives a measure of performance and runs at module init
time.  The self test option can be enabled through a configuration
option CONFIG_CRC32_SELFTEST.

The test stresses the pre and post loops and is thus not very realistic
since actual uses will likely have addresses and lengths that are at
least 4 byte aligned.  However, the main loop is long enough so that the
performance is dominated by that loop.

The expected values for crc32_le and crc32_be were generated with the
original version of crc32.c using CRC_BITS_LE = 8 and CRC_BITS_BE = 8.
These values were then used to check all the values of the BITS
parameters in both the original and new versions.

The performance results show some variability from run to run in spite
of attempts to both warm the cache and reduce the amount of OS noise by
limiting interrutps during the test.  To get comparable results and to
analyse options wrt performance the best time reported over a small
sample of runs has been taken.

[[email protected]: Minor changelog tweaks]
Signed-off-by: Bob Pearson <[email protected]>
Signed-off-by: Darrick J. Wong <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
rpears0n authored and torvalds committed Mar 23, 2012
1 parent fbedceb commit 3863ef3
Show file tree
Hide file tree
Showing 2 changed files with 691 additions and 117 deletions.
10 changes: 10 additions & 0 deletions lib/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,16 @@ config CRC32
kernel tree does. Such modules that use library CRC32 functions
require M here.

config CRC32_SELFTEST
bool "CRC32 perform self test on init"
default n
depends on CRC32
help
This option enables the CRC32 library functions to perform a
self test on initialization. The self test computes crc32_le
and crc32_be over byte strings with random alignment and length
and computes the total elapsed time and number of bytes processed.

config CRC7
tristate "CRC7 functions"
help
Expand Down
Loading

0 comments on commit 3863ef3

Please sign in to comment.